test(desktop): stop the agent's terminal commands in the real app, with real shells and real tmux
Merged
WA
17d ago+1181+1181+0123456789012345678901234567890123456789-500-500-012345678901234567890123456789
Summary
Terminal cancel ships without a feature flag, so this tests it in the real app, with real shells and a real tmux server. It asserts what is running and which panes exist, never which calls were made.
Builds on #8705, #8720, #8722 and #8725, all on staging.
- Stop: ends an agent command in a plain shell, and a tagged tmux run, closing only its pane. The user's own command, and the pane the user split beside the agent's, keep running.
- Sign-out: through the web app's logout, and through the session cookie going away (another account signing in). Every agent command stops, and the user's tmux panes keep running.
- Switching Terminal off: the same.
- A tmux run whose chat was put away: sign-out stops it, though no live terminal holds it any more.
- Launch recovery:
- after an interrupted sign-out, the previous process's run is stopped;
- after a crash mid-wait (the call never got its result), it is stopped;
- a run handed back as
runningsurvives a quit and the relaunch, and its pane can still be read; - a finished run is only forgotten;
- a pane that took a recorded id after a tmux restart is never touched.
- tmux without pane options: using real tmux 2.9a's refusal text, a run goes ahead untracked, and Stop and sign-out leave it alone.
How it is built
- Agent and user commands ignore SIGHUP, SIGINT and SIGTERM, so only Sim's own stop (which escalates to SIGKILL) can end them, and a stray stop would show.
- Each launch gets its own tmux server (
TMUX_TMPDIR). - Every process name carries a per-run suffix, so concurrent runs on one machine never see each other's processes.
- The fixture Sim and its helpers move to
e2e/executor-sim.ts, shared with the background executor suite. - The macOS Desktop E2E job installs tmux, so the tmux scenarios run in CI. Without tmux they skip, with the reason given.
- Each scenario's status and duration go to
TERMINAL_CANCEL_REPORT_PATH(test-results/terminal-cancel-report.jsonin CI, uploaded on failure). A failed scenario attaches its calls, its panes, the app's output and the process list. - By design, sign-out and Terminal off close every shell. So a user's command in a plain-shell tab is checked against Stop, and a user's command in a tmux pane is checked against every path.
Type of Change
- Test coverage
Testing
- EC2 (Linux, real tmux 3.4): 12/12. Each of 14 guards, removed in turn, turns its scenario red:
- Stop (plain shell and tmux);
- user commands and panes left alone;
- the sign-out, cookie and Terminal-off paths;
- untracked runs;
- the launch and sign-out sweeps;
- the tag check on recorded runs;
- dropping finished records;
- keeping collectable runs;
- marking runs handed back.
- Cold runs: 120/120 across 10 fresh Playwright invocations on EC2, on this branch rebased onto staging.
- Mac (no tmux installed): the 4 plain-shell scenarios pass and the 8 tmux scenarios skip.
- The background executor suite after the fixture move: 11/11 on the Mac.
Checklist
- Code follows project style guidelines
- Self-reviewed my changes
- Tests added/updated and passing
- No new warnings introduced
- I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)