Repository navigation
feat(terminal): draw with libghostty by default on herdr-core servers - #2976
Conversation
|
Warning Review limit reachedYou'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. View limit details
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. |
…playing the backlog
|
Review round on 309a476: omo CLEAR; Codex (Terra, xhigh) no HIGH, two MEDIUMs.
|
…on-core # Conflicts: # src/lib/settings.ts
|
Merged origin/main once (454ecf3; the only conflict was 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. |
|
Local merge gate (owner-approved): origin/main merged (one settings.ts conflict, both kept), |
… 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).
…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.
## 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).
… 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.
What
Settings > Terminal > Draw with libghostty (#2908) is on by default.
terminal-history, as the desktop app runs); on herdr and mirrored panes xterm.js draws exactly as before.falseis kept, only a missing or invalid value means on. Note: since feat(terminal): draw herdr-core panes with libghostty, Kitty graphics pictures included, behind a Settings toggle #2908 every settings save writes this key, so a device that saved any setting on a main build after feat(terminal): draw herdr-core panes with libghostty, Kitty graphics pictures included, behind a Settings toggle #2908 also hasfalsestored and stays off; released versions never had the key, so their users get the new default.Gates (step 1 checklist, measured on isolated hc 0.1.17 + this stack)
seq 1 200000, ABBA)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 storedfalsestays 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