Commit Graph

1 Commits

Author SHA1 Message Date
PeterPonyu 0465562fa4 fix(tmux-subagent): wait for session readiness before spawning attach pane
`opencode attach` was invoked inside a freshly-split tmux pane before the
child session appeared in the opencode server's status map.  The process
exited immediately (session not found), tmux auto-closed the pane, and the
subagent ran invisibly in the background — the race documented in #3505.

Fix: call `waitForSessionReady` *before* `executeActions` in
`session-created-handler.ts`, mirroring the guard already present in
`TmuxSessionManager.ensureSessionReadyBeforeSpawn()`.  If the session does
not become attachable within the timeout the handler returns early without
spawning a pane at all, eliminating the transient-pane and silent-close
failure modes.  The now-unreachable post-spawn readiness-check / pane-close
cleanup branch is removed.

Adds a regression test suite (session-created-handler.test.ts) covering:
- not-ready session → no pane spawned, no polling started
- duplicate session.created → idempotent
- non session.created event type → no action
- already-tracked session → idempotent

Closes #3505

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 07:54:52 -04:00