Conversation
Fetches `claude auth status` at startup and displays the logged-in email (or email @ org, or auth method) right-aligned in the footer. Fails silently when the command is unavailable or the user is not logged in. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Session TranscriptApproach
Key Files to Modify
Step-by-Step ImplementationStep 1: type AuthStatus struct {
LoggedIn bool `json:"loggedIn"`
AuthMethod string `json:"authMethod"`
Email string `json:"email"`
OrgName string `json:"orgName"`
}
func GetAuthStatus() (*AuthStatus, error) {
cmd := exec.Command("claude", "auth", "status")
output, err := cmd.Output()
// parse JSON...
}Step 2: Add message type in type AuthStatusFetchedMsg struct {
Status *claudeauth.AuthStatus
Error error
}Step 3: Dispatch in func (m *Model) Init() tea.Cmd {
return tea.Batch(
func() tea.Msg { return StartupModalMsg{} },
PRPollTick(),
func() tea.Msg {
status, err := claudeauth.GetAuthStatus()
return AuthStatusFetchedMsg{Status: status, Error: err}
},
)
}Step 4: Handle message in
Step 5: Footer display Example footer display: The user info is rendered on the right side using padding calculations (similar to how the header right-aligns content). Potential Risks / Edge Cases
Test Coverage
Assistant: New package:
Modified:
Modified:
Modified:
|
There was a problem hiding this comment.
Pull request overview
Adds a small “who am I logged in as?” indicator to the TUI by querying Claude CLI auth status at startup and rendering a right-aligned user string in the footer.
Changes:
- Introduces
internal/claudeauthto runclaude auth status --output-format json, parse the JSON, and provide a display string. - Fetches auth status asynchronously on app startup and passes the derived display string into the footer model.
- Extends the footer to optionally render right-aligned user info and adds tests covering basic presence/priority behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/ui/footer.go | Adds userInfo state and appends a right-aligned user string to the rendered footer. |
| internal/ui/footer_test.go | Adds tests for setting/clearing user info and flash-message priority. |
| internal/claudeauth/auth.go | New helper package for querying and formatting Claude auth status. |
| internal/claudeauth/auth_test.go | Unit tests for display-string logic and JSON unmarshalling expectations. |
| internal/app/app.go | Fetches auth status on init and updates the footer with the display string. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
internal/claudeauth/auth.go
Outdated
| // It returns nil without an error when the output cannot be parsed, so callers can fail | ||
| // silently when the command is unavailable or outputs an unexpected format. |
There was a problem hiding this comment.
The doc comment says GetAuthStatus returns nil without an error when the output can’t be parsed / the command is unavailable, but the implementation currently returns the exec/json.Unmarshal error in those cases. Please either update the comment to match the actual behavior, or adjust the function to implement the documented “fail silently” contract (e.g., return nil, nil for these cases).
| // It returns nil without an error when the output cannot be parsed, so callers can fail | |
| // silently when the command is unavailable or outputs an unexpected format. | |
| // It returns a non-nil error if the command is unavailable, fails to run, or if the output | |
| // cannot be parsed as valid JSON. |
Summary
Displays the logged-in Claude account information (email and org) in the TUI footer, helping users distinguish which account is active.
Changes
claudeauthpackage that queriesclaude auth status --output-format jsonand parses the resultTest plan
go test ./internal/claudeauth/...— unit tests for DisplayString and JSON parsinggo test ./internal/ui/...— footer tests for user info display, flash priority, and narrow width handling🤖 Generated with Claude Code
Fixes #325