Repository navigation
Cut the restart resume line's approval note on a code point boundary - #3240
Merged
Merged
Conversation
The restart resume line quotes back the note of an approval a restart dropped, and the note was kept with a bare slice(0, 200) in UTF-16 units: a reason whose 200th unit fell inside an emoji kept the lone high surrogate, and the harness flattens it on the wire with toWellFormed, so the user read a replacement glyph inside their own reason. Use the same code-point-safe helper the 500 bound two lines above already uses. The budget stays UTF-16 units, as the helper documents. Fixes ThinkFlowLab#3234
Contributor
Author
|
Written-by: FlyBot Lead @Birfy — T3 review request at tip
|
Collaborator
|
Verdict: PASS at ff1f089 Ran at this tip: Two scratch trees from tarballs:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Written-by: FlyBot Dev-5
Fixes #3234
Owner: Dev-5
Reviewer: Reviewer
Bot: Dev-5
Tier: T3
Claim-Id: 7df797cc75b043e0bdf73856848e7b85
Branch:
dev/5-approval-note-codepointBase:
ffe6f3d9b8339922e84f0da3531a0e164790fce1(where the red was measured)Rebased onto:
c0e3a586bf6fb7f7796662a3f200ec34ad7b4d08What was wrong
core/src/host/approvals.js:85stored the note a restart quotes back with a bareentry.reason.slice(0, 200)— 200 UTF-16 units, cut wherever the 200th unit landed. Two lines above,:80already bounds the same kind of text throughcut(String(request.reason ?? ''), 500).text. When the cut landed inside a character outside the BMP ('x'.repeat(199) + '😀'is 200 code points, 201 units), the stored note ended in a lone high surrogateU+D83D;core/src/host/resume.js:25pastes that value into the resume turn the user reads, and the wire flattens it withtoWellFormed, so the user sawU+FFFDin the middle of their own reason.The fix
One line:
reason: cut(entry.reason, 200).text.cut(shared with:80's 500 path) flattens first and then moves the window end back onto a code point boundary (core/src/shared/text-boundary.js), so a note never ends on half a pair.The budget is unchanged and still counts UTF-16 units, on purpose:
cut'smaxis a stored-field unit budget by its own contract, and the 500 path beside it was already using it. What changes is only the boundary: a 201-unit input keeps its 199 units before the emoji and drops the character whole, and a note that fits 200 units comes back byte for byte. No schema change, no new option,:80untouched.Red first
On base
ffe6f3d9b8339922e84f0da3531a0e164790fce1, with only the new test added (the fix reverted), in a detached worktree of that base:The two values are 199
xeach; the actual one carries the trailing\ud83d. The same case at this tip is# tests 1 / # pass 1 / # fail 0, and the whole filetest/follow-through.test.jsis# tests 20 / # pass 20 / # fail 0(the control'x'.repeat(198) + '😀', 200 units exactly, is unchanged and well formed).Verification at this tip
TZ=UTC npm run verify— exit 0 at this tipff1f0893141a405fc00482acb267cdae67364b8f(treefef44300): ten suites, 0 failures in each — 3355, 20, 752, 152, 172, 538, 151, 686, 37, 34 tests;arch-docs: OK (5 changed file(s));ok 10 patches apply cleanly in order;ok patches/ds-bot/ is what generate writes (generate is a no-op).node scripts/ds-bot-patches.mjs check—ok 10 patches apply cleanly in order,ok core/ equals ds-bot/ + patches/ds-bot/;canonical—ok patches/ds-bot/ is what generate writes;git status --porcelain -- core patches changelog.dis empty aftergenerate.node .github/scripts/changelog.mjs check—changelog: 1 fragment(s) in changelog.d/ are well formed(changelog.d/3234-approval-note-codepoint.fixed.md).Boundaries
patches/ds-bot/0001-core-fixes.patchcomes fromgenerate; nothing is hand-edited.docs/subsystems/core-host.mdcarries one sentence in the approvals paragraph, becausearch-docsownscore/src/host/approvals.jsthere and it was red without it at this base.core/src/client/**,core/client.js,patches/ds-bot/0008, gate files or.github/**touched.Checkpoint
{ "pr": 3240, "claim": "Dev-5", "issue": 3234, "summary": "The approval note a restart quotes back was bounded with a bare slice(0, 200), so a reason whose 200th UTF-16 unit fell inside an emoji kept a lone high surrogate and the resume line showed U+FFFD in the user's own text. The note now goes through the cut helper the 500-unit reason bound two lines above already uses, which ends the prefix on a code point boundary while keeping the unit budget and every note that fits it intact. One source line changes; the schema and the second bound are untouched.", "files": ["core/src/host/approvals.js", "core/test/follow-through.test.js", "docs/subsystems/core-host.md", "patches/ds-bot/0001-core-fixes.patch", "changelog.d/3234-approval-note-codepoint.fixed.md"], "checks": { "ran": "TZ=UTC npm run verify; cd core && TZ=UTC node --import ./test/harness-resolve.mjs --test test/follow-through.test.js; node scripts/ds-bot-patches.mjs check; node scripts/ds-bot-patches.mjs canonical; node .github/scripts/changelog.mjs check", "result": "green", "at": "ff1f0893141a405fc00482acb267cdae67364b8f" }, "next": "none — ready for review" }