Skip to content

fix(terminal): keep desktop history when a hidden pane is revealed - #33534

Merged
nwparker merged 1 commit into
mainfrom
nwparker/cold-restore-cap
Oct 25, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/cold-restore-cap

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​31 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​31
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1

ELI5

When you reopen a terminal tab that has more than 1,000 lines of history, it sometimes keeps only the last 1,000. This change stops that.

What Changed

Before: a pane with 1,500 lines of output is put to sleep, and the app is relaunched. You then open the workspace and switch to that pane's tab. At first the pane holds all 1,500 lines; once the tab is shown, it drops to the last 1,000 rows.

After: the pane keeps its history up to the desktop depth of 5,000 rows.

Mechanism: the main process keeps a hidden copy of each terminal.

  • The first time a pane produces output, main builds that copy from the pane's on-screen buffer.
  • It asked the screen for only 1,000 rows, which is the phone limit.
  • A hidden pane that got output while it was hidden is repainted from main's copy when it is revealed, so the pane inherits the 1,000-row cut.
  • Main now builds the copy at 5,000 rows. That is the depth main's copy keeps anyway.
  • Phone snapshots still apply their own 1,000-row cap where they are published, so phones are unaffected.

Why

The copy is what the desktop pane is repainted from, so it needs desktop depth.

Alternatives considered:

  • Skip the repaint when main's copy is shorter than the pane. That would leave hidden output unpainted.
  • Pass the user's scrollback setting through. The runtime's settings type doesn't carry it, and main's copy keeps 5,000 rows regardless.

The cost is one larger buffer read per pane, on its first output only.

Linked Issue

N/A (maintainer).

Visual Proof

N/A: there's no visual change beyond the history length. The reproduction is described under Testing.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • New test src/main/runtime/headless-hydration-desktop-depth.test.ts. It fails before the fix (1,000 rows) and passes after it (all 1,500 rows, including line 1).

  • pnpm tc:node, oxlint and the ratchets pass, along with the hydration and terminal-multiplex suites.

  • Reproduced on macOS from main, three runs out of three:

    1. Two tabs; print 1,500 lines in tab 1.
    2. Sleep the workspace with tab 2 active.
    3. Relaunch, open the workspace, and switch to tab 1.
    4. The xterm buffer went from L0001–L1500 to roughly L0502–L1500.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Platform and connection: works the same on every platform. SSH and WSL panes take the same path.
  • Phones: unaffected, because they publish through their own 1,000-row cap.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Main built its copy of a hidden pane from the renderer's xterm at the
phone's 1000-row limit, and the hidden-output reveal repaints the pane
from that copy, so a restored pane with more history lost all but its
last 1000 rows on first reveal.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9f9bee72-d090-47ab-a73c-abf08feb6214
Commits

Reviewing files that changed from the base of the PR and between 7d18e19 and 76e3723.

Files selected for processing: 3
  • src/main/runtime/headless-hydration-desktop-depth.test.ts
  • src/main/runtime/scrollback-limits.ts
  • src/main/runtime/terminal/output/headless-terminal-hydration.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 309f819 into main Oct 25, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant