Skip to content

fix(agents): truncate exec command detail on code-point boundaries#96963

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
Bartok9:salvage/96424-exec-detail-codepoint
Jun 27, 2026
Merged

fix(agents): truncate exec command detail on code-point boundaries#96963
vincentkoc merged 3 commits into
openclaw:mainfrom
Bartok9:salvage/96424-exec-detail-codepoint

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Salvages #96424 by @ly-wang19 onto current main — original authorship preserved. The original was auto-closed by openclaw-barnacle for the author's >20-active-PR cap, not on merits; the bug is still live on main.

The exec command-detail middle-truncation (src/agents/tool-display-exec.ts) cuts at a raw UTF-16 code-unit offset, so an exec detail containing emoji/astral characters near either boundary renders a lone surrogate (the replacement glyph) around the .

Root Cause

Symptom — A long exec command detail with emoji near the head or tail truncation boundary shows a broken glyph at the cut.

Root cause — Line 445: return \${oneLine.slice(0, half)}…${oneLine.slice(-(maxLength - 1 - half))}`;`. Both slices are code-unit cuts; a boundary inside a surrogate pair severs it.

Fix + why this level — Use the surrogate-safe sliceUtf16Safe for both head/tail offsets. The truncation site is the only producer of the boundary, so it's the correct layer.

Addressing the browser-safety review (ClawSweeper P1)

ClawSweeper correctly flagged that importing sliceUtf16Safe from src/utils.ts would pull node:fs/node:os/node:path into the Control UI browser-shared bundle (ui/vite.config.ts treats tool-display-exec.ts as browser-shared). Fixed (recommended option 1): the surrogate-safe helpers now live in a new self-contained, dependency-free module src/shared/text/surrogate-safe-slice.ts.

  • tool-display-exec.ts imports directly from the node-free module — no Node built-ins can leak into the browser bundle.
  • src/utils.ts re-exports sliceUtf16Safe/truncateUtf16Safe from the new module, so all existing Node-side callers are unchanged (zero churn).
  • The new module has zero imports (verified) — pure UTF-16 arithmetic.

Evidence

Real behavior proof — reproduced the rendered exec-detail boundary with an astral character (U+1F600) straddling the head cut (maxLength=120, half=59, emoji units at indices 58/59):

buggy head tail : "aaaa\ud83d…bbb" lone surrogates: 1 rendered: aaaa�…bbb
fixed head tail : "aaaa…bbbb"      lone surrogates: 0

The buggy raw-slice path keeps a lone high surrogate \ud83d (renders as ); the fixed safe-slice path drops the whole emoji cleanly.

Regression test: src/agents/tool-display.test.ts — asserts no lone surrogate at either boundary of the exec detail; fails without the fix.

 Test Files  1 passed (1)
      Tests  42 passed (42)

Changes from original

  • Rebased onto current main.
  • No code-behavior changes from @ly-wang19's original fix.
  • Added: moved the surrogate-safe helpers to a browser-safe module per ClawSweeper review (so the exec display path stays Node-free for the Vite bundle).

Credit: Salvage of #96424 by @ly-wang19 — rebased onto current main. Original closed by the >20-active-PR queue cap, not on merits.

compactRawCommand in src/agents/tool-display-exec.ts middle-truncated the
one-line command with raw String.prototype.slice. When the head or tail
boundary fell between the two UTF-16 code units of a surrogate pair (e.g. an
emoji like U+1F600), the slice kept a lone surrogate, which renders as the
replacement character in the tool-call summary shown in chat/transcripts.

Use the existing sliceUtf16Safe helper for both ends so the boundary falls on
a code-point boundary, dropping the whole emoji instead of half of it. This is
behavior-preserving for non-surrogate input.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 26, 2026
@clawsweeper

clawsweeper Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 26, 2026, 2:49 AM ET / 06:49 UTC.

Summary
The PR moves UTF-16 surrogate-safe slicing into a browser-safe shared text module, uses it for exec command middle truncation, preserves src/utils.ts re-exports, and adds an exec display regression test.

PR surface: Source +11, Tests +22. Total +33 across 4 files.

Reproducibility: yes. Current main raw-slices long exec details in compactRawCommand, and the PR body provides before/after live output showing the lone surrogate before the fix and zero lone surrogates after.

Review metrics: none identified.

Root-cause cluster
Relationship: canonical
Canonical: #96963
Summary: This PR is the active salvage branch for the exact exec-detail surrogate-boundary fix; a sibling open PR tracks the related generic tool-display truncation surface.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Next step before merge

  • [P2] No repair lane is needed because there is no concrete code blocker left; remaining work is ordinary maintainer review and required-check gating.

Security
Cleared: The diff adds no dependencies, workflows, lockfile changes, secret handling, permissions, package-resolution changes, or new code execution surface.

Review details

Best possible solution:

Land the focused exec-display Unicode truncation fix after normal maintainer review, while tracking the adjacent generic tool-display truncation surface in the sibling PR.

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

Yes. Current main raw-slices long exec details in compactRawCommand, and the PR body provides before/after live output showing the lone surrogate before the fix and zero lone surrogates after.

Is this the best way to solve the issue?

Yes. Using the existing surrogate-safe slice semantics at the exec truncation boundary, while moving the helper into a Node-free shared module for browser-shared imports, is the narrow maintainable fix.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a normal-priority display bug fix with a narrow affected surface and no data-loss, outage, or security impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes copied before/after output showing the raw slice leaves one lone surrogate and the fixed path leaves zero for the exec-detail boundary.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied before/after output showing the raw slice leaves one lone surrogate and the fixed path leaves zero for the exec-detail boundary.
Evidence reviewed

PR surface:

Source +11, Tests +22. Total +33 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 58 47 +11
Tests 1 22 0 +22
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 80 47 +33

What I checked:

Likely related people:

  • SebTardif: Authored the merged middle-truncation PR that added the raw-slice exec and generic tool-display truncation behavior now being made surrogate-safe. (role: introduced behavior; confidence: high; commits: 81b9da0bb0ff; files: src/agents/tool-display-exec.ts, src/agents/tool-display-common.ts, src/agents/tool-display.test.ts)
  • vincentkoc: Live PR metadata for the merged middle-truncation PR identifies this person as the merger for the change that introduced the current raw-slice behavior. (role: merger; confidence: medium; commits: 81b9da0bb0ff; files: src/agents/tool-display-exec.ts, src/agents/tool-display-common.ts)
  • steipete: Authored the prior Control UI change that removed a Node src/utils.ts import from the browser tool-display path, which is the same boundary this PR preserves. (role: browser-boundary contributor; confidence: high; commits: 1eb023b26c6f; files: ui/src/ui/tool-display.ts, src/utils.ts)
  • Narahari Raghava: Local blame in this grafted checkout points current snapshot lines for the exec display and utility helper to the current-main graft commit, though deeper feature history is more specific. (role: recent current-main area contributor; confidence: low; commits: cf512f639b31; files: src/agents/tool-display-exec.ts, src/utils.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.

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 26, 2026
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 26, 2026
ClawSweeper flagged that importing sliceUtf16Safe from src/utils.ts into
tool-display-exec.ts pulls node:fs/os/path into the Control UI browser-shared
bundle (ui/vite.config.ts treats tool-display-exec.ts as browser-shared).

Move sliceUtf16Safe/truncateUtf16Safe into a self-contained, dependency-free
module src/shared/text/surrogate-safe-slice.ts. src/utils.ts re-exports them
(zero churn for existing Node-side callers), and tool-display-exec.ts now
imports directly from the node-free module so no Node built-ins can leak into
the browser bundle.
@Bartok9

Bartok9 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the P1 browser-safety finding: moved the surrogate-safe slice helpers into a new dependency-free module src/shared/text/surrogate-safe-slice.ts and pointed tool-display-exec.ts at it directly, so no node:* built-ins can leak into the Control UI browser bundle. src/utils.ts re-exports for Node-side callers (zero churn). Added real before/after rendering proof to the PR body. @clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 26, 2026
@vincentkoc
vincentkoc requested a review from a team as a code owner June 27, 2026 00:14
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: googlechat Channel integration: googlechat channel: matrix Channel integration: matrix channel: telegram Channel integration: telegram app: android App: android app: ios App: ios app: web-ui App: web-ui labels Jun 27, 2026
@vincentkoc
vincentkoc merged commit 4d9cd7d into openclaw:main Jun 27, 2026
247 of 255 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

wangmiao0668000666 pushed a commit to wangmiao0668000666/openclaw that referenced this pull request Jun 27, 2026
…penclaw#96963)

* fix(agents): truncate exec command detail on code-point boundaries

compactRawCommand in src/agents/tool-display-exec.ts middle-truncated the
one-line command with raw String.prototype.slice. When the head or tail
boundary fell between the two UTF-16 code units of a surrogate pair (e.g. an
emoji like U+1F600), the slice kept a lone surrogate, which renders as the
replacement character in the tool-call summary shown in chat/transcripts.

Use the existing sliceUtf16Safe helper for both ends so the boundary falls on
a code-point boundary, dropping the whole emoji instead of half of it. This is
behavior-preserving for non-surrogate input.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* refactor: move surrogate-safe slice helpers to browser-safe module

ClawSweeper flagged that importing sliceUtf16Safe from src/utils.ts into
tool-display-exec.ts pulls node:fs/os/path into the Control UI browser-shared
bundle (ui/vite.config.ts treats tool-display-exec.ts as browser-shared).

Move sliceUtf16Safe/truncateUtf16Safe into a self-contained, dependency-free
module src/shared/text/surrogate-safe-slice.ts. src/utils.ts re-exports them
(zero churn for existing Node-side callers), and tool-display-exec.ts now
imports directly from the node-free module so no Node built-ins can leak into
the browser bundle.

* fix(agents): use shared utf16 helper in exec display

---------

Co-authored-by: ly-wang19 <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 27, 2026
…penclaw#96963)

* fix(agents): truncate exec command detail on code-point boundaries

compactRawCommand in src/agents/tool-display-exec.ts middle-truncated the
one-line command with raw String.prototype.slice. When the head or tail
boundary fell between the two UTF-16 code units of a surrogate pair (e.g. an
emoji like U+1F600), the slice kept a lone surrogate, which renders as the
replacement character in the tool-call summary shown in chat/transcripts.

Use the existing sliceUtf16Safe helper for both ends so the boundary falls on
a code-point boundary, dropping the whole emoji instead of half of it. This is
behavior-preserving for non-surrogate input.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* refactor: move surrogate-safe slice helpers to browser-safe module

ClawSweeper flagged that importing sliceUtf16Safe from src/utils.ts into
tool-display-exec.ts pulls node:fs/os/path into the Control UI browser-shared
bundle (ui/vite.config.ts treats tool-display-exec.ts as browser-shared).

Move sliceUtf16Safe/truncateUtf16Safe into a self-contained, dependency-free
module src/shared/text/surrogate-safe-slice.ts. src/utils.ts re-exports them
(zero churn for existing Node-side callers), and tool-display-exec.ts now
imports directly from the node-free module so no Node built-ins can leak into
the browser bundle.

* fix(agents): use shared utf16 helper in exec display

---------

Co-authored-by: ly-wang19 <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
xydigit-zt pushed a commit to xydigit-zt/xydigit-zt-openclaw that referenced this pull request Jun 28, 2026
…penclaw#96963)

* fix(agents): truncate exec command detail on code-point boundaries

compactRawCommand in src/agents/tool-display-exec.ts middle-truncated the
one-line command with raw String.prototype.slice. When the head or tail
boundary fell between the two UTF-16 code units of a surrogate pair (e.g. an
emoji like U+1F600), the slice kept a lone surrogate, which renders as the
replacement character in the tool-call summary shown in chat/transcripts.

Use the existing sliceUtf16Safe helper for both ends so the boundary falls on
a code-point boundary, dropping the whole emoji instead of half of it. This is
behavior-preserving for non-surrogate input.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* refactor: move surrogate-safe slice helpers to browser-safe module

ClawSweeper flagged that importing sliceUtf16Safe from src/utils.ts into
tool-display-exec.ts pulls node:fs/os/path into the Control UI browser-shared
bundle (ui/vite.config.ts treats tool-display-exec.ts as browser-shared).

Move sliceUtf16Safe/truncateUtf16Safe into a self-contained, dependency-free
module src/shared/text/surrogate-safe-slice.ts. src/utils.ts re-exports them
(zero churn for existing Node-side callers), and tool-display-exec.ts now
imports directly from the node-free module so no Node built-ins can leak into
the browser bundle.

* fix(agents): use shared utf16 helper in exec display

---------

Co-authored-by: ly-wang19 <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
QiuYuang pushed a commit to QiuYuang/openclaw that referenced this pull request Jul 1, 2026
…penclaw#96963)

* fix(agents): truncate exec command detail on code-point boundaries

compactRawCommand in src/agents/tool-display-exec.ts middle-truncated the
one-line command with raw String.prototype.slice. When the head or tail
boundary fell between the two UTF-16 code units of a surrogate pair (e.g. an
emoji like U+1F600), the slice kept a lone surrogate, which renders as the
replacement character in the tool-call summary shown in chat/transcripts.

Use the existing sliceUtf16Safe helper for both ends so the boundary falls on
a code-point boundary, dropping the whole emoji instead of half of it. This is
behavior-preserving for non-surrogate input.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* refactor: move surrogate-safe slice helpers to browser-safe module

ClawSweeper flagged that importing sliceUtf16Safe from src/utils.ts into
tool-display-exec.ts pulls node:fs/os/path into the Control UI browser-shared
bundle (ui/vite.config.ts treats tool-display-exec.ts as browser-shared).

Move sliceUtf16Safe/truncateUtf16Safe into a self-contained, dependency-free
module src/shared/text/surrogate-safe-slice.ts. src/utils.ts re-exports them
(zero churn for existing Node-side callers), and tool-display-exec.ts now
imports directly from the node-free module so no Node built-ins can leak into
the browser bundle.

* fix(agents): use shared utf16 helper in exec display

---------

Co-authored-by: ly-wang19 <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 1, 2026
…penclaw#96963)

* fix(agents): truncate exec command detail on code-point boundaries

compactRawCommand in src/agents/tool-display-exec.ts middle-truncated the
one-line command with raw String.prototype.slice. When the head or tail
boundary fell between the two UTF-16 code units of a surrogate pair (e.g. an
emoji like U+1F600), the slice kept a lone surrogate, which renders as the
replacement character in the tool-call summary shown in chat/transcripts.

Use the existing sliceUtf16Safe helper for both ends so the boundary falls on
a code-point boundary, dropping the whole emoji instead of half of it. This is
behavior-preserving for non-surrogate input.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* refactor: move surrogate-safe slice helpers to browser-safe module

ClawSweeper flagged that importing sliceUtf16Safe from src/utils.ts into
tool-display-exec.ts pulls node:fs/os/path into the Control UI browser-shared
bundle (ui/vite.config.ts treats tool-display-exec.ts as browser-shared).

Move sliceUtf16Safe/truncateUtf16Safe into a self-contained, dependency-free
module src/shared/text/surrogate-safe-slice.ts. src/utils.ts re-exports them
(zero churn for existing Node-side callers), and tool-display-exec.ts now
imports directly from the node-free module so no Node built-ins can leak into
the browser bundle.

* fix(agents): use shared utf16 helper in exec display

---------

Co-authored-by: ly-wang19 <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 3, 2026
…penclaw#96963)

* fix(agents): truncate exec command detail on code-point boundaries

compactRawCommand in src/agents/tool-display-exec.ts middle-truncated the
one-line command with raw String.prototype.slice. When the head or tail
boundary fell between the two UTF-16 code units of a surrogate pair (e.g. an
emoji like U+1F600), the slice kept a lone surrogate, which renders as the
replacement character in the tool-call summary shown in chat/transcripts.

Use the existing sliceUtf16Safe helper for both ends so the boundary falls on
a code-point boundary, dropping the whole emoji instead of half of it. This is
behavior-preserving for non-surrogate input.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* refactor: move surrogate-safe slice helpers to browser-safe module

ClawSweeper flagged that importing sliceUtf16Safe from src/utils.ts into
tool-display-exec.ts pulls node:fs/os/path into the Control UI browser-shared
bundle (ui/vite.config.ts treats tool-display-exec.ts as browser-shared).

Move sliceUtf16Safe/truncateUtf16Safe into a self-contained, dependency-free
module src/shared/text/surrogate-safe-slice.ts. src/utils.ts re-exports them
(zero churn for existing Node-side callers), and tool-display-exec.ts now
imports directly from the node-free module so no Node built-ins can leak into
the browser bundle.

* fix(agents): use shared utf16 helper in exec display

---------

Co-authored-by: ly-wang19 <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
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: android App: android app: ios App: ios app: web-ui App: web-ui channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: matrix Channel integration: matrix channel: telegram Channel integration: telegram cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: codex extensions: deepinfra extensions: fal extensions: google extensions: litellm extensions: memory-core Extension: memory-core extensions: minimax extensions: openai extensions: openrouter extensions: xai gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants