Skip to content

Fix Resume button not showing for crashed spawned sessions#67

Open
0xabstracted wants to merge 1 commit intomainfrom
fix/resume-button-race-condition
Open

Fix Resume button not showing for crashed spawned sessions#67
0xabstracted wants to merge 1 commit intomainfrom
fix/resume-button-race-condition

Conversation

@0xabstracted
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes a race condition where the Resume button doesn't appear on sessions that crash immediately after spawning (exit code 1)
  • When a spawned agent crashes before invoke('create_session') returns, the pty-exit handler can't find the session in the store yet, so it skips the server status update — leaving the maestro session stuck at spawning
  • The Resume button only renders for ['completed', 'stopped', 'failed', 'idle'], so spawning sessions never show it

Changes (useSessionStore.ts)

  1. applyPendingExit now sends status: 'stopped' to the maestro server when consuming a pending exit that has a maestroSessionId
  2. handleSpawnTerminalSession now calls applyPendingExit on the new session before adding it to the store, catching the race immediately

Test plan

  • Spawn a session that crashes immediately (e.g., bad working directory or invalid command) — verify Resume button appears
  • Normal session lifecycle (spawn → work → complete) — verify Resume button still works
  • App restart with exited sessions — verify sessions restore correctly
  • Verify no duplicate server status updates for sessions that exit normally (pty-exit handler + applyPendingExit are idempotent since both send stopped)

🤖 Generated with Claude Code

When a spawned agent crashes immediately (exit code 1), the pty-exit event
fires before invoke('create_session') returns. At that point the terminal
session isn't in the store yet, so the pty-exit handler can't find the
maestroSessionId and skips the server status update. The server session
stays stuck at 'spawning', which doesn't match the Resume button's
condition of ['completed', 'stopped', 'failed', 'idle'].

Two fixes:
- applyPendingExit now sends status:'stopped' to the maestro server when
  consuming a pending exit with a maestroSessionId
- handleSpawnTerminalSession now calls applyPendingExit before adding the
  session to the store, catching the race immediately

Co-Authored-By: Claude Opus 4.6 <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