Skip to content

feat(terminal): draw with libghostty by default on herdr-core servers - #2976

Merged
devswha merged 3 commits into
mainfrom
feat/ghostty-default-on-core
Nov 5, 2026
Merged

devswha merged 3 commits into
mainfrom
feat/ghostty-default-on-core

Conversation

@devswha

@devswha devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner

What

Settings > Terminal > Draw with libghostty (#2908) is on by default.

Gates (step 1 checklist, measured on isolated hc 0.1.17 + this stack)

Gate Result
Phone first load (slow 4G 1.6 Mbps/150 ms, CPU x4, fresh profile, median of 5) off 7,510 ms / on 7,918 ms: +408 ms, within +0.5 s (wasm served br since #2953: 1.11 MB -> 345 KB, re-open fetches no wasm)
Low-end phone frames (CPU x6, seq 1 200000, ABBA) after #2959 on is at or below off: median finish 10.5 s vs 10.8 s, stalls > 50 ms 4 vs 7
Screen reader (real NVDA 2026.2, Windows 11 VM, Edge 156) on: NVDA reads new output; off (xterm, screen reader mode off): reads nothing. Known follow-ups in #2963
iOS long-press copy (iOS 27 Simulator, Safari) provisionally equal: neither xterm nor libghostty shows a selection/copy menu on a 1.6 s long-press (driven with simctl + AXe touch). Pending one manual check once Simulator components are installed on the test Mac. Copy keeps working through the key bar's copy button and OSC 52 (#2925)

Validation

  • bun test src/lib/settings: pass (the two tests that pinned the old default now pin the new one: missing/invalid means on, a stored false stays off, the key stays out of the whole-record save).
  • bun scripts/terminal-ghostty-demo-regression.ts: pass (herdr-core pane drawn with libghostty, herdr's own and off stay xterm).
  • bun run check fast: pass (exit 0) on this head

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

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 1 minute.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ea4957e and 454ecf3.

Files selected for processing: 5

  • changelog.d/ghostty-default-on.md
  • src/lib/ghostty/overlay-fallback.test.ts
  • src/lib/ghostty/overlay.ts
  • src/lib/settings.test.ts
  • src/lib/settings.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

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review round on 309a476: omo CLEAR; Codex (Terra, xhigh) no HIGH, two MEDIUMs.

  • MEDIUM, reproduced (unit test): when libghostty failed while replaying the backlog, term.write and term.reset stayed wrapped around the freed module, and the next write threw ReferenceError: Cannot access 'overlay' before initialization before reaching xterm. Fixed in the next commit: that path restores xterm's own write/reset before rethrowing. src/lib/ghostty/overlay-fallback.test.ts fails on the previous head with that error and passes now. Default on makes this path reachable for everyone on herdr-core, so it is fixed here rather than as a follow-up.
  • MEDIUM, not reproduced: during an upgrade, a tab still running the previous version can write false to ovis:terminal-ghostty on an unrelated settings save (it read the missing key as false), turning the new default off for that device. Same family as the note in the description (any save since feat(terminal): draw herdr-core panes with libghostty, Kitty graphics pictures included, behind a Settings toggle #2908 wrote the key). A separate key would avoid it but would also discard real opt-outs; left as is, recorded here.

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Merged origin/main once (454ecf3; the only conflict was src/lib/settings.ts, where main added terminalAttachButton next to terminalGhostty: both kept). bun install --frozen-lockfile + bun run check fast: pass on 454ecf3.

omo on this head (its review confirms 454ecf3 adds only the main merge): BLOCK on one reproduced MEDIUM that predates this PR but reaches more users with the new default: with Pictures in the terminal on, text after an iTerm2 inline image lands on a different row in libghostty than in xterm. This PR already used its extra fix round, so it is tracked in #2980 for the maintainer's call.

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate (owner-approved): origin/main merged (one settings.ts conflict, both kept), bun run check fast passed at this head, omo re-check of the merge: no HIGH; one reproduced MEDIUM that already exists on main for users who opted into terminal images (text after an iTerm2 inline image lands on a different row under libghostty) is #2980 and is being fixed next. Default on in herdr-core mode only; devices that turned it off stay off. Step-1 gates in the PR body. Merged without waiting for GitHub CI.

@devswha
devswha merged commit a3754c1 into main Nov 5, 2026
11 of 12 checks passed
@devswha
devswha deleted the feat/ghostty-default-on-core branch November 5, 2026 12:03
devswha added a commit that referenced this pull request Nov 5, 2026
… draws on herdr-core (#2985)

## Summary

`scripts/core-history-scroll-demo-regression.ts` (Integration and
browser) fails on main since #2976: on a herdr-core server libghostty
now draws the pane by default, so xterm's own `.xterm-rows` are hidden
under its layer, and the script's `waitFor()` on a *visible*
`.xterm-rows` with `HIST-300` times out.

Scrolling the history itself works with libghostty: the overlay follows
xterm's view (`term.onScroll` -> `vt.scrollFromBottom`). The fix is
test-only:

- wait for `HIST-300` on the rows the user sees: libghostty's
`.ghostty-row` when the pane has `data-renderer="ghostty"`, else xterm's
rows;
- after the wheel scrolls xterm's view back, also wait until the drawn
rows show an older line than before, so a libghostty layer that stops
following the scroll fails here instead of passing on xterm's buffer
alone.

## Validation

- On origin/main a8a155c the script fails (`waitFor ... resolved to
hidden <div class="xterm-rows">`); the unchanged script passes with
`ovis:terminal-ghostty` set to false, which pins the cause to the
default change.
- With this change: `bun scripts/core-history-scroll-demo-regression.ts`
-> `PASS core` and `PASS herdr`.
- With `vt.scrollFromBottom(...)` in `src/lib/ghostty/overlay.ts`
temporarily replaced by `vt.scrollFromBottom(0)`, the new check fails:
"the wheel moved xterm's view but the rows drawn still start at
HIST-257".
- `bun run check fast`: pass (workflow syntax, generated types/themes,
typecheck, build, unit 12076 pass / 0 fail, actionlint).
devswha added a commit that referenced this pull request Nov 5, 2026
…y draws, as xterm does (#3012)

## What

When libghostty draws a pane (default on herdr-core since #2976), glyphs
now fit their cells the way xterm.js's rows fit them
(`src/lib/terminalGlyphs.ts`):

- A two-cell glyph (Hangul, kana, Han) that leaves its cells half empty
is widened/enlarged with the same `glyphFit` xterm's rows use. Before,
Korean read looser than with xterm, and a syllable being typed (sized by
the xterm fit) came out larger than the committed ones beside it
(13.87px vs 13px in `terminal-ipad-ime-regression`).
- The two-cell box and the fit span inherit `text-decoration`:
underlined Hangul lost its underline (an inline-block takes none from
its parent).
- A Nerd Font icon wider than its one cell is drawn smaller inside it
(`oversizedIcon`/`iconScale`), so it no longer spills over the next cell
or pushes the rest of its run off its columns.
- Widths are measured once per glyph and font, and a late web font
(`followLateFaces`) redraws the rows from their kept runs; a new cell
size redraws them too.
- The screen a pane opens on is primed only once something was written,
so a pane whose first paint comes after the layer attaches is not read
out by a screen reader.

Design follows xterm.js + this repo's own `terminalGlyphs.ts` (the same
fit functions), so both renderers draw CJK and icons alike.

## Validation

- Failing first: the new core-mode checks in
`scripts/terminal-ghostty-demo-regression.ts` fail on main (`a Hangul
syllable fills its two cells as xterm draws it (0.767)`) and pass on
this branch.
- `bun run check fast`: pass.
- `HERDR_TEST_MODE=unit bun test src/lib/ghostty`: pass.
- With libghostty also drawing herdr panes (local branch, not in this
PR): `terminal-hangul-seam` (0 stray pixels, closing bars 445 / 444.97
px), `terminal-cjk-punctuation`, `terminal-late-faces`,
`terminal-ipad-ime`, `terminal-bundled-mono`, `terminal-composition`
regressions pass.
- Not run: full suite, Windows, iOS.
devswha added a commit that referenced this pull request Nov 5, 2026
## What

libghostty (Settings > Terminal > Draw with libghostty, default on since
#2976) now draws panes on herdr's own server too, not only on
herdr-core. A device that turned the setting off keeps xterm.js.

- `src/lib/ghostty/capture.ts`: the held bytes go to libghostty once the
server lists its features, on either server; herdr's own server no
longer gives up. xterm stays the engine underneath (input, IME,
selection, links, search, the folded mirror).
- `src/lib/ghostty/overlay.ts`: a run made only of boxed cells (a wide
or icon cell each) puts its colour and italic on the innermost box, not
on the run's span. When a Korean screen had a different colour in every
cell (three elements a cell), each element sat under a parent with its
own inherited colour and was styled from scratch. With CPU x4 that took
773 us/element against ~250-300 us after the change and ~300 us for
xterm, and the frames fell behind (the sync-output regression failed 3/3
with the layer on and passed with xterm). The boxes and what they draw
are unchanged.
- Colours as xterm draws them, now that herdr users get the layer by
default: xterm's `minimumContrastRatio` (4.5) through `terminalFold.ts`
`readableColor`, except box, block and Powerline glyphs (xterm's
`treatGlyphAsBackgroundColor`); faint dims the text by half, not the
background; an underline or strikethrough takes its text's colour; boxed
cells of a bold run carry `xterm-bold`, so xterm's
`span:not(.xterm-bold)` rule no longer makes them normal weight.
- Screen reader on herdr's own server: herdr paints a scrolled view as
output, so frames until 1 s after a wheel, a swipe or a viewport-tools
scroll (page keys, Jump to bottom: `VIEW_MOVED_EVENT`) announce nothing.
Only when xterm keeps no history (herdr's own server).
- Settings text (en/ko/ja/zh): the row no longer says "only on
herdr-core"; pictures (Kitty graphics) still need herdr-core, since
herdr redraws from its grid.
- Browser regressions read the rows the user sees
(`scripts/shown-rows.ts`: libghostty's rows while it draws, xterm's
otherwise or while a mirror is folded). xterm's own rows are hidden and
no longer redrawn under the layer, so ~40 scripts that read
`.xterm-rows` text are updated; their assertions are unchanged.

## Gate numbers (herdr mode, isolated herdr test session, loopback,
telemetry off)

| Gate | Off (xterm) | On (libghostty) | Result |
|---|---|---|---|
| Phone first load (390x844, 1.6 Mbps/150 ms, CPU x4, median of 5) |
7113 ms | 7226 ms (+113) | PASS (limit +500) |
| Re-open: wasm bytes from network | - | 0 (5/5 from the service worker)
| PASS |
| Low-end CPU x6, `seq 1 200000` (median of 6) | 263 ms, 0 stalls, p95
50 ms | 243 ms, 0 stalls, p95 42 ms | PASS |
| Sync output, Korean truecolor per cell, CPU x4 | pass | pass (after
this PR's change; 3/3 fail before) | PASS |
| Screen reader: new output announced, scroll not | - | announced / not
| PASS |

Parity: selection/copy, find, file links, IME (Linux, Safari, iPad), key
bar, Hangul spacing (seams, column alignment), CJK punctuation, late
fonts, mirrored panes drawn from `pane.read` (unfolded by libghostty,
folded by xterm) all pass the browser regressions with libghostty
drawing.

## Validation

- Failing first: the herdr case in
`scripts/terminal-ghostty-demo-regression.ts` fails on main (no
`data-renderer`) and passes here.
- `bun run check fast`: pass.
- With CPU x4 and tracing on, `terminal-sync-output-regression` (Korean
truecolor frames) passes 2/2 with the layer on; `terminal-sync-output`,
`terminal-ghostty-demo`, `terminal-hangul-seam`, `terminal-ipad-ime`,
`terminal-late-faces`, `terminal-cjk-punctuation` pass after the change.
- Browser regressions run locally with the layer on: listed above, plus
the ~40 migrated scripts (each PASS).
- Not run: `windows-terminal-browser-qa.ts` (needs native Windows), real
iOS long-press and VoiceOver/NVDA (the layer is the same code as
herdr-core mode, where they were checked in step 1).
devswha added a commit that referenced this pull request Nov 5, 2026
… itself (#3035)

## What

libghostty now draws every pane: the Settings > Terminal > Draw with
libghostty switch is gone, and a device that had turned it off is drawn
by libghostty too. xterm.js stays the engine underneath (input, IME,
selection, links, search, scrolling) and still draws by itself only
where the layer cannot, so a pane never goes blank:

- the libghostty module does not load or fails (old browser, CSP, out of
memory): `capture.ts` / `overlay.ts` hand the pane back to xterm, as
before;
- an iTerm2 or sixel picture (Pictures in the terminal), which
libghostty does not take (#2980): xterm draws that pane, as before.

Changes: `terminalGhostty` removed from `Settings` (type, default,
scope, sanitize, its `ovis:terminal-ghostty` key, telemetry projection),
the Settings row and its en/ko/ja/zh strings, the `ghosttyRef` plumbing
in `PaneTerminal.tsx`/`useTerminalMount.ts` (the capture always starts),
and the docs (DESIGN.md, development.md, comments). An old tab's
whole-record save that still carries the field is dropped by
`sanitizeSettings` as any unknown field.

Design follows Ghostty's own split (libghostty-vt as the terminal core,
the app's own renderer), as in #2908/#2976/#3025; keeping xterm's
renderer only as an automatic fallback matches how browsers keep a
software path when a GPU path fails.

## Gates (herdr mode, isolated herdr test session, loopback, telemetry
off)

See the Validation comment below for the numbers of this head (phone
first load vs xterm, re-open wasm bytes, CPU x6 runaway output,
announcements).

## Validation

- Failing first: in `scripts/terminal-ghostty-demo-regression.ts` a
device with the old switch stored off is drawn by libghostty; on main it
stays xterm (`waiting for .pane-terminal[data-renderer='ghostty']` times
out), on this branch it passes.
- `bun run check fast`: see below.
- Browser regressions: see below.
- winvm (native Windows, main 0df1012): `pr-check.ps1` incl.
`windows-terminal-browser-qa.ts` PASS before this change; this change
does not touch the mirror path.
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