Repository navigation
fix(browser): UTF-16-safe page text truncation - #146131
nocodet888-arch wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Thanks for the contribution. This PR still needs the requested real-behavior proof, and the branch has been idle since that ask. Close as stalled awaiting real behavior proof: the dated proof request and head activity are over three weeks old, evidence remains mock-only, and no maintainer engagement or protected signal is present. The underlying fix remains useful. So I’m closing this for now to keep the review queue honest. Please reopen or open a fresh PR with real-behavior proof (a live run, logs, or a reproducible validation transcript) and it will be reviewed again. Review detailsBest possible solution: Retain the shared UTF-16 helper approach in a refreshed patch with Chrome-backed output proving the complete-character boundary behavior. Do we have a high-confidence way to reproduce the issue? Yes, from source: the current Playwright page-text path slices abcd😀 at five UTF-16 units, retaining a lone high surrogate. A real Chrome-backed reproduction was not executed. Is this the best way to solve the issue? Yes, reusing the existing SDK truncation helper is the narrow repair and preserves the current budget and truncation flag. Security review: Security review cleared: The patch reuses an existing text helper without changing authorization, execution, dependencies, or sensitive-data handling. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning medium; reviewed against 78e406060b56. |
|
ClawSweeper recorded closeout evidence for this proposed close.
|
What Problem This Solves
getPageTextViaPlaywrighttruncated visible page text with raw.slice(0, maxChars). Emoji/CJK at the budget boundary can split a UTF-16 surrogate pair, producing a lone high/low surrogate in model-facing text. Sibling snapshot/responses paths already usetruncateUtf16Safe.Why This Change Was Made
Replace
.slicewithtruncateUtf16Safefromopenclaw/plugin-sdk/text-utility-runtime, matchingpw-tools-core.responses.ts/pw-tools-core.snapshot.ts.User Impact
Before: Page-text truncation could emit a broken trailing surrogate.
After: Truncation backs up to a code-unit boundary; emoji at the edge is dropped whole.
Evidence
extensions/browser/src/browser/pw-tools-core.activity.ts,extensions/browser/src/browser/pw-tools-core.activity.test.tsgetPageTextViaPlaywright→truncateUtf16SafeReal behavior proof
Behavior or issue addressed
maxChars=5on"abcd😀"returns"abcd"with no lone surrogate (raw.slicewould keep a high surrogate).Canonical reachability path
getPageTextViaPlaywright→locator.innerText→truncateUtf16Safe(text, maxChars)Shared helper / provider constraint check
Reuses shared
truncateUtf16Safealready used by snapshot/responses.Real environment tested
Local Vitest with Playwright page mocks (
installTextPage).Exact steps or command run after this patch
node scripts/run-vitest.mjs extensions/browser/src/browser/pw-tools-core.activity.test.ts -t "surrogate pair" --reporter=verboseEvidence after fix
Observed result after fix
Output is
"abcd"(emoji dropped whole); no lone surrogate remains.What was not tested
Live Playwright against a real Chrome page with emoji near the char budget.
Fix classification
Root cause fix