Skip to content

fix(cli): exclude terminated sessions from ao status active count with --include-terminated#2118

Open
Bdandc wants to merge 1 commit into
AgentWrapper:mainfrom
Bdandc:fix/status-include-terminated-active-count
Open

fix(cli): exclude terminated sessions from ao status active count with --include-terminated#2118
Bdandc wants to merge 1 commit into
AgentWrapper:mainfrom
Bdandc:fix/status-include-terminated-active-count

Conversation

@Bdandc

@Bdandc Bdandc commented Jun 12, 2026

Copy link
Copy Markdown

What

Fixes a session-count bug in the ao status footer summary: with terminated sessions present, ao status --include-terminated counted them as active (e.g. 5 active sessions across 2 projects when all 5 were terminated), while plain ao status correctly showed 0 active sessions.

Why

The summary totals in packages/cli/src/commands/status.ts counted every displayed session (totalWorkers += workers.length). Since --include-terminated adds terminal sessions to the displayed list, they leaked into the "active" count. The flag should only affect visibility, never what counts as active.

How

  • Summary totals (workers and orchestrators) now skip sessions where isTerminalSession() is true, pairing each SessionInfo with its source Session (the arrays are parallel by construction).
  • Display behavior is unchanged: terminated sessions are still listed when the flag is passed, and the N terminated sessions hidden footer still appears when it isn't.

Tests

Added three tests in packages/cli/__tests__/commands/status.test.ts:

  1. Default (no flag): terminated sessions excluded from the active count (and hidden-footer still printed)
  2. --include-terminated: terminated sessions are displayed but not counted as active
  3. --include-terminated: terminated orchestrators don't produce a · 1 orchestrator suffix

Verified tests 2–3 fail without the fix and pass with it.

Verification

  • pnpm --filter @aoagents/ao-cli typecheck
  • eslint on changed files ✅
  • pnpm --filter @aoagents/ao-cli test: 907 passed, 1 failed — the failure (canonicalCompareKey > expands ~ to HOME in path-equality.test.ts) is pre-existing and environment-specific (macOS /tmp/private/tmp symlink); it fails identically on a clean tree without this change.

🤖 Generated with Claude Code

…h --include-terminated

The footer summary in 'ao status' counted every displayed session as
active, so '--include-terminated' inflated the 'N active sessions across
M projects' line with terminated/exited sessions. The flag should only
affect visibility, never the active count.

Summary totals (workers and orchestrators) now skip sessions where
isTerminalSession() is true, regardless of the display flag.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant