Skip to content

studio: find in page on Cmd/Ctrl+F - #10061

Merged
danielhanchen merged 34 commits into
mainfrom
studio-find-in-page
Sep 2, 2026
Merged

danielhanchen merged 34 commits into
mainfrom
studio-find-in-page

Conversation

@shimmyshimmer

Copy link
Copy Markdown
Member

Adds a find bar to the Studio shell, on Cmd+F / Ctrl+F.

It floats over the workspace on screen, tints every match with the active one picked out, counts them, and walks them with Enter / Shift+Enter or the arrow buttons. Escape closes it, and pressing the chord again re-selects the field so the next keystroke starts a new search. It is a rebindable action, so it appears in Settings > Shortcuts alongside the rest.

Why not just leave it to the browser

The browser's own find cannot reach a message the widen-only mount window has not committed yet, counts the sidebar and the composer as part of the page, and does not exist at all on the desktop build. This is the one default that deliberately takes a chord the browser owns. The chord is cancellable in every engine we ship on, so the handler wins it, and Settings still flags it as browser-reserved.

Keeping it off the hot path

The thing that matters here is that a Studio nobody is searching pays nothing, and that a Studio somebody is searching does not stutter.

  • Nothing exists when the bar is closed. FindInPage renders null unless open. The index, the mutation observer and the highlights all live inside the bar, so a closed bar is one boolean in a store and one keydown listener.
  • Highlights never touch the DOM. Painting goes through the CSS Custom Highlight API: a Highlight is a set of Ranges drawn over text that is already laid out. Nothing is inserted, nothing reflows, and the text nodes that streaming markdown, thread-fast-copy and the export path all read back are left alone. Wrapping matches in <mark> would mutate the thread on every keystroke and would also retrigger our own observer.
  • The document is flattened once, not per keystroke. A keystroke runs indexOf over a string. One flatten of a 40-message conversation measured 0.1 to 1.0 ms, and typing a 14-character query produced zero long tasks.
  • Streaming is debounced to one re-index per 300 ms, trailing edge only, and skipped entirely while the field is empty. Mutations from the bar's own counter are filtered out so it cannot order a re-index of itself.
  • Everything is bounded: 4M characters indexed, 5000 matches counted, 400 ranges painted in a window that travels with the active match.

Correctness details worth calling out

  • completeProgressiveMounts() runs on open, so messages the mount window has not committed yet are still findable.
  • Block boundaries get a separator, so a match cannot run from the end of one paragraph into the start of the next.
  • Off-route workspaces (inert) and modal-shadowed content (aria-hidden) stay out of the count. Switching between two kept-alive workspaces only flips inert and adds nothing, so the observer watches that attribute too, otherwise the bar would keep reporting matches from the workspace you just left.
  • A run whose case fold would change length keeps its case instead. Turkish dotted I folds to two code units, and one of those in a thread would shift every offset after it and paint highlights a character to the left of the word.
  • Non-breaking spaces answer to the space key, substituted one for one so offsets are untouched.
  • An engine with no highlight registry falls back to selecting the active match, which is what a browser's own find does.

Look

No border in either mode. Light is the chatbox's own background and shadow, pinned to .unsloth-composer-surface by a test so a composer restyle fails here rather than drifting a shade off. Dark sits one step above --card, because the bar floats over cards that are themselves --card and would otherwise dissolve into whatever scrolls under it. That step is also what gives the buttons inside a hover that shows: the ghost variant's own --muted/50 lands within a shade of the surface.

Verification

  • smoke-find-in-page.html, a new harness in the existing smoke-* style, driven in a real browser: chord opens and the browser's own find bar stays suppressed, 24 matches counted with an inert panel's 3 correctly excluded, Enter and Shift+Enter walk and scroll while leaving an already-visible match alone, a streamed reply took the count 24 to 25 without yanking the reader, Escape tears down both highlight registries, light and dark both legible.
  • 27 new node tests covering the flatten, the offset map, the search, the bounds, the paint window and the wiring.
  • typecheck clean, i18n:check:strict clean, 6090 of 6090 tests pass, build succeeds within the bundle budget, eslint clean on the new code.

Adds a find bar to the Studio shell. It floats over the workspace on
screen, tints every match with the active one picked out, counts them,
and walks them with Enter / Shift+Enter or the arrow buttons. Escape
closes it. The chord is a rebindable action, so it shows up in
Settings > Shortcuts like every other one.

The engine only exists while the bar is open, so a Studio nobody is
searching runs one keydown listener and nothing else: no index, no
observer, no ranges.

Highlights are painted through the CSS Custom Highlight API rather than
by wrapping matches in <mark>. Nothing is inserted into the thread, so
nothing reflows, and the text nodes that streaming markdown,
thread-fast-copy and the export path all read back are left alone.

The document is flattened into one string once and searched with
indexOf, so a keystroke never walks the DOM. The flatten is redone only
when the document changes, debounced to 300ms and skipped entirely while
the field is empty.

Correctness details worth calling out:

- completeProgressiveMounts() runs on open, so messages the widen-only
  mount window has not committed yet are still findable.
- Block boundaries get a separator, so a match cannot run from the end
  of one paragraph into the start of the next.
- Off-route workspaces and modal-shadowed content stay out of the count,
  including on a workspace switch, which only flips inert.
- A run whose case fold would change length keeps its case, so offsets
  cannot drift and paint a highlight over the wrong word.

Everything is bounded: 4M characters indexed, 5000 matches counted, 400
ranges painted in a window that travels with the active match.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 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-02T12:30:08.932349Z afee89e 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.

Dark goes #272727 to #2c2c2c. The message cards it floats over are
#212121, and one step was not quite enough to read as a separate
surface while scrolling.

Light keeps the composer's shadow shape but a touch larger and darker,
0 3px 10px -2px at 0.2 rather than 0 2px 8px -2px at 0.16. The composer
sits at the bottom of the page with nothing under it; this bar has a
conversation moving beneath it and needs slightly more to sit on.

The test that pinned the light shadow to the composer's now checks the
relationship instead: same shape, larger blur, higher alpha, and no more
than half again either, so it cannot drift into a different material.
The dark bound moves from --accent to --border, which is the value it
actually has to stay under now that the buttons hover on a plain wash.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

Back to the composer's 0.16, wider instead: 0 3px 14px -1px, against the
composer's 0 2px 8px -2px. Same darkness, more of it, which lifts the
bar off a moving conversation without reading heavier than the box it
was copied from.

The test follows: alpha now has to EQUAL the composer's, and blur and
spread both have to grow, so darkening it again fails here.
Alpha 0.16 to 0.13, geometry unchanged. The wider spread is what lifts
the bar off the conversation, so the ink can come down below the
composer's rather than match it.

The test flips with it: alpha now has to be strictly softer than the
composer's, and no less than 0.7 of it, so this cannot fade to nothing
either.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Restore Mod+KeyF in BROWSER_RESERVED_VALUES. I deleted the line while
trimming the comment beside it, and the test that should have caught it
only SKIPPED the deliberate exceptions instead of asserting they are
flagged. It now asserts both directions.

Index:

- Reject subtrees the engine is not painting. Attributes alone missed a
  responsive `hidden lg:flex`, so text nobody can see was counted and
  walked to. checkVisibility, guarded, and opacity left out so a message
  fading in stays findable.
- Fold per code point when the whole-run fold grows. One dotted I made
  every other word in its node case-sensitive.
- Take the prefix of a text node bigger than the ceiling. One Bash log
  arrives as one node, and dropping it whole indexed nothing at all.
- Match a query across collapsed whitespace. A markdown soft wrap is a
  newline inside one text node, so searching the phrase as it renders
  missed. Only queries containing whitespace take the pattern path;
  single words keep indexOf.

Engine and shell:

- Start a fresh query from the scroll container's top, not the window's.
  The thread viewport begins below the navbar, so a match clipped off
  the top of it still had a positive top and sent the reader backwards.
- Refuse to open while any modal backgrounds the scope, using the
  registry's own foreground check rather than the Settings store.
- Fixed rather than absolute, and capped to the viewport. On a route
  whose outer container scrolls, the bar sat at the top of a scope
  taller than the window; on a narrow window it ran off the left edge.

The re-index interval is a throttle, not a debounce. The behaviour is
right, since a debounce leaves the count frozen for as long as a reply
takes to write, so the name and the comment now say what it does.

Measured on a 322K character, 7750 element thread: one flatten is 5ms,
about 1.7% of the interval, with the visibility check in place.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Went through all eleven. Nine were right and are fixed in 1fd766d, one I could not reproduce as described, and one I am leaving as designed. Details below, with what I actually checked in each case.

Fixed

Add Mod+KeyF to the reserved-binding set. Correct, and my fault: I deleted the line while trimming the comment next to it. isBrowserReservedBinding("Mod+KeyF") did return false. Restored, and the test that should have caught it was the real problem, it only skipped the deliberate exceptions instead of asserting they are flagged. It now asserts both directions, so dropping a value from the set fails rather than passing quietly.

Exclude CSS-hidden content from the index. Correct. The predicate only read attributes, and a responsive hidden lg:flex is a class, so text nobody can see was counted and walked to. Now rejects anything checkVisibility reports as not painted, guarded for engines without it. Opacity is deliberately left out so a message still fading in stays findable. Verified in the harness: a display: none panel holding the search term drops out of the count.

Preserve case-insensitive matching around expanding folds. Correct. HELLO İ indexed verbatim, so hello returned nothing. Now folds per code point when the whole-run fold grows, keeping only the folds that fit, so one dotted I no longer makes the rest of its node case-sensitive. Offsets still line up, which is what the whole-run fallback was protecting.

Index the prefix of an oversized text node. Correct. A single node past the ceiling indexed nothing at all, which is exactly the content the ceiling exists for. Confirmed: a 4M+ character node produced an empty index and zero matches for a word in its first eight characters. Now takes the prefix that fits.

Match whitespace as it is rendered. Correct, and the case that matters most is not multiple spaces but a markdown soft wrap, which is a newline inside one text node rendered as one line. Searching the phrase a reader can see missed it. A query containing whitespace now matches runs of whitespace in the document; single-word queries, which are most of them, keep the indexOf path. Block separators are not whitespace, so boundaries stay closed. Verified end to end: wrapped phrase about unsloth now matches across a newline plus ten spaces, and the highlight lands on the rendered phrase, so the offset map survived the variable-length match.

Compare matches against the scroll viewport top. Correct. Measured the thread scroller's top at 122px in the harness, scrolled until one match sat between the window top and the scroller top, and confirmed the old rule picked that clipped occurrence while the new one picks the first match actually on screen.

Disable find while any modal backgrounds the scope. Correct that the gate only tracked Settings. One correction to the reasoning: the scope would not have been zero-result, since aria-hidden lands on an ancestor and the walk starts at the scope, so it would have found matches in a region the reader cannot reach. Either way the bar should not open. Now asked at press time through the registry's own foreground check, which covers every modal. Verified: the chord does nothing while the scope is backgrounded and works again once it is not.

Keep the bar visible in non-chat scroll containers. Correct. Reproduced by adding an outer-scroller mode to the harness. Now fixed rather than absolute, with a top offset derived from --studio-content-top-inset so it clears the navbar and the chat header. Verified: opening at scrollTop 2000 leaves the scroller at 2000, and the bar holds its position while the page scrolls to the bottom.

Fit the find bar within narrow viewports. Correct, it measured 452px with no cap. The input is now narrow by default and wide from sm up, plus max-w-[calc(100vw-2rem)] as a backstop. The browser I was testing in would not emulate a narrow viewport, so I verified it in a same-origin iframe, which has its own 100vw: at 380px the bar is 348px, sits at left 16 / right 364, and its contents do not overflow.

Corrected rather than changed

Debounce reindexing from the final streaming mutation. The description of the code is right, it is a throttle. The behaviour is the one I want, though: a true debounce leaves the count frozen and newly arrived text unfindable for as long as a reply takes to write, which can be minutes. So I fixed the name and the comment instead of the code, since the documentation was what was wrong.

On the cost concern, measured on a 322K character, 7750 element thread, which is the worst rung #9016 benchmarks: one flatten is about 5ms, roughly 1.7% of the 300ms interval, with the new visibility check included. Same figure whether style is clean or was just dirtied by an insertion.

Not changing

Preserve existing user ownership of Mod+KeyF. The mechanism is real, shortcutOwningBinding walks SHORTCUT_DEFS in order and a new default can shadow an older override. But that is how the registry is designed, the file says so, and it already has an answer: findConflicts flags the clash and the Shortcuts tab renders it as "Another shortcut has this chord and runs instead". Adding a bespoke migration for this one action would mean it silently ships unbound for those users, and would be the only default in the list behaving that way. Happy to revisit if we would rather have that mechanism generally.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Both are against the visibility check and the ceiling I added last round.

Stop asking checkVisibility about content-visibility. A skipped subtree
is not a hidden one: the Hub README sets content-visibility: auto on its
root and every child, and so does a maths-bearing thread, so passing
contentVisibilityAuto dropped everything below the fold from the index.
Nothing would have put it back, since scrolling renders a subtree
without mutating the DOM and the observer never fires. Measured on the
real thing: an element inside a skipped subtree answers false with the
flag on and true with it off.

Text in a skipped subtree has no geometry of its own, so the walk now
aims at the nearest ancestor that is laid out. The subtree keeps its
contain-intrinsic-size box, which is close enough to scroll to, and it
renders on the way, so the highlight lands once it does.

Enforce the ceiling before writing a block separator. A node landing
exactly on the cap let the next separator push length past it, and the
negative room that followed turned slice(0, room) into "all but the last
character" of the following node. Measured overshoot on a 4,000,000 cap:
500,000 characters. Now nothing lands past the cap by any route the walk
can take to it, which is what the second new test asserts.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Both of these are right, and both are against code I added in the last round. Fixed in e76db4c.

Keep content-visibility subtrees searchable. Correct, and it is worse than a Hub README: index.css puts content-visibility: auto on .aui-math-block and .aui-math-display too, so a maths-bearing thread would have lost everything below the fold as well. The comment on the code-block rule in that file already says not to reach back for content-visibility: auto there partly because find-in-page cannot see skipped content, so I had walked straight into the thing the file warns about.

The distinction that makes it real is that checkVisibility answers differently for the container and its contents. Measured on a genuinely skipped subtree in the harness, placeholder height 400px:

  • container, contentVisibilityAuto: true → true
  • inner element, contentVisibilityAuto: true → false
  • inner element, contentVisibilityAuto: false → true

So the walk was rejecting exactly the descendants it needed. The flag is now off, which leaves genuinely hidden elements rejected as before. And you are right that nothing would have recovered it: scrolling renders a subtree without mutating the DOM, so the observer never fires.

There is a second half the finding does not mention. Text in a skipped subtree has no geometry of its own, so a range inside it comes back collapsed and the walk could not scroll to it even once indexed. The reveal now falls back to the nearest ancestor that is laid out, which for a skipped subtree is its contain-intrinsic-size box. Verified end to end: the term is found (1/1), the walk scrolls to it, the subtree renders on the way, and the highlight paints on it.

Enforce the cap before adding a block separator. Correct, and the overshoot is as large as you describe. Reproduced with a node landing exactly on MAX_INDEX_CHARS followed by another across a block boundary:

ceiling:                 4000000
indexed length:          4500000
overshoot past the cap:   500000

room came out as -1 and slice(0, -1) took all but the last character of the following node, so the cap bought nothing. The check now happens before the separator is written, and there is a second test that runs every shape the walk can reach the ceiling by, one oversized node, many small ones, and a boundary landing in the middle, asserting none of them index past the cap. Overshoot is now 0 for all three.

npm test is 6103 passing, typecheck and i18n parity clean, build within the bundle budget.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ 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[bot]

This comment was marked as resolved.

Walk through display: contents wrappers instead of skipping them. An element
with no box is the first thing checkVisibility calls invisible, and the shell
and the training page both wrap their content in one, so the index came back
empty for most of the app.

Re-anchor from the viewport after progressive completion. That growth prepends,
so keeping the ordinal moved the highlight to an older match off screen.

Handle Escape on the bar rather than the field, so it also closes from the walk
and close buttons instead of falling through to the bare-Escape decline.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

All three are right. Fixed in fabb09a.

Descend through display-contents wrappers. Correct, and the blast radius is bigger than the training page. Measured in a browser on a wrapper with one visible child:

element checkVisibility({contentVisibilityAuto: false, opacityProperty: false, visibilityProperty: true})
display: contents wrapper false
its child true

So the walk was rejecting a subtree on the strength of the one element in it that has no box. Four places use the class: studio-page.tsx:186, sidebar.tsx:434, history-card-grid.tsx:446 and training-wizard.tsx:127. Between the shell's and the training page's, that is most of what there is to search outside a thread.

display: contents is also the only visible case the spec's "no associated box" clause catches, so the fix is to ask which one it is, and only on the branch that was about to skip:

if (checkVisibility(...) !== false) return false;
return computedDisplay(element) !== "contents";

getComputedStyle is therefore called once per hidden subtree root and never on a visible document.

Re-anchor after progressive rows are prepended. Correct. Reproduced with a thread opened at a retained query, scrolled to message 21, with six older messages arriving inside the progressive window. Same run, the only difference being what the completion rebuild passes:

counter active match its top, viewport top is 122
at open 6/27 "...a search for unsloth has somewhere to land" 122
keeping the ordinal 6/33 "An older message about unsloth, number 6" -1620
re-anchoring 11/33 "Unsloth Studio runs 500+..." 909

1742px above the top of the viewport, and the next step from there walks further back into the history the reader never asked for. Re-anchored, the active match is exactly the first one at or after the viewport top. The observer's throttled rebuild still keeps the ordinal, which is the append-only case it was written for; a test now pins that there is exactly one caller left doing so.

Handle Escape beyond the query input. Correct. declineToolRequest ships as bare Escape with skipInTextFields: true, and isTextEntryFocused only recognises INPUT, TEXTAREA and contenteditable, so a focused walk button is not shielded. activationBelongsToFocus does not cover it either: that guard is for Enter, NumpadEnter and Space.

The handler moved from the field to the landmark, so it catches the bubble from all four controls. Measured with a counter on the window listener, counting only presses that arrive not already defaultPrevented:

Escape pressed from bar closes reaches the window listener
the query field yes no
Previous match yes no
Next match yes no
Close find yes no
a button outside the bar n/a yes

The last row is the control: it is the path Escape took from the walk buttons before.

Three regression tests, and the harness grew a display: contents wrapper and a prepend so the first two are reproducible by hand as well. Full pass green: typecheck, locale parity, 6106 tests, build within budget.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Skip an inline SVG. Only HTML elements report an uppercase tag, so <svg>
answered "svg" and walked past a skip list spelled in HTML casing.

Leave the chord to the browser when the scope is behind a modal. useShortcut
prevents the event before calling the handler, so declining from inside it
killed native find too. New claims option, asked before the event is consumed.

Complete only the progressive mounts this search can read, so opening find on
another route no longer forces a retained conversation to mount every withheld
row.

Hand focus back to where the bar took it from, ignore the Enter that commits an
IME candidate, and keep the chat composer's pill labels out of the index.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

All six are right. Fixed in cf3f668.

Normalize SVG tag names before applying the skip list. Correct. Measured on an inline <svg><text> in an HTML document:

element tagName
<div> DIV
<svg> svg
<text> text

So the one entry in the list that can appear in a foreign namespace was the one entry that never matched. With the harness carrying a diagram, a search for its label came back 1/1 with a live Range whose start container was an SVG <text>, which is exactly what the list exists to prevent. Uppercasing before the lookup is a no-op for HTML, which already reports that way.

Let native find handle backgrounded modal content. Correct, and it is a regression this PR introduced: before it, Cmd/Ctrl+F behind a modal opened the browser's own find. Measured on the same chord:

defaultPrevented bar opens
normally true yes
behind a modal, before true no
behind a modal, after false no

The middle row is the dead chord. useShortcut prevents at line 181 and calls the handler at 186, so no answer from inside the handler can give the key back. Rather than special-case this call site, the hook grew a claims option asked immediately before preventDefault, and the bar passes its background check there. Everything else is unchanged: enabled still gates registration, and an action that passes no claims behaves exactly as before.

Complete only progressive mounts in the active scope. Correct. __root.tsx:570 keeps the chat mounted and flips inert on it, so a search on Hub was asking a conversation nobody can see to mount every row it had withheld, for an index that then skips all of it. completeProgressiveMounts now takes an optional filter over the withholding thread's viewport, and the find engine passes indexReaches, which answers the same question the walk does. Checked against the live harness DOM:

element indexReaches(scope, el)
a message in the conversation true
a paragraph under inert false
the find bar's own field false
a control outside the scope false

One trap worth naming: the loop's exit condition read activeCompleters.size === 0, and left that way a declined completer holds it open forever. The exit reads the filtered set now, and the no-filter, accept-all and accept-none cases were each run to confirm they resolve.

Restore focus after closing the find bar. Correct. document.activeElement was BODY after Escape. The bar now captures what focus is leaving on mount, above the effect that fills the field, and hands it back on unmount:

before after
close with focus in the bar BODY the control that had it
close after the reader clicked elsewhere that element that element

The second row is the guard: it only restores when closing dropped focus on the floor, so it never takes focus back from somewhere the reader put it.

Ignore navigation keys while the IME is composing. Correct. An Enter carrying the composition flag was prevented and walked the match list:

counter defaultPrevented
composing Enter, before 1/27 to 2/27 true
composing Enter, after 1/27 to 1/27 false
plain Enter, after 1/27 to 2/27 true

isImeComposing already existed for exactly this, covering both isComposing and the legacy 229, so the guard is that call ahead of preventDefault.

Exclude the chat composer from the search scope. Correct. The draft itself lives in a textarea the index cannot read, so what the composer actually contributed was its chrome: <span>Search</span> at thread.tsx:5545 and the rest of the pill labels. Searching for "code" or "images" landed on the toolbar instead of the conversation. data-find-skip on ComposerPrimitive.Root settles it; the primitive spreads its rest props onto Primitive.form, so the attribute reaches the DOM.

Six regression tests, and the harness grew an inline SVG. Full pass green: typecheck, locale parity, 6112 tests, build within budget, and lint back at its baseline count on every file touched.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

One rule now decides who keeps their place in the match list: the ordinal
survives a pure append at the tail, which is what a streaming reply produces,
and nothing else. Prepended history, a workspace switch flipping inert and a
breakpoint revealing a column all renumber the list, so they re-anchor to the
reader's viewport. An unchanged document is an append of nothing, which leaves
the settled thread's 400ms mount probe unable to take back an Enter pressed
while it ran.

Invalidate the index on resize as well as on mutations. Crossing a breakpoint
changes what is rendered with nothing in the DOM to observe.

Clear the search when the shell unmounts, so signing out does not hand the next
user the last one's query, open and focused.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

All four are right. Fixed in fa9ef22.

Three of them are the same question asked in three places: when a rebuild finds a different document, does the reader's ordinal still mean anything? Rather than answer it per call site, there is now one test. The ordinal survives a pure append at the tail, and nothing else:

return !indexRef.current.text.startsWith(before);

A streaming reply only ever adds to the end, so match 20 is still match 20. Everything else renumbers, and re-anchors to the viewport instead. An unchanged document is an append of nothing, which is what makes the third finding fall out for free.

Re-anchor matches after non-append mutations. Correct. Modelled the shell's two parked workspaces in the harness, since __root.tsx:570 switches by flipping inert rather than by mounting anything, and the other workspace's matches come before the thread's:

counter active match its top, viewport top is 122
in the conversation 7/27 "Training with Unsloth is about twice as fast" 337
after the switch, keeping the ordinal 7/12 "Another workspace, unsloth line 7" -589
after the switch, re-anchored 1/12 first match in the new workspace recomputed

711px above the top of the viewport, in a workspace the reader had not looked at yet.

Rebuild the index when responsive visibility changes. Correct, and nothing recovered it. class is deliberately outside the observer's attributeFilter (it changes on every hover), so a breakpoint crossing is not a mutation at all, and the index reads computed visibility. Reproduced by flipping only a class, which is the same non-event:

counter
hidden 0/0
revealed, before 0/0
revealed, and retyping the query 0/0
revealed, after 1/1
hidden again, after 0/0

The third row is the part worth naming: nothing marked the index stale, so even editing the query kept searching the layout that had gone. A resize listener now goes through the same 300ms throttle as a mutation, so dragging a window edge costs one rebuild an interval rather than one a frame.

Preserve navigation made during the progressive-mount probe. Correct, and it is a consequence of the previous round's fix. The probe waits out its 400ms search interval on a settled thread even though it mounted nothing, and the re-anchor was unconditional. With three Enters pressed inside that window:

counter
at open 6/27
after three Enters 9/27
after the probe, before 7/27
after the probe, after 9/27

7 is what the viewport anchor computes there, measured directly: the active match is 9th in document order while the first match at or below the viewport top is 7th. That gap is the jump back. It only appears when the walk did not have to scroll, which is the common case in a window tall enough to show several matches at once.

Clear find state when crossing the authentication boundary. Correct. /login is in HIDDEN_NAVBAR_ROUTES, so the whole SidebarProvider branch including the bar is unmounted, while the store is module-global and keeps the query on purpose. Measured across a sign-out and a sign-in in the same tab:

open query
signed in, bar up true "unsloth"
at /login, before true "unsloth"
at /login, after false ""
next user signs in, after false ""

Reset on unmount rather than on enabled going false: a dialog turns that off, and the search should still be there when it closes. close still keeps the query, so reopening still offers the last search.

Checked the append case did not regress along the way. A reply landing at the tail: 6/27 to 6/28, ordinal held. A removal: re-anchored, as the rule now says it should.

Four regression tests, and the harness grew a second parked workspace and a shell that can unmount. Full pass green: typecheck, locale parity, 6116 tests, build within budget, lint errors at their baseline count on every file touched.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Leave Escape to the IME while it is composing. The guard was on the Enter path
but not on the bar-level Escape added last round, so dismissing a candidate
closed the bar out from under the word being typed.

Ask for one match past the cap, so a page holding exactly MAX_MATCHES no longer
reads as more than that. findMatches stops at the limit it is given, so the
count alone could not tell the two apart.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Both are right. Fixed in 30bf0b0.

Preserve Escape during IME composition. Correct, and it is a gap I opened last round: moving the handler from the field to the landmark carried the Enter path's composition guard nowhere. The file that defines isImeComposing already says this in its own comment, that Escape cancels a candidate and Enter commits one, so this was walking past the warning next door. Measured with an Escape carrying the composition flag:

bar query defaultPrevented
composing, before closes lost from view true
composing, after stays open "unslo" false
not composing, after closes kept for reopening true

Letting it through is safe rather than merely quieter: use-shortcut.ts:174 stands aside for a composing event before it even looks for a binding, so the bare-Escape decline cannot take it either. There is a test pinning that, since the safety of this handler depends on it.

Show '+' only when matches exceed the cap. Correct. findMatches stops at the limit it is given, so the count is the same 5000 whether the page holds 5000 or 5001, and count >= MAX_MATCHES read the exact case as the truncated one. Asking for one past the cap is the whole difference; the probe match is thrown away and only its existence is kept, so nothing downstream sees a list longer than the cap.

Driven through the real bar with a block of that exact size:

occurrences before after
4999 1/4999 1/4999
5000 1/5000+ 1/5000
5001 1/5000+ 1/5000+

Three regression tests. Full pass green: typecheck, locale parity, 6119 tests, build within budget, lint errors at their baseline count on every file touched.

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

This comment was marked as resolved.

Four things found going over this against its merge base. The reveal-chain one
you already fixed in 4ef77f6 while I was writing it, so this is the rest.

**The final match in the document was unreachable from the bottom of it.**
`search` asks `findMatches` for `MAX_MATCHES + 1` so a page holding exactly the
cap does not have to read as a floor, then throws the extra one away. Taking it
off the tail is right only while the window starts at the top. Once the reader
is far enough down the anchored window IS the tail, so the discarded entry was
the document's last occurrence, which is also the one nearest them. Reproduced
on 6000 matches with the reader at the bottom: the window covered the final
occurrence at offset 11998 and the walk ended at 11996. The trim now takes
whichever end the reader is further from, judged by the anchor `findMatches`
had already resolved, so it costs no second layout read and still costs nothing
under the cap, where the thunk is never called.

**`getComputedStyle` ran twice per element.** `skipsSubtree` resolved a style
and so did `visit`, while the comment on `computedStyle` says "One read per
element" and quotes the 8000-element measurement on that basis. The tag and
attribute half of the rule is now asked first and on its own, so a subtree
turned down on markup costs no layout read at all and everything else costs
one, which is what the comment already claimed.

**`text-[15px]` on the query field.** A raw pixel size ignores the UI font size
preference, which `tests/studio/test_ui_font_scale_contract.py` exists to catch,
and it was failing on it. Now `text-ui-15`, the token for that size.

**The walk arrows were the hugeicons 02 pair.** #10129 moved every directional
arrow in the app to lucide because that shaft is a bezier that bows out rather
than meeting at a point, and after it there is no other use of the pair left in
the tree to match.

Verification: 115 in the find suite, 6178 in the frontend suite, typecheck and
locale parity clean, build within the bundle budget. The font-scale contract is
back to 12 passing. Separately, on the pre-rebase tree: 432/432 in the browser
harness across chromium, firefox and webkit, and 339/339 in the
keyboard-shortcuts harness across the same three on macOS, Windows and Linux,
which is what says `claims` left the other 51 shortcuts alone.

Five regression tests, each A/B'd against a revert of the code it covers.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

Round 20: both items were correct, and one of them is a gap in my own previous fix. Both fixed in 7befd69.

Lazily-compiled regex still threw at scan time. V8 compiles a regex on first use, not in the constructor, so the oversized-pattern guard I added last round caught nothing: the constructor accepted a 199,997 character source and the SyntaxError came out of the first exec instead, back outside the try. Reproduced exactly as reported. matchPattern now runs the pattern once against the empty string before returning it, which forces the compile while it can still be caught and leaves lastIndex at 0 for the real scan. Failure returns null and falls through to the literal scan, as before.

Worth recording that my first attempt at the regression test passed with and without the fix, because the query was longer than the haystack and the length guard returned before a pattern was ever built. The test now uses a query shorter than the index and I confirmed it fails without the fix and passes with it.

Compare composer was not skipped. SharedComposer is rendered from chat-page.tsx into CompareShell, so it never sits under the data-find-skip marker on the thread's own composer, and compare searches counted composer chrome. Marked its root, four lines, same treatment the regular composer already gets. One correction to the report: there is no "Drop files here" string in shared-composer.tsx, so that specific affordance is not what was being counted; the underlying point stands.

Verification: 6179/6179 tests, typecheck, i18n:check:strict, build and bundle:check clean. Biome is unchanged from the head I started on, 2 pre-existing errors in find-in-page.tsx and 2 in shared-composer.tsx. I initially let a biome check --write reorder 415 lines of imports in shared-composer.tsx; that is unrelated churn in a file this PR does not otherwise touch, so I reverted it and reapplied only the 4 lines.

Earlier this round: 432/432 browser checks across chromium, firefox and webkit, and staging CI on danielhanchen#1277.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 7befd69b75

ℹ️ 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".

Alternating whole spellings of the query only reaches text that is all-composed
or all-decomposed. One occurrence can be neither: joining two text nodes joins
two sources, so a composed accent in one and a decomposed one in the next make
a single visible word with a spelling the query cannot be written in.

Measured against the platform, which is the baseline the rest of this file is
held to. Native find matches a mixed occurrence from an all-composed query on
chromium, firefox and webkit; this returned nothing, including for the
two-inline-nodes shape the flatten itself creates.

The pattern is now built per cluster rather than per query, which is also
smaller than what it replaces: the old form wrote the whole query once per
spelling, this writes it once and pays about eight characters for each cluster
that actually has two spellings. That matters here because an oversized pattern
is refused by the engine, which is why matchPattern catches a compile failure at
all.

The preserved-whitespace guard widened with it. "Spelt the way it was typed" can
no longer be a lookup in a list of whole spellings, since a mixed hit is in no
such list; it is now equality after composing, which whitespace flexing does not
survive, so a hit that only flexed a space is still told apart from one that
merely spells a letter differently.

One regression test, A/B'd against a revert of the code it covers: 117 in the
find suite, 6180 in the frontend suite, typecheck and locale parity clean, build
within the bundle budget.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

Status check on the current head, plus one small cleanup in ce5d6b7.

The 38 red checks on this PR are cancelled, not failed. Every run for ba14739 was created at 11:27:30 and stopped at roughly 2m40s, with conclusion cancelled across all of them, including Rust, Tauri and llama.cpp jobs that a frontend-only commit cannot reach. No newer SHA superseded them, so this was an external sweep of the queue rather than anything in the change. gh pr checks renders cancelled as fail, which is what makes the list look alarming. CI has not actually validated this head yet.

The staging failures were a stale snapshot, not a live defect. Staging had been replicated at 4ef77f6, two commits back, and reported edit-reply-keeps-tool-order.test.ts failing with no stub for import "./delete-thread-message". Since that file is nowhere near find in page, I checked it rather than assuming: 21/21 on plain main, and 21/21 again on a real local merge of current main into the current PR head. So the combination that matters is clean, and the failure belongs to the older snapshot. Staging is re-replicated at the current head and running.

Cleanup. matchPattern still wrapped its single pattern source in a one-element array and chose between escaped[0] and a joined alternation that could never be reached. That shape was left over from when I was alternating whole spellings; per-cluster alternation replaced it. Removed the dead branch, four lines. The lazy-compile probe is untouched.

The per-cluster canonical source reads correctly to me and composes properly with what was already there: the length guard and the asTyped check still use whole-query variants, which is right, since a mixed hit is in no such list and is caught by the compose-and-compare instead.

Verification on the current head: 6180/6180 frontend tests, typecheck clean, biome at the 2 pre-existing errors in this feature, pre-push gate PASS.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: ce5d6b7bf6

ℹ️ 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".

The handler sat on the bar, so it only ever saw presses that started inside it.
Clicking a message to read it is the ordinary thing to do with a find bar open,
and from there Escape did not close it.

The second half is what makes this more than an annoyance. `declineToolRequest`
is bare Escape with `skipInTextFields`, and `isTextEntryFocused` only recognises
INPUT, TEXTAREA and contenteditable, so a message body does not shield it. With
a tool confirmation waiting, the unprevented Escape carried on to the registry
and denied the call. Closing a find bar must not be able to answer a tool
request.

Now a window listener for the lifetime of the open bar, in the capture phase so
it runs ahead of the registry's own keydown rather than racing it. Two presses
it deliberately does not take: a modal above the bar backgrounds the scope and
owns Escape, and an open popover, menu or listbox is dismissed by its own
Escape first. Composition is still left to the IME.

The handler on the landmark is gone rather than kept alongside, so there is one
path in and the inside presses cannot be taken twice.

117 in the find suite, 6180 in the frontend suite, typecheck and locale parity
clean, build within budget, and 432/432 in the browser harness across chromium,
firefox and webkit, which is where an event-phase change is actually decided.
The capture assertion was A/B'd: switching the listener to the bubble phase
fails it.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@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: 9f8a50a75b

ℹ️ 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".

*/
function canonicalSource(needle: string, dotted: boolean): string {
let out = "";
for (const [cluster] of needle.normalize("NFD").matchAll(CLUSTER_PATTERN)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve composed Hangul in canonical patterns

For any Hangul query, NFD decomposes a syllable such as 가 into separate Jamo, but CLUSTER_PATTERN does not group those Jamo as one cluster. Normalizing each Jamo back to NFC therefore leaves the regex containing only the decomposed spelling, while the normally composed text in the index no longer matches—even an exact query like findMatches(...text: "가", "가") returns no results. Group Hangul composition sequences or retain the whole composed alternative when constructing this pattern.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct, and severe: every Hangul query returned nothing, an exact one-syllable query included. Reproduced against an index whose text is literally 가나다 hello, where 가, 가나다 and 나다 each gave zero matches.

This PR was merged before I could land the fix, so it is in #10200 along with a bundle-budget fix. Hangul now gets its own branch in CLUSTER_PATTERN, ahead of the general one and covering Jamo Extended-A and Extended-B, so a syllable's leading, vowel and trailing Jamo stay one cluster and compose back. Both spellings reach the other, and accented Latin is unchanged.

@danielhanchen

Copy link
Copy Markdown
Member

Two CI findings from the staging run, one real and one not ours.

The startup bundle budget was genuinely broken by this PR, and is now fixed in afee89e. Staging failed bundle:check at 1567.9 KB against a 1562.5 KB budget. I A/B'd it locally with two clean builds rather than guessing:

  • main alone: 1560.7 KB transfer, within budget with 1.8 KB to spare
  • main + this PR: 1566.2 KB transfer, 3.7 KB over

So main had already eaten almost all the headroom, but the PR is what crossed the line. The cause was the barrel: FIND_SKIP_ATTRIBUTE and FIND_SCOPE_ATTRIBUTE were declared inside find-text-index.ts, so the four ordinary chat and settings components that only mark a subtree were each pulling the whole index module into their chunk. They now live in lib/find-attributes.ts, a module with no imports, re-exported from find-text-index.ts so it stays the single import for anything about the index. Nothing else moved.

Result: 1553.0 KB, within budget with 9.5 KB to spare, which is more headroom than main has on its own. That is a better fix than raising BUDGET, which the check offers as the alternative.

The workflow-trigger lint failure is not from this PR. It is tests/security/test_scan_packages.py::test_context_dependent_unsloth_zoo_findings_are_digest_pinned, an unsloth_zoo digest-pinning assertion. This PR touches two files outside studio/frontend, the frontend CI workflow entry and the Playwright driver, and neither goes near that test or the pinning data. Flagging rather than fixing, since it is out of scope here.

Also worth recording: the red checks on the PR itself were cancelled, not failed. Every run for the previous head started at 11:27:30 and stopped at about 2m40s with conclusion cancelled, including Rust and Tauri jobs a frontend change cannot reach, and no newer SHA superseded them.

Verification on the current head: 6180/6180 frontend tests, typecheck, i18n:check:strict, build and bundle:check all clean, biome at the 2 pre-existing errors in this feature, 432/432 browser checks across chromium, firefox and webkit, pre-push gate PASS.

On the Escape fix: we reached the same conclusion at the same time and my version conflicted with 9f8a50a. Theirs is the better of the two, since it also stands aside for a backgrounded modal and for an open popover, so I dropped mine and kept only the bundle change.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@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: afee89e172

ℹ️ 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".

const spaced = raw
.replace(HARD_SPACE_PATTERN, " ")
.replace(DOTTED_I_PATTERN, "i");
const folded = spaced.toLowerCase();

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 Handle multi-character Unicode case folds

When visible text contains a German sharp s, such as Straße, and the user searches using the conventional uppercase spelling STRASSE, this lowercases the strings to straße and strasse, respectively, so the finder returns no match. Unicode case folding also expands characters such as ß and ligatures, meaning toLowerCase() does not fulfill the function's case-folding contract; add length-changing alternatives during matching while preserving the original DOM offsets.

Useful? React with 👍 / 👎.

Comment on lines +79 to +80
const PORTAL_SURFACE_SELECTOR =
'[data-slot="popover-content"], [role="menu"], [role="listbox"]';

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 Include the floating monitor panels in portal search

When the floating API monitor or resource monitor is open, all of its visible text remains outside the marked scope: __root.tsx mounts ApiMonitorOverlay before the scope, settings-dialog.tsx does the same indirectly for FloatingMonitor, and neither panel emits any selector listed here. Because Cmd/Ctrl+F is nevertheless consumed by the custom finder, users cannot search the visible request log or resource readout; mark these interactive panels as searchable portal surfaces or mount them inside the scope.

Useful? React with 👍 / 👎.

Comment on lines +305 to +308
function clippedAway(style: ResolvedStyle | null): boolean {
return (
style?.clipPath === "inset(50%)" ||
style?.clip === "rect(0px, 0px, 0px, 0px)"

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 Map KaTeX matches to the painted equation

When a Markdown response contains KaTeX, .katex-mathml is clipped with clip: rect(1px, 1px, 1px, 1px), which this exact check does not exclude, while the actually painted .katex-html sibling is discarded because KaTeX marks it aria-hidden="true". The finder therefore indexes the clipped MathML tree and its annotation—often producing duplicate counts—but every resulting highlight is invisible. Fresh evidence beyond the earlier decorative-separator case is KaTeX's concrete split between a clipped searchable mirror and an ARIA-hidden painted tree; special-case that pair so ranges map to the painted equation.

Useful? React with 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member

This merged while I was mid-review, so recording the two findings that landed with it and where they are fixed: #10200.

Hangul search returns nothing at all. NFD takes a syllable apart into leading, vowel and trailing Jamo, none of which are combining marks, so CLUSTER_PATTERN made three clusters out of one syllable and composed none of them back. On main today, against an index whose text is literally 가나다 hello, the queries 가, 가나다 and 나다 each return zero matches. Fixed with a Hangul branch ahead of the general one.

The startup bundle is over budget on main, at 1566.2 KB against 1562.5 KB, which makes that job red for every PR opened against main right now. main before this PR was 1560.7 KB, within budget with 1.8 KB to spare, so the headroom was already almost gone and this feature crossed the line. The comment on FindInPage says a Studio nobody is searching "runs one keydown listener and no engine", which was true at runtime but not in the bundle: both halves were one module, so the index, the observer and the highlights shipped on the first screen anyway. #10200 makes it a real split and gets 3.6 KB back, warms the chunk on idle so the first press does not wait, and raises the budget once with the measurement recorded.

One correction to my earlier comment here: I said moving the attribute constants into their own module fixed the budget, with a "9.5 KB to spare" number. That measurement was taken on this branch alone rather than on the merge with main, so it was not comparable to what CI reports, and the constants split alone did not fix it. The lazy split is what actually moves the number.

Also for the record, the red checks on this PR at merge time were cancelled rather than failed: every run for the head started at 12:11 and stopped at around 2m40s, including Rust and Tauri jobs a frontend change cannot reach.

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.

3 participants