fix(acp): keep session update text truncation surrogate-safe#102378
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 12:18 AM ET / 04:18 UTC. Summary PR surface: Source +4, Tests +26. Total +30 across 2 files. Reproducibility: yes. from source inspection: current main slices ACP session-update and streamed-output text at raw UTF-16 code-unit boundaries, so a limit can cut through an emoji surrogate pair. I did not execute tests because this was a read-only review. Review metrics: none identified. 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 focused ACP projector truncation fix after maintainer review, exact-head CI, and the required proof gate are satisfied, keeping the behavior in the existing private projector helper. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current main slices ACP session-update and streamed-output text at raw UTF-16 code-unit boundaries, so a limit can cut through an emoji surrogate pair. I did not execute tests because this was a read-only review. Is this the best way to solve the issue? Yes for the code shape: reusing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6e4670f9c147. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +4, Tests +26. Total +30 across 2 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 (3 earlier review cycles)
|
20c7741 to
bd60126
Compare
bd60126 to
8f9f3bc
Compare
acp-projector's truncateText function used String.prototype.slice(0, N) on session update text that is sent to AI providers in the prompt context. When the truncation boundary falls inside a UTF-16 surrogate pair (emoji, CJK extended), the resulting string contains a dangling surrogate that can corrupt the prompt. Replace .slice(0, maxChars-1) with truncateUtf16Safe(input, maxChars-1) so the truncation point always falls on a complete code-point boundary.
8f9f3bc to
e9a2f78
Compare
|
Land-ready review complete for exact head What changed during maintainer review:
Proof:
Known proof gaps: none for this bounded owner path. |
|
Merged via squash.
|
…w#102378) * fix(acp): keep session update text truncation surrogate-safe acp-projector's truncateText function used String.prototype.slice(0, N) on session update text that is sent to AI providers in the prompt context. When the truncation boundary falls inside a UTF-16 surrogate pair (emoji, CJK extended), the resulting string contains a dangling surrogate that can corrupt the prompt. Replace .slice(0, maxChars-1) with truncateUtf16Safe(input, maxChars-1) so the truncation point always falls on a complete code-point boundary. * fix: make ACP projection truncation UTF-16 safe --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
ACP session updates and streamed output were truncated with raw UTF-16 code-unit slices. A boundary through an emoji or another supplementary Unicode character could emit a lone surrogate. The streamed-output path also needed to preserve a contiguous prefix after a split code point was dropped.
Why This Change Was Made
truncateUtf16Safeprimitive for bounded session-update text.User Impact
ACP status updates and streamed replies remain valid Unicode at truncation boundaries. Output still honors the configured UTF-16-unit limits and remains a contiguous prefix of the original stream.
Evidence
corepack pnpm test src/auto-reply/reply/acp-projector.test.tsgit diff --checkAI-assisted: Yes