agent-orchestrator/packages/web/server
Harshit Singh Bhandari 845fffdfd9
fix(runtime-tmux,web): keep tmux session alive after agent exit (#1758)
* fix: keep tmux session alive after agent exit (closes #1756)

Two related fixes:

1. runtime-tmux: append `exec "${SHELL:-/bin/bash}" -i` to the launch
   command so the pane drops to an interactive shell when the agent
   exits, instead of letting the empty pane take down the whole tmux
   session. The lifecycle still detects agent termination via
   `agent.isProcessRunning` and transitions the session to
   `agent_process_exited` — the runtime just stays usable so the user
   can run shell commands or manually re-launch the agent.

2. mux-websocket: add a `tmux has-session` guard at the top of
   `pty.onExit`. When the tmux session is genuinely gone (e.g. `ao
   stop` killed it out from under a still-subscribed dashboard), skip
   the three doomed `attach-session` spawns introduced by the
   MAX_REATTACH_ATTEMPTS bound in #1640 and notify subscribers
   immediately. The bound from #1640 still covers transient
   tmux-server hiccups where the session does still exist.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(mux): make tmuxHasSession async to avoid blocking the event loop

The has-session probe added in #1756 ran via execFileSync inside
node-pty's onExit callback, freezing every WebSocket connection,
HTTP request, and in-flight terminal for up to the 5 s subprocess
timeout whenever an agent exited and tmux was slow to respond.

Switch tmuxHasSession to promisified execFile and await it from the
onExit handler, mirroring the execFileAsync pattern in runtime-tmux.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 19:41:03 +05:30
..
__tests__ fix(runtime-tmux,web): keep tmux session alive after agent exit (#1758) 2026-05-10 19:41:03 +05:30
direct-terminal-ws.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
mux-websocket.ts fix(runtime-tmux,web): keep tmux session alive after agent exit (#1758) 2026-05-10 19:41:03 +05:30
start-all.ts feat(windows): complete Windows support (#1025) 2026-05-09 00:10:53 +05:30
terminal-observability.ts chore: rename @composio scope to @aoagents across all packages 2026-04-09 15:59:33 +00:00
tmux-utils.ts fix(runtime-tmux,web): keep tmux session alive after agent exit (#1758) 2026-05-10 19:41:03 +05:30