Conversation
Shows Claude CLI version, active session details (name, ID, cwd), and authentication status (login method, organization, email) by running `claude --version` and `claude auth status`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a /status slash command to the Plural TUI application that displays diagnostic information including Claude CLI version, active session details (name, ID, working directory), and authentication status (login method, organization, email). It shells out to claude --version and claude auth status with 5-second timeouts, and maps subscription types to human-readable display names.
Changes:
- Added
/statuscommand registration, dispatch, and handler that runs two Claude CLI subprocesses and formats the output - Added
claudeAuthStatusstruct withloginMethodDisplay()for mapping subscription types to human-readable names - Added 8 new test functions covering all status command scenarios plus dispatcher integration
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
internal/app/slash_commands.go |
Adds /status command definition, dispatch case, claudeAuthStatus type, loginMethodDisplay(), runClaudeVersion/runClaudeAuthStatus functions (as overridable vars), and handleStatusCommand handler |
internal/app/slash_commands_test.go |
Adds tests for no-session, with-session, auth-error, not-logged-in, unnamed-session, login method display mapping, and dispatcher integration; updates existing tests to include /status |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // handleStatusCommand shows session and Claude CLI status information. | ||
| func handleStatusCommand(m *Model, _ string) SlashCommandResult { | ||
| var sb strings.Builder | ||
| sb.WriteString("**Status**\n\n") | ||
|
|
||
| // Claude CLI version | ||
| version := runClaudeVersion() | ||
| fmt.Fprintf(&sb, " Version: %s\n", version) | ||
|
|
||
| // Session info | ||
| if m.activeSession != nil { | ||
| sess := m.activeSession | ||
| name := sess.Name | ||
| if name == "" { | ||
| name = "(unnamed)" | ||
| } | ||
| fmt.Fprintf(&sb, " Session name: %s\n", name) | ||
| fmt.Fprintf(&sb, " Session ID: %s\n", sess.ID) | ||
| fmt.Fprintf(&sb, " cwd: %s\n", sess.WorkTree) | ||
| } else { | ||
| sb.WriteString(" Session: none\n") | ||
| } | ||
|
|
||
| // Auth status | ||
| authStatus, err := runClaudeAuthStatus() | ||
| if err != nil { | ||
| logger.Get().Debug("failed to get claude auth status", "error", err) | ||
| sb.WriteString(" Login: could not determine\n") | ||
| } else if !authStatus.LoggedIn { | ||
| sb.WriteString(" Login: not logged in\n") | ||
| } else { | ||
| fmt.Fprintf(&sb, " Login method: %s\n", authStatus.loginMethodDisplay()) | ||
| if authStatus.OrgName != nil && *authStatus.OrgName != "" { | ||
| fmt.Fprintf(&sb, " Organization: %s\n", *authStatus.OrgName) | ||
| } | ||
| if authStatus.Email != "" { | ||
| fmt.Fprintf(&sb, " Email: %s\n", authStatus.Email) | ||
| } | ||
| } | ||
|
|
||
| return SlashCommandResult{ | ||
| Handled: true, | ||
| Response: sb.String(), | ||
| } | ||
| } |
There was a problem hiding this comment.
The /status command executes two subprocess calls (claude --version and claude auth status) synchronously within the Bubbletea Update loop (called from sendMessage()). Each has a 5-second timeout, so the UI could freeze for up to 10 seconds if the claude binary is slow to respond or not found. Other slash command handlers (/help, /mcp, /plugins) are instant, and /cost only reads a local file. Consider running these subprocess calls asynchronously via a tea.Cmd and displaying a loading indicator, or at minimum reducing the timeouts significantly (e.g., 2 seconds each).
internal/app/slash_commands.go
Outdated
| ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) | ||
| defer cancel() | ||
|
|
||
| cmd := exec.CommandContext(ctx, "claude", "auth", "status") |
There was a problem hiding this comment.
The command claude auth status is executed without specifying a JSON output format flag (e.g., --output-format json), but the output is then parsed as JSON with json.Unmarshal. If claude auth status outputs human-readable text by default (which depends on the CLI version and whether stdout is a TTY), this will fail to parse. Consider adding --output-format, json to the command arguments to explicitly request JSON output, consistent with how other Claude CLI commands use --output-format in this codebase (see internal/claude/process_manager.go:226).
| cmd := exec.CommandContext(ctx, "claude", "auth", "status") | |
| cmd := exec.CommandContext(ctx, "claude", "auth", "status", "--output-format", "json") |
Ensures JSON output regardless of TTY detection, addressing PR review feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
/statusslash command that displays Claude CLI version, active session info (name, ID, cwd), and authentication details (login method, organization, email)claude --versionandclaude auth statusunder the hood, with a 5s timeoutTest plan
go test ./...)varfunctions for testability🤖 Generated with Claude Code