Skip to content

fix(cli): keep task/flow/commitment/audit table text truncation UTF-16 safe#101622

Closed
wm0018 wants to merge 4 commits into
openclaw:mainfrom
wm0018:fix/cli-truncate-utf16-safe
Closed

fix(cli): keep task/flow/commitment/audit table text truncation UTF-16 safe#101622
wm0018 wants to merge 4 commits into
openclaw:mainfrom
wm0018:fix/cli-truncate-utf16-safe

Conversation

@wm0018

@wm0018 wm0018 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where CLI table text rendering for openclaw tasks list, openclaw flows list, openclaw commitments list, and openclaw audit list could display broken U+FFFD replacement characters () when task names, flow descriptions, commitment scopes, or audit event text contained an emoji or CJK supplementary character at the column width truncation boundary.

All four commands share the same truncate(value, maxChars) pattern using raw String.prototype.slice(0, maxChars - 1), which cuts at UTF-16 code unit boundaries. Emoji like 🚀 are surrogate pairs (2 code units) and get split.

Why This Change Was Made

Replace value.slice(0, maxChars) and value.slice(0, maxChars - 1) with truncateUtf16Safe in all four commands — the standard UTF-16-safe truncation helper already used across the codebase.

User Impact

CLI tasks, flows, commitments, and audit table output containing emoji or CJK near column width limits now display cleanly truncated text.

Evidence

Tests

$ node scripts/run-vitest.mjs src/commands/truncate-text-utf16.test.ts

 Test Files  1 passed (1)
      Tests  2 passed (2)

Files Changed (5 files, +44/-6)

 src/commands/audit.ts                      |  3 ++-
 src/commands/commitments.ts                |  3 ++-
 src/commands/flows.ts                      |  4 +++-
 src/commands/tasks.ts                      |  4 +++-
 src/commands/truncate-text-utf16.test.ts   | 31 +++++++++++++++++++++++++++++++

…6 safe

CLI table rendering for tasks, flows, commitments, and audit commands
all share the same truncate(value, maxChars) pattern using raw slice,
which can split surrogate pairs at truncation boundaries producing
broken U+FFFD in terminal output.

Replace slice with truncateUtf16Safe in all four commands.
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close: this PR's current head is tree-identical to the consolidated maintainer-labeled PR at #101654, which explicitly supersedes this branch and carries the broader UTF-16 truncation sweep.

Root-cause cluster
Relationship: superseded
Canonical: #101654
Summary: The current PR is superseded by an open consolidated PR with the same tree and broader cluster ownership.

Members:

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

Canonical path: Land or reject the consolidated PR at #101654 as the single owner for this UTF-16 truncation sweep, and close duplicate branches that now have the same tree.

So I’m closing this here and keeping the remaining discussion on #101654.

Review details

Best possible solution:

Land or reject the consolidated PR at #101654 as the single owner for this UTF-16 truncation sweep, and close duplicate branches that now have the same tree.

Do we have a high-confidence way to reproduce the issue?

Yes from source inspection: current main still uses raw .slice(0, maxChars - 1) in flow, commitment, and audit table truncation paths, which can split a surrogate pair at the cutoff. I did not run the CLI end to end in this read-only review.

Is this the best way to solve the issue?

Yes, using the existing truncateUtf16Safe helper at each bounded caller is the right repair shape, but this branch is no longer the best landing vehicle because the consolidated PR has the same tree and owns the broader cluster.

Security review:

Security review cleared: The reviewed diff adds no dependency, workflow, permission, secret-handling, or package-resolution changes; it only swaps bounded string slicing for an existing helper and adds tests.

AGENTS.md: found and applied where relevant.

What I checked:

  • Canonical replacement is live: Live GitHub data shows fix: keep bounded text truncation UTF-16 safe #101654 is open, maintainer-labeled, and its body says it consolidates and supersedes this PR with Blacksmith Testbox, pnpm check:changed, autoreview, and git diff --check evidence. (080eb95c554c)
  • No unique tree remains: The current PR head and the consolidated PR head resolve to the same tree bf8da45dd2d4e91ece9cf97e7aa219f923bfcc00, so this branch no longer carries unique landable code. (5156ffc1036e)
  • Current-main source still needs canonical fix: Current main still truncates flow table text with raw slice, so the user-visible problem is real but should be landed through the consolidated PR. (src/commands/flows.ts:35, 60f0749b7fb3)
  • Current-main source still needs canonical fix: Current main still truncates commitment table text with raw slice, matching the reported surrogate-pair boundary problem. (src/commands/commitments.ts:27, 60f0749b7fb3)
  • History provenance: Blame ties the current raw CLI truncation helpers in flows, commitments, and audit to commit 395fbb8eb6319a5853deef9d83388fc2a5ca898c; the tasks table had already been repaired in commit 4d5cd05a64bf596b750d0486107d9d2aef96d1ad. (src/commands/flows.ts:30, 395fbb8eb631)

Likely related people:

  • steipete: Peter Steinberger authored the current-main command-table helpers in commit 395fbb8eb6319a5853deef9d83388fc2a5ca898c and opened the tree-identical consolidated PR that supersedes this branch. (role: recent area contributor and canonical consolidator; confidence: high; commits: 395fbb8eb631, 080eb95c554c, 5156ffc1036e; files: src/commands/flows.ts, src/commands/commitments.ts, src/commands/audit.ts)
  • maweibin: The tasks table UTF-16-safe truncation currently on main comes from commit 4d5cd05a64bf596b750d0486107d9d2aef96d1ad, a closely related prior fix in the same CLI truncation family. (role: related recent contributor; confidence: medium; commits: 4d5cd05a64bf; files: src/commands/tasks.ts)

Codex review notes: model internal, reasoning high; reviewed against 60f0749b7fb3.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@clawsweeper clawsweeper Bot removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 7, 2026
Exercise truncateUtf16Safe at the exact maxChars boundaries used by
the private truncate() helpers in tasks.ts (16/88), flows.ts (10),
and commitments.ts (16/28/90). Each test proves a lone high surrogate
produced by raw slice is cleanly dropped by truncateUtf16Safe.
@wm0018
wm0018 force-pushed the fix/cli-truncate-utf16-safe branch from 8f3e2c9 to 6ec4dc0 Compare July 7, 2026 12:25
@openclaw-barnacle openclaw-barnacle Bot added channel: zalouser Channel integration: zalouser app: web-ui App: web-ui extensions: memory-lancedb Extension: memory-lancedb cli CLI command changes agents Agent runtime and tooling size: L and removed size: S labels Jul 7, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 7, 2026
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Thanks @wm0018. The useful table-truncation work from this PR was consolidated with the sibling UTF-16 boundary fixes into #101654 and landed on main in a9582a1bb62aa70bb0b0ceb72536d0d76f08eab8.

The canonical PR uses the existing truncateUtf16Safe helper, preserves the audit/commitment/flow/task limits, and adds caller-level surrogate-boundary coverage. A maintainer update to this fork branch also picked up unrelated UI ancestry, so #101654 is the clean replacement. Closing this PR as superseded.

@steipete steipete closed this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: zalouser Channel integration: zalouser cli CLI command changes commands Command implementations extensions: memory-lancedb Extension: memory-lancedb P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L 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.

2 participants