Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(tmux): blank indn so the emulator actually accumulates a scrollback

enesfe2da682ce6e
diff --git a/src/core/pty-manager.ts b/src/core/pty-manager.ts
index b8c83eb6e..59dd9763c 100644
--- a/src/core/pty-manager.ts
+++ b/src/core/pty-manager.ts
@@ -68,11 +68,16 @@ setw -g aggressive-resize on
# Not our copy path any more (the emulator owns selection), but kept so an app that emits
# OSC 52 itself (vim "+y, gh, yazi) still reaches the local clipboard via the client's handler.
set -g set-clipboard on
-# Keep tmux on the NORMAL screen. By default the client enters the alternate screen
-# (\\e[?1049h), which has NO scrollback — xterm's own scrollback and the history we hydrate on a
-# warm reattach would both be invisible. Blanking smcup/rmcup (@) makes tmux emit no ?1049 at
-# all, so its output flows into the emulator's scrollback and the mouse wheel scrolls it.
-set -ga terminal-overrides ',*:smcup@:rmcup@'
+# Two capabilities are blanked (@), and BOTH are load-bearing for scrollback:
+# - smcup/rmcup: without them blanked the client enters the alternate screen (\\e[?1049h), which
+# has NO scrollback at all — neither xterm's own nor the history we hydrate on a warm reattach
+# would be reachable.
+# - indn (parm_index): with it advertised, tmux scrolls the pane with CSI S (SU). xterm.js
+# implements SU as a REGION scroll and DISCARDS the lines it pushes off the top — they never
+# reach the scrollback (real xterm saves them; xterm.js does not). Blanked, tmux falls back to
+# plain line feeds at the bottom row, which xterm DOES push into the scrollback. Measured: with
+# indn advertised, 80 lines of output left baseY=0 (nothing scrollable); blanked, baseY=58.
+set -ga terminal-overrides ',*:smcup@:rmcup@:indn@'
`
}
diff --git a/src/core/tmux-conf.test.ts b/src/core/tmux-conf.test.ts
index cbee5afd8..82fff3bc4 100644
--- a/src/core/tmux-conf.test.ts
+++ b/src/core/tmux-conf.test.ts
@@ -27,10 +27,14 @@ describe('tmuxConf', () => {
it('keeps OSC 52 as a safety net for apps that emit it themselves', () => {
expect(c).toContain('set -g set-clipboard on')
})
- it('keeps tmux on the NORMAL screen (smcup@/rmcup@) so xterm owns the scrollback', () => {
+ it('blanks smcup/rmcup AND indn — either one alone leaves nothing to scroll', () => {
// Without this, tmux enters the alternate screen (\x1b[?1049h), which has no scrollback:
// xterm's scrollback + the hydrated tmux history would both be invisible.
- expect(c).toContain(`set -ga terminal-overrides ',*:smcup@:rmcup@'`)
+ // smcup@/rmcup@: the alternate screen has no scrollback at all.
+ // indn@: with `indn` advertised tmux scrolls the pane with CSI S (SU), and xterm.js DISCARDS
+ // the lines SU pushes off the top instead of saving them — 80 lines of output left baseY=0
+ // (nothing to scroll). Blanked, tmux uses plain line feeds, which xterm does save.
+ expect(c).toContain(`set -ga terminal-overrides ',*:smcup@:rmcup@:indn@'`)
})
it('floors history-limit at 1000', () => {
expect(tmuxConf(10)).toContain('set -g history-limit 1000')
diff --git a/src/shared/ssh.test.ts b/src/shared/ssh.test.ts
index d12045e44..d5bf23158 100644
--- a/src/shared/ssh.test.ts
+++ b/src/shared/ssh.test.ts
@@ -160,8 +160,8 @@ describe('remoteTmuxConf', () => {
expect(c).toContain('terminal-overrides')
expect(c).toContain('Ms=')
})
- it('keeps tmux on the NORMAL screen (smcup@/rmcup@) so the emulator owns the scrollback', () => {
- expect(c).toContain(`set -ga terminal-overrides ',*:smcup@:rmcup@'`)
+ it('blanks smcup/rmcup AND indn so the emulator actually accumulates a scrollback', () => {
+ expect(c).toContain(`set -ga terminal-overrides ',*:smcup@:rmcup@:indn@'`)
})
it('APPENDS both terminal-overrides (neither clobbers the other)', () => {
// Both lines must use the append form (`-a`), or the second `set` would replace the first
diff --git a/src/shared/ssh.ts b/src/shared/ssh.ts
index 21710fb68..3bd289f51 100644
--- a/src/shared/ssh.ts
+++ b/src/shared/ssh.ts
@@ -104,10 +104,11 @@ set -g destroy-unattached off
setw -g aggressive-resize on
set -g set-clipboard on
set -ag terminal-overrides ',xterm*:Ms=\\E]52;%p1%s;%p2%s\\007'
-# Keep tmux on the NORMAL screen (see tmuxConf): the alternate screen has no scrollback, so the
-# emulator's scrollback + the hydrated history would be invisible. APPENDED (-ga), so the OSC 52
-# override above survives — a plain non-append set here would replace it.
-set -ga terminal-overrides ',*:smcup@:rmcup@'
+# Keep tmux on the NORMAL screen and off CSI S (see tmuxConf for the full reasoning): the alternate
+# screen has no scrollback, and with indn advertised tmux scrolls the pane with SU, whose lines
+# xterm.js discards instead of saving — either one leaves the user with nothing to scroll. APPENDED
+# (-ga), so the OSC 52 override above survives — a plain non-append set here would replace it.
+set -ga terminal-overrides ',*:smcup@:rmcup@:indn@'
`
}