Summary
When pasting a large chunk of text into the dashboard terminal and scrolling up, the beginning of the pasted text is not visible. Scrollable history is being lost.
Current Architecture
Browser (xterm.js) ←→ WebSocket ←→ Tower (node-pty) ←→ tmux session ←→ shell/claude
Current buffer sizes
- xterm.js
scrollback: 10,000 lines (Terminal.tsx:42)
- tmux
history-limit: not set (default: 2,000 lines)
- Server RingBuffer: 1,000 lines (
tower-server.ts:364)
Current tmux config (per session)
alternate-screen off — tmux writes to normal buffer so xterm.js native scroll works
mouse off — xterm.js handles selection and clipboard
status off — dashboard has its own tabs
- No
history-limit set
Root Cause Analysis
The most likely culprit is tmux's default history-limit of 2,000 lines. Even with alternate-screen off, tmux manages its own internal buffer. However, since alternate-screen is off, xterm.js should be receiving all output in its normal buffer (10,000 line scrollback). Possible causes:
- tmux
history-limit too small (2,000 default) — may affect output flow
- RingBuffer too small (1,000 lines) — affects replay on reconnect
- xterm.js scrollback may need increase for heavy use
- Possible
\x1b[3J (clear scrollback) sequences from applications inside tmux
CRITICAL: Read Before Fixing
Read codev/resources/terminal-tmux.md in its entirety before making ANY changes. This area has wasted 10+ hours on previous bugs. Rules:
- Never quick-fix Terminal.tsx — understand the full architecture first
- Intermittent = external state mutation — grep for all code touching tmux options
- tmux
-g is GLOBAL — always use -t <session> for per-session settings
- Test after changes — build, install, restart Tower, verify in dashboard
Proposed Fix (Conservative)
- Set tmux
history-limit to 50,000 on session creation (tower-server.ts ~line 572)
- Set tmux
history-limit to 50,000 on session reconnection (~line 810)
- Increase RingBuffer from 1,000 to 10,000 lines (
tower-server.ts:364)
- Increase xterm.js scrollback from 10,000 to 50,000 (
Terminal.tsx:42)
Key Files
| File |
Role |
packages/codev/dashboard/src/components/Terminal.tsx |
xterm.js setup, scrollback config |
packages/codev/src/agent-farm/servers/tower-server.ts (~line 572) |
tmux session creation |
packages/codev/src/agent-farm/servers/tower-server.ts (~line 810) |
tmux session reconnection |
packages/codev/src/terminal/pty-session.ts |
RingBuffer initialization |
codev/resources/terminal-tmux.md |
READ THIS FIRST |
Summary
When pasting a large chunk of text into the dashboard terminal and scrolling up, the beginning of the pasted text is not visible. Scrollable history is being lost.
Current Architecture
Current buffer sizes
scrollback: 10,000 lines (Terminal.tsx:42)history-limit: not set (default: 2,000 lines)tower-server.ts:364)Current tmux config (per session)
alternate-screen off— tmux writes to normal buffer so xterm.js native scroll worksmouse off— xterm.js handles selection and clipboardstatus off— dashboard has its own tabshistory-limitsetRoot Cause Analysis
The most likely culprit is tmux's default history-limit of 2,000 lines. Even with
alternate-screen off, tmux manages its own internal buffer. However, since alternate-screen is off, xterm.js should be receiving all output in its normal buffer (10,000 line scrollback). Possible causes:history-limittoo small (2,000 default) — may affect output flow\x1b[3J(clear scrollback) sequences from applications inside tmuxCRITICAL: Read Before Fixing
Read
codev/resources/terminal-tmux.mdin its entirety before making ANY changes. This area has wasted 10+ hours on previous bugs. Rules:-gis GLOBAL — always use-t <session>for per-session settingsProposed Fix (Conservative)
history-limitto 50,000 on session creation (tower-server.ts~line 572)history-limitto 50,000 on session reconnection (~line 810)tower-server.ts:364)Terminal.tsx:42)Key Files
packages/codev/dashboard/src/components/Terminal.tsxpackages/codev/src/agent-farm/servers/tower-server.ts(~line 572)packages/codev/src/agent-farm/servers/tower-server.ts(~line 810)packages/codev/src/terminal/pty-session.tscodev/resources/terminal-tmux.md