Skip to content

fix(test): read the header crumb apart from the session line in the reconnect regression - #2937

Merged
devswha merged 1 commit into
mainfrom
fix/main-reconnect-header
Nov 5, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/main-reconnect-header

Conversation

@devswha

@devswha devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Summary

scripts/reconnect-header-demo-regression.ts fails on main (reproduced on ea3b07fa):

error: innerText: Error: strict mode violation: locator('.context-sub') resolved to 2 elements:
    1) <div class="context-sub">…</div>
    2) <div class="context-sub context-session" title="Worked 1m · Transcript size unknown">…</div>

#2909 added the session line (.context-sub.context-session) under the pane title, so the regression's crumb locator now matches two elements. The product is right: the session line is a second row that App.tsx already hides while the connection word (Reconnecting… / Connected) has the crumb's place. Only the test's locator was too broad, so this PR narrows it to the crumb: .context-sub:not(.context-session).

No product code changes.

Validation

  • bun scripts/reconnect-header-demo-regression.ts: failed before (strict mode violation above), passes after: PASS 390, PASS 412, PASS 1280.
  • bun run check fast: passed (workflow syntax, generated types/themes, typecheck, build, unit tests: 11869 pass, 0 fail, 46 skip)
  • Skipped: bun run check full (test-only change to a single browser script; CI's Integration and browser job runs it).

…econnect regression

#2909 added a second .context-sub (.context-session) under the pane title,
so the reconnect header regression's crumb locator matched two elements and
Playwright's strict mode failed it on main. Target the crumb alone; the
product already hides the session line while the connection word shows.
@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 3 minutes.

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 ea3b07f and 5e5eba5.

Files selected for processing: 1

  • scripts/reconnect-header-demo-regression.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

Local merge gate (owner-approved): test-only fix; the script failed on main and passes at 390/412/1280; check fast green; omo CLEAR. Merged without waiting for GitHub CI to unblock main's browser lane.

@devswha
devswha merged commit 24b8a87 into main Nov 5, 2026
11 checks passed
@devswha
devswha deleted the fix/main-reconnect-header branch November 5, 2026 09:14
devswha added a commit that referenced this pull request Nov 5, 2026
… pictures included, behind a Settings toggle (#2908)

## What

Settings > Terminal > **Draw with libghostty** (off by default, this
device only). On a PC that runs herdr-core, as the desktop app does, a
pane is drawn by [libghostty-vt](https://github.com/ghostty-org/ghostty)
(Ghostty's terminal core, MIT) instead of xterm.js's own text layer, and
the pictures a program sends with the **Kitty graphics protocol** are
drawn: `chafa -f kitty`, `timg -pk`, `kitten icat
--transfer-mode=stream`.

xterm stays the engine underneath: it still takes every key, IME
syllable, paste, click, selection, link, search and scroll, and still
answers the program's queries. Its text and cursor layer is hidden;
libghostty draws the same bytes, in the same order, as plain DOM rows
over xterm's screen at xterm's cell size, plus a canvas per Kitty
placement (below or above the text, as Kitty's z says). libghostty
answers nothing: a reply it made to a replayed stream would reach the
program as typing (herdr-core already answers size queries itself).

This complements #2871 (sixel and iTerm2 through `@xterm/addon-image`,
which has no Kitty graphics): libghostty has no sixel, the addon has no
Kitty, and the two layers do not overlap.

## How

- `src/lib/ghostty/ghostty-vt.wasm`: libghostty-vt at ghostty e95bed6
for wasm32, rebuilt by `scripts/ghostty-vt/build.sh` with
`kitty-on-wasm.patch`. Upstream turns Kitty graphics off on freestanding
wasm; the patch turns it on, refuses the file / temp-file /
shared-memory media (no filesystem in a browser), and links ghostty's
bundled wuffs PNG decoder. 1.11 MB (345 KB brotli). The build now writes
.br/.gz copies beside it, but the server still serves precompressed
copies for js/css only, so today the module goes out uncompressed
(follow-up below). Notices for ghostty, wuffs and uucode in
THIRD_PARTY_NOTICES.md.
- `src/lib/ghostty/capture.ts`: from the terminal's mount (setting on),
every byte xterm is given is held; once the server lists its features
and says `terminal-history` (herdr-core), the overlay module is loaded
and starts from those bytes. herdr's own server, a module that fails to
load, or more than 32 MB held leave the terminal to xterm and never
fetch the module.
- `src/lib/ghostty/vt.ts`, `overlay.ts`: the wasm wrapper (rows as
styled runs, the render state's Kitty image list, palette from the xterm
theme, scroll sync with xterm's own herdr-core history) and the DOM
layer. Each cell carries its own grapheme and width, so a combining mark
never shifts a wide cell.
- CSP: `script-src 'self' 'wasm-unsafe-eval'` (the same line #2871
adds), so the page may compile WebAssembly; no string eval.
- The choice applies to a pane the next time it is opened (the
description says so): libghostty must see the stream from its first
byte.

Design reference: Ghostty's own split of a terminal core (libghostty-vt)
from the renderer an app draws with, rather than a second terminal
widget; everything already built on xterm keeps working while the
drawing moves. Clean-room from ghostty's public MIT source.

## Validation

- `bun run check fast`: pass (exit 0) on 312eb94 (merged with
origin/main 22a4b33, #2871 and #2937 included). `check full` not run
here; CI runs the browser lane.
- `bun scripts/terminal-ghostty-demo-regression.ts` (new, added to
`scripts/ci-browser.sh`): a herdr-core pane is drawn from its first byte
(printed before the module loaded), a Kitty picture is drawn at its row
and goes on `a=d`, a wide cell after a combining accent stays the CJK
character (fails on the first head), ANSI red under a palette that names
no ANSI colours is xterm's red (fails before 8189fde), typing still
reaches the pane through xterm; on herdr's own server and with the
setting off nothing is drawn by libghostty and the `.wasm` is never
fetched.
- `bun test src/lib/settings.test.ts server/static.test.ts
server/static-encoding.test.ts scripts/compressed-assets.test.ts
scripts/changelog-fold.test.ts`: pass.
- Manual, isolated hc 0.1.17 core (own HC_SESSION, XDG dirs, socket) +
this branch's server on loopback, headless Chromium at 1280x800 and
390x844: chafa / timg / icat (stream) pictures drawn; with the setting
off xterm draws none; resize (rows match xterm), wheel through history
(top 10 rows identical to xterm's), drag selection + copy + Quote,
Korean text input, `less` alternate screen and back.
- Known, not in this PR: `kitten icat` in its default mode gives up
because herdr-core answers the DA1 query on the server before the
browser's Kitty reply arrives, and hc gives the pty no pixel size; those
are herdr-core-side.

## Follow-ups (this PR is step 0)

The end state is one rendering path: libghostty draws every terminal, on
herdr-core and on herdr, and xterm's drawing code goes.

1. **Default on for herdr-core** once: the two renderers match row text
and cell colours across the themes (a two-renderer browser regression);
light-theme contrast correction matches xterm's minimumContrastRatio
4.5; cursor and selection positions match for emoji, CJK, combining
marks, Nerd icons and box glyphs; link hover underline and cursor blink
are drawn.
2. **herdr mode too, then drop xterm's drawing**, gated on:
- serve the module's precompressed copy (server/static.ts compresses
js/css only today);
- phone first load: the extra 345 KB brotli adds at most 0.5 s to the
first terminal text on an emulated 4G phone with a 4x CPU slowdown
(median of 5, off vs on);
- repeat loads: 0 wasm bytes on the second visit and across a build that
keeps the module (the service worker serves `/assets/` cache-first and
carries a same-named file into the new build's cache);
- iOS long-press select and copy on the libghostty rows (iOS Simulator
script);
- screen readers: VoiceOver and NVDA read new output and walk the rows
(the layer is aria-hidden today);
- low-end phone frame time under runaway output at a 6x CPU slowdown: no
more 50 ms stalls than xterm, p95 frame gap at most 33 ms.
Then input, selection and search move to libghostty's key encoder,
selection and search APIs, and xterm's parser and renderer are removed.
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