fix: transition session status from spawning to working after launch#106
Open
AgentWrapper wants to merge 5 commits intomainfrom
Open
fix: transition session status from spawning to working after launch#106AgentWrapper wants to merge 5 commits intomainfrom
AgentWrapper wants to merge 5 commits intomainfrom
Conversation
aa68571 to
113f9b0
Compare
8c2e449 to
a680c7e
Compare
3e94e45 to
1d6c90e
Compare
There was a problem hiding this comment.
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.
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>
5d483ed to
0a3b5e6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
spawn()insession-manager.tsnow callsupdateMetadata()afterpostLaunchSetup()succeeds, immediately persistingstatus: "working"(and updating the returnedSessionobject). Previously, sessions were written withstatus: "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.enrichSessionWithRuntimeState()now auto-transitionsspawning → workingwhen the agent is detected asactivevia JSONL activity detection. This covers sessions created before this fix and races where the lifecycle manager hasn't fired.page.tsxandSessionDetail.tsxboth use the correct relative/api/sessions/{id}endpoint. No changes needed.Test plan
status: "spawning"fromspawn()— now correctly expect"working""transitions status from spawning to working after successful launch"— verifies both returned session and persisted metadata"auto-transitions spawning → working when agent is detected as active"— verifies the safety-net inenrichSessionWithRuntimeState()Fixes the "Sessions stuck in Spawning phase after ao spawn" bug.
🤖 Generated with Claude Code