Skip to content

03: Migrate src/render/team-pick.ts to use visibleWidth and clipToWidth - #162

Merged
shouze merged 2 commits into
feat/bun14-terminal/02-renderfrom
feat/bun14-terminal/03-team-pick
Aug 23, 2026
Merged

03: Migrate src/render/team-pick.ts to use visibleWidth and clipToWidth#162
shouze merged 2 commits into
feat/bun14-terminal/02-renderfrom
feat/bun14-terminal/03-team-pick

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?

@shouze
shouze force-pushed the feat/bun14-terminal/03-team-pick branch from 0930584 to a6e00e6 Compare August 23, 2026 15:45
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/bun14-terminal/03-team-pick into feat/bun14-terminal/02-render 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/03-team-pick into feat/bun14-terminal/02-render 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

Migrates team-pick rendering to terminal-aware width measurement and clipping for Unicode and ANSI-safe output.

Changes:

  • Uses visibleWidth for candidate sizing.
  • Uses clipToWidth for focused-item truncation.

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

Comment thread src/render/team-pick.ts
Comment thread src/render/team-pick.ts
Comment thread src/render/team-pick.ts Outdated
shouze added 2 commits August 23, 2026 18:05
- Replace t.length with visibleWidth(t) for accurate team name width measurement
- Handle emoji and CJK characters correctly in team pick sliding window
- Replace .slice() truncation with clipToWidth() for Unicode-safe clipping
- Add tests for candidate teams with emoji, CJK, and complex grapheme sequences
- Verify team name wrapping respects actual terminal column width

Fixes: #143
Fixes:

1. Keep ellipsis styled with bold/magenta when clipping focused team name.
   Previously, clipToWidth added a partial reset that moved the ellipsis
   outside the bold/magenta style; now the styled text is clipped first,
   then a styled ellipsis is appended.

2. Use visibleWidth() instead of .length when computing padding for the
   team-pick bar in render.ts. This prevents over-padding with CJK team
   names (where JS .length ≠ terminal columns).

3. Add comprehensive test coverage for CJK and emoji team names:
   - Width measurement with Chinese characters (2 cols each)
   - Clipping behavior with wide characters
   - Ellipsis styling preservation
   - Mixed ASCII/emoji team names
   - Window rendering with wide character constraints

All 29 team-pick tests and 153 render tests passing.
@shouze
shouze force-pushed the feat/bun14-terminal/03-team-pick branch from a6e00e6 to 2ac87cd Compare August 23, 2026 16:05
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/bun14-terminal/03-team-pick into feat/bun14-terminal/02-render will be

96.07%

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, 436–438, 504–508, 520–521, 526–533, 535–543, 545–546
   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 d0ff402 into main Aug 23, 2026
5 checks passed
@shouze
shouze deleted the feat/bun14-terminal/03-team-pick 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