Repository navigation
fix(terminal): stop cold restore dropping all scrollback on large checkpoints - #10479
Merged
brennanb2025 merged 3 commits intoJul 25, 2026
Merged
Conversation
…ckpoints The checkpoint read cap shipped without its write bound. history-reader.ts reads checkpoint.json through a 16MiB cap that throws past the limit, and the catch swallows it to checkpoint=null; history-manager.ts still writes the checkpoint with an unbounded JSON.stringify. Every fallback then collapses (stale-generation log, unlinked legacy scrollback.bin), so the terminal reopens empty with nothing surfaced. Raise the read cap to cover the largest checkpoint the writer can legitimately emit, derived from the scrollback policy's 50k-row max preset so it cannot drift back under the writer. A bound is kept so a corrupt file still cannot OOM the main process. Bounding the writer instead would not recover the scrollback: the stringify throw lands in handleWriteError, which adds the session to disabledSessions and permanently stops history recording for it.
Contributor
📝 WalkthroughWalkthroughThe checkpoint maximum byte limit increased to 200,000,000 bytes. The history reader test helper now supports checkpoint field overrides, and tests verify restoration of 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 87022a38-7315-4bf9-b154-b3fa36970acf
📒 Files selected for processing (2)
src/main/daemon/history-reader-memory.test.tssrc/main/daemon/terminal-history-file-limits.ts
The cap was derived as 2 * LEGACY_TERMINAL_SCROLLBACK_BYTES_100_MB, but that constant is a legacy byte-preset setting value with no other consumer, and the 50k-row bucket it was attributed to has no upper byte bound. Same value, stated without the false policy linkage.
The retained oversized-checkpoint test passed with the byte guard removed entirely — 200MB of NUL fails JSON.parse, so detectColdRestore returned null either way. Assert the bounded reader directly, as the amplification test does. Also: a 50k-row max preset of ordinary text measures ~14MB serialized, not 'far below' by an unbounded margin — per-cell-colored output can still exceed the cap, which is what a writer-side snapshot trim has to fix.
This was referenced Jul 25, 2026
brennanb2025
added a commit
that referenced
this pull request
Jul 25, 2026
#10500) * test(terminal): pin checkpoint-only cold restore of a large checkpoint Triaging a report that checkpoint-only cold restore renders blank at every checkpoint size found no v1.4.156 regression: an A/B of v1.4.155 against origin/main returned byte-identical ColdRestoreInfo at 1.01, 5.56, 11.30 and 20.61 MiB, all 300 marker lines intact on both refs. Blankness tracks the meta.endedAt eligibility gate, not size — a cleanly ended session refuses to cold-restore at any size, which is by design and unchanged between the refs. What the triage did surface is a coverage gap. #10179's 16MiB checkpoint read cap sat under what the unbounded writer emits, so a large checkpoint threw, was swallowed to checkpoint=null, and the pane reopened empty; #10479 raised the cap but nothing pinned the round trip it had broken. history-reader-memory covers the bounded reader at its limit, not writer→reader recovery. Adds that round trip through the real HistoryManager writer and HistoryReader over a header-only log, and pins the endedAt gate that has now been mistaken for a size regression twice. Fails at the pre-#10479 cap with the exact production symptom (detectColdRestore returns null). * test(terminal): fail loudly when writeSync is unavailable writeLargeScrollback ignored writeSync's boolean, which is false when xterm's private _core.writeSync goes away. The size assertions catch that in the large-checkpoint test (416 bytes vs 16MiB), but the endedAt gate is size-independent, so that test silently passed on an empty snapshot — pinning the gate over no scrollback at all. * test(terminal): cut large-checkpoint fixture peak RSS from 1.2GiB to 800MiB The filler colored per line, not per cell as its comment claimed, so the serialized seed only tracked plain-text size and needed 26k buffer rows to clear 16MiB. The xterm buffer costs rows x cols, which made this single file raise the whole src/main/daemon/ suite's peak RSS 5.2x (241MiB -> 1244MiB) — a real OOM risk on CI right after #10299 bounded readers for that reason. Carrying the bytes in SGR runs instead of rows reaches a larger seed from 5.5k rows: suite peak RSS 1244MiB -> 793MiB, and the margins improve too (seed 25.16MiB = 1.57x the threshold vs 1.19x before, checkpoint.json 46.1MiB = 2.88x vs 1.20x). Also makes the fixture match its own comment and be more representative of real colored agent output. Re-verified all three mutations still fail: cap at 16MiB -> "expected null not to be null"; endedAt gate deleted -> test 2 fails; writeSync unavailable -> both fail. * test(terminal): tighten timeout, reuse prod dir-name helper, dispose first Review follow-ups, all test-only: - Import getHistorySessionDirName instead of hand-rolling encodeURIComponent. Equivalent today, but that helper exists to absorb encoding changes, so the hand-rolled copy would silently diverge from the writer it is checking. - Index FILLER_ROWS by its own length so growing the array cannot leave rows unused. - 300_000ms -> 60_000ms. The file runs in ~2.8s and vitest's own default is 30s; a 5-minute ceiling turns a hung regression into a stalled job rather than a failure. 60s keeps Windows headroom. - Take the snapshot, dispose, then checkpoint, so a throwing checkpoint() cannot leak the buffer. Note this is memory-neutral, not a saving: peak RSS is set at getSnapshot(), where the buffer and the serialized strings coexist, and measured ~800MiB either way. Mutations re-verified: cap at 16MiB -> "expected null not to be null"; endedAt gate deleted -> test 2 fails; writeSync unavailable -> both fail.
brennanb2025
added a commit
that referenced
this pull request
Jul 25, 2026
…ad path (#10499) * perf(terminal): drop the JSON structural pre-scan from the history read path readTerminalHistoryJson/Async walked every character of checkpoint.json in interpreted JS before handing the same string to native JSON.parse. On a 26.8MB checkpoint that scan measured 63-330ms — 2.7-12x the JSON.parse it guards, and 57% of the whole read path — all of it synchronous main-thread work. readTerminalHistoryJsonAsync exists so cold-restore reads do not block the main thread; running the scan inline right after the async read defeated its own stated purpose. The scan also had a correctness cost: TERMINAL_HISTORY_JSON_MAX_STRUCTURAL_TOKENS was 1_000_000, and oscLinks is unbounded at ~10 structural tokens per link, so roughly 100k OSC-8 hyperlinks tripped the assert, history-reader swallowed the throw to a null checkpoint, and the terminal restored blank — the same user-visible loss #10479 just fixed for the byte cap. checkpoint.json and meta.json are our own SerializeAddon output, not untrusted input: the byte cap still bounds the read, and a corrupt file fails JSON.parse into the same catch. The shared helper stays for the call sites that do handle untrusted JSON. * test(terminal): pin iterative JSON.parse for the dropped nesting-depth cap The retired pre-scan enforced two limits; the new tests only covered the structural-token half. Dropping the 128-level nesting cap is safe solely because V8 parses JSON iteratively — depth costs heap, not stack — so a deeply nested checkpoint parses instead of overflowing. Verified: 10M-deep arrays and objects parse without throwing on V8 14.6. That property is an engine guarantee this code now silently depends on, and a recursive parser would abort the daemon outright rather than throw into the callers' catch. The test fails on main with "JSON nesting exceeds 128 levels" and costs 4ms. * docs(terminal): drop the rot-prone benchmark figure from the reader comment Keeps the durable rationale for skipping the pre-scan (self-authored input, byte cap still bounds the read, corrupt files land in the callers' existing catch) and moves the "~57% of the read path" measurement to the PR body, where it cannot go stale against a later change to this path. Addresses the CodeRabbit comment-length nitpick against the repo's one-line-if-possible comment guideline.
6 tasks done
This was referenced Jul 27, 2026
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…ckpoints (stablyai#10479) * fix(terminal): stop cold restore dropping all scrollback on large checkpoints The checkpoint read cap shipped without its write bound. history-reader.ts reads checkpoint.json through a 16MiB cap that throws past the limit, and the catch swallows it to checkpoint=null; history-manager.ts still writes the checkpoint with an unbounded JSON.stringify. Every fallback then collapses (stale-generation log, unlinked legacy scrollback.bin), so the terminal reopens empty with nothing surfaced. Raise the read cap to cover the largest checkpoint the writer can legitimately emit, derived from the scrollback policy's 50k-row max preset so it cannot drift back under the writer. A bound is kept so a corrupt file still cannot OOM the main process. Bounding the writer instead would not recover the scrollback: the stringify throw lands in handleWriteError, which adds the session to disabledSessions and permanently stops history recording for it. * fix(terminal): anchor checkpoint read cap to its own reasoning The cap was derived as 2 * LEGACY_TERMINAL_SCROLLBACK_BYTES_100_MB, but that constant is a legacy byte-preset setting value with no other consumer, and the 50k-row bucket it was attributed to has no upper byte bound. Same value, stated without the false policy linkage. * fix(terminal): assert the checkpoint byte cap, correct its rationale The retained oversized-checkpoint test passed with the byte guard removed entirely — 200MB of NUL fails JSON.parse, so detectColdRestore returned null either way. Assert the bounded reader directly, as the amplification test does. Also: a 50k-row max preset of ordinary text measures ~14MB serialized, not 'far below' by an unbounded margin — per-cell-colored output can still exceed the cap, which is what a writer-side snapshot trim has to fix.
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
stablyai#10500) * test(terminal): pin checkpoint-only cold restore of a large checkpoint Triaging a report that checkpoint-only cold restore renders blank at every checkpoint size found no v1.4.156 regression: an A/B of v1.4.155 against origin/main returned byte-identical ColdRestoreInfo at 1.01, 5.56, 11.30 and 20.61 MiB, all 300 marker lines intact on both refs. Blankness tracks the meta.endedAt eligibility gate, not size — a cleanly ended session refuses to cold-restore at any size, which is by design and unchanged between the refs. What the triage did surface is a coverage gap. stablyai#10179's 16MiB checkpoint read cap sat under what the unbounded writer emits, so a large checkpoint threw, was swallowed to checkpoint=null, and the pane reopened empty; stablyai#10479 raised the cap but nothing pinned the round trip it had broken. history-reader-memory covers the bounded reader at its limit, not writer→reader recovery. Adds that round trip through the real HistoryManager writer and HistoryReader over a header-only log, and pins the endedAt gate that has now been mistaken for a size regression twice. Fails at the pre-stablyai#10479 cap with the exact production symptom (detectColdRestore returns null). * test(terminal): fail loudly when writeSync is unavailable writeLargeScrollback ignored writeSync's boolean, which is false when xterm's private _core.writeSync goes away. The size assertions catch that in the large-checkpoint test (416 bytes vs 16MiB), but the endedAt gate is size-independent, so that test silently passed on an empty snapshot — pinning the gate over no scrollback at all. * test(terminal): cut large-checkpoint fixture peak RSS from 1.2GiB to 800MiB The filler colored per line, not per cell as its comment claimed, so the serialized seed only tracked plain-text size and needed 26k buffer rows to clear 16MiB. The xterm buffer costs rows x cols, which made this single file raise the whole src/main/daemon/ suite's peak RSS 5.2x (241MiB -> 1244MiB) — a real OOM risk on CI right after stablyai#10299 bounded readers for that reason. Carrying the bytes in SGR runs instead of rows reaches a larger seed from 5.5k rows: suite peak RSS 1244MiB -> 793MiB, and the margins improve too (seed 25.16MiB = 1.57x the threshold vs 1.19x before, checkpoint.json 46.1MiB = 2.88x vs 1.20x). Also makes the fixture match its own comment and be more representative of real colored agent output. Re-verified all three mutations still fail: cap at 16MiB -> "expected null not to be null"; endedAt gate deleted -> test 2 fails; writeSync unavailable -> both fail. * test(terminal): tighten timeout, reuse prod dir-name helper, dispose first Review follow-ups, all test-only: - Import getHistorySessionDirName instead of hand-rolling encodeURIComponent. Equivalent today, but that helper exists to absorb encoding changes, so the hand-rolled copy would silently diverge from the writer it is checking. - Index FILLER_ROWS by its own length so growing the array cannot leave rows unused. - 300_000ms -> 60_000ms. The file runs in ~2.8s and vitest's own default is 30s; a 5-minute ceiling turns a hung regression into a stalled job rather than a failure. 60s keeps Windows headroom. - Take the snapshot, dispose, then checkpoint, so a throwing checkpoint() cannot leak the buffer. Note this is memory-neutral, not a saving: peak RSS is set at getSnapshot(), where the buffer and the serialized strings coexist, and measured ~800MiB either way. Mutations re-verified: cap at 16MiB -> "expected null not to be null"; endedAt gate deleted -> test 2 fails; writeSync unavailable -> both fail.
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…ad path (stablyai#10499) * perf(terminal): drop the JSON structural pre-scan from the history read path readTerminalHistoryJson/Async walked every character of checkpoint.json in interpreted JS before handing the same string to native JSON.parse. On a 26.8MB checkpoint that scan measured 63-330ms — 2.7-12x the JSON.parse it guards, and 57% of the whole read path — all of it synchronous main-thread work. readTerminalHistoryJsonAsync exists so cold-restore reads do not block the main thread; running the scan inline right after the async read defeated its own stated purpose. The scan also had a correctness cost: TERMINAL_HISTORY_JSON_MAX_STRUCTURAL_TOKENS was 1_000_000, and oscLinks is unbounded at ~10 structural tokens per link, so roughly 100k OSC-8 hyperlinks tripped the assert, history-reader swallowed the throw to a null checkpoint, and the terminal restored blank — the same user-visible loss stablyai#10479 just fixed for the byte cap. checkpoint.json and meta.json are our own SerializeAddon output, not untrusted input: the byte cap still bounds the read, and a corrupt file fails JSON.parse into the same catch. The shared helper stays for the call sites that do handle untrusted JSON. * test(terminal): pin iterative JSON.parse for the dropped nesting-depth cap The retired pre-scan enforced two limits; the new tests only covered the structural-token half. Dropping the 128-level nesting cap is safe solely because V8 parses JSON iteratively — depth costs heap, not stack — so a deeply nested checkpoint parses instead of overflowing. Verified: 10M-deep arrays and objects parse without throwing on V8 14.6. That property is an engine guarantee this code now silently depends on, and a recursive parser would abort the daemon outright rather than throw into the callers' catch. The test fails on main with "JSON nesting exceeds 128 levels" and costs 4ms. * docs(terminal): drop the rot-prone benchmark figure from the reader comment Keeps the durable rationale for skipping the pre-scan (self-authored input, byte cap still bounds the read, corrupt files land in the callers' existing catch) and moves the "~57% of the read path" measurement to the PR body, where it cannot go stale against a later change to this path. Addresses the CodeRabbit comment-length nitpick against the repo's one-line-if-possible comment guideline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cold restore silently loses all terminal scrollback when
checkpoint.jsonexceeds 16 MiB. This release shipped a READ bound without its matching WRITE bound.Read side is bounded:
src/main/daemon/history-reader.ts:80-86reads the checkpoint viareadTerminalHistoryJsonAsync(..., TERMINAL_HISTORY_CHECKPOINT_MAX_BYTES), where the constant was16 * 1024 * 1024.src/shared/node-bounded-file-reader.ts:26-28throws past the cap, and the barecatchathistory-reader.ts:84-86swallows it tocheckpoint = null.Write side is not:
src/main/daemon/history-manager.ts:210is a plainJSON.stringify(checkpointFile)with no bound.Every fallback then collapses, so the failure is total, not partial:
restoreFromIncrementalLogtakeselse if (log.generation !== 0) return null(history-reader.ts:207); any session that has ever checkpointed hasgeneration >= 1.scrollback.binwas unlinked atopenSession.detectColdRestorereturnsnulland the terminal reopens empty, with nothing surfaced to the user.At
v1.4.155the checkpoint was read unbounded, so this failure mode did not exist. #10179 introduced both halves; the revert in #10255 reclaimed the writer but could not reclaim the reader, because #9990 had already landed onhistory-reader.ts.git diff v1.4.155..origin/main -- src/main/daemon/history-manager.tsis empty, confirming the writer sits at exactly the release base.The fix: raise the read cap to
200_000_000. A bound is retained, so a corrupt or runaway file still cannot read unboundedly into the main process.Why not bound the writer instead
Restoring
stringifyJsonWithinByteLimitathistory-manager.ts:210would not recover the lost scrollback, and would trade one silent failure for a worse one:try, whosecatchcallshandleWriteError→this.disabledSessions.add(sessionId)(history-manager.ts:328-331). That permanently stops all history writes for that session —appendIncrements(:148) andcheckpoint(:179) both return early thereafter.onWriteErroris never wired in production. The sole non-test construction site isnew HistoryManager(opts.historyPath)atsrc/main/daemon/daemon-pty-adapter.ts:181, with no options object.So option (a) converts a per-restore silent failure into a per-session permanent one, with zero observability.
Reachability — stated honestly
On a real heavy-use machine, 1279
checkpoint.jsonfiles at the default 5000-row preset max out at 0.97 MiB (mean 0.05 MiB, none above 8 MiB) — roughly 16x under the old cap. Realistic exposure is the 25k/50k row presets combined with dense output. Narrow but real — and when it hits, the loss is silent and total.Screenshots
No visual change. This PR changes one numeric constant and a test file.
Testing
oxlint— clean on both changed filesnpm run typecheck— clean, all three tsconfigspnpm test— full daemon suite: 68 files passed / 2 skipped (70), 1029 tests passed / 5 skipped (1034)pnpm build— not run. The change is one numeric constant plus a test file, with no build-surface change. Flagging rather than ticking.oxfmt --check— "All matched files use the correct format".check:max-lines-ratchetclean, no new bypasses.Two tests, both proven to fail when their guard is removed:
restores a checkpoint larger than the retired 16MiB read cap. PinningTERMINAL_HISTORY_CHECKPOINT_MAX_BYTESback to16 * 1024 * 1024makes it fail withexpected undefined to be 'xxx…'—detectColdRestorereturningnull, precisely the silent-empty-restore symptom.ignores oversized checkpoint and metadata files before parsingpreviously asserted onlydetectColdRestore(...) === null, which was vacuous — 200MB of NUL bytes failsJSON.parseregardless, so the test stayed green with the byte cap disabled entirely (it merely slowed from 1ms to 1489ms). It now also asserts the bounded reader directly (expect(() => readTerminalHistoryJson(...)).toThrow(/File too large/)), the idiom already used at:129-131. Verified two ways: with the size check innode-bounded-file-readerstubbed out, the old form passed 4/4 while the new form fails.Note this test previously asserted that an oversized checkpoint restores to
null. That assertion was written when the writer guaranteed such a file could not exist; it encoded the broken asymmetry rather than protecting against it, so it was re-scoped rather than defended.Not executed: no live Electron cold restore of a real >16 MiB session — the fix is exercised through
detectColdRestoreat the unit level, not through an actual crash-and-reopen. Not run on Windows, Linux, SSH, or WSL.AI Review Report
Three independent review rounds, each re-reviewing the prior round's output until one returned clean. Risks checked: the read/write asymmetry itself, the write-side alternative, main-process memory and latency on the startup path, test validity, scope creep, and cross-platform behavior.
Round 1 — flagged the cap's derivation as false. The constant was introduced as
2 * LEGACY_TERMINAL_SCROLLBACK_BYTES_100_MB, justified as "the policy's 100MB budget for the 50k-row max preset." No such budget exists:legacyTerminalScrollbackBytesToRowsmaps anything>= 75_000_000to 50k rows, so that bucket has no upper byte bound, and the anchor is a frozen migration input with no other consumer — a dead constant made the sole anchor of a live memory bound. The claimed drift protection was illusory, since the writer has no byte bound to drift under. Changed to a literal200_000_000(identical value, zero behavior change) with the actual reasoning stated. Real drift protection is the >16MiB regression test, not the expression.Round 2 — found the vacuous test above, and corrected the comment's remaining overclaim to a measured figure.
Round 3 — returned clean, no changes.
Cross-platform: explicitly checked for macOS, Linux, and Windows. The change is a platform-independent integer with no path, shell, shortcut, or Electron-specific behavior, so macOS/Linux/Windows/WSL/SSH behavior is identical. The one platform note is the oversized-file test fixture, now
200,000,001bytes: sparse and free on APFS/ext4. This test never runs on Windows in CI —pr.ymlis a singleubuntu-latestjob, the only Windows vitest job (computer-e2e.yml:82-95) uses a file allowlist that excludes it, andwin-crash-survival-e2e.ymlpath-filters!src/**/*.test.*. On local Windows, libuv'sftruncatemaps toSetEndOfFile; NTFS tracks Valid Data Length, so the region is allocated rather than zero-filled. The new test costs 76ms; the whole file runs in ~387ms.Performance — the key question, measured rather than estimated. At the 200MB cap on Node 26: read 12-15ms (async, yields),
toString('utf8')21-77ms, structural scan 472-478ms,JSON.parse87-168ms — ~593-723ms of synchronous main-thread stall, ~360-630MB transient RSS.MAX_STRING_LENGTH(536,870,888) is not reachable at this cap. Note this read runs in the Electron main process (DaemonPtyAdapteris constructed atdaemon-init.ts:666), not in the forked PTY server, and it happens beforecoldRestoreReplaySemaphore.acquire(history-reader.ts:187), so N parallel pane mounts each hold their own copy.The cap was deliberately not lowered. The failure is asymmetric: undershooting means silent, total scrollback loss (this bug), while overshooting costs a one-off sub-second stall on a file that must be corrupt or pathological to exist. A 64MB cap would bound the stall at ~230ms but re-opens the silent-blank failure for exactly the 25k/50k users this PR exists to protect.
On JSON escaping (raised in review and withdrawn). JSON expansion is exactly
1 + 5fwherefis the fraction of bytes that are C0 controls, so exceeding 2x needs >20% of all bytes to be control characters. Measured against a real@xterm/headless+SerializeAddonpipeline: 1.01x plain, 1.13x SGR-dense, 1.15x per-cell truecolor, 2.00x at the densest reachable shape (19.96% ESC). The 6x all-ESC figure is not reachable — decisively, feedingBuffer.alloc(4096, 0x1b)through the real terminal yields a serialized length of 0. The checkpoint isSerializeAddonoutput regenerated from the parsed buffer (headless-emulator.ts), not raw PTY bytes, so bare ESC cannot reachcheckpoint.jsonat all.Security Audit
No new input-handling, command-execution, path-handling, auth, secrets, dependency, or IPC surface. The change relaxes a resource bound on an already-existing read path.
The relevant risk is denial-of-service via resource exhaustion, and it is a real increase: a malicious or corrupt
checkpoint.jsoncan now pull up to 200MB into main-process memory instead of 16 MiB. Mitigating factors: the file is written by the app itself into its own user-scoped history directory (not attacker-supplied over any network or IPC boundary), a bound is still enforced before any allocation (validateSizethrows onstats.sizebeforeBuffer.allocUnsafe), and this is the same exposurev1.4.155shipped with.One finding for follow-up, not fixed here — see Notes.
Notes
Residual risk, stated plainly:
history-manager.ts:210, so this is a guard, not a guarantee. Measured through the real serializer, a 50k-row max preset of ordinary text is ~4.1MB at 80 cols, ~10.1MB at 200 cols, and ~13.8MB at 200 cols with 6 SGR runs per row — comfortably under. But per-cell-colored output can exceed even 200MB: image rendering (chafa,viu) filling a 50k-row buffer extrapolates to ~391MB serialized, which hits this same silent-drop path. That figure is extrapolated from a 2,000-row run; the 50k-row run OOM'd the serializer. No read-cap value fixes this case — only bounding the writer's snapshot does. This is the real follow-up.catchathistory-reader.ts:84-86is unchanged, so any future checkpoint read failure remains silent. Left alone deliberately to keep this PR to one concern.TERMINAL_HISTORY_JSON_MAX_STRUCTURAL_TOKENS = 1_000_000(terminal-history-file-reader.ts:7) meets an unboundedoscLinksarray (daemon-checkpoint-file.ts:11;headless-osc-link-ranges.tsapplies no cap). Each{row,startCol,endCol,uri}entry is ~10 structural tokens, so roughly 100,000 OSC-8 hyperlinks trips the limit and throws into the same catch, producing an identical empty restore.ls --hyperlink=autoacross a 50k-row buffer can plausibly reach that. Worth a follow-up.On the structural-token guard: it does not defend this file shape. The checkpoint is a flat object whose payload is a few giant string values, and the scanner skips string interiors — a 200MB checkpoint counts ~34 structural tokens against a 1,000,000 limit. It defends a different shape (many small nodes), and via unbounded
oscLinksit is itself a drop path (4 above).