Skip to content

fix(terminal): keep a fitted Hangul run's background whole, so no light line follows each Korean word - #2263

Merged
devswha merged 2 commits into
mainfrom
fix/mac-pwa-terminal-parity
Oct 28, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/mac-pwa-terminal-parity

Conversation

@devswha

@devswha devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner

What it fixes

Closes #2262. In the terminal, Korean text on a background colour showed a thin light vertical line right after each Korean word: in Claude Code's prompt block, in a highlighted line, and in inverse video. The owner reported it in Ovis for Mac.

Reproduced on the test MacBook Air (isolated herdr session and test servers) in the real Ovis.app, in a WKWebView with the app's configuration, and in Mac Chrome; also in Linux Chrome. It shows at 1x and 2x, on light and dark themes. It is already there at b48c66a, before #2243, so #2243 did not cause it; it dates from the glyph fit itself.

The cause

lib/terminalGlyphs.ts fits a Hangul syllable to its two cells:

All of that was written on xterm's own span, which also paints the cells' background (SGR background, inverse, block cursor). The clipped and stretched box ended inside a device pixel, while the next span's background starts on a whole one. The pixel between them was drawn half-covered, so a line of the pane's colour showed through.

The change

The fit goes on a span inside xterm's (marked with the module's BOX_CLASS, so the observer leaves it alone). xterm's span keeps its background on a box that is neither stretched nor clipped, and its own letter-spacing becomes 0. The inner span inherits text-decoration and font-weight, because xterm makes every span of a row an inline-block, which an underline does not reach into. The text, the columns and the copy are unchanged: the run still closes on the Latin row's column, and an underline stays under its cells.

Ovis for Mac (real app), main This PR
main fix

WKWebView with the app's configuration, light theme. Top: b48c66a (before #2243). Middle: main. Bottom: this PR.

before #2243
main
this PR

Checks

  • New browser check scripts/terminal-hangul-seam-regression.ts (added to ci-browser.sh). It draws Korean on dark, light and inverse backgrounds with the bundled faces, then reads the screenshot's device pixels on both sides of each fitted run's right edge, at 1x and 2x on light and dark themes. It also checks that the closing bar of |가나다라마바사| stands on the Latin row's column.
    • Fails on main and at b48c66a: 16 to 20 stray pixels per configuration, for example 204,202,198 against the block's 38,38,38.
    • Passes with this PR, with 0 stray pixels in Linux Chrome and Mac Chrome 156.
  • WKWebView probe (the app's configuration, not committed), stray pixels at the 21 fitted edges: main 16 light / 10 dark; b48c66a 14 / 10; this PR 0 / 0.
  • Unit test: bun test src/lib/terminalGlyphs.test.ts passes (34 tests). The fitted-run case now asserts that xterm's span carries no transform or clip and that the fit is on the inner span; it fails on main.
  • bun run check fast: pass (typecheck, build, 8177 unit tests, 0 fail).
  • Performance, measured the same way in Chrome, Safari and the app's WKWebView on the Mac, main → this PR:
    • keystroke-to-paint median about 33 ms in each, unchanged;
    • a 3 s Korean flood at 59-60 fps in each, unchanged.
  • QA ran in a fresh clone in /tmp on the test Mac, against isolated herdr sessions. Everything started for it is stopped and removed afterwards.

Reviews

  • omo-native-code-reviewer: PASS (APPROVE). No HIGH or MEDIUM findings. It reran the new check against main's terminalGlyphs.ts (fails) and this branch (passes), and checked block, bar and underline cursors, bold, italic, dim, underline and strikethrough in Chromium. Two LOW notes, both fixed in the second commit:
    • terminal-ipad-ime-regression.ts compared the pending syllable's size with xterm's outer span. The enlarged size now sits on the inner span, so the check reads the inner span (passes).
    • The seam check sampled the pane's colour three device pixels into the next cell, where a full-height | could sit. It now samples at the row's far end (passes).
  • Codex (gpt-6.1-sol, fast, xhigh): PASS. No findings. It went over cursors, decorations, inheritance, copy, the late-face path, observer re-entrancy, the IME view and the emoji path.

Related

The lane also measured Mac app vs Safari PWA vs Chrome terminal parity. With no coding font installed the three are identical: DOM renderer, Menlo, 16.5px rows, same latency and fps. With JetBrains Mono installed, Chrome draws it, while Safari and the app draw Menlo, so row height and count differ. That needs a product choice and is not part of this PR.

…ht line follows each Korean word

The glyph fit (centering padding, scaleX, trailing clip) moves to a span inside xterm's, which keeps the cells' background and block cursor on an untransformed, unclipped box. The clipped or stretched edge ended inside a device pixel, and the background painted there left a line of the pane before the next cell's (before and after #2243, in Chromium and WebKit, at 1x and 2x).
…s it, and the pane's colour where no row reaches
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 9a44f27 and 93e65c8.

Files selected for processing: 6
  • changelog.d/terminal-hangul-seam.md
  • scripts/ci-browser.sh
  • scripts/terminal-hangul-seam-regression.ts
  • scripts/terminal-ipad-ime-regression.ts
  • src/lib/terminalGlyphs.test.ts
  • src/lib/terminalGlyphs.ts

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

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed thin light seams appearing between Korean text on colored terminal backgrounds in Ovis for Mac, Safari, and Chrome.
    • Improved the rendering of fitted Korean text so background colors align cleanly across character cells in light and dark themes.

Fitted Hangul glyph styling now uses a child span instead of the xterm span. Tests and a browser regression check span structure, background edges, and alignment. Browser CI runs the regression, and the iPad IME check measures the fitted glyph span when available.

Changes: Hangul terminal rendering

Layer / File(s) Summary
Fitted glyph span and unit tests
src/lib/terminalGlyphs.ts, src/lib/terminalGlyphs.test.ts
Fitted glyph styles move to a child span that inherits text decoration and font weight. Tests check the outer span’s styles and the child run’s text and layout.
Browser seam regression and integration
scripts/terminal-hangul-seam-regression.ts, scripts/ci-browser.sh, scripts/terminal-ipad-ime-regression.ts, changelog.d/terminal-hangul-seam.md
The browser regression checks fitted-run edge pixels and Korean and Latin closing-bar alignment across light and dark themes at 1x and 2x. Browser CI runs the script. The IME check measures the fitted glyph span when present. The changelog describes the reported rendering issue.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: noobear

Merge Risk: Minimal · up to 93e65

The change addresses the reported Hangul background seam; normal browser checks should pass before merging.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the terminal Hangul background seam fix and its user-visible result. It is specific and related to the main change.
Description check Passed The description clearly explains the problem, cause, implementation, linked issue, validation checks, regression results, performance results, and QA scope. It uses equivalent headings instead of the …
Linked Issues check Passed PR #2263 addresses issue #2262. src/lib/terminalGlyphs.ts moves Hangul fitting styles to an inner span and leaves xterm's background span unclipped and untransformed. This targets the reported seam …
Out of Scope Changes check Passed The changes stay within issue #2262. The changelog documents the fix. The browser script and unit-test updates verify the seam and preserve alignment. The iPad IME regression update adapts an existing…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Description check

Explanation

The description clearly explains the problem, cause, implementation, linked issue, validation checks, regression results, performance results, and QA scope. It uses equivalent headings instead of the template headings, but it includes the required change and validation information.

Full details: Linked Issues check

Explanation

PR #2263 addresses issue #2262. src/lib/terminalGlyphs.ts moves Hangul fitting styles to an inner span and leaves xterm's background span unclipped and untransformed. This targets the reported seam on colored, inverse, highlighted, and prompt backgrounds. The PR adds scripts/terminal-hangul-seam-regression.ts, registers it in browser CI, and updates unit coverage. The reported checks pass at device scale factors 1 and 2 in light and dark themes, including Linux Chrome, Mac Chrome, and the configured WKWebView.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #2262. The changelog documents the fix. The browser script and unit-test updates verify the seam and preserve alignment. The iPad IME regression update adapts an existing check to the new inner span. No unrelated product behavior or unrelated feature change is shown.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 5 files. (1 skipped: 1 unsupported.)

Finishing Touches: 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 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

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Merging 93e65c8. Codex was at capacity, so an omo reviewer on gpt-6.1-sol and an independent second reviewer reviewed it; both pass with no findings. The glyph fit's centring, widening and trim no longer sit on xterm's own span, which paints the cells' background (SGR background, inverse, block cursor), so a fitted Hangul run's background stays whole. The new scripts/terminal-hangul-seam-regression.ts finds 0 stray pixels in all four configurations on this head and fails on its pixel assertion at the base; #2243's widening and row height are unchanged; the terminalGlyphs tests (34), build, typecheck and the iPad/iPhone IME replay pass. Closes #2262. The second reviewer ran main and this head in Chrome against isolated herdr sessions across 16 configurations (light/dark, DPR 1/2, 1200/390 px, 13/16 px) with SGR backgrounds, inverse, a highlighted line, a block cursor on a Hangul cell and a selection: the seam regression finds 6 to 20 stray pixels per configuration on main and 0 here (21 run edges each); Latin and Hangul alignment rows are pixel-identical to main; selections copy exactly. Not checked here: native Mac rendering (the PR reproduced and verified it on the test MacBook Air), performance, Korean clipboard selection and block-cursor screenshots.

@devswha
devswha merged commit d34727d into main Oct 28, 2026
19 of 21 checks passed
@devswha
devswha deleted the fix/mac-pwa-terminal-parity branch October 28, 2026 14:20
devswha added a commit that referenced this pull request Oct 28, 2026
…ery device, so Mac app, Safari and Chrome match (#2272)

## What it changes

The owner saw Ovis for Mac and the PWA or web app look different. For
example, the terminal's Korean row count did not match between them.
This came out of the mac-pwa-parity measurements (the seam that report
also found is fixed separately in #2263).

Measured on the test MacBook Air with the same isolated test server, a
1200x760 viewport at 2x, 13px and light theme. The same measuring script
ran in Chrome 156, Safari 27 and a WKWebView with Ovis for Mac's
configuration:

- **With no coding font installed, the three already matched:** Menlo,
16.5px rows, DOM renderer, keystroke-to-paint about 33ms, about 60fps
under a Korean flood. No performance gap between the surfaces was
measurable.
- **With JetBrains Mono installed, they did not.**
- Chrome draws the installed copy, with 17px rows and 936px for 120
columns.
  - Safari hides installed fonts from pages, so it draws Menlo.
- Ovis for Mac draws Menlo too: its WKWebView draws installed fonts but
its canvas, which xterm measures with, cannot see them, so #1942 drops
them.
- Rows were therefore 17px against 16.5px. A 900px-tall pane held 52
rows in Chrome and 54 in the app.
- **The bundled "JetBrains Mono Web" face was dropped in the app too**
when JetBrains Mono was installed. Its `@font-face` read
`local("JetBrains Mono Regular")` first, so it resolved to the installed
copy.

Dori chose the option that makes every surface the same: the bundled
JetBrains Mono becomes the terminal's default Latin face on every
device. The owner did not pick an option, and he tests main before a
release.

## The change

- **The terminal's first text font is `"JetBrains Mono Web"`**
(`lib/fontFamily.ts`), ahead of the installed JetBrains Mono, Fira Code,
D2Coding, Menlo, Consolas and Noto Sans Mono CJK KR. Those now draw only
if the face does not load. A font typed in Settings still goes first.
The icon font and Ovis Hangul Mono keep their places.
- **The face comes from the bundled files only** (`fonts/fonts.css`): no
`local()` copy, which the app's canvas cannot measure, and a new
**bold** (`JetBrainsMono-Bold.woff2`, JetBrains Mono v2.304 unchanged)
so bold text is not synthesized. `measurableFontStack` always keeps the
face, as it keeps the bundled icon and Hangul faces.
- **The grid is measured from the face, never from a fallback.** xterm
measures its cell only when the family is set, so the terminal opens
without the face while it has not loaded (`openingFontStack`). The font
effect (`useTerminalRefits.ts`) then loads the stack and sets it whole,
exactly as for a font typed in Settings. If the face is slower than the
effect's 3s wait, it is set when it arrives (`monoFaceArrived`, which
waits on the face alone: the font set's load for a whole stack rejects
as soon as any one face fails). A face that arrives while two fingers
pinch keeps the pinch's live size, and the shared pty is sized once,
when the fingers lift (`pinchingRef`).
- **A new terminal's pane is attached only once its first font is set**
(`usePaneAttach.ts`, `fontSettled`). The font effect settles a shared
signal after its first apply, which `loadFontStack`'s existing 3s bound
already limits, and the first fit and `attach` wait for it. Before, a
cold load without an installed JetBrains Mono attached the pty at the
fallback's grid. On Linux that was Noto's 19px rows (169x42 in the merge
pass's run, 132x35 here). The pty was then resized again when the face
arrived (141x47, 110x39), so the program reflowed twice. Now the attach
goes out once, at the face's grid. A face slower than 3s still attaches
at the fallback's grid and is set when it comes, as before. Without
this, the terminal measured a fallback's cell, the face arrived, and
xterm re-measured without a refit. In the check below, the grid then ran
1030px wide in an 880px pane.
- **License:** `THIRD_PARTY_NOTICES.md` now lists both files under the
release's OFL 1.1 text (already included, identical to the release's
`OFL.txt`). `DESIGN.md` records the decision. Zed similarly draws its
terminal in a face it ships (`.ZedMono`).

## Every surface, measured (13px)

Rows are for the same 1200x760 window. The Hangul gap is the row minus
the Hangul ink (0.913em = 11.87px).

| Surface | Latin face (main → this PR) | Row px | Grid for 120 cols |
Hangul gap px | Keystroke-to-paint median ms | Flood fps |
|---|---|---|---|---|---|---|
| Chrome, Mac, no font installed | Menlo → JetBrains Mono Web | 16.5 →
17 | 939 → 936 | 4.6 → 5.1 | 33.1 → 33.2 | 60.2 → 60.2 |
| Safari, Mac, no font installed | Menlo → JetBrains Mono Web | 16.5 →
17 | 939 → 936 | 4.6 → 5.1 | 34 → 49* | 59.5 → 58.5 |
| Ovis for Mac, no font installed | Menlo → JetBrains Mono Web | 16.5 →
17 | 939 → 936 | 4.6 → 5.1 | 33 → 33 | 59.8 → 59.0 |
| Chrome, Mac, JetBrains Mono installed | JetBrains Mono → JetBrains
Mono Web | 17 → 17 | 936 → 936 | 5.1 → 5.1 | 33 → 33.2 | 59.6 → 60.2 |
| Safari, Mac, JetBrains Mono installed | Menlo → JetBrains Mono Web |
16.5 → 17 | 939 → 936 | 4.6 → 5.1 | 48 → 35 | 59.8 → 59.4 |
| Ovis for Mac, JetBrains Mono installed | Menlo → JetBrains Mono Web |
16.5 → 17 | 939 → 936 | 4.6 → 5.1 | 34 → 33 | 59.8 → 59.6 |
| Chrome, Linux (1x and 2x) | Noto Sans Mono CJK KR (19px, from #2243's
table) → JetBrains Mono Web | 19 → 17 | - | 6 → 5.1 | - | - |

*Safari's median moves between 33 and 49ms from run to run on both
builds; Chrome and the app do not.

At this window every Mac surface holds 40 rows, before and after. Rows
differed before only when the window height fell between 16.5px and 17px
steps (a 900px pane: 52 against 54). Now every surface has the same row,
so the counts match at any size. A pane on Linux gains rows (19 → 17px);
one on a Mac or on Windows with Consolas loses about 3% of them (16.5 →
17px). Windows and the iPhone were not measured in this PR.

**Bundle size:** +94,588 bytes (`JetBrainsMono-Bold.woff2`). The regular
face (92,164 bytes) was already shipped for the chat. A device now
fetches the regular face when the terminal opens (most pages already
fetched it for the chrome's code text), and the bold only when bold text
is drawn. Both are fingerprinted assets the service worker keeps.

## Before and after (the Mac with JetBrains Mono installed)

| | main | this PR |
|---|---|---|
| Chrome |
![](https://gist.githubusercontent.com/devswha/950ace129649e5d1f28343f013bb3eaa/raw/7215b18f0a0402afa2bbe7464af290d2ecab844c/chrome-main-jbm-crop.png)
|
![](https://gist.githubusercontent.com/devswha/950ace129649e5d1f28343f013bb3eaa/raw/7215b18f0a0402afa2bbe7464af290d2ecab844c/chrome-mono-jbm-crop.png)
|
| Safari |
![](https://gist.githubusercontent.com/devswha/950ace129649e5d1f28343f013bb3eaa/raw/7215b18f0a0402afa2bbe7464af290d2ecab844c/safari-main-jbm-crop.png)
|
![](https://gist.githubusercontent.com/devswha/950ace129649e5d1f28343f013bb3eaa/raw/7215b18f0a0402afa2bbe7464af290d2ecab844c/safari-mono-jbm-crop.png)
|
| Ovis for Mac |
![](https://gist.githubusercontent.com/devswha/950ace129649e5d1f28343f013bb3eaa/raw/7215b18f0a0402afa2bbe7464af290d2ecab844c/app-main-jbm-crop.png)
|
![](https://gist.githubusercontent.com/devswha/950ace129649e5d1f28343f013bb3eaa/raw/7215b18f0a0402afa2bbe7464af290d2ecab844c/app-mono-jbm-crop.png)
|

(The light lines after Korean words in the dark rows are the seam #2263
fixes; this branch does not include it.)

## Checks

- **New browser check** `scripts/terminal-bundled-mono-regression.ts`
(added to `ci-browser.sh`). It holds the face's download until the
terminal has drawn its rows, so the face always arrives late, and checks
at 1x and 2x that:
  - the terminal opened without the face;
  - the cell is the face's advance (7.79 against 7.80px);
- the row is `terminalLineHeight`'s for the face (17px), with a Hangul
gap of 5.13px;
  - the grid fits its host again;
  - `|가나다라마바사|` closes on the Latin row's column.

It also checks the pty: when the face arrives within the font effect's
wait, the pane's `attach` frame carries the face's grid (110x39) and no
`resize` follows. A slow face sends one resize, for its grid. Frames are
counted only after a definite signal: the DOM change made in the same
task as the frame (the font family set, the pinch badge hidden) or the
attach frame itself. Nothing polls animation frames.

  It also covers three late cases:
  - the face is slower than the font effect's wait;
- a font typed in Settings fails to load (404) while the face still
loads;
- the face arrives mid-pinch on a 390x844 touch screen, both when the
pinch grew the font (13 → 22px) and when it came back to the saved size.
The live size must hold, no resize may be sent while the fingers are
down, and exactly one must be sent when they lift.

  Results:
  - Passes here.
  - Fails on main: the face never becomes the terminal's.
- Fails on a mutant that opens with the face while it loads: the grid
stays 1030px wide in an 880px pane.
- Fails on a mutant that waits on the whole stack: the face never
applies after the typed font's 404.
- Fails on a mutant that ignores the pinch: the size snaps back to 13px
from 22.
- Fails on a mutant that attaches without waiting for the first font:
attached at 132x35, then resized to 110x39.
  - `scripts/terminal-pinch-regression.ts` still passes.
- **Unit tests:** `bun test src/lib/fontFamily.test.ts
src/lib/typography.test.ts` cover the new stack order, both weights with
no `local()`, `measurableFontStack` keeping the face, and
`openingFontStack`. They fail on main.
- **`bun run check fast`:** pass (typecheck, build, 8192 unit tests, 0
fail).
- **QA:** in a fresh clone in `/tmp` on the test Mac, against an
isolated herdr session; a JetBrains Mono installed for the test was
removed afterwards.

## Reviews

- **omo-native-code-reviewer: PASS (APPROVE)**, with three MEDIUMs, all
fixed:
  - The slow-face path was untested. Now covered by the slow-face case.
- A dead `try/catch` around `fonts.check`, with a misnamed test. Both
removed.
  - A late face during a live pinch. Fixed with `pinchingRef`, below.

LOW notes fixed: the late-wait comment, and the sourced 0.913 constant
in the check. LOW notes left:
- Every cold load ends with one forced pty resize once the face is set.
This is the same path a font typed in Settings already takes. On Windows
it does change the grid, from Consolas to JetBrains Mono.
- An unquoted "JetBrains Mono Web" typed in Settings is not recognised
as the bundled face. It still draws, but is waited for like any typed
font.
  - typography.test repeats a check of the stack's head.
- **Codex (gpt-6.1-sol, fast, xhigh): PASS** on the third pass.
- First pass: BLOCK with two MEDIUMs. A late face overwrote an active
pinch. The late wait loaded the whole stack, so a typed font's 404 ended
it before the face arrived. Fixed with `monoFaceArrived` and a pinch
guard.
- Second pass: BLOCK with two MEDIUMs. The guard missed the first apply
and a pinch at the saved size, which got two resizes. Replaced the guard
with an explicit `pinchingRef` shared with the pinch handler.
`finishPinch` now sizes the pty once when a pinch that kept its size
ends on a different grid.
- Third pass on the delta: no findings, including touchcancel, unmount,
a chat view taking over, and the Settings handoff.
- `bun run check fast` on the final commit: pass (typecheck, build, 8192
unit tests, 0 fail).
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.

Terminal: a thin light line after each Korean word on a background colour

1 participant