fix(matrix): truncate thread starter body on code-point boundaries#96961
fix(matrix): truncate thread starter body on code-point boundaries#96961Bartok9 wants to merge 2 commits into
Conversation
truncateThreadStarterBody (reached via summarizeMatrixThreadStarterEvent) truncated the thread-root body with a raw `value.slice(0, 497)`. When the 500-char boundary falls in the middle of an astral character (emoji etc.), the raw slice cuts the surrogate pair in half and leaves a lone high surrogate before the ellipsis, rendering as a broken/replacement glyph. Use the SDK's surrogate-safe `sliceUtf16Safe` so truncation stops on a code-point boundary, dropping the half character entirely. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed June 26, 2026, 7:10 PM ET / 23:10 UTC. Summary Reproducibility: yes. Current main still calls raw Review metrics: 3 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Land a Matrix-only PR that imports Do we have a high-confidence way to reproduce the issue? Yes. Current main still calls raw Is this the best way to solve the issue? No for the current head. The two-file Matrix fix is the right layer, but the current branch must be narrowed because the broad second commit is unrelated and crosses automation, security, message-delivery, protocol, docs, and generated-output boundaries. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a82902c725b2. Label changesLabel changes:
Label justifications:
Evidence reviewedSecurity concerns:
Acceptance criteria:
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
|
Real behavior proof — before/afterHost: macOS (Darwin 25.4.0, arm64), node v25.5.0, repo source via its own tsx. Driving the patched Before (
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Branch narrowed as recommended. Force-pushed back to the single @clawsweeper re-review |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
1 similar comment
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Superseded by the clean replacement PR #97121, now merged to The landed diff preserves the original Matrix fix and contributor credit, touching only |
What Problem This Solves
Matrix thread-starter previews truncate long bodies by UTF-16 code-unit offset. If the boundary lands inside an astral character such as an emoji, the preview contains a lone surrogate and renders mojibake in the agent's thread context.
Why This Change Was Made
The truncation site is the canonical producer of the bounded thread-starter body. This change reuses the existing public
sliceUtf16Safehelper so the cut backs up to a valid surrogate boundary while preserving the existing 500-code-unit limit and...suffix.User Impact
Long Matrix thread starters no longer split emoji or other astral characters at the truncation boundary. Short bodies and BMP-only text retain their existing output.
Evidence
mainreproduces the defect with 496acharacters followed by😀: the raw slice leaves a lone high surrogate before the ellipsis.6/6tests passed.git diff --checkpassed.Provenance and Credit
This PR salvages the original fix from #96407 after that PR was auto-closed by the active-PR queue cap. The implementation preserves @ly-wang19's original authorship and is rebased by @Bartok9 onto current
main.