Skip to content

perf(studio): keep hovered-message state still while the thread scrolls - #9068

Closed
danielhanchen wants to merge 51 commits into
mainfrom
perf-hover-suppress
Closed

danielhanchen wants to merge 51 commits into
mainfrom
perf-hover-suppress

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

The problem

Wheel-scrolling a long chat with the cursor resting on the conversation changes the hovered message on every step. The cursor does not move; the content moves under it, so the browser re-hit-tests and assistant-ui's per-message mouseenter / mouseleave fire each time, each calling message.setIsHovering().

Chromium, 300K characters of thread (43,422 DOM nodes, 220 messages), fresh page per arm, medians of 3, identical 20-step gesture, with a capture-phase listener counting boundary events:

arm gesture ms frames > 33 ms long tasks lt ms pointerover distinct targets
nothing 666.3 0 0 0 0 0
cursor left on a message 1562.2 11 11 1170 20 20
cursor on the scroller gutter 664.4 0 0 0 0 0
hover, then move to the gutter 666.6 0 0 0 0 0

Twenty steps, twenty boundary events, twenty distinct targets, costing 895.9 ms of main-thread work between them over the nothing floor, about 45 ms each, landing as 11 long tasks averaging about 106 ms. An earlier version of this line said "about 90 ms each", which conflated the two: 90 ms is milliseconds per long task, not per boundary event. Every arm that generates zero boundary events sits on the gesture's own floor. A prior hover leaves nothing behind, so this is live work and no cleanup after the fact can help.

After

gesture ms frames > 33 ms long tasks
control 1562.2 11 11 / 1170 ms
this branch 666.8 0 0

Against a 666.3 ms nothing floor measured in the same run. Gone, not reduced.

Why not the obvious fix

The first attempt was to take the action bar off React state entirely and reveal it with a CSS group-hover rule. It made things 2.6x worse, and that is the useful part of this PR's evidence, because it is a natural experiment: it keeps all 110 user action bars mounted instead of mounting and unmounting one at a time, adding roughly 440 subscribed buttons and changing nothing else. Same 11 boundary events, contemporaneous control:

gesture ms long tasks ms per event
control (assistant-ui autohide, bars unmounted) 1380.9 11 / 1000 ms 91
CSS group-hover, all bars mounted 3635.1 11 / 3223 ms 293
the same without the two :has() rules 3952.2 11 / 3544 ms 322

So the cost of one boundary event scales with how many subscribed components are mounted in the whole thread, not with the one message whose hover changed. That is the actual defect and it is upstream: the write is per-message, the notification is not. Studio is pinned to @assistant-ui/react 0.12.28, so the notification scoping cannot be fixed from here. This stops the churn instead of making it cheaper.

:has() is not the driver: removing both :has() rules made it marginally worse, inside the run-to-run spread.

How

While the viewport is scrolling, mouseenter and mouseleave aimed at a message are swallowed in the capture phase, before reaching the listener assistant-ui installed on it. When scrolling stops, the message actually under the cursor is resolved once and a single synthetic pair is delivered.

Capture-phase interception is what makes this possible without patching upstream: those two events do not bubble, but they do have a capture phase, so a listener on document sees them first and stopPropagation there prevents the target's own listener from running.

The filter is narrow: only events whose target is a [data-message-id] element, which is exactly what MessagePrimitive.Root renders and attaches to. CSS :hover is engine state rather than an event and is untouched, so buttons keep their hover styling.

What review found: this was five regressions, not one behaviour change

The section that used to sit here claimed a single behaviour change, that the action bar
settles rather than follows during a scroll. That claim was wrong, and the check that
"pinned" it passed on every tree while all five of the following were live. Counting
VISIBLE action bars, chromium, 3 repetitions, merge base against this branch before the
fix:

case merge base before fix after fix
cursor leaves the thread, then it scrolls 0/3 3/3 phantom bar 0/3
touch drag scroll 0/3 3/3 phantom bar 0/3
thread switch, then wheel without moving 0/3 3/3 bar missing 0/3
hovering while a reply streams 0/3 3/3 bar gone for the whole stream 0/3
PageDown with the cursor parked 0/3 3/3 phantom bar 0/3

The merge-base column is the one that decides how these are described. The base does not
do any of them, so this PR introduced all five rather than preserving pre-existing
behaviour.

The fourth is the worst and no reviewer raised it. A streaming reply auto-scrolls on
every token, so scrolling never went quiet and every boundary event was swallowed for
the length of the response: the action bar was unreachable for the whole of a model
answer. That is not the change that was signed off.

The three causes

The hook remembered a pointer position, updated only from a pointermove on the
viewport, so nothing invalidated it when the cursor left for the composer or the sidebar.
It did not check pointerType, so a finger counted as a cursor. And it treated any
scroll as a user gesture.

So: the settled message is now resolved from the [data-message-id]:hover selector,
engine state this hook does not disturb, which is empty when the cursor is outside the
thread and empty under a finger. There is no stored coordinate left to go stale, and the
synthetic events no longer carry clientX / clientY at all, since assistant-ui's
listener reads neither. Non-mouse pointers are ignored. And suppression applies only
while a wheel, touch drag or scrolling key is recent, so a thread that scrolls itself is
left alone.

The win is unchanged

Read the table below with two qualifiers established after it was measured, both of them in the comments on this PR.

First, the merge base cannot run this harness at all: smoke-heavy-thread.html, smoke-heavy-thread-main.tsx and playwright_heavy_thread.py are pure additions on this branch, so every merge-base column here was taken on a base tree with the branch's fixture copied in.

Second, these absolute figures need a slower effective CPU than an idle host of this size provides, and on a fast desktop CPU this change does nothing measurable. A re-run of the hover_last gesture across an Emulation.setCPUThrottlingRate ladder, base against this branch:

rate base ms head ms frames over 33 ms long tasks
1x 667.2 666.6 n/a, both zero n/a, both zero
2x 949.8 699.8 8 against 1 3 against 0
4x 1537.5 733.4 12 against 1 11 against 1

The gutter control arm is flat at every rate on both trees, which is what makes the ladder trustworthy: the throttle changes the price of a boundary event, not the cost of the gesture itself. Read the 1x row as the honest result it is. This helps users on slower machines and does nothing on a fast desktop CPU.

An independent study run at 1x with CPU throttling disabled agrees, and its agreement is not a contradiction of anything above: it puts the 300K scroll cell at -0.1% on chromium and -0.6% on firefox, both inside its 10% trigger, which is exactly the 1x row of the ladder. Note that cell is a scroll with no cursor parked on a message, so it is measuring the gesture floor rather than the boundary-event cost this change removes.

The behavioural result, that the bar stops following whatever message drifts under a stationary cursor, is measured at 1x and does not depend on load at all.

300K chromium, 20-step gesture, median of 3, all three trees on a matched harness:

gesture ms frames > 33 ms long tasks worst frame
merge base 994.5 11 6 113 ms
before the fix 716.6 1 1 92.2 ms
after the fix 716.6 1 1 81 ms

The correction costs nothing measurable.

The gate

tests/studio/hover_semantics_probe.py runs these cases in CI under PROBE_STRICT. It
exits 1 on the tree without the fix and 0 with it; that was checked rather than assumed.
Two defects in the probe itself were fixed before its green was trusted: it wrote results
without an explicit utf-8 encoding, which is the check that already failed CI once on
this branch, and a case that raised carried no failure key, so the gate went green
precisely when the probe stopped working.

The older tests/studio/actionbar_visibility_check.py table is kept below for the
at-rest and on-hover assertions, which do hold. It is not evidence about any of the five
cases above, because it passed while all five were live.

Untested and unresolved, stated rather than guessed

  • The timing above is chromium only. The five behaviour cases were run on chromium; the
    base-versus-head three-way is chromium.
  • The touch case is chromium only. Playwright has no touch emulation for Firefox, so
    there is no Firefox touch row here. That is an absent measurement, not a pass.
  • Playwright's WebKit is a proxy for the webviews Desktop embeds (WKWebView, WebKitGTK),
    not those webviews.
  • QUIET_MS is still 150 and still untuned. No sweep was run.
  • An open review item may revise the headline. It argues that Shiki highlighting
    started by expandTools() overlaps the keystroke and scroll windows in repetitions 2
    and 3, which would contaminate the scroll median this PR quotes. Under investigation;
    the three columns above were all measured the same way, so the comparison is expected
    to survive even if the absolute numbers move, but that is reasoning and not yet a
    measurement.
  • The upstream notification scoping is worth reporting to assistant-ui with the
    natural-experiment numbers above; not done here.

danielhanchen and others added 14 commits August 16, 2026 15:48
…ontent

Users report Studio and Desktop going sluggish after long generations with
code cells and text. That is a statement about content volume, so the new
harness varies characters of thread content rather than message count, and
the fixture carries the mix the report names: prose, large code fences, tool
calls with collapsible output, code-execution result panes, HTML and canvas
artifacts, and inline images.

The primary metrics are DOM-observable and wall-clock, because Unsloth
Desktop is a Tauri webview and not Chromium. PerformanceObserver accepts
type longtask on WebKit 26.5 and Firefox 153 without throwing and then never
fires, so support is read from supportedEntryTypes; CDP counters are recorded
alongside and labelled Chromium-only.
…ne chatter

Re-opening the thread throws away every highlighted fence, so repetitions 2
and 3 were measuring a thread that was still building itself: on Chromium at
300K the scroll gesture read 667ms on the first repetition and 1100ms on the
two after it, and the difference was the re-highlighting.

Firefox 153 emits exactly two scroll-anchoring notices per run at every size.
A warning count that grows with the thread still fails; a constant one does
not, or the harness could never report a Gecko number.
…ng floored metrics

Measured from the end of the gesture, time to settle reads ~50ms at every
size on every engine, because the answer is then three frames, which is the
minimum the loop can return. From the start of the action it is what a user
waits.

A count that goes 0 to 4 has answered the question and counts as
discriminating. A floored timing that is zero or negative at the smallest
size has not: it says the action resolves inside one frame there, which is a
metric with no room to move.
A WebKit page that ran out of memory at 300K on a loaded machine took eight
good measurements down with it. The cell is now recorded as crashed, the run
continues, and the verdict still fails on it.
…cess can

On a macos-14 runner Chromium finished all three sizes in 90 seconds and then
Playwright's WebKit wedged at the smallest size and never came back, which
cost the whole matrix. page.evaluate and browser.new_page have no timeout,
and SIGALRM does not help: the sync API blocks the main thread inside a
greenlet, so the exception lands in the driver and the caller never resumes.
The process boundary is the only bound that works, so the docstring says to
drive one engine per invocation under an external timeout.
A modal Radix menu parks pointer-events: none on <body> while it is open.
pointer-events is inherited, so that single write invalidates computed style
for the whole mounted subtree underneath it. On a long chat thread that
subtree is the thread, so opening a menu costs a full-document style
recalculation that scales with the thread rather than with the menu.

Ten menus move to modal={false}. Dialogs, alert dialogs and sheets keep
modal semantics, which are correct and wanted there.

Dropping the shield also drops the click it used to absorb, so a single
click on a control beside an open menu would both dismiss the menu and fire
that control. In the assistant action bar the neighbours are Refresh and an
unconfirmed Delete message. swallowDismissingClick restores just the
absorbed click, so dismissal still costs exactly one click.

Message action menu, chromium, 25K to 300K characters, medians of 3:
open+close 345.2 -> 3291 ms becomes 62.2 -> 73.8 ms, and the harness growth
verdict goes from 10.44x DISCRIMINATES to flat.
Wheel-scrolling a long chat with the cursor resting on the conversation, which
is how a long chat is read, changes the hovered message on every step: the cursor
does not move but the content moves under it, so the browser re-hit-tests and
assistant-ui's per-message mouseenter/mouseleave fire each time.

Measured on chromium at 300K characters of thread (43,422 DOM nodes, 220
messages), fresh page per arm, medians of 3. A 20-step gesture with the cursor on
a message produces exactly 20 pointerover events against 20 distinct targets and
costs 1562.2 ms with 11 long tasks totalling 1170 ms. The same gesture with the
cursor over the scroller gutter, where the element underneath never changes,
costs 664.4 ms with no long tasks, which is the gesture's own 20-step floor.

This swallows those boundary events in the capture phase while the viewport is
scrolling, then resolves the message actually under the cursor once and delivers
a single synthetic pair when scrolling stops. Capture-phase interception is what
makes it possible without patching upstream: mouseenter and mouseleave do not
bubble but do have a capture phase, so a listener on document sees them first.

After: 666.8 ms, 0 frames over 33 ms, 0 long tasks, against a 666.3 ms floor on
the same run. The regression is gone rather than reduced.

The filter is narrow: only events targeting a [data-message-id] element, which is
exactly what MessagePrimitive.Root attaches to. CSS :hover is engine state rather
than an event and is untouched, so buttons keep their hover styling.

The one behaviour change is that during an active scroll the action bar does not
follow the cursor between messages; it settles onto the correct one when scrolling
stops. tests/studio/actionbar_visibility_check.py pins both that and the unchanged
cases across chromium, webkit and firefox: hidden at rest, exactly one bar shown
on hover, hidden again after, and after a scroll the pointer did not participate
in, exactly one bar shown and on the message under the pointer.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member Author

Off-chromium timing, and it narrows what this PR fixes

The description measured chromium only. Here are all three, 300K characters, fresh page per arm, medians of 3, with the boundary-event counter running.

engine pointerover per 20-step gesture before after
chromium 20, 20, 20 1562.2 ms, 11 frames > 33 ms, 11 long tasks / 1170 ms 666.8 ms, 0, 0
firefox 3, 1, 1 850.0 ms, 1 frame > 33 ms, worst frame 201 ms 667.0 ms, 0, worst 18 ms
webkit 2, 0, 0 644.0 ms, 0 frames > 33 ms 643.0 ms, 0

The boundary counts predict the timings, which is the strongest confirmation of the mechanism I have. Whether an engine re-hit-tests hover while content moves under a stationary cursor is an engine decision and the three do not agree. Chromium re-hit-tests on every scroll step. WebKit essentially does not, so there is no regression on WebKit to fix and the two columns are the same number. Firefox is in between: it fires almost no boundary events, but the one it does fire is expensive, worst frame 201 ms against 18 ms after.

What that means for the claim

  • Chromium surfaces: this is the fix. Studio in Chrome or Edge, and Unsloth Desktop on Windows via WebView2.
  • Firefox: a real but smaller win, 850.0 to 667.0 ms, and it removes the one dropped frame.
  • Desktop on macOS and Linux (WKWebView and WebKitGTK): a no-op, not a fix, because the problem does not appear to occur there.

So this should not be described to users as fixing scroll on the desktop app generally. It fixes it on Windows.

One caveat I do not want to paper over: Playwright's WebKit is a proxy for WKWebView and WebKitGTK, not the webview Desktop actually embeds, and Desktop Linux additionally forces the software renderer via WEBKIT_DMABUF_RENDERER_FORCE_SHM, which this harness does not replicate. "No regression on the proxy" is good evidence, not a guarantee. Since the cost here is main-thread JavaScript rather than paint, the renderer difference should not matter, but that is reasoning and not a measurement.

A check worth naming

The chromium boundary count stays at 20 in both columns. That is intended and it is the check that this hook does what it says: the counter watches pointerover, which is the engine's hit-test churn, while the hook swallows mouseenter / mouseleave, which is what assistant-ui listens to. The hook does not stop the engine hit-testing, it stops the result reaching React. A count that dropped would have meant it was doing something other than what it claims.

Numbers are in the file comment as well, so they survive the PR.

Gaps, unchanged and deliberate

QUIET_MS = 150 is still untuned; no sweep was run. Touch and trackpad momentum scrolling remain out of scope. delete and reopen carry-over remain unquantified. I would rather these stay written down than get filled in with a guess.

Whether the engine re-hit-tests hover while content moves under a stationary
cursor is an engine decision and the three do not agree. Chromium fires 20
boundary events over the 20-step gesture, firefox 1 to 3, webkit 0 to 2, and the
timings follow: 1562.2 to 666.8 ms on chromium, 850.0 to 667.0 on firefox, and
644.0 to 643.0 on webkit, where there was no regression to fix.

So this is load-bearing for Chromium surfaces including Desktop on Windows via
WebView2, and a no-op rather than a fix for Desktop on macOS and Linux. Playwright's
WebKit is a proxy for WKWebView and WebKitGTK rather than the embedded webview, so
that is evidence and not a guarantee.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen and others added 5 commits August 17, 2026 08:26
A guard armed from Radix's onPointerDownOutside and disarmed by a fixed 300 ms
timer misses three of the four ways a person dismisses a menu. Measured on the
heavy-thread smoke page by pressing the adjacent unconfirmed Delete message
button with the action bar menu open:

  gesture                   pre-PR    before    after
  quick press and release   safe      safe      safe
  press held 600 ms         safe      DELETED   safe
  press, busy main thread    safe      DELETED   safe
  touch tap                 safe      DELETED   safe

held reproduces on chromium, webkit and firefox; touch on chromium and webkit
(Playwright Firefox has no touch support). The pre-PR column is the same tree
with the action bar menu back on the body modal layer.

Two causes. The timer is gone before the browser synthesises click on release,
and a press can be held for as long as the user likes. And on touch,
usePointerDownOutside in react-dismissable-layer 1.1.11 defers to the resulting
click and listens on ownerDocument in the bubble phase, so React's root
container has already run the control's onClick before Radix calls us; a guard
armed there cannot swallow the click that armed it.

So watch pointerdown directly, on document, in the capture phase, which is
ahead of both. Arm state is module level because the dismissing pointerdown
unmounts the content synchronously, so anything torn down in the effect cleanup
would be gone before the click arrives. Disarmed by that click, a pointercancel,
a keydown, or the next gesture, never by a deadline.

Adds the four dismissal variants plus two over-swallow checks (a menu item
selection and an unrelated second click must still land) as a CI gate.
Three defects in the harness that produced this PR's numbers, all of which
make the table claim more than it measured.

Re-seed between repetitions. The delete action removes the last assistant
message from the runtime and the re-open path deliberately preserves that
runtime, so repetition N measured a thread N-1 messages shorter than the one
the pre-action census passed, and a different content mix, because the message
it takes is a different kind each time. Measured on chromium: 300K went
220 to 219 to 218 messages and 35086 to 34438 highlighted tokens over the
default three repetitions; 25K, where one cycle is the whole fixture, went
20 to 19 to 18 messages and 3216 to 2520 tokens, losing 22 percent of the
highlighting by repetition two and 2 of its 3 images by repetition three. The
harness's own expectedPerCycle image gate would have failed on repetition
three at both sizes, but it is only ever evaluated once, before repetition one.

Re-seeding is not free and the effect is larger than the shrinkage it fixes:
the 300K menu open and close median moves from 71.9 ms to 352.0 ms, because
without it repetitions two and three open a menu on a thread that has already
been through one. Both are honest numbers; only the second is the one the
table says it is reporting.

Stub the fork-count endpoint as {"count":0}. getForkCount reads data.count,
so {} set the count to undefined, and undefined <= 0 is false, so the badge
rendered a pill and a git-branch icon on every message with a mounted action
bar. 110 of them at 300K, which real Studio never shows for an unforked
message. Timing effect is inside the noise floor; the reason to fix it is that
the harness page was not showing the UI it claims to.

Count the repetitions that produced no timing. median() drops None, so an
action that timed out in one repetition was silently dropped and the summary
still reported a median of three. harness_failures only ever read the summary,
so that passed. Record dropped_repetitions and fail on it, and fail when the
per-repetition census disagrees about how many messages were on screen.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…dismissal

Two defects in the guard as first written, both found by attacking it rather
than by re-running the case it already passed.

The armed window had no upper bound. Plenty of dismissing gestures never
become a click: measured on chromium, a right click outside an open menu
raises contextmenu instead, and the swallower survived to eat the user's next
real left click 900 ms later. That is worse than the fixed deadline it
replaced, because a bounded window that occasionally misses is at least
attributable, while an unbounded one swallows a click with nothing to
associate it with. The window now opens at pointerup rather than at
pointerdown, so a press held for a minute is still covered and a gesture that
produces no click is still bounded, plus a drop on pointercancel, keydown and
window blur.

And on touch the guard denied Radix its own dismissal. Radix defers touch
dismissal to a once click listener on document in the bubble phase, which the
capture-phase swallow is exactly what stops. A tap on a focusable control
still closed the menu, via useFocusOutside, which is why the first version
looked correct; a tap on plain thread background left the menu open on
chromium and webkit. Radix's deferred handler takes no arguments and ignores
the click entirely, so re-raising a bare non-bubbling click at document
releases it.

The probe now covers nine cases and asserts the menu actually closed, which it
previously recorded and ignored. Its neutral spot is grid-searched for a
genuinely non-focusable element and it fails rather than falling back if none
exists: the first run of the touch case silently landed on a button and
reported a pass for a case it had not tested.

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

const target = event.target;
if (!(target instanceof Element)) return;
if (target.closest(MENU_SURFACE)) return;
arm(event.pointerType === "touch");

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 Stop the dismissing pointerdown before it reaches controls

When an open converted menu is dismissed by pressing a control that acts on pointerdown—notably another adjacent Radix dropdown trigger—the underlying control still acts before the later click is swallowed, so one press can close the current menu and open the other instead of merely dismissing. Fresh evidence in the final tree is that this capture handler only calls arm(...); it never cancels or redirects the pointerdown, so adding the listener did not provide the interception discussed in the earlier review thread.

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 observation about the code is accurate and I am declining the remedy, so this is a thumbs down rather than a fix. This is the same point as the earlier thread on this file, which I agreed with in part and answered there; the part I did not take is this one, and re-reading the final tree has not changed it.

You are right that the capture handler only calls arm(...) and never cancels the pointerdown. That is deliberate, for a reason that is load-bearing rather than an oversight.

Cancelling it would break dismissal. Radix's outside handler is a bubble-phase listener on document. Calling stopPropagation from a capture-phase listener on that same node stops the event before it reaches the target and it never bubbles back, so Radix's listener never runs and the menu does not close. There is no phase at which the event can be denied to a descendant control and still delivered to document on the way back up, because the control is a descendant of document. The interception you are asking for and the dismissal are the same event.

And the residue is not a defect. I checked every onPointerDown in the frontend: 26, all of them either drag starts (window resize handles, the floating monitor, the panel resize handle, the card carousel) or bare stopPropagation guards. Nothing destructive runs on pointerdown. "Delete message" and "Refresh" are React onClick, which the capture-phase swallow covers, and that is measured on all three engines including a held press and a touch tap.

The specific outcome you name, one press closing this menu and opening an adjacent one, is not a broken state either. Measured: open the action bar More menu, then press the composer tools trigger, and the open menu count is 1 on the merge base, on head, and after the fix. Opening the second still closes the first. That is ordinary menubar behaviour, and it is not worth breaking dismissal to prevent.

The half of your earlier item that WAS a real bug, that the guard had to be armed at the pointerdown rather than at the click for touch to be fixable at all, is exactly what this handler exists to do, and it is why the touch click-through no longer deletes a message.

pre-commit-ci Bot and others added 2 commits August 17, 2026 09:32
…and keep the settings preset menu modal on mobile

Two more breaks, both found by attacking the change rather than re-running what
already passed.

A right click outside an open menu raises contextmenu and never a click, so
arming for it could only ever eat the user's next left click. Measured on
chromium, webkit and firefox: the click after a right-click dismissal was
suppressed. The release-anchored bound added in the previous commit shortened
that from forever to 500 ms, which is a smaller bug and still a bug; not
arming for a gesture that cannot produce a click is the answer. The bound
stays, for the cases nobody has enumerated.

And the chat settings preset menu could not be opened at all below the mobile
breakpoint, where the panel is a Sheet. Its trigger is asChild over a div that
contains an input, so with no modal shield the release-click of the opening
press lands on that input, focus leaves the portalled content, and a non-modal
Radix layer dismisses on focus-outside. Traced on chromium at 420x900 with a
MutationObserver and the pointer never moving: the menu mounted at t=33 ms and
was gone by t=208 ms. It is modal there again. That costs nothing, because the
Sheet has already parked pointer-events:none on the body and there is no
second invalidation to save; on desktop the panel renders inline and the menu
stays non-modal.

The probe's right-click case now fires inside the grace window rather than
after it. The version that waited it out passed on a tree that was still
eating the click, because it only asked whether a bound existed and not
whether the guard should have armed at all.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 18, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 64fc622c94

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

# Conflicts:
#	studio/frontend/src/components/assistant-ui/thread.tsx
@danielhanchen

Copy link
Copy Markdown
Member Author

Resolved against main tip after #8992 landed. Head e8d3f25a2. Same single conflict as #9051, in thread.tsx: #8992's modal={false} on the action bar carried a rationale comment that an earlier comment pass had removed here. I kept main's comment. No assertion from either side was dropped.

Two things were worth checking after this particular merge rather than assuming, because #8992 lands directly underneath this PR's subject matter.

The action-bar autohide did not make these assertions vacuous

#8992 added autohide="not-last", which unmounts every action bar but the newest reply's. Since this PR is entirely about when a hovered bar appears and disappears, a green probe after the merge could easily have meant "there is no bar to get wrong" rather than "the suppression works".

It does not. On the merged tree, ablating the suppression itself, replacing if (!scrolling || event.timeStamp - lastMouseMoveAt < MOVING_MS) with if (true), turns h7_pen_drift_during_scroll red in both repetitions, exit 1. The failure is exactly the behaviour this PR removes: bars_during_gesture goes from a steady [1,1,1,...] to [1,0,0,0,0,0,0,0,0,1,0,1,0,1] and the owner drifts from the hovered message to the one being scrolled past. Restoring it turns the probe green again, exit 0, all cases.

So the assertions still mean what they meant. Full probe on the merged tree with PROBE_STRICT=1: exit 0.

No DOM-node-count assertion to re-baseline

#8992's Shift+Tab end sentinel costs one node per assistant message, which would silently invalidate any hard-coded DOM total. This branch does not assert on one. I checked rather than adjusting a number to make something pass.

Verified on the merged tree

  • Frontend suite: 3778 tests, 3777 passed. The single failure is the pre-existing main-side mmproj-fallback module resolution error, open as Studio: make the mmproj fallback import resolvable under node's type stripping #9181 and reproducible on a clean checkout of main.
  • test_hover_probe_contract.py and test_playwright_suites_run_in_ci.py: 18 passed.
  • Stray-file audit: no generated artefacts in this branch or in any merge commit on it.

One thing from resolving this that is not this PR's but is worth knowing here, since this branch sits on the same action bar: on unmodified main, ten dismissal gestures now delete a message without confirmation, because #8992 took the modal shield off the action-bar menu and nothing replaced it. Measured, with the pre-#8992 commit as a zero-deletion control. Raised as #9195; the guard that fixes it is in #9051.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: e8d3f25a25

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

A mouse press that dismisses the menu over a focusable control focuses that
control, and the press can be held. Enter on a focused button is an activation,
so the browser generates a click for it right then, before the release click the
guard exists to eat. There is one arm and `swallowClick` spent it on whichever
click arrived first, so the keyboard one consumed it and the release landed on a
live control. With the menu open and the press on the adjacent unconfirmed
"Delete message" button, that deletes the message.

Measured on the heavy-thread smoke page, press and hold Delete, press Enter while
still holding, release. The two clicks the document sees, both `isTrusted`, and
what reached the button:

    engine     keyboard click      release click       reached Delete   messages
    chromium   detail 0, id -1     detail 1, id 1      YES              10 -> 9
    firefox    detail 0, id -1     detail 1, id 0      YES              10 -> 9
    webkit     detail 0, id -1     detail 1, id 1      YES              10 -> 9

`document.activeElement` after the press is the Delete button on all three, so
the menu's own close does not return focus to its trigger and the sequence is
reachable everywhere rather than being a chromium quirk.

The fix swallows a keyboard-generated click while the dismissing pointer is
still down, but does not consume the arm, so the release is still caught.
`detail` is the discriminator rather than `pointerId`: it lives on `UIEvent` and
so is defined for a click on every engine, and firefox numbers the release
pointer 0, which a check for a missing or negative id would misread.

`held_enter` covers it in the dismiss guard probe, which studio-frontend-ci
already runs on chromium. It is red on this tree without the fix on all three
engines and green with it, and the other eleven cases are unchanged: the
selection click, the second click, and the click after a right click or a drag
off all still land.

held_modifier is next to it and does not overlap. Shift produces no click at
all, so it only asks whether the guard disarms on keydown, which it already
does not.
The comment said each boundary crossing costs about 90ms. It does not. 90ms is
1000ms of long tasks divided by 11 long tasks, which is milliseconds per long
task, relabelled as milliseconds per event. The per-event figure is the arm
difference over the event count, (1380.9 - 664.4) / 20, so about 36ms.

Both numbers are in the comment now, each labelled as what it measures. Nothing
else changes: the 716.5ms the 20 crossings cost between them is what the hook
removes and that total was never in question.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 18, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 18, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 18, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 18, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

Two limits on the h7_pen_drift_during_scroll case, and a correction to what I wrote in its commit message

Re-proven against the current head rather than the merge it was written on, with the mutation made in its own worktree and the probe file checksummed before and after every run:

a2_head   chromium  11 reps  pen=cdp   break_true  0/11  EXIT=0
a2_mut    chromium  11 reps  pen=cdp   break_true 11/11  EXIT=1

The mutation is one line, if (event.pointerType !== "mouse") return; removed from the hook. The mechanism is visible in the output rather than inferred: on head owners_during_gesture stays the same message id for all 14 samples, and on the mutant it walks to the scroll target and strangers_during_gesture becomes non-empty. Zero skipped, zero inconclusive. Three other mutants (all guards reverted, remembered pointer coords, any scroll counted as a gesture) leave the case false, so it is specific to the pointerType guard rather than tracking "some guard is missing".

Limit one: this is a chromium-surface assertion. Firefox and Playwright's WebKit have no CDP pen endpoint, so the case falls back to a synthetic event, and it does not merely pass on both trees there, it fails to discriminate at all:

firefox  head pen={'synthetic'}  0/2      webkit  head pen={'synthetic'}  0/2
firefox  mut  pen={'synthetic'}  0/2      webkit  mut  pen={'synthetic'}  0/2

On those two engines h7 is a code-path smoke test, not a guard assertion. Treat it as chromium-only coverage.

Limit two, and this is a correction to my own commit message. I wrote that Playwright's WebKit is a proxy for WKWebView and WebKitGTK rather than Safari. The WebKitGTK half is exact, and the bundle says so itself:

WebKit Platform: GTK
Builder OS: Ubuntu 24.04.4 LTS

The WKWebView half is not supported by anything run here. WKWebView is Apple's Cocoa-port embedding API, and nothing on a Linux host exercises it, so that claim would only hold for a macOS run. Read every WebKit row on this PR as WebKitGTK and WPE, and as saying nothing about WKWebView or about Safari.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 18, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 18, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 18, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

danielhanchen commented Aug 19, 2026 •

Copy link
Copy Markdown
Member Author

The hover suppression in use-hover-quiet-during-scroll.ts plus the thread.tsx wiring looks self-contained, but this branch also reworks the menu dismiss guard in lib/menu-dismiss.ts and six chat components, so could you split that out and keep this PR to the hover path?

@danielhanchen

Copy link
Copy Markdown
Member Author

Closing this. It has conflicted with main since 19 August and was never measured under the current protocol, so there is no evidence to justify rebasing it.

Keeping hovered-message state still is still a sensible idea. If it comes back it should come back with a 100K measurement against a concurrent null control.

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