fix(web): the terminal cursor no longer leaves faint lines when it blinks off#21641
Problem
At a fractional device pixel ratio the integrated terminal's cursor leaves two faint lines at the top and bottom of its cell when it blinks off (https://git.cafe/pingdotgg/t3code/issues/11402). On a Mac that happens after View > Zoom In in the desktop app (one step gives a ratio of about 2.19) or with browser zoom on web; elsewhere at a 125% or 150% display scale. Row edges then fall partway through device pixels, so the row's background repaint only partly covers the cursor's edge pixels and blends over them instead of replacing them.
Change
renderGhosttySnapshot in apps/web/src/terminal/ghostty/renderer.ts puts each row's top and bottom on whole device pixels, using the canvas transform's scale, and draws the row's background, selection, text clip, solid Powerline separators (https://git.cafe/pingdotgg/t3code/pulls/5607) and the cursor with that snapped height. Neighbouring rows share an exact edge, so repainting a row replaces every pixel it drew. At a whole-number ratio, such as the default 2 on a Retina display, nothing moves. The mocked context in surface.test.ts gets a getTransform stub.
Scope and approval
https://git.cafe/pingdotgg/t3code/issues/11402 is a triaged bug; the triage suggests "snap row/cursor Y to the device pixel grid" with an offscreen-canvas pixel test. When closing https://git.cafe/pingdotgg/t3code/pulls/11620, @juliusmarminge invited a smaller version: "If you want to send that smaller version with an offscreen-canvas pixel test at a fractional origin, that would be welcome." This rebuilds @Lucenx9's https://git.cafe/pingdotgg/t3code/pulls/11424 (the same snapping) on current main, as its closing comment suggested, with a real-canvas test in place of the mocked one.
One correction to the triage: on main the row origin is always a whole CSS pixel (clientHeight and the cell height are integers), so the fractional edges come from the device pixel ratio. Snapping only the origin in surface.ts would leave every later row between device pixels, which is why the snap is per row and why the test uses a fractional canvas transform. Web and desktop share this renderer; the triage notes mobile's native terminal does not use it.
Verification
New
renderer.browser.test.tsdraws on a real Chromium canvas at 1.25x and 2.2x for the bar, block, underline and hollow cursors: cursor on, then off, then a count of the pixels that are not the background. Onmainall 8 fail, leaving 6 to 36 pixels (2.2x block: 36, an 18-pixel line at the top and the bottom of the cell); with the change all 8 pass with 0. A second case draws a separator, then repaints only its row without it: with https://git.cafe/pingdotgg/t3code/pulls/5607's unsnapped height it leaves 1 pixel below the row at both ratios, with the change 0.surface.test.ts: 28 passed.vp lint,vp fmt --checkand the web typecheck are clean.Real app: the dev desktop app from this branch on a fresh
.t3with a throwaway project, light theme, terminal focused at an idle prompt. I set the ratio to 2.2 over CDP (Emulation.setDeviceMetricsOverride), close to the 2.19 one Zoom In step gives, since the menu's Zoom In can't be driven from the automation. The terminal canvas region was exported every 100 ms for 3 s (exact canvas pixels, not a screen capture):blink-off frames pixels left in the cursor cell, every off frame main15 36 (device rows 8 and 48, 18 each) this branch 15 0 At the default ratio of 2 this branch also leaves 0 in all 14 off frames.
Cursor off at 2.2x, before (6x, nearest neighbour):
Before: two faint lines stay where the cursor was
After:
Blinking, before on the left and after on the right (4x):
Not checked: Windows or Linux at a fractional display scale (same renderer and arithmetic), and the Zoom In menu item itself. Not changed: horizontal edges, which only matter for a cursor or separator at either end of a row, where it meets the row repaint's own edge; the issue reports the top and bottom lines.
Claude Opus 5.5 via T3 Code
Fixes #11402 GitCafe: https://git.cafe/pingdotgg/t3code/issues/11402
Evidence
Maintainer captures of the real web app's integrated terminal. Before is main at 8d3b061121. After is this branch's head 2a5ca7fae5 with that main merged in locally (a1c2f1e5f3). The branch is on a fork, so that merge was not pushed: the branch still needs a merge of main (205 commits behind). Between before and after, only the three files in this PR differ.
Environment for every capture: chromium-headless-shell 148.0.7778.96 (Playwright 1.60.0), CSS viewport 1280×800, zoom 100%. The device pixel ratio is set with CDP Emulation.setDeviceMetricsOverride deviceScaleFactor, not browser zoom, so the layout is identical at every ratio. The terminal uses the default font family at 11 px (15 px rows, so row edges fall on fractional device pixels) and runs bash --norc --noprofile. Each dev server ran on its own isolated state.
The number in each row is how many pixels that differ from the background remain in the cursor cell (±1 device px) on a blink-off frame, read from the canvas right after an on→off transition. Each sheet shows the zoomed before and after cursor cell, a zero-threshold cell diff, and the whole panel before and after with a zero-threshold panel diff.
| row | DPR | theme | cursor | before | after | sheet |
|---|---|---|---|---|---|---|
| S1 | 1 | dark | block, off | 0 | 0 (whole panel identical) | S1 |
| S2 | 1.25 | dark | block, off | 11 | 0 | S2 |
| S3 | 1.5 | dark | block, off | 11 | 0 | S3 |
| S4 | 2 | dark | block, off | 0 | 0 (whole panel identical) | S4 |
| S5 | 2.2 | dark | block, off | 34 | 0 | S5 |
| S6 | 1.25 | light | block, off | 9 | 0 | S6 |
| S7 | 2.2 | light | block, off | 32 | 0 | S7 |
| S8 | 1.25 | dark | bar, off | 5 | 0 | S8 |
| S9 | 2.2 | dark | bar, off | 14 | 0 | S9 |
| S10 | 1.25 | dark | block, on | solid | solid | S10 |
| S11 | 2.2 | dark | block, on | solid | solid, starts 1 device px lower | S11 |
Cursor off at 2.2, dark (S5). Before leaves lines at the top and bottom of the cell; after leaves nothing:
Recordings are about 6 s each, roughly 6 blink cycles at 500 ms on and 500 ms off, with before on the left and after on the right. They are canvas frames copied on every animation frame and upscaled nearest-neighbour. The two halves come from separate sessions, so their blink phases are up to 0.5 s apart. In each off phase at 1.25 and 1.5, the left half keeps a one-device-pixel line at the bottom of the cell; at 2.2 it keeps lines at the top and bottom. The right half's cell is empty. At DPR 1 and 2 both halves stay clean.
- R1 DPR 1, dark, block
- R2 DPR 1.25, dark, block
- R3 DPR 1.5, dark, block
- R4 DPR 2, dark, block
- R5 DPR 2.2, dark, block
- R6 DPR 1.25, light, block
- R7 DPR 2.2, light, block
- R8 DPR 1.25, dark, bar
- P1 DPR 1.25, dark, cursor on a Powerline separator
What else changed:
- At DPR 1 and 2, no pixel in the whole panel differs.
- At fractional ratios on
main, the dark theme shows faint full-width seams at row boundaries, 2/255 or less from the background. This branch removes them, which is why the whole-panel diffs there count 11k to 40k pixels. - No glyph pixel differs in any row.
- The visible cursor block can move by up to 1 device px. At 2.2 it starts 1 px lower and is still solid.
- A handful of single pixels at the panel's edge or padding corner differ by 1 to 8 levels.
Driver: capture.mjs, compose.mjs, pair.mjs. Raw PNGs and JSON: raw-captures-21641.tar.gz. Fixture matrix: matrix.md.
Verification log
- Proof audit, pass 1 (matrix derived from the diff): blink rows are recordings and cursor-off frames are stills. It found that the bug needs row edges on fractional device pixels, so the captures use an 11 px terminal font. The cursor shape comes from the terminal's escape codes; the app has no setting for it.
- Proof audit, pass 2: SUFFICIENT. The SHAs match, and
8d3b061121..a1c2f1e5f3touches only the three PR files. Every still's cursor-cell count was recomputed from the raw PNGs and matches. All 8 block and bar recordings show the fringe in 7 of 7 off frames onmainat a fractional ratio and in 0 of 7 on this branch; at DPR 1 and 2, both show 0. The auditor rebuilt S5 from the driver on fresh isolated servers: after was 0, before was 34, and both whole panels came out pixel-identical to the stored captures. - Tests on the local merge
a1c2f1e5f3:surface.test.tspasses 28/28.renderer.browser.test.ts(real canvas, Chromium) passes 10/10, and all 10 fail withmain'srenderer.tsswapped in. - CI on head
2a5ca7fae5: every check succeeded, including Build and Typecheck, Lint, Test Web and the Test Server shards. GitHub's merge-conflict check against the current base was still pending. CI has not run on amainmerge, because none is pushed. - Not verified:
- Underline cursor (optional in the matrix).
- Bar cursor in light theme at 2.2. Its parts are covered by S9, R8 and S7.
- Hollow unfocused cursor. It never blinks, so it can't show this bug.
- A remnant specific to an erased Powerline separator: not reproduced on
main; only the generic row seam shows. - Desktop app with View > Zoom In, and a real HiDPI display. The ratio was emulated in headless Chromium.
- Windows and Linux fractional display scaling.
- Captured and audited by Claude Opus 5.5 via Claude Code in T3 Code.
- Code review on head
d1cc00b55b(read-only, both reviewers run in parallel). Both agree that snapping row tops to device pixels (renderer.tsrowTop) is the right and minimal fix for the top and bottom lines. They found no regression in selection, wide characters, Powerline glyphs, theme changes or resize. The per-blink cost is onegetTransform()per render, which is negligible. Nothing outsideapps/webis touched.- Reviewer A, Claude Sonnet 5.5: MERGE. It calls the column-0 edge (below) a pre-existing follow-up, not a blocker.
- Reviewer B, Claude Opus 5.5: FIX_FIRST. The same fringe still appears on the vertical edge when the cursor is in column 0, because the cursor and the row fill both start at
padding= 4 CSS px, which is 8.76 device px at a 2.19 ratio. The last column's right edge has the same problem. The tests miss it because they usecursorX: 1, and at 1.25 the padding lands on a whole pixel. Suggested fix: fill the row background across the full canvas width, or snap the x edges too, and add acursorX: 0test case. - Minor: underline and strikethrough decorations still use
metrics.height. That stays within one device pixel and inside the row.
Checks
- SuccessfulCodeRabbitGitHub
Review completed
- Successful
Skipped - Not affected
- SuccessfulNative fingerprint diffGitHub
- Skipped
- SkippedEAS PreviewGitHub
- Skipped
- Skipped
- SkippedRemove preview downloadGitHub
- SkippedDeploy web previewGitHub
- SkippedBuild preview JS bundleGitHub
- SuccessfulNative fingerprint diffGitHub
- SuccessfulCheckGitHub
- SkippedRustGitHub
- Skipped
- SkippedRelease SmokeGitHub
- SuccessfulTestGitHub
- SuccessfulBuild and TypecheckGitHub
- SuccessfulTest WebGitHub
- SuccessfulLabel PR 21641GitHub
- SkippedEAS PreviewGitHub
- Skipped
- SuccessfulLabel PR sizeGitHub
- SkippedDeploy web previewGitHub
- SuccessfulLintGitHub
- SuccessfulTest Server 2GitHub
- SuccessfulTest Server 4GitHub
- SuccessfulTest Server 3GitHub
- SuccessfulTest Server 8GitHub
- SuccessfulTest Server 6GitHub
- SuccessfulTest Server 5GitHub
- SuccessfulTest Server 1GitHub
- SuccessfulTest Server 7GitHub
- SuccessfulChangesGitHub
- SuccessfulNative fingerprint diffGitHub
- SuccessfulCollect PR targetsGitHub
- SuccessfulPrepare PR size configGitHub
Added 1 commit
- fix(web): the terminal cursor no longer leaves faint lines when it blinks offd0eea17
Approvability
Verdict: Approved at d0eea17
Macroscope's review found this PR approvable — This is a focused terminal rendering bug fix that snaps row repaint boundaries at fractional device-pixel ratios, with comprehensive browser regression coverage and no configuration, schema, or deployment impact. The remaining changes only update test mocks.
You can add or adjust custom eligibility rules. Learn more.
Added 1 commit
- ci: rerun checkseff31ae
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
09033fa7-63a5-4355-9629-7c9dc9611ca4
📥 Commits
Reviewing files that changed from the base of the PR and between cd667ddf81bc1db9567399c7ad427206ff685060 and 2a5ca7fae59e7ad59caaceb32822f72d7d16a608.
📒 Files selected for processing: 1
apps/web/src/terminal/ghostty/surface.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
renderGhosttySnapshotaligns row positions to device pixels and uses the resulting row height for rendering row content and cursors. Browser tests cover cursor and Powerline separator repainting at two fractional device-pixel ratios.Changes: Ghostty row alignment
Layer / File(s) Summary Align rendered rows
apps/web/src/terminal/ghostty/renderer.tsThe renderer rounds row positions using the canvas vertical scale. It uses the resulting row height for backgrounds, selection fills, text clipping, and cursors. The Powerline separator receives explicit rendered dimensions. Test row alignment and repainting
apps/web/src/terminal/ghostty/renderer.browser.test.ts,apps/web/src/terminal/ghostty/surface.test.tsBrowser tests check that cursor styles and Powerline separators leave no non-background pixels after partial repainting at device-pixel ratios 1.25 and 2.2. The canvas test context provides getTransform.Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers:
flamboh
Merge Risk: ⚪ Minimal · up to 2a5ca
No actionable merge-blocking risk was established for this rendering change.
Pre-merge checks: Passed 4
Check name Status Explanation Title check Passed The title clearly and concisely describes the main fix: preventing faint terminal cursor lines after the cursor blinks off. 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 pull request includes all required sections: Problem, Change, Scope and approval, and Verification. It provides reproduction context, linked issue and maintainer approval, focused test results, ma… Full details: Description check
Explanation
The pull request includes all required sections: Problem, Change, Scope and approval, and Verification. It provides reproduction context, linked issue and maintainer approval, focused test results, manual evidence, limitations, and the agent and harness used.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Added 3 commits
Merged main, where both tests that failed this PR's CI are fixed (#21699, #21893). #5607 landed in the meantime and draws Powerline separators with the unsnapped cell height, so 90cee20220 passes them the row's snapped height and stubs getTransform in its test. A new browser case shows the unsnapped triangle leaving 1 pixel below its row at both ratios. Description updated to match.