Skip to content

fix-model-list-utf16-truncation#102796

Closed
Kevin23-design wants to merge 1 commit into
openclaw:mainfrom
Kevin23-design:codex/fix-model-list-utf16-truncation
Closed

fix-model-list-utf16-truncation#102796
Kevin23-design wants to merge 1 commit into
openclaw:mainfrom
Kevin23-design:codex/fix-model-list-utf16-truncation

Conversation

@Kevin23-design

Copy link
Copy Markdown
Contributor

Use this PR title:

fix(models): avoid broken emoji when model table rows are truncated

PR body:

## What Problem This Solves

Fixes an issue where users viewing model table output would see broken emoji or other supplementary Unicode characters when long model names were truncated.

## Why This Change Was Made

Model table truncation now keeps UTF-16 boundaries intact while preserving the existing fixed-width table behavior and ASCII `...` suffix. This only affects terminal table rendering for model-list style output; JSON and plain output remain unchanged.

## User Impact

Users can expect truncated model table rows to remain readable and well-formed, including model names that contain emoji or other non-BMP Unicode characters.

## Evidence

- RED: `node scripts/run-vitest.mjs src/commands/models/list.format.test.ts` failed before the fix with dangling surrogate output.
- GREEN: `node scripts/run-vitest.mjs src/commands/models/list.format.test.ts` passed after the fix.
- Focused regression proof: `node scripts/run-vitest.mjs src/commands/models/list.format.test.ts src/commands/models/list.table.test.ts` passed.
- `git diff --check` passed.

Known proof gap: Blacksmith Testbox/Crabbox proof could not run because no `crabbox` binary is installed/discoverable in this environment.

Copilot AI review requested due to automatic review settings July 9, 2026 12:19
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS labels Jul 9, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label 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

Fixes terminal model-list table truncation so it doesn’t split UTF-16 surrogate pairs (preventing broken emoji / non-BMP characters) while keeping the existing fixed-width behavior and ASCII ... suffix.

Changes:

  • Switch model cell truncation to truncateUtf16Safe for surrogate-safe truncation.
  • Add focused Vitest coverage to prevent regressions (ellipsis behavior + surrogate-boundary truncation).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/commands/models/list.format.ts Uses surrogate-safe UTF-16 truncation for fixed-width table cells (including the max <= 3 path and the ... suffix path).
src/commands/models/list.format.test.ts Adds regression tests ensuring truncation never returns lone surrogates and preserves ASCII ellipsis behavior.

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

Copy link
Copy Markdown
Member

Closing this as another tiny UTF-16 fragment rather than a complete terminal-formatting fix.

The three production-line substitution avoids a lone surrogate, but it tests only the helper directly. It does not drive the model-list CLI/table path or define the actual fixed-width contract for emoji and other wide graphemes. UTF-16 code-unit safety and terminal display width are different invariants; fixing one isolated formatter without the active rendering proof leaves the broader contract ambiguous.

Please fold this into the wider text-boundary work with an active model-list rendering test and an explicit choice of code units versus terminal cell width.

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

Labels

commands Command implementations size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants