Skip to content

02: Migrate src/render.ts to use render/terminal.ts facade - #160

Merged
shouze merged 2 commits into
feat/bun14-terminal/01-terminalfrom
feat/bun14-terminal/02-render
Aug 23, 2026
Merged

02: Migrate src/render.ts to use render/terminal.ts facade#160
shouze merged 2 commits into
feat/bun14-terminal/01-terminalfrom
feat/bun14-terminal/02-render

Conversation

@shouze

@shouze shouze commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

How did you verify your code works?

- Replace stripAnsi() inline implementation with import from render/terminal.ts
- Replace clipAnsi() inline implementation with import from render/terminal.ts
- Replace all stripAnsi(x).length calls with visibleWidth(x)
- Replace all clipAnsi(x, n) calls with clipToWidth(x, n)
- Update renderHelpOverlay() pad function to use visibleWidth()
- Add tests for CJK repository names and emoji in extract paths
- Verify background color preservation in active line clipping

Fixes: #142
@shouze
shouze force-pushed the feat/bun14-terminal/02-render branch from 084274c to f17c8bf Compare August 23, 2026 15:45
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/bun14-terminal/02-render into feat/bun14-terminal/01-terminal will be

96.06%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.78%100%88.24%89.84%166, 190–195, 197–199, 201–202, 223, 410–411, 434–436, 502–506, 518–519, 524–531, 533–541, 543–544
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

1 similar comment
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/bun14-terminal/02-render into feat/bun14-terminal/01-terminal will be

96.06%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.78%100%88.24%89.84%166, 190–195, 197–199, 201–202, 223, 410–411, 434–436, 502–506, 518–519, 524–531, 533–541, 543–544
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

@shouze
shouze marked this pull request as ready for review August 23, 2026 15:56
Copilot AI lite review requested due to automatic review settings August 23, 2026 15:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates src/render.ts away from local ANSI-width helpers (stripAnsi / clipAnsi) to the centralized src/render/terminal.ts façade, so terminal column measurement and ANSI-safe clipping are handled consistently across the codebase.

Changes:

  • Import and use visibleWidth and clipToWidth from src/render/terminal.ts for width calculations and line clipping.
  • Remove the in-file stripAnsi / clipAnsi implementations from src/render.ts.
  • Update several alignment calculations to use visible-width semantics instead of raw string length.
Suppressed comments (1)

src/render.ts:432

  • The re-pick hints line pads using barPlain.length, which counts UTF-16 code units rather than terminal columns. If a team/candidate label contains wide characters (emoji/CJK), the suffix alignment can drift and the line can wrap unexpectedly. Use visibleWidth(...) for the pad calculation.
    const bar = renderTeamPickHeader(dm.candidates, dm.focusedIndex, barWidth);
    const barPlain = stripAnsi(bar);
    // Pad between bar content and suffix to keep suffix right-aligned.
    const padLen = Math.max(0, barWidth - barPlain.length);
    const line = pc.dim(REPICK_PREFIX) + bar + " ".repeat(padLen) + pc.dim(REPICK_SUFFIX);
    lines.push(clipToWidth(line, termWidth) + "\n");

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/render.ts
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sébastien HOUZÉ <sebastien.houze@fulll.fr>
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/bun14-terminal/02-render into feat/bun14-terminal/01-terminal will be

96.06%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.80%100%88.24%89.86%166, 190–195, 197–199, 201–202, 223, 411–412, 435–437, 503–507, 519–520, 525–532, 534–542, 544–545
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

@shouze
shouze merged commit 5666ace into main Aug 23, 2026
5 checks passed
@shouze
shouze deleted the feat/bun14-terminal/02-render branch August 23, 2026 16:10
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.

2 participants