Skip to content

fix(js): preserve visible SVG text geometry on padded rows - #186

Merged
konard merged 2 commits into
mainfrom
issue-185-svg-row-padding
Jul 26, 2026
Merged

fix(js): preserve visible SVG text geometry on padded rows#186
konard merged 2 commits into
mainfrom
issue-185-svg-row-padding

Conversation

@konard

@konard konard commented Jul 26, 2026

Copy link
Copy Markdown
Member

Summary

  • exclude leading and trailing blank terminal cells from visible SVG text runs
  • retain the original cell-grid offset, internal spaces, wide-glyph width, styling, background rendering, and vector rendering
  • add a PTY regression that proves a five-cell ok 表 run begins at column two and is not measured as a padded twelve-cell row
  • add a patch changeset for the JavaScript package

Root cause and reproduction

Terminal buffers pad every row to their full width. The renderer coalesced that padding with adjacent default-style text and emitted the full padded width as SVG textLength. Chromium disregards edge spaces when measuring the text, then stretches the visible glyphs to the full target width.

Before the fix, the new regression produces:

<text x="0" ... textLength="120">  ok 表     </text>

After the fix, the same terminal frame produces:

<text x="20" ... textLength="50">ok 表</text>

A real 96×36 OpenCode frame from link-assistant/formal-ai#841 was also re-rendered and inspected in Chromium. Its (no output) row is now an unstretched eleven-cell run (textLength="99") rather than a full-row run.

Automated verification

  • bun test js/tests/terminal-capture.test.mjs --timeout 10000 (10 passed)
  • bun run lint
  • bun run format:check
  • bun run check:duplication
  • bun scripts/validate-changeset.mjs
  • full bun test js/tests/ --timeout 10000: 751 passed, 10 skipped; 28 unrelated jq tests could not run because this local environment has no jq executable
  • Playwright/Chromium render of the real OpenCode snapshot visually verified

Fixes #185

@konard konard added the parity-exempt Change is intentionally single-language; skip JS/Rust parity check label Jul 26, 2026
@konard
konard merged commit 8612191 into main Jul 26, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parity-exempt Change is intentionally single-language; skip JS/Rust parity check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal SVG stretches visible glyphs across padded rows in browsers

1 participant