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>
This commit is contained in:
shadowdaoandClaude Opus 5.5 committed 2026-11-17 15:09:09 -08:00
1 parent 21bd7f5347
commit ce0198203a
3 files changed
+15 -6

No files matched your search

+1 -1
View File
@@ -153,7 +153,7 @@ fn the_image_ships_the_config_and_tmux() {
"set -g destroy-unattached off",
"set -g window-size latest",
"set -g default-terminal \"tmux-256color\"",
"set -as terminal-overrides \",xterm*:smcup@:rmcup@:indn@\"",
r#"set -as terminal-overrides ",xterm*:smcup@:rmcup@:indn@:clear=\\E[H""#,
] {
assert!(conf.lines().any(|l| l == line), "missing: {line}");
}
+2 -1
View File
@@ -326,7 +326,8 @@ RUN npx --yes playwright@latest --version \
# `tmux` rides this layer, the last apt layer and the cheapest to change: it
# keeps AWS workspaces' terminals alive while the app is closed (one tmux
# server per tab, app/src-tauri/src/host/persistent.rs, config
# /etc/triple-c/tmux.conf below). Unused on Docker projects. ~1.2 MB.
# /etc/triple-c/tmux.conf below). Unused on Docker projects. +3 packages
# (tmux, libevent-core, libutempter0), ~1.5 MB installed.
ARG APT_REFRESH=
RUN echo "apt refresh: ${APT_REFRESH:-unset}" \
&& for i in 1 2 3 4 5; do \
+12 -4
View File
@@ -35,10 +35,18 @@ set -s set-clipboard on
# Draw in xterm.js's normal screen, not its alternate screen, so scrolled-off
# output lands in the app's own scrollback and its copy cleanup and link
# detection keep working. `indn@` too: with it tmux scrolls with CSI S (SU),
# and xterm.js's SU deletes the top line instead of saving it to scrollback;
# without it tmux scrolls with plain newlines, which xterm.js keeps.
set -as terminal-overrides ",xterm*:smcup@:rmcup@:indn@"
# detection keep working (smcup@/rmcup@). Two more, both measured by feeding
# tmux's real output into xterm.js:
# * indn@: with it tmux scrolls with CSI S (SU), and xterm.js's SU deletes the
# top line instead of saving it to scrollback (4 of 300 fast lines kept);
# without it tmux scrolls with newlines, which xterm.js keeps (all 300).
# * clear=\E[H: tmux sends `clear` when its client exits, which without an
# alternate screen wiped the session's last screen (Claude's goodbye, the
# shell's last output) from the tab. Its full redraws repaint every row
# anyway (checked: 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).
set -as terminal-overrides ",xterm*:smcup@:rmcup@:indn@:clear=\\E[H"
# The mouse belongs to xterm.js (selection, links, wheel scrollback).
set -g mouse off