fix(qa-matrix): keep room scenario preview truncation UTF-16 safe#102606
Conversation
Replace 7x `.slice(0, N)` with `truncateUtf16Safe(..., N)` in runMatrixStreamingPreviewScenario and runMatrixToolProgressScenario to prevent surrogate pair corruption in body/formattedBody previews. Ref. lsr911 pattern — mechanical substitution, no behavior change.
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 5:37 AM ET / 09:37 UTC. Summary PR surface: Source +13. Total +13 across 1 file. Reproducibility: yes. by source inspection: current main slices Matrix preview body/formattedBody artifacts with 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 findings
Review detailsBest possible solution: Use Do we have a high-confidence way to reproduce the issue? Yes by source inspection: current main slices Matrix preview body/formattedBody artifacts with Is this the best way to solve the issue? Yes for the main fix shape: reusing the existing plugin SDK Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4cc92009ed90. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +13. Total +13 across 1 file. 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
|
Co-authored-by: 黄剑雄0668001315 <[email protected]>
|
Land-ready review complete on exact head
No docs or changelog entry is required because this only changes private QA evidence formatting. |
|
Merged via squash.
|
…enclaw#102606) * fix(qa-matrix): keep room scenario preview truncation UTF-16 safe Replace 7x `.slice(0, N)` with `truncateUtf16Safe(..., N)` in runMatrixStreamingPreviewScenario and runMatrixToolProgressScenario to prevent surrogate pair corruption in body/formattedBody previews. Ref. lsr911 pattern — mechanical substitution, no behavior change. * test(qa-matrix): prove UTF-16 artifact boundaries Co-authored-by: 黄剑雄0668001315 <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Matrix QA stores bounded body and formatted-body previews in scenario artifacts and timeout diagnostics. Raw UTF-16 slicing could leave a dangling surrogate when an emoji crossed the 200- or 237-code-unit boundary, producing invalid evidence text.
Why This Change Was Made
Use the shared
truncateUtf16Safehelper for every room-scenario preview boundary. A local artifact-preview helper keeps all 200-unit call sites consistent and preserves the prior distinction between an absent value and an empty string.User Impact
QA Matrix evidence remains valid text around emoji boundaries. Transport behavior, Matrix events, final replies, limits, and configuration are unchanged.
Evidence
node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extensions.config.ts extensions/qa-matrix/src/runners/contract/scenarios.test.ts— 74 passedoxfmton both changed filesoxlinton both changed filesgit diff --checkRegression coverage asserts exact 200-unit body/formatted-body artifact output, preserves empty strings, and asserts the exact 237-unit timeout diagnostic line. No live Matrix run is needed because the change only formats already-observed evidence; event selection, network I/O, and delivery are untouched.
Risk
Low. This replaces unsafe presentation-only slices with the shared normalization helper and reduces production LOC. No API, config, dependency, or state change.
AI-assisted
Initial patch generated with Claude Code; maintainer review refactored the call sites and added public-path regression coverage.