Skip to content
This repository was archived by the owner on Mar 21, 2026. It is now read-only.

Add /status slash command#322

Merged
zhubert merged 2 commits intomainfrom
add-status-slash-command
Mar 10, 2026
Merged

Add /status slash command#322
zhubert merged 2 commits intomainfrom
add-status-slash-command

Conversation

@zhubert
Copy link
Copy Markdown
Owner

@zhubert zhubert commented Mar 10, 2026

Summary

  • Adds a /status slash command that displays Claude CLI version, active session info (name, ID, cwd), and authentication details (login method, organization, email)
  • Runs claude --version and claude auth status under the hood, with a 5s timeout
  • Maps subscription types to human-readable login methods (e.g. "max" → "Claude Max Account")

Test plan

  • All existing tests pass (go test ./...)
  • 8 new test functions covering: no session, with session, auth error, not logged in, unnamed session, login method display mapping, dispatcher integration
  • CLI calls extracted as overridable var functions for testability

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings March 10, 2026 17:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /status command registration, dispatch, and handler that runs two Claude CLI subprocesses and formats the output
  • Added claudeAuthStatus struct with loginMethodDisplay() 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.

Comment on lines +389 to +433
// 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(),
}
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

cmd := exec.CommandContext(ctx, "claude", "auth", "status")
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
cmd := exec.CommandContext(ctx, "claude", "auth", "status")
cmd := exec.CommandContext(ctx, "claude", "auth", "status", "--output-format", "json")

Copilot uses AI. Check for mistakes.
Ensures JSON output regardless of TTY detection, addressing PR review feedback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zhubert zhubert merged commit 193e4ab into main Mar 10, 2026
1 check passed
@zhubert zhubert deleted the add-status-slash-command branch March 10, 2026 17:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants