You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(render) 02 - Migrate src/render.ts to use src/render/terminal.ts #142
src/render.ts contains two in-house helpers used at 15+ call sites across the file:
stripAnsi(str): limited SGR regex that misses OSC 8 hyperlinks and cursor movement sequences.
clipAnsi(str, maxVisible): manual character loop that miscounts emoji and CJK characters (each code point is treated as 1 column).
renderHelpOverlay() contains a third inline variant: s.replace(/\x1b\[[0-9;]*m/g, "").length.
After #141, src/render/terminal.ts provides visibleWidth and clipToWidth as drop-in replacements backed by Bun 1.4 native APIs.
Additionally, renderGroups passes fragmentMaxChars (computed as termWidth - FRAGMENT_INDENT - 1) to highlightFragment. This migration is an opportunity to verify that highlightFragment interprets this budget as a terminal column limit, not a byte or code-unit limit.
Solution
Replace every usage of the in-house helpers with calls to src/render/terminal.ts:
Before
After
stripAnsi(str).length
visibleWidth(str)
clipAnsi(str, n)
clipToWidth(str, n)
inline s.replace(...).length in renderHelpOverlay
visibleWidth(s)
Delete stripAnsi and clipAnsi from src/render.ts once all call sites are migrated.
src/render.ts imports from src/render/terminal.ts only - it does not call Bun.stringWidth, Bun.sliceAnsi, or Bun.stripANSI directly.
Acceptance Criteria
src/render.ts no longer defines stripAnsi or clipAnsi.
src/render.ts does not call Bun.stringWidth, Bun.sliceAnsi, or Bun.stripANSI directly.
The existing test "right-aligns match count to termWidth" in src/render.test.ts still passes.
New test: a repo whose name contains CJK characters or wide characters (e.g. "org/\u524D\u7AEF-service") with termWidth=60; visibleWidth(stripAnsi(repoLine)) <= 60.
New test: a file path containing a wide character in highlighted text; the rendered line does not exceed termWidth.
New test: a section header with a long Unicode team name; the rendered line does not exceed termWidth.
bun test src/render.test.ts passes.
bun run lint and bun run format:check are clean.
bun run knip is clean.
Definition of Done
PR reviewed and merged into feat/bun14-terminal.
Zero lint errors, zero format diff, test suite green.
changed the title [-]feat(render) 02 - Migrer src/render.ts vers src/render/terminal.ts[/-][+]feat(render) 02 - Migrate src/render.ts to use src/render/terminal.ts[/+]on Aug 23, 2026
Activity
[-]feat(render) 02 - Migrer src/render.ts vers src/render/terminal.ts[/-][+]feat(render) 02 - Migrate src/render.ts to use src/render/terminal.ts[/+]