fix(models): align model list truncation by terminal width#102819
Conversation
There was a problem hiding this comment.
Pull request overview
Aligns openclaw models list / openclaw models scan fixed-width table rendering with terminal-visible cell widths so columns stay aligned when model keys include wide Unicode graphemes (emoji, CJK, etc.). This builds on packages/terminal-core’s grapheme/ANSI-aware width and truncation helpers while keeping JSON/plain output unchanged.
Changes:
- Switch
pad()andtruncate()to usevisibleWidth()/truncateToVisibleWidth()for terminal-cell budgeting. - Add unit tests for the formatting helpers and a regression test covering wide-grapheme alignment in the model list table.
- Reuse the shared formatting helpers so both list and scan table outputs benefit.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/commands/models/list.format.ts | Makes table padding/truncation operate on terminal visible width (grapheme/ANSI-aware) instead of string length. |
| src/commands/models/list.table.test.ts | Adds regression coverage ensuring the fixed-width model table stays aligned with wide graphemes in model keys. |
| src/commands/models/list.format.test.ts | Adds direct tests for pad()/truncate() behavior with wide characters and surrogate-pair safety. |
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 9:57 AM ET / 13:57 UTC. Summary PR surface: Source +8, Tests +84. Total +92 across 3 files. Reproducibility: yes. by source inspection: current main measures fixed-width model table cells with UTF-16 string length while terminals render CJK and emoji by visible cell width. I did not run a live CLI reproduction in this read-only review. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Merge the narrow formatter fix after redacted real CLI output or a maintainer proof override confirms aligned wide-grapheme rows for Do we have a high-confidence way to reproduce the issue? Yes, by source inspection: current main measures fixed-width model table cells with UTF-16 string length while terminals render CJK and emoji by visible cell width. I did not run a live CLI reproduction in this read-only review. Is this the best way to solve the issue? Yes for the code shape: reusing existing terminal-core visible-width helpers in AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2d5dd6c03584. Label changesLabel justifications:
Evidence reviewedPR surface: Source +8, Tests +84. Total +92 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
d5c5cbf to
8218479
Compare
8218479 to
98f9b35
Compare
98f9b35 to
44d6414
Compare
|
Maintainer proof for exact head
The scan metadata table needs no duplicate fixture: This is the best fix: terminal-core remains the Unicode/grapheme-width owner, while model-table-specific column widths and the existing ASCII ellipsis stay local. @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Merged via squash.
|
…102819) * fix(models): align model list truncation by terminal width * fix(models): sanitize formatter input before measuring width * test(models): tighten terminal-width regressions --------- Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where users viewing
openclaw models listoropenclaw models scantable output could see misaligned columns when truncated model names contain emoji, CJK, or other wide graphemes.Why This Change Was Made
Model table formatting now treats column budgets as terminal visible cell widths, reusing the existing terminal-core width and grapheme-aware truncation helpers. This keeps fixed-width table rendering aligned while still avoiding split surrogate pairs; JSON and plain output are unchanged.
User Impact
Users can expect model table rows to stay readable and aligned when model names contain wide Unicode characters.
Evidence
node scripts/run-vitest.mjs src/commands/models/list.table.test.tsfailed before the visible-width padding fix because theInputcolumn started one terminal cell too far right for a wide model key.node scripts/run-vitest.mjs src/commands/models/list.format.test.ts src/commands/models/list.table.test.tspassed oncodex/model-list-terminal-width.git diff --check HEAD~1..HEADpassed.Known proof gap: Blacksmith Testbox/Crabbox proof could not run in the local Codex environment because no
crabboxbinary was installed/discoverable.