Repository navigation
fix(terminal): keep restored OSC-8 ranges across a no-op resize - #17759
Conversation
Cold restore seeded a checkpoint's OSC-8 link ranges and then replayed records that resize, so any resize record after the checkpoint dropped them and restored hyperlinks in scrollback lost clickability. Same-size resize records reach the durable log routinely, because every attach re-asserts the pane's dimensions and session-output-plane records each one without a same-size dedupe — so an ordinary reattach was enough to lose the links. Restored ranges are row-indexed, so clearing them on a reflow is right; a resize to the size already applied is not a reflow. Gate on the dimensions actually changing. Introduced in d46349c ("fix: improve mobile link modifier handling", #5597), which added setRestoredOscLinks along with unconditional clearing in both resize() and clearScrollback(). clearScrollback's clearing is correct and is unchanged, with a test pinning it. Found during adversarial review of #17752 and filed as #17756. Not a regression from that PR: #17667 had incidentally masked it by gating no-op resizes to protect a snapshot cache, and removing the cache removed the gate. The same gate returns here on its own terms — as a correctness fix with tests, rather than as a side effect of a cache.
Greptile SummaryThis PR preserves restored OSC-8 hyperlink ranges when a terminal receives a no-op resize while continuing to invalidate them after actual dimension changes or scrollback clearing.
Confidence Score: 5/5The PR appears safe to merge, with focused behavior and regression coverage for both preservation and invalidation paths. The new guard suppresses only resize calls whose requested dimensions already match the terminal, while real dimension changes still clear restored hyperlink ranges and reach the underlying terminal resize.
|
| Filename | Overview |
|---|---|
| src/main/daemon/headless-emulator.ts | Adds an early return for unchanged dimensions so restored row-indexed OSC-8 ranges survive no-op resize records. |
| src/main/daemon/headless-emulator-restored-osc-links.test.ts | Verifies preservation across same-size resizes and invalidation after column changes, row changes, and scrollback clearing. |
Reviews (1): Last reviewed commit: "fix(terminal): keep restored OSC-8 range..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthrough
Merge Risk: ⚪ Minimal · up to This change preserves clickable links in restored terminal history during no-op resizes while still clearing link ranges when dimensions actually change. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. ✨ 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 |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Early return on same-size resize —
HeadlessEmulator.resize()now returns before clearingrestoredOscLinkswhenthis.terminal.cols/rowsalready match the requested dims, so restored OSC-8 ranges survive the same-size resize records that cold restore replays on every reattach. - Focused regression suite — five exact-
toEqualcases pinning same-size keep, col/row-change drop, repeated same-size replay, and the (unchanged)clearScrollbackdrop.
The guard is sound: terminal.cols/rows are only ever mutated by resize() itself, so the equality check exactly matches "no reflow happened". The fix corrects the root cause for every caller (live, replay, runtime mirrors) rather than deduping records at the durable-log layer, and clearScrollback()'s clearing is correctly left intact. Tests are exact and the two same-size cases fail against the pre-fix behavior; I verified the suite passes (5/5). Daemon-only, no wire or persisted-format change.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Hosted iOS security e2e (three branch-only harness bugs): - `simctl privacy grant` terminates the app; the relaunch cold-resumes straight onto the session route, so skip workspace-row activation when the hybrid handoff already landed on /session/. Activation failures now name the document href. - Uploaded-path regex fused two abutting orca-paste-*.png paths; use a lazy segment quantifier. - Photos orders by capture date, which addmedia takes from file birth time; stage a freshly written fixture copy (copyFile clones birth time on APFS) so "last Photo" is the fixture. Root tests: - Allowlist walker skips -test-fakes / -test-fixture(s) / .test-support sources, which are not mobile call sites. - Drop the height-only OSC-8 test: main's #17759 clears restored ranges on any dimension change and pins it. - Drop serve-update-handoff-startup-order.test.ts: main pins the same order against main-process-preflight.ts. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…lyai#17759) Cold restore seeded a checkpoint's OSC-8 link ranges and then replayed records that resize, so any resize record after the checkpoint dropped them and restored hyperlinks in scrollback lost clickability. Same-size resize records reach the durable log routinely, because every attach re-asserts the pane's dimensions and session-output-plane records each one without a same-size dedupe — so an ordinary reattach was enough to lose the links. Restored ranges are row-indexed, so clearing them on a reflow is right; a resize to the size already applied is not a reflow. Gate on the dimensions actually changing. Introduced in 10fe9a0 ("fix: improve mobile link modifier handling", stablyai#5597), which added setRestoredOscLinks along with unconditional clearing in both resize() and clearScrollback(). clearScrollback's clearing is correct and is unchanged, with a test pinning it. Found during adversarial review of stablyai#17752 and filed as stablyai#17756. Not a regression from that PR: stablyai#17667 had incidentally masked it by gating no-op resizes to protect a snapshot cache, and removing the cache removed the gate. The same gate returns here on its own terms — as a correctness fix with tests, rather than as a side effect of a cache.

Fixes #17756.
ELI5
Terminals can contain clickable links. When Orca restores a terminal's history after a restart, it recovers those links along with the text.
It was throwing them away. Restored links are remembered by which row they're on, so if the terminal gets resized the remembered positions are wrong and Orca clears them — correct. But it also cleared them when the terminal was "resized" to the size it already was, which isn't a resize at all. That happens routinely: every time you reattach to a terminal, Orca re-asserts its dimensions.
So the common case — restore a session, reattach to it — silently lost every clickable link in the restored scrollback. Now a resize only clears them when the size actually changed.
The bug
HeadlessEmulator.resize()clearedrestoredOscLinksunconditionally:The cold-restore path seeds the ranges and then replays records that resize:
history-reader.ts:298—setRestoredOscLinks(checkpoint.oscLinks)→:313—replay.resize(record.cols, record.rows)daemon-durable-history-snapshot.ts:91(set) →:180(resize, viareplayPendingRecords)And same-size resize records genuinely reach the durable log:
session-output-plane.ts:109-111records every resize with no same-size dedupe, while every attach re-asserts the pane's dimensions.Net effect: cold-restore a session whose post-checkpoint log holds any resize record — including a no-op one from an ordinary reattach — and the checkpoint's OSC-8 ranges are dropped. Restored hyperlinks lose clickability. Cosmetic fidelity loss, not corruption.
Where it was introduced
d46349c —
fix: improve mobile link modifier handling(#5597), 19 Jun 2026.That commit added
setRestoredOscLinksand, in the same change, unconditional clearing in bothresize()andclearScrollback():if (this.disposed) { return } + this.restoredOscLinks = [] this.terminal.resize(cols, rows)The intent was right — row-indexed ranges don't survive a reflow — but the guard was missing, so it also fired on same-size resizes.
clearScrollback()'s clearing from that commit is correct and is left alone (with a test pinning it).Not a regression from the recent perf work
#17667 incidentally masked this by gating no-op resizes to protect a snapshot cache; #17752 removed that cache and with it the gate, restoring the pre-existing behavior byte-for-byte. So the bug was latent from June, briefly hidden, and is now fixed on its own terms — as a correctness change with tests, rather than as a side effect of a cache.
Fix
Return early when
cols/rowsalready match. Chosen over deduping resize records insession-output-plane.tsbecause it fixes the root cause for every caller — live sessions, replay emulators, and runtime mirrors — not just the durable-log path.Verification
New
headless-emulator-restored-osc-links.test.ts, 5 cases. Confirmed the two same-size cases fail before the fix and pass after; the three real-invalidation cases (col change, row change,clearScrollback) pass throughout, so the fix doesn't over-correct.pnpm tcclean; 2956 tests pass acrosssrc/main/daemonand the runtime suites; changed-code quality gate clean.Risk
Daemon-only; no renderer, wire, or persisted-format change.