Skip to content

feat(terminal): libghostty alone parses every attached pane by default - #4761

Merged
devswha merged 2 commits into
mainfrom
feat/ghostty-only-everywhere
Nov 25, 2026
Merged

devswha merged 2 commits into
mainfrom
feat/ghostty-only-everywhere

Conversation

@devswha

@devswha devswha commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Step 8 of moving the terminal from xterm to libghostty. It builds on step 7 (#4760), which turned the libghostty-only path on by default for phones and tablets.

This turns that path on by default on every device, on herdr-core and herdr alike. One exception keeps xterm's full parse: a mirrored pane. That is a Windows PC's pane, or one on a machine without a PTY host, which is repainted from pane.read. Its folded view stands the IME's preedit on xterm's rows. The choice is made before the first byte, and a pane not yet known to be mirrored counts as attached.

localStorage ovis:ghostty-only (on / off) still decides over the default.

Nothing on screen is meant to change. Rows, the cursor, selections, links, pictures and the scroll position are drawn by the same libghostty layer as before. Only xterm's second, hidden parse is dropped.

Speed

All runs used the same recording, a 1.56 MB Claude Code session, with 5 runs per arm. All 10 runs got identical bytes.

Desktop (1280x800, no CPU throttle):

Both engines (before) libghostty only (default after this)
Main thread 491 ms 340 ms (1.44x)
Browser CPU 4160 ms 1660 ms (2.51x)
Start to settled 582 ms 457 ms
Heap growth 2.2 MB 3.4 MB (the 8 MiB kept for a handover)

Phone emulation (390x844, 4x CPU throttle), for reference from step 7:

  • main thread: 5326 ms -> 2141 ms (2.49x)
  • browser CPU: 10600 ms -> 3660 ms (2.90x)

Also in this PR

Default-on brought three browser scripts to fail on the first CI run:

  • The outputProbe in useTerminalMount counted bytes reaching xterm. xterm now gets controls only, so the probe counts each output frame where it enters the terminal, whichever engine parses it. This fixes sidebar-activity and terminal-release-no-watch.
  • A real difference: an OSC 52 whose ST was split between ESC and the backslash was copied one frame late. xterm ends a string at its ESC, so the picture writer and the control scanner now pass that ESC on with the write it ends, and send only the backslash after it. Unit tests in controls.test.ts and itermPictureWriter.test.ts cover it; both fail without the fix.
  • replay-clipboard reads xterm's own OSC parse state, so it runs with the libghostty-only path off. That is the path mirrored panes and every fallback still take.

Tests

  • capture.test.ts: the default is on unless the pane is mirrored, and a stored choice decides over it.
  • overlay-fallback.test.ts: the case without the flag now sets "off", since the default is on.

Validation

Step 8: the libghostty-only path is on by default on any device and
either server (herdr-core and herdr), except a mirrored pane (a Windows
PC's, repainted from pane.read), whose folded view stands the IME's
preedit on xterm's rows. The choice is made before the first byte; a pane
not yet known to be mirrored counts as attached.
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • libghostty now parses terminal output by default on attached panes, except mirrored panes, which continue using xterm parsing.
    • The saved “on” and “off” preferences continue to override the default.

The default libghostty parser selection now depends on whether a pane is mirrored, rather than on coarse-pointer state. The "on" and "off" local-storage choices still override the default. Terminal mounting passes mirrored-pane state to capture setup.

Changes: Ghostty capture selection

Layer / File(s) Summary
Default parser selection
src/lib/ghostty/capture.ts, src/lib/ghostty/capture.test.ts
Without a stored choice, libghostty is selected for non-mirrored panes and not selected for mirrored panes. The tests cover the default and stored choices.
Mirrored-state wiring and capture tests
src/lib/useTerminalMount.ts, src/lib/ghostty/capture.ts, src/lib/ghostty/overlay-fallback.test.ts
Terminal mounting passes a mirrored-state callback to captureForGhostty. The capture tests provide the new callback argument.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Possibly related PRs

  • devswha/ovis#4760: Adds a phone and tablet default that uses the same stored-choice setting and default-selection logic.
  • devswha/ovis#4759: Adds the ovis:ghostty-only option whose default this PR changes.
  • devswha/ovis#4669: Routes masked-prompt reads to libghostty while the overlay is attached, in a context where xterm still parses the stream.
Merge Risk: Minimal · up to b768e

This change makes libghostty the only parser for attached panes on every device and keeps xterm's full parse for mirrored panes. No actionable merge-blocking risk was found, and the localStorage override still allows a fallback.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main behavior change: libghostty-only parsing becomes the default for every attached pane. The changeset matches this: ghosttyOnly now defaults to on except for mirrored panes, and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template. It has a Change section that explains the default-on libghostty-only path, the mirrored-pane exception, and the localStorage override. It also has a Va…
Full details: Title check

Explanation

The title names the main behavior change: libghostty-only parsing becomes the default for every attached pane. The changeset matches this: ghosttyOnly now defaults to on except for mirrored panes, and the tests were updated to match. The title uses the conventional feat(terminal) prefix and is specific enough to scan history.

Full details: Description check

Explanation

The description follows the repository template. It has a Change section that explains the default-on libghostty-only path, the mirrored-pane exception, and the localStorage override. It also has a Validation section that lists the checks run and their results. It has no linked issue for the feature, which the template asks for, but the PR links the prior step (#4760), and the template calls for a linked issue only for features. Validation lists bun run check fast and nine browser suites. It does not state whether bun run check full was run or whether contract tests for HTTP/WS changes apply. The changelog entry required by CONTRIBUTING.md is not mentioned.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bc6d5d3 and b768e31.

Files selected for processing: 4

  • src/lib/ghostty/capture.test.ts
  • src/lib/ghostty/capture.ts
  • src/lib/ghostty/overlay-fallback.test.ts
  • src/lib/useTerminalMount.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

…it ends a write; the scripts' probe counts output frames

With libghostty parsing every pane by default, three browser scripts
failed. Two waited on the outputProbe, which counted bytes reaching xterm;
xterm now gets controls only, so the probe counts each output frame where
it enters the terminal, whichever engine parses it.

The third showed a real difference: an OSC 52 whose ST was split between
ESC and the backslash was copied one frame late, because the picture
writer held the trailing ESC and the control scanner waited for the
backslash. xterm ends a string at its ESC: both now pass that ESC on
with the write it ends, and send only the backslash after it.

replay-clipboard reads xterm's own OSC parse state, so it runs with the
libghostty-only path off (the path mirrored panes and every fallback take);
the libghostty-only clipboard guard is covered by the unit tests.
@devswha
devswha merged commit 741a7f1 into main Nov 25, 2026
27 of 29 checks passed
@devswha

devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head afed07b45. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit finished, with no review that names this head.

main moved but untouched: merged without update. Its new commits up to 29444b8dd change no file of this pull request, none imported by one, nothing that decides which checks run, and no core path.

Reviews: step 8 flips the default of the step 5 path (reviewed there: gate reviewer, Codex adversarial, CodeRabbit with 16 threads fixed) to every attached pane; CodeRabbit on this PR. On the lane brief's word.

@devswha
devswha deleted the feat/ghostty-only-everywhere branch November 25, 2026 20:44
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