Skip to content

studio: stop find in page matching part way through a grapheme - #10200

Merged
danielhanchen merged 55 commits into
mainfrom
studio-find-in-page-followup
Sep 6, 2026
Merged

danielhanchen merged 55 commits into
mainfrom
studio-find-in-page-followup

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Find in page can currently end a match part way through a character. The fix is one thing: ask Intl.Segmenter whether both edges of a candidate land where a grapheme starts, and drop the candidate when they do not.

What main does today

Reproduced against main at cc0cdab40, one text node per row:

document query main with this PR
café (decomposed) cafe [0,4] no match
🇩🇪🇫🇷 🇩🇪 [0,2] no match
👍🏽 👍 [0,2] no match
👨‍👩‍👧 👩 [3,5] no match
क्ष क [0,1] no match
1️⃣ 1 [0,1] no match

Each of those paints a highlight over part of a character: the thumb of a hand whose skin tone stays unpainted, one half of a flag, cafe inside café with the combining acute left hanging off the end. Enter then walks the reader to it.

This is not the Hangul defect. #10209 fixed "a Korean query finds nothing"; this is "a match may stop inside what the page draws as one character", which is still open and is not specific to any script.

The fence

alignsToGraphemes asks startsGrapheme about both edges. Ahead of it is a cheap test that decides almost every match without a segmentation: nothing below U+0300 can extend a grapheme or be extended into one, so Latin prose costs four comparisons per candidate. That fact is asserted over every code point below U+0300 rather than argued for.

Seeking is billed by what it costs rather than by how often it happens. A seek is 0.2us into a page of Hangul and 1236us into a page of flags, so no count is right for both; the budget is what a scan of the same index would cost, and once a search has spent it the boundaries are tabulated once and answer everything after. Wall time between two searches is the reader thinking and is not charged to either.

Where there is no Intl.Segmenter, every candidate is taken unchecked, which is what happens today. Firefox shipped one in 125 and was the last engine to; hand-rolling UAX 29 for the versions behind it is a second Unicode implementation to keep current, and the only thing at stake is whether those readers get the fix now or when they upgrade.

WebKit cannot be asked with containing

Segments.prototype.containing in WebKit answers the segment that ENDS at an offset rather than the one that starts there. Over x and a thumbs up:

containing(0) containing(1) containing(2)
spec / iterator 0 1 1
Chromium 151 0 1 1
Firefox 153 0 1 1
WebKit 26.5 0 0 1

startsGrapheme seeks with containing while it is under its budget, so taken at face value this fence threw away every match beside an emoji or an accent on Safari and on both WebKit-backed Tauri webviews. Not consistently either: past the budget the boundaries come from the iterator, which is correct, so the answers changed back on their own once a search had done enough work.

One fixture settles it, once per process. Where the engine fails it, boundaries are tabulated instead: the same answer by the slower route, not a second implementation of UAX 29.

What the engines' own find does, measured

window.find, reading the selection back rather than the boolean:

document query Chromium Firefox WebKit this PR
👍🏽 👍 selects 👍🏽 selects half selects half no match
क्ष क selects क्ष selects half selects half no match
1️⃣ 1 selects 1️⃣ selects half selects 1️⃣ no match
กำ ก selects กำ selects half selects half no match
👨‍👩‍👧 👩 no match no match no match no match

So the three engines do not agree with each other, and none of them does what this PR does. Chromium matches and then EXPANDS the selection to the whole cluster; Firefox paints half; WebKit is split. This PR refuses instead.

Refusing is the conservative half of the right answer: it can never paint part of a character, which is the defect. Expanding, as Chromium does, would also find 👍🏽 for a reader who typed 👍, and is the better behaviour. That is a bigger change -- it moves the ends of a match, and so the highlight, the counter and the walk -- and belongs in its own PR rather than smuggled into this one. Worth knowing that this trades "paints half" for "finds nothing" on those queries.

Verification

  • 6902/6902 frontend tests, typecheck, build, bundle:check within budget with 14.8 KB transfer to spare. Biome reports the same 2 pre-existing errors as main.
  • A differential harness against main's module over 2.78M queries / 86k documents / 4 DOM shapes under Node, and 250k queries each inside Chromium 151, Firefox 153 and WebKit 26.5. Every match the fence keeps is aligned at both edges; every aligned occurrence is kept unless a kept match already covers it; nothing is invented; ordering, non-overlap and bounds hold throughout.
  • With Intl.Segmenter deleted, head is byte-identical to main in all three engines, over the same corpora.
  • Locale and timezone do not move a grapheme boundary: checked over en, tr, ko, th, ja, ar, hi, el and against four host locales including tr_TR and ko_KR.
  • Worst case on the largest index the feature can hold (4M chars, all flags / all Hangul / all marks): first search 328ms on WebKit, 311ms on Firefox, 18ms on Chromium; every search after, 1-4ms.

History

This opened as a Hangul cluster-pattern fix plus a lazy split of the find bar, both of which main has since done itself (#10209, #10236). It then grew a hand-rolled UAX 29 fallback and a set of offsets tracking what a truncating walk left in doubt. Both were correct; both have been removed here as more machinery than the defect warrants. What is left is the fence, its budget, and the tests that hold it to the platform's own answer.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 2, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-06T08:14:32.524061Z dafd278 Manual request
🔒 Security Review ✅ Completed 2026-09-03T17:43:13.107699Z a57c935 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member Author

Confirmed the cluster pattern in studio/frontend/src/features/find-in-page/lib/find-text-index.ts still splits a Hangul syllable into Jamo on main, so Korean queries come back empty against text on screen. Will get this reviewed.

The shell prevents the chord's default and only then renders the bar, so
deferring the bar behind `lazy` leaves a reader who presses it early with no
native find and no bar either. Warming the chunk on idle narrows that window
but does not close it, and it never opens at all on Safari, which has shipped
requestIdleCallback behind a feature flag in every version to date and so
always takes the one second timer instead.

The smoke harness already caught this and was taught not to: `open_bar` grew a
ten second wait for the landmark, which is exactly the delay being measured.
Revert that wait, carry the bar in the entry again, and drop the test that
asserted the split. Against a deferred build five webkit checks that the bar is
a search landmark fail; against this one the harness is 432/432 across
chromium, firefox and webkit.

The budget raise this PR already makes is what pays for it: 1,566.3 KB eager
transfer, 6.0 KB inside the new ceiling. The split was not needed to fit.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

danielhanchen commented Sep 2, 2026 •

Copy link
Copy Markdown
Member Author

Round 2 done, both items genuine and fixed in 06ff5ef. Both are in the Hangul work I added, and both reproduced first.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 2, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 2, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

danielhanchen commented Sep 2, 2026 •

Copy link
Copy Markdown
Member Author

Round 3: both items genuine, both in my own Hangul work, both fixed in f97dc9d and reproduced first.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 2, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

danielhanchen commented Sep 3, 2026 •

Copy link
Copy Markdown
Member Author

Round 36, pushed as 1f09f25c3. Two items, both reproduced, both fixed, and one of them holes a proof I have leaned on since round 21.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1f09f25c37

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 1f09f25c37

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

danielhanchen commented Sep 3, 2026 •

Copy link
Copy Markdown
Member Author

Converged. Codex reviewed 1f09f25c37 and found nothing. 9a073b6c9 on top is the closing comment pass, AST-verified as touching no code.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 9a073b6c9c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 9a073b6c9c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: a57c935bcf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: a57c935bcf

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

The find bar became its own lazily loaded module on main (#10236), the index
grew portal surfaces and `renumbersMatches` (#10237), and #10209 landed its own
Hangul handling. Resolved by keeping both sides:

- `OffsetRuns`, `unsafe` and `shifted` sit alongside `rootLength` and
  `surfaces` on `FindTextIndex`, and `buildTextIndex` returns all of them.
- `CLUSTER_PATTERN` and the Hangul spelling helpers are main's, which require
  the vowel and carry the lint exemption. `canonicalSource` uses
  `partiallyComposedHangul` for the half-composed spelling and keeps the
  longest-first sort the grapheme fence needs.
- Every component-source assertion now reads `find-bar.tsx`, and the store
  tests are main's, since the store is gone.

`check-bundle-budget.ts` is back to main's: the branch only reflowed its
comments and added a note that the find bar is eager, which main's lazy split
has made untrue.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de6c76509f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1138 to +1139
cost.seen = (cost.seen ?? 0) - ((cost.seen ?? 0) % SEEK_BLOCK);
cost.since = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Charge partial seek blocks before resetting the window

When a query produces fewer than SEEK_BLOCK boundary checks, this resets both the partial seek count and its timer without adding any of that work to cost.spent. Consequently, repeated searches can never trigger the boundary-table fallback: for example, a near-tail query with one candidate in a large regional-indicator run repeatedly performs an expensive Intl.Segmenter.containing() seek on every query edit. Preserve or account for the partial block at the end of each search so actual seek cost eventually reaches the scan budget.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The accounting is as you describe: endSeekWindow rounds cost.seen down to a whole block and drops the open block's elapsed time, so a search that never completes a block is never charged. I could not reproduce the consequence, and the numbers say the fallback it would trigger is the more expensive answer, so this is a 👎 rather than a fix.

Instrumented containing and the iterator over a 4M index of nothing but regional indicators, which is the worst document this code can be given:

  • 200-match query, 25 searches: 9,975 seeks, 0 table buys, 10ms total.
  • 15-match query, 25 searches: 727 seeks, 0 table buys, 19ms total.
  • 30 searches of a tail-anchored query: 2.2-2.7ms each, flat, 70ms total.

One full scan of that index, which is what buying the table costs, is 107-110ms. So in every shape I could build, charging the partial block would trip the table and make the search slower, not faster: the seeks it would replace cost about a microsecond each here, because containing is not linear in the offset on V8.

The design already says this: the budget is measured time, not a count, and completed blocks are charged. What is dropped is bounded by one partial block per search. If an engine ever makes containing expensive enough for that to matter, the seeking path is not used there anyway, because it has to pass the correctness probe added in 06dc474 first, and WebKit already fails it and goes straight to the table.

Happy to be shown a document where this bites; the harness is a few lines and I will take the two-line change if it does.

The fence is what this PR is for: no match may begin or end part way through a
grapheme, which main still allows. It needs `Intl.Segmenter` and the cheap
sub-U+0300 test in front of it, and nothing else.

Removed the hand-rolled UAX 29 fallback for engines with no segmenter, and the
bookkeeping that tracked which offsets a truncating walk left in doubt. Both
were correct and both were answering questions this feature can decline: a
reader on Firefox 104 to 124 keeps the behaviour they have today, and a document
cut at the 4M ceiling keeps it at the seam. What is left is the fence itself,
its budget, and the tests that hold it to the platform's own answer.

Behaviour is unchanged everywhere a segmenter exists: half a flag, a bare
thumb before its skin tone, one member of a ZWJ family, a consonant inside a
conjunct, `cafe` inside a decomposed `café` and a keycap digit are all still
refused, and every whole-grapheme query still matches at the same offsets.
@danielhanchen

Copy link
Copy Markdown
Member Author

Rewritten to one fix, and the title and description now say what that is.

main has since done both halves of what this opened as: #10209 fixed the Hangul cluster pattern, #10236 put the find bar behind lazy. What was left over is the grapheme fence, which main still needs: a match can end part way through a character, so a search for a bare 👍 highlights the thumb of 👍🏽 and leaves its skin tone unpainted.

Merged main in as de6c76509, then cut the engine in ed62ad82a. Gone: the hand-rolled UAX 29 fallback for engines with no Intl.Segmenter, and the offsets tracking what a truncating walk left in doubt. Both were correct, and both answered questions this feature can decline. A reader on Firefox 104 to 124 keeps the behaviour they have today, and a document cut at the 4M ceiling keeps it at the seam.

2694/892 across 3 files, down to 1034/570 across 2. Behaviour is unchanged everywhere a segmenter exists, checked case by case against the pre-cut branch. 6900/6900 frontend tests, typecheck, build and bundle:check clean; Biome reports main's 2 pre-existing errors and no new ones.

The round-by-round log above is trimmed to one line each. The rounds themselves stand, but most of them are about code this PR no longer contains.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed62ad82ad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +787 to +789
if (!alignsToGraphemes(index, hit.index, end)) {
pattern.lastIndex = hit.index + 1;
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retry preserved whitespace before skipping a greedy hit

Inside preserved-whitespace content such as <pre>, a query ending in whitespace can have a valid occurrence hidden by the greedy \s+ pattern. For example, with text "x \u0301", the first space is a complete grapheme and "x " should match it exactly, but the regex initially consumes both spaces, the second space's combining mark makes this boundary check fail, and advancing lastIndex past the start prevents retrying the shorter valid match; findMatches consequently returns no occurrence. Retry an exact/shorter whitespace match at the same start before discarding the candidate.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mechanism is real and I reproduced it, but it is 👎 because it needs input this code never receives, and both fixes for it are worse than the defect.

Reproduced at head: "x \u0301", query "x " returns [] although [0,2] is an aligned literal occurrence. Greedy \s+ takes both spaces, the second carries the mark, the fence rejects, and lastIndex = start + 1 cannot come back for the shorter one.

Measured the reach: over 302,667 queries on 9,512 documents, 111 aligned occurrences are missed, and every one needs a combining mark attached to whitespace. It is wider than your example inside that family (108 of the 111 have no mark in the query at all, e.g. "hello \u0301 world" with query "ello "), and empty outside it. A combining mark on a space does not occur in chat, code or tool output.

Both repairs cost more than that:

  • Lazy \s+?: a lazy quantifier at the END of a pattern never expands, so a query of "\r\n" matches only the CR and the fence then rejects it for splitting the pair. The existing test a CRLF is one grapheme, which the fast path has to know about fails on it. Tried it; it is wrong.
  • A negative lookahead for a joiner after the run: this works (/x\s+(?![\p{Grapheme_Extend}\p{Mc}\p{Emoji_Modifier}\u200d])/u backtracks to [0,2] as wanted), but property escapes need the u flag, and putting the whole query pattern in unicode mode changes escapeForRegex and the lastIndex = start + 1 step for every query in the app to repair a case with no real input. Doing it without u means re-adding the range tables this PR just removed.

The failure mode here is a lost match, never a wrong one: the fence's invariant still holds, and nothing gets painted over half a character. That is the right side to fail on for input this exotic. Recorded rather than fixed.

…first

WebKit's `Segments.prototype.containing` answers the segment that ENDS at an
offset rather than the one that starts there. Over `x` and a thumbs up it reads
0, 0, 1 where Chromium and Firefox both read 0, 1, 1, so every interior boundary
answers "not a boundary".

`startsGrapheme` seeks with `containing` while it is under its budget, so on
Safari and on both WebKit-backed Tauri webviews this fence threw away every
match beside an emoji or an accent. Not consistently, either: past the budget
the boundaries are tabulated from the ITERATOR, which is correct, so the answers
changed back on their own once a search had done enough work.

Found by running the fence in all three engines over 250,000 queries each: the
same corpus is clean on Chromium and Firefox and had 40 violations on WebKit, of
the form "this occurrence is aligned by your own segmenter, and you dropped it".

One fixture settles it, once per process, and its answer is not a matter of
opinion: `containing(1)` over a code unit and a surrogate pair is the start of
the pair. Where the engine gets that wrong, boundaries are tabulated instead --
the same answer by the slower route, not a second implementation of UAX 29.
Measured on a 4M index in WebKit, that costs 328ms once and 1ms a search after,
against Firefox's own 311ms worst case on the seeking path.
@danielhanchen

Copy link
Copy Markdown
Member Author

Simulated this across the three engines before trusting it, and found one thing that would have broken Safari.

WebKit's Segments.prototype.containing is off by one. Asked about the first code unit of a cluster that follows an astral one, it answers the cluster that ENDS there rather than the one that starts there: over x and a thumbs up it reads 0, 0, 1 where Chromium 151 and Firefox 153 both read 0, 1, 1. startsGrapheme seeks with containing while it is under its budget, so this fence was throwing away every match beside an emoji or an accent on Safari and on both WebKit-backed Tauri webviews. Intermittently, too: past the budget the boundaries come from the iterator, which is correct, so the answers changed back once a search had done enough work.

Fixed in 06dc474bf by probing one fixture per process whose answer the spec fixes, and tabulating instead where the engine fails it. Same answer, slower route, no second implementation of UAX 29. Measured on a 4M index in WebKit: 328ms once, then 1ms a search, against Firefox's own 311ms worst case on the seeking path.

How it was found. A differential harness against main's module, checking five invariants rather than an expected output: every kept match is aligned at both edges; every aligned occurrence is kept unless a kept match already covers it; nothing is invented; ordering and non-overlap hold; offsets stay addressable. 2.78M queries over 86k documents and 4 DOM shapes under Node, and 250k queries inside each engine against real DOM nodes. Clean on Chromium and Firefox, 40 violations on WebKit, all of the form "aligned by your own segmenter, and you dropped it". Clean everywhere after the fix.

Also checked. With Intl.Segmenter deleted, head is byte-identical to main in all three engines. Locale and timezone do not move a grapheme boundary (en, tr, ko, th, ja, ar, hi, el, and four host locales including tr_TR). CRLF is never split. Worst case on a 4M index stays interactive in every engine. Exported surface is identical to main, 27 symbols, nothing added or removed, and no backend, schema or API file is touched, so an existing install has nothing to migrate.

One thing worth a second opinion, in the description now. Measured with window.find and the selection read back, the engines do not agree with each other and none does what this PR does: Chromium matches 👍 in 👍🏽 and EXPANDS the selection to the whole cluster, Firefox paints half, WebKit is split. This PR refuses. Refusing can never paint part of a character, which is the defect, but it trades that for "finds nothing" on those queries where Chromium finds the whole thing. Expanding is the better behaviour and is a bigger change -- it moves the ends of a match, and so the highlight, the counter and the walk -- so it belongs in its own PR rather than in this one.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Two ways a match could still end part way through a grapheme, both at a seam
where the walk dropped text:

- `startsGrapheme` returned true for `at === text.length` unconditionally. When
  the ceiling lands between a letter and the mark that joins it, the index ends
  on the letter and the mark is in the node that was left out, so the text alone
  says the letter is whole and the page says otherwise.
- The per-node cut moved only for a surrogate pair, so `MAX_NODE_CHARS` landing
  between a letter and its mark split the pair for every other extender.

Both are settled rather than assumed, from the one thing a cut has in hand: the
text it is dropping. `joinsAcross` asks the segmenter whether the kept tail runs
on into the next code point, over a 32-character window, and only the junctions
that really join become seams. `alignsToGraphemes` consults them ahead of the
cheap test, which reads the text either side of an edge and so cannot see a cut
at all -- at the end of a truncated index there is no next character to read.

Deciding rather than refusing is what keeps the far side of a cut findable: a
blanket refusal makes the first character after every clip unmatchable, which
three existing tests already pin.

Verified: the two reported cases now return no match, 6904/6904 frontend tests,
and the invariant harness against main is unchanged over 1.19M queries.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…ixed size

A window taken as the last 32 code units is not the text the segmenter would
see. Regional indicators prove it: a run pairs off from its START, so the tail
of an ODD run reads as an even one and the indicator after the cut looks like a
fresh flag rather than the back half of this one. A node of one ASCII character,
49,998 indicators and then two more, cut between the last two, returned the
second-to-last on its own while the page pairs it with the one that was dropped.

`exactTail` reads back to a character below U+0300 instead. Such a character can
neither extend nor be extended, which the sweep over every code point below
U+0300 already asserts, so it always begins a cluster and the window from it
segments exactly as the whole string does. Where there is no anchor within the
window the junction is unknown rather than open, and a match may not end on it:
that costs the one occurrence ending exactly at a cut inside an unbroken run,
which is the side to fail on.

Verified: the reported case now returns no match, the text after the cut is
still findable, both earlier seam cases stay fixed, 6905/6905 frontend tests,
and the invariant harness against main is unchanged over 1.19M queries.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Entering a block cleared the text a clip had dropped; leaving one did not. A
node clipped inside a block therefore stayed readable to the sibling after that
block, and decided a junction the block separator had already settled: a dropped
suffix ending in a Prepend joined the first character of the next block, putting
a seam on text that had nothing dropped in front of it and making it unfindable.

Reproduced against head: a `DIV` holding a clipped node whose dropped tail ends
U+0600, followed by the inline text `a`, returned no match for `a`.

Leaving a block clears it, as entering one does.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: c5d7f8690d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: dafd278a2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants