Skip to content

Comments

fix: transition session status from spawning to working after launch#106

Open
AgentWrapper wants to merge 5 commits intomainfrom
fix/spawn-status-transition
Open

fix: transition session status from spawning to working after launch#106
AgentWrapper wants to merge 5 commits intomainfrom
fix/spawn-status-transition

Conversation

@AgentWrapper
Copy link
Collaborator

Summary

  • Primary fix: spawn() in session-manager.ts now calls updateMetadata() after postLaunchSetup() succeeds, immediately persisting status: "working" (and updating the returned Session object). Previously, sessions were written with status: "spawning" and only the lifecycle manager's polling loop would transition them — causing the "stuck in Spawning" bug when the lifecycle manager wasn't running or hadn't polled yet.
  • Safety-net fix: enrichSessionWithRuntimeState() now auto-transitions spawning → working when the agent is detected as active via JSONL activity detection. This covers sessions created before this fix and races where the lifecycle manager hasn't fired.
  • Web page verification: Confirmed page.tsx and SessionDetail.tsx both use the correct relative /api/sessions/{id} endpoint. No changes needed.

Test plan

  • Updated 2 existing tests that asserted status: "spawning" from spawn() — now correctly expect "working"
  • Added test: "transitions status from spawning to working after successful launch" — verifies both returned session and persisted metadata
  • Added test: "auto-transitions spawning → working when agent is detected as active" — verifies the safety-net in enrichSessionWithRuntimeState()
  • All 227 core tests pass
  • All 129 CLI tests pass
  • Typecheck clean across all packages
  • Lint: 0 errors (pre-existing warnings only)

Fixes the "Sessions stuck in Spawning phase after ao spawn" bug.

🤖 Generated with Claude Code

@AgentWrapper AgentWrapper force-pushed the fix/spawn-status-transition branch 3 times, most recently from aa68571 to 113f9b0 Compare February 18, 2026 22:54
@AgentWrapper AgentWrapper force-pushed the fix/spawn-status-transition branch from 8c2e449 to a680c7e Compare February 19, 2026 00:08
@AgentWrapper AgentWrapper force-pushed the fix/spawn-status-transition branch from 3e94e45 to 1d6c90e Compare February 19, 2026 08:35
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

AgentWrapper and others added 5 commits February 20, 2026 19:26
The `-p` flag in Claude Code is one-shot/print mode — the agent exits
after generating a single response. This caused spawned agents to
terminate immediately instead of staying alive for interactive work.

Changes:
- Use --append-system-prompt for prompt delivery (keeps agent interactive)
- Add systemPromptFile support to avoid tmux truncation on long prompts
- Transition session status from spawning → working after launch
- Persist spawning→working safety-net transition to disk in all paths
  (list, get, restore)
- Add tests for prompt delivery, status transitions, and disk persistence

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a deterministic, machine-readable table command for orchestrator
agents to query session state without parsing human-formatted output.

Changes:
- Add `ao session table [-p project] [--json]` subcommand with columns:
  SESSION, STATUS, ACTIVITY, PR, CI, BUGBOT, SESSION_URL, PR_URL
- Extract detectSessionPR() into shared lib/scm-data.ts to eliminate
  duplicate PR detection logic between status.ts and session.ts
- Add orchestrator prompt section documenting session table usage
- Add tip #9: no markdown links in terminal output
- Add output format tests (no ANSI, column alignment, sort order)
- Clean up integration test: remove duplicate unit test already covered
  by agent-claude-code plugin tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add dedicated unit tests for detectSessionPR() covering all edge
  cases: null SCM, undefined project, SCM throws, metadata fallback,
  SCM overrides metadata, no-branch sessions
- Rewrite integration test to exercise full sessionManager.spawn()
  pipeline (stub agent → plugin registry → spawn → tmux → metadata)
  instead of calling runtime.create() directly
- Add no-branch test in status.test.ts verifying the behavior change
  from removing the if(branch) guard before SCM detectPR call

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Wrap getSCM() in try/catch in session table so unknown SCM plugins
  don't crash the entire command
- Use prUrl from detectSessionPR() in status command instead of stale
  metadata URL, ensuring SCM-detected PR moves are reflected

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use config.port instead of hardcoded 3000 in orchestrator prompt
- Remove 2 duplicate null-activity tests (identical to existing test)
- Assert on URL path not port in session table tests (port is config concern)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AgentWrapper AgentWrapper force-pushed the fix/spawn-status-transition branch from 5d483ed to 0a3b5e6 Compare February 20, 2026 14:03
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