Skip to content

fix(models): align model list truncation by terminal width#102819

Merged
steipete merged 3 commits into
openclaw:mainfrom
Kevin23-design:codex/model-list-terminal-width
Jul 9, 2026
Merged

fix(models): align model list truncation by terminal width#102819
steipete merged 3 commits into
openclaw:mainfrom
Kevin23-design:codex/model-list-terminal-width

Conversation

@Kevin23-design

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users viewing openclaw models list or openclaw models scan table 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

  • RED: node scripts/run-vitest.mjs src/commands/models/list.table.test.ts failed before the visible-width padding fix because the Input column started one terminal cell too far right for a wide model key.
  • GREEN: node scripts/run-vitest.mjs src/commands/models/list.format.test.ts src/commands/models/list.table.test.ts passed on codex/model-list-terminal-width.
  • git diff --check HEAD~1..HEAD passed.

Known proof gap: Blacksmith Testbox/Crabbox proof could not run in the local Codex environment because no crabbox binary was installed/discoverable.

Copilot AI review requested due to automatic review settings July 9, 2026 12:59
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S labels Jul 9, 2026

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

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() and truncate() to use visibleWidth() / 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.

@vincentkoc vincentkoc self-assigned this Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 9:57 AM ET / 13:57 UTC.

Summary
The PR updates model table formatting to use terminal visible-width padding and truncation for wide Unicode model names, with focused formatter and table regression tests.

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
Relationship: canonical
Canonical: #102819
Summary: This PR is the active canonical candidate for the model-list terminal-width truncation fix; the earlier same-author PR was closed as too narrow, and the other related hits are adjacent Unicode/table work on different surfaces.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal output, copied live output, logs, or a terminal screenshot from openclaw models list or openclaw models scan showing aligned wide-grapheme rows; redact IPs, keys, phone numbers, endpoints, and other private details.
  • Resolve or rerun the current failing CI shard if it remains red on the latest head.
  • Update the PR body after adding proof so ClawSweeper can re-review automatically, or ask a maintainer to comment @clawsweeper re-review if it does not trigger.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body/comments only list tests and diff-check evidence; add redacted terminal output, a terminal screenshot, logs, recording, or copied live CLI output showing after-fix alignment, then update the PR body for re-review.

Risk before merge

  • [P1] No after-fix real CLI output proof has been posted, so maintainers cannot verify the terminal rendering path outside tests without a proof override.
  • [P1] The live status rollup showed one failing CI shard on the current head; logs were not inspected in this read-only review, so this is merge hygiene rather than a patch finding.

Maintainer options:

  1. Decide the mitigation before merge
    Merge the narrow formatter fix after redacted real CLI output or a maintainer proof override confirms aligned wide-grapheme rows for openclaw models list or openclaw models scan.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No repair lane is appropriate because the review found no concrete patch defect; the remaining blocker is contributor real-behavior proof, CI hygiene, or a maintainer proof override.

Security
Cleared: The diff changes only internal TypeScript formatter logic and colocated tests, with no dependency, CI, secret, package, or code-execution surface change.

Review details

Best possible solution:

Merge the narrow formatter fix after redacted real CLI output or a maintainer proof override confirms aligned wide-grapheme rows for openclaw models list or openclaw models scan.

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 src/commands/models/list.format.ts is the narrow shared fix for the models list and models scan table callers. Merge readiness still depends on real behavior proof or a maintainer proof override.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2d5dd6c03584.

Label changes

Label justifications:

  • P3: This is a small CLI table readability bug fix with limited blast radius and no config, persistence, provider-routing, or security surface change.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body/comments only list tests and diff-check evidence; add redacted terminal output, a terminal screenshot, logs, recording, or copied live CLI output showing after-fix alignment, then update the PR body for re-review.
Evidence reviewed

PR surface:

Source +8, Tests +84. Total +92 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 16 8 +8
Tests 2 84 0 +84
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 100 8 +92

What I checked:

  • Root policy applied: Root AGENTS.md was read fully; no scoped AGENTS.md was found under the touched src/commands/models or packages/terminal-core paths, so root review and proof policy applies. (AGENTS.md:1, 2d5dd6c03584)
  • Current-main formatter still has the bug-prone behavior: Current main pads with String.padEnd and truncates with value.length/slice, which does not match terminal cell width for CJK or emoji. (src/commands/models/list.format.ts:8, 2d5dd6c03584)
  • PR fix uses existing terminal-width helpers: The PR imports visibleWidth, truncateToVisibleWidth, and sanitizeTerminalText, then pads/truncates by sanitized visible terminal width while preserving the ASCII ellipsis behavior for wider budgets. (src/commands/models/list.format.ts:1, 8218479d9fce)
  • Both affected commands share the helper: models scan imports pad and truncate from list.format.ts, so the helper-level change covers both table outputs named in the PR body. (src/commands/models/scan.ts:20, 2d5dd6c03584)
  • Terminal-core contract supports the fix: visibleWidth measures grapheme terminal cells and truncateToVisibleWidth drops whole overflowing grapheme clusters, which is the table-cell invariant this PR needs. (packages/terminal-core/src/ansi.ts:172, 2d5dd6c03584)
  • Regression coverage is focused: The PR adds formatter tests for wide characters, surrogate safety, and terminal control sanitization plus a model-table test that checks the Input column starts after the expected visible width. (src/commands/models/list.table.test.ts:29, 8218479d9fce)

Likely related people:

  • steipete: GitHub path history shows repeated recent ownership around model command files and the terminal-core package refactor that owns the visible-width helper surface. (role: recent area contributor and refactor owner; confidence: high; commits: de1dfab03ef0, 47f0af0d2dde; files: src/commands/models/list.format.ts, src/commands/models/scan.ts, packages/terminal-core/src/ansi.ts)
  • vincentkoc: GitHub path history shows a recent current-main touch to list.format.ts, and the live PR has a maintainer follow-up commit by this user plus assignment on the item. (role: recent area contributor and current follow-up owner; confidence: high; commits: eea777c9fc9c, 8218479d9fce; files: src/commands/models/list.format.ts, src/commands/models/list.format.test.ts)
  • jbetala7: GitHub path history shows the recent terminal-core wide-grapheme table fix that established a closely related visible-width table invariant. (role: adjacent width-helper contributor; confidence: medium; commits: 29dd7847fd96; files: packages/terminal-core/src/ansi.ts, packages/terminal-core/src/table.ts, packages/terminal-core/src/table.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-09T13:26:30.318Z sha 8352309 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 9, 2026
@vincentkoc
vincentkoc force-pushed the codex/model-list-terminal-width branch from d5c5cbf to 8218479 Compare July 9, 2026 13:37
@steipete
steipete force-pushed the codex/model-list-terminal-width branch from 8218479 to 98f9b35 Compare July 9, 2026 14:05
@steipete
steipete force-pushed the codex/model-list-terminal-width branch from 98f9b35 to 44d6414 Compare July 9, 2026 14:17
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Maintainer proof for exact head 44d6414b81b55b4a06e60438696282ece3be1100:

  • Exact-head CI completed successfully: 43 jobs passed, 12 intentionally skipped, 0 failed.
  • Sanitized direct AWS Crabbox run run_5c2f159bccc7 used public networking, no Tailscale, no instance profile, no hydration, trusted bootstrap IMDS/no-role and exact-SHA checks, then passed the focused formatter/table tests 7/7.
  • The same run exercised the real openclaw models list CLI in a PTY with configured ASCII, CJK, emoji, and combining-mark refs. Its source-blind output validator reported:
live-proof: table Input offset=43 for ASCII/CJK/emoji/combining keys
live-proof: rich PTY, plain, and JSON modes passed without split graphemes

The scan metadata table needs no duplicate fixture: src/commands/models/scan.ts imports and directly calls the same pure pad/truncate owner, with no scan-specific width branch. I also removed the redundant hand-written surrogate test helper, made alignment compare against the rendered header instead of a magic column, verified all three commits' signatures and the stable rebase patch identity, and ran a fresh full-branch autoreview with no actionable findings.

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

@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete
steipete merged commit a1466b2 into openclaw:main Jul 9, 2026
97 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants