Skip to content

parity: input/coordinates observes the page before its input, fixing the double-click cell's race (refs #168) - #436

Merged
SSFSKIM merged 2 commits into
mainfrom
fix/168-parity-focus
Nov 20, 2026
Merged

SSFSKIM merged 2 commits into
mainfrom
fix/168-parity-focus

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Refs #168. This doesn't close it: step 3, CI-opt's five-run batch and turning parity-browser on for PRs, follows the merge.

What changes (tests and fixture only, no shipped behaviour, no version bump)

api/browser-cuaapi/double-click failed 2 in 20 on both hosts. In CI-opt's run 44681961859, the type cell found the page with focus on body, the document reporting focused: false, and the field empty. The double and drag cells after it then ran out their selector deadlines.

Cause: a harness race.

  • The cell clicked right after goto, which returns at load and can come before the first contentful paint.
  • Until that paint, Chromium's renderer defers commits and drops every input event except pointer moves, yet still acknowledges the event, so CDP reports success. This is WidgetInputHandlerManager::DispatchEvent, whose comment reads: "We don't want users interacting with stuff they can't see".
  • So the click was lost and the keys went to body.
  • END then scrolled the document to its bottom. That is why the later cells' viewport points missed: their failures came only from the type cell.

Fix (test/browser-parity/scenarios/input/coordinates.mjs, test/browser-parity/fixture/corpus-pages.mjs):

  • Observe first. Each cell starts with tab.screenshot(), the observation a model makes before acting, which also makes a background tab (created active: false) render. It then waits, bounded at 5 s, for html[data-rendered="yes"], which the page sets in its second animation frame, after its first frame has painted.
  • No retries, no loosened assertions. The type cell checks that the input has focus before typing, and that it still has focus after the type acknowledgement.
  • Fixture attributes for state. Focus is read from a fixture attribute (html[data-input-focus]), not through performance or activeElement. This keeps the scenario usable on the vendor's read-only evaluator.
  • Independent cells. end-key sets its own focus and text with locator.fill, so it doesn't depend on what the type cell left behind.
  • Diagnostics. Failures print the paint marker, focus, value, pointer and scroll position in the public log.

Evidence

  • parity-browser at 9f60aa47: three consecutive greens, one at a time: 44692632997, 44694126969, 44695890738. The earlier head 98a09e0b was also three greens.
  • plugin and test: green, 44697469361.
  • Unit tests: coordinates-type.test.mjs has 7 cases, with a stand-in page that throws on performance and passes frozen elements, a double that blurs after typing, and the paint-gated cases. All 7 fail against the old scenario.

Limits

  • The standalone corpus has not been run on the vendor's browser service, because that needs the Mac mini. The scenario avoids what the vendor's read-only evaluator forbids, but that is verified only by the frozen-wrapper double.
  • input/dom's type cell could hit the same race in principle. It runs after get_visible_dom and has never failed, so it is left as it is.
  • Squash subject: commit 9f60aa47 reuses 98a09e0b's message by mistake. The intended subject is "parity: input/coordinates observes the page before its input and reads it through fixture attributes (refs parity-browser hosted gate: fix the two racy parity cells (waitfor deadline race, drag ended wait), then run it on PRs #168)".

Review

  • reviewer-low on 98a09e0b: incorrect.
    • P1: the first-contentful-paint signal depended on presentation feedback, which a background tab may never give.
    • P2: the vendor evaluator has no performance and its element wrappers are read-only.
    • P2: focus was not asserted after typing.
  • All three are fixed in 9f60aa47.

Sminos-Session: cursor235#b93055dd (cua on macbook)

…start from their own state (refs #168)

Chrome's renderer drops every input event but a pointer move while it defers
commits for paint holding, before the page's first contentful paint
(WidgetInputHandlerManager::DispatchEvent), and the dropped click still
answers ok. Run 44681961859's double-click case shows that signature: the
type cell's click left the focus on body and the field empty, then end-key's
END on body scrolled the page to its bottom (the scroll cell read scrollY
1970), so double and drag clicked scrolled-away targets.

The input page now marks html[data-first-contentful-paint] from a paint
observer. Every cell waits for it (5 s, bounded) and scrolls to the top;
end-key focuses the input holding 'pointer' itself; the type cell checks its
click focused the input before typing. Each failure reports whether the page
had painted, the focus, the value, the pointer's last point, the element at
the click's point and scrollY.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…start from their own state (refs #168)

Chrome's renderer drops every input event but a pointer move while it defers
commits for paint holding, before the page's first contentful paint
(WidgetInputHandlerManager::DispatchEvent), and the dropped click still
answers ok. Run 44681961859's double-click case shows that signature: the
type cell's click left the focus on body and the field empty, then end-key's
END on body scrolled the page to its bottom (the scroll cell read scrollY
1970), so double and drag clicked scrolled-away targets.

The input page now marks html[data-first-contentful-paint] from a paint
observer. Every cell waits for it (5 s, bounded) and scrolls to the top;
end-key focuses the input holding 'pointer' itself; the type cell checks its
click focused the input before typing. Each failure reports whether the page
had painted, the focus, the value, the pointer's last point, the element at
the click's point and scrollY.

Sminos-Session: cursor235#b93055dd (cua on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T08:06:24.466675Z 9f60aa4 PR opened
ℹ️ 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant