AWS terminals survive the app closing (tmux) and reattach on connect #87

Merged
jknapp merged 6 commits from feat/aws-persistent-sessions into main 2026-11-17 23:46:53 +00:00
6 Commits
Author SHA1 Message Date
shadowdaoandClaude Opus 5.5 ac0bb456d3 fix(aws): persistent terminals review fixes
Secret Scan / scan (push) Successful in 7s
Build App (Preview) / compute-version (pull_request) Successful in 12s
Secret Scan / scan (pull_request) Successful in 10s
Build App (Preview) / create-release (pull_request) Successful in 2s
Build App (Preview) / build-macos (pull_request) Successful in 6m50s
Build Container / build-container (pull_request) Successful in 7m27s
Build App (Preview) / build-windows (pull_request) Successful in 15m59s
Build App (Preview) / build-linux (pull_request) Successful in 23m19s
Build App (Preview) / prune-previews (pull_request) Successful in 3s
Build App (Preview) / test (pull_request) Successful in 26m19s
- Probe is three-state: an unanswered probe is an Err (tab retries), never
  "no tmux" — nothing is pruned or ended on it, opens fail rather than
  silently losing persistence.
- Web terminal execs are web-<key>: a desktop reattach no longer
  supersedes the web exec, nor does a web close/disconnect touch the
  desktop's.
- A tab closed while disconnected is queued (pending_end) and ended at
  the next connect; a reattach of a closed/queued id is Ended and is not
  remembered again.
- Cost ruling documented: a detached Claude keeps the workspace up
  (HostSection note, Sessions flags detached Claude sessions).
- end_all waits for pane pids; the same script runs in the entrypoint's
  TERM hook and before the idle watcher's lifetime-cap push.
- TMUX/TMUX_TMPDIR dropped from the client env and reserved.
- Store cleared on a move to Docker and on a death-watch stop.
- Frontend: no duplicate reopen of a tab still opening; quick-exit
  backoff then stop; the replay is exactly one chunk, so live output
  keeps its URL/OSC/SSO handling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:09:09 -08:00
shadowdaoandClaude Opus 5.5 9211d06cef docs: persistent AWS terminals in CLAUDE.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:09:09 -08:00
shadowdaoandClaude Opus 5.5 5284a527fb feat(ui): reopen and reattach persistent AWS terminals
- A tab on a persistent terminal reattaches when its connection drops
  (retrying while the tunnel comes back, "[Session ended]" only when the
  workspace says it is gone, or the project stopped); closing a tab ends it.
- usePersistentTerminals: once per AWS connection (project id + endpoint)
  the terminals this app opened that still run are reopened as tabs, in
  order, without taking focus; a reopened tab attaches only after its
  listeners are up, so its replayed history and tmux's first draw land.
- Project Home -> Sessions lists the workspace's terminals (open here,
  detached, attached elsewhere, opened elsewhere) with Reattach and End.
- The one-time "no tmux in this image" notice is a toast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:09:09 -08:00
shadowdaoandClaude Opus 5.5 ce0198203a fix(container): keep a persistent terminal's last screen when it exits
tmux sends terminfo's clear when its client exits; without an alternate
screen that wiped Claude's or the shell's last output from the tab.
clear=\E[H keeps it. Checked by feeding tmux's real output into xterm.js:
bash clear, ED 2, a curses alternate screen, a re-attach over an old
screen and Claude Code's TUI all match tmux's own view of the pane, and
300 fast lines all reach the scrollback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:09:09 -08:00
shadowdaoandClaude Opus 5.5 21bd7f5347 feat(aws): terminals outlive the app in tmux and reattach on connect
On an AWS project whose image has tmux and /etc/triple-c/tmux.conf, each
tab (Claude and bash, desktop and web terminal) runs its unchanged
command inside its own tmux server, tmux -L triple-c-<session id>, so the
server inherits only that exec's environment (copy-at-connect pairs stay
off argv). App exit, a dropped tunnel and the agent's SIGHUP only detach;
closing a tab ends the session (kill-server).

- host/persistent.rs: command construction, probe cached per tunnel
  (forgotten when a tunnel registers), list/history/end/end_all, replay.
- storage/terminal_store.rs: per-project open terminals (id = tmux key,
  kind, label) in terminal-sessions.json; pruned by the workspace listing,
  cleared on Stop and Remove.
- New commands list_workspace_terminals, reattach_terminal_session
  (attach-session, never creates; optional history replay),
  end_workspace_terminal; open_terminal_session returns
  {persistent, notice} (one-time no-tmux notice).
- Stop ends every tmux server in the step that closes the terminals,
  before the WIP push's snapshot.
- ExecSessionManager: an exec that takes a session id over ends the old
  one without its exit callback.
- Ignored live test through the real agent (host::persistent::live_tests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:09:09 -08:00
shadowdaoandClaude Opus 5.5 7951da008e feat(container): tmux and its config for persistent AWS terminals
tmux rides the Python apt layer (the last, cheapest one) and
/etc/triple-c/tmux.conf (outside the seed-only home) makes it invisible
behind xterm.js: no prefix, no status line, escape-time 0, truecolor,
OSC 8/52, and smcup@/rmcup@/indn@ so output lands in xterm.js's own
scrollback (xterm.js's CSI S drops lines instead of keeping them).

The entrypoint's TERM hook ends the app's tmux servers before its own
WIP push, so nothing writes after the push's snapshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:09:09 -08:00