fix-model-list-utf16-truncation#102796
Conversation
There was a problem hiding this comment.
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
truncateUtf16Safefor 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. |
|
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. |
Use this PR title:
PR body: