fix: keep task title truncation UTF-16 safe in restart/diagnostic output#101934
Conversation
Three private copies of formatTaskBlocker share the same pattern — task.title.slice(0, 80) — which can split surrogate pairs in task titles, producing broken U+FFFD in restart blocker diagnostics, gateway reload logs, and CLI run-loop output. Replace raw slice with truncateUtf16Safe in all three locations. Relevant files: - gateway/server-reload-handlers.ts:270 - infra/restart-coordinator.ts:73 - cli/gateway-cli/run-loop.ts:569
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 2:02 AM ET / 06:02 UTC. Summary PR surface: Source -20, Tests +22. Total +2 across 6 files. Reproducibility: yes. Current main has three raw Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the shared formatter after redacted real diagnostic output proof is added and exact-head checks finish green or are explicitly adjudicated. Do we have a high-confidence way to reproduce the issue? Yes. Current main has three raw Is this the best way to solve the issue? Yes for the code shape. A side-effect-free shared task formatter is narrower and cleaner than keeping three helpers or exporting formatting through task-registry maintenance, but merge readiness still needs real behavior proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a3f00d32c914. Label changesLabel justifications:
Evidence reviewedPR surface: Source -20, Tests +22. Total +2 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (6 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Land-ready verification at exact head
No changelog entry is required: this corrects internal restart-blocker formatting without changing the user-visible contract. |
|
Merged via squash.
|
…put (openclaw#101934) * fix: keep task title truncation UTF-16 safe in restart/diagnostic output Three private copies of formatTaskBlocker share the same pattern — task.title.slice(0, 80) — which can split surrogate pairs in task titles, producing broken U+FFFD in restart blocker diagnostics, gateway reload logs, and CLI run-loop output. Replace raw slice with truncateUtf16Safe in all three locations. Relevant files: - gateway/server-reload-handlers.ts:270 - infra/restart-coordinator.ts:73 - cli/gateway-cli/run-loop.ts:569 * refactor(tasks): centralize restart blocker formatting * fix(tasks): keep restart formatter side-effect free * refactor(tasks): tighten restart blocker ownership --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Gateway restart diagnostics had three copies of the same task-blocker formatter. Each used
task.title.slice(0, 80), so an emoji or supplementary CJK character crossing that UTF-16 boundary could leave a lone surrogate in terminal and log output.Why This Change Was Made
The final implementation moves the formatter and its
truncateUtf16Safeboundary into one side-effect-free task module. The gateway reload handler, restart coordinator, and lazy gateway run loop all call that same formatter; the three duplicate implementations and the helper-only test are gone.Keeping the helper independent from task-registry maintenance avoids eagerly materializing maintenance/runtime state from the gateway run loop. The restart-blocker type is imported directly from its owner rather than retained through an internal re-export shim.
User Impact
Task titles in restart, reload, and drain diagnostics remain bounded to 80 UTF-16 units without rendering broken replacement characters. Existing ASCII output is unchanged.
Evidence
createSafeGatewayRestartPreflight: 79 ASCII characters plus a crossing emoji produces 79 ASCII characters, with no lone surrogate.60d1b4a7f8ad3604daa654387d0dcea4b1ab239d: clean, confidence 0.98.git diff --checkand targeted oxfmt checks passed.Risk checklist
Did user-visible behavior change? (Yes/No)
Yes. Broken UTF-16 output at the task-title boundary is repaired.
Did config, environment, or migration behavior change? (Yes/No)
No.
Did security, auth, secrets, network, or tool execution behavior change? (Yes/No)
No.
What is the highest-risk area?
Gateway restart diagnostic formatting.
How is that risk mitigated?
One canonical formatter now owns all three call sites, with exact production-path and existing caller-suite coverage.