Skip to content

cua: a let-go lease's undo waits for the page's size, and the tab's next lease waits for the undo (browser-cua :186, E13) - #166

Merged
SSFSKIM merged 2 commits into
masterfrom
cua-undo-fence
Oct 26, 2026
Merged

SSFSKIM merged 2 commits into
masterfrom
cua-undo-fence

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

What

When a cua connection lets go of a tab's lease, its undo of the agent's CDP toggles now counts as done only once the page reads its view's size again, if the undo cleared a device-metrics override. The tab's next lease, from this connection or another, starts only after that undo is done. Both waits are bounded. Closes the cause of the 2026-10-24 P4-W row (e2e/browser-cua.spec.ts:186) and the 2026-10-08 E13 row (a late undo overtaking the next lease's toggles).

Cause (measured, not assumed)

The release bound (RESET_BOUND_MS) was never what failed. Throwaway diagnostic runs on Electron 44 / Chromium 152 (2026-10-26; mini run 40311614893, hosted maws-app 40311728565, 40312068417, 40312071190) logged every release and timed the reads:

  • every undo answered in 0–10 ms; the release bound never won;
  • right after Emulation.clearDeviceMetricsOverride's reply, with no detach at all, the page still read the override's 800 (innerWidth and Page.getLayoutMetrics alike) in 8, 1, 5 and 9 of 30 tries. It read the parked 1280 up to 83 ms later;
  • hosted run 40311728565 reproduced :186 itself: undo answered in 1 ms, detach in 3 ms, reattach read 800, then 1280 31 ms later.

So Chromium answers the clear before the view's restored size reaches the page, and waiting for the reply alone is not enough. The browser-side handler does return FallThrough "so that the response is only sent to the client once updates were applied", but the restored view size reaches the page separately.

Fix

  • filter.ts readsViewSize: the page's layout viewport against its view's bounds, at the page's zoom, with a scrollbar's width allowed.
  • connection.ts: the undo polls Page.getLayoutMetrics after a cleared override until the page reads its view's size. It stops if the attachment ends and never sends to a detached tab, since that would re-attach it. The host's detach reply still waits at most RESET_BOUND_MS (1 s). When the bound passes first, a log line names the tab and what is still out (method names or the page size, never params). The undo is registered in TabClaims (undoing/undoOf), and a new attach waits for it. It settles by UNDO_WAIT_MS (2 s) from the letting go, logged when it settles unfinished, so a hung undo cannot wedge later attaches.
  • An attach that waited for a connection that has closed since goes no further (review finding).

Verified with a second diagnostic on top of the fix (40 detach/reattach cycles per run): 0 wrong reads on the mini (40314152517) and on a hosted Mac (maws-app 40314235301). Detaches that waited for the page's size took 22–30 ms on the mini; on the cold hosted box the first three took 59, 118 and 489 ms. No undo line was logged.

Gates (head 5662a4c)

  • Class 1a on the pool: 40316175837 green (static, unit 1–4/4, probes); also green on the first commit d9d321b (40314197527).
  • Mini (--runner macos), e2e:browser-cua 7/7 four times: 40316186184 (with unit:darwin, 17 files, 360 tests), 40316186362, 40316177141, 40316186658.
  • Hosted Macs (Lane: hosted), e2e:browser-cua 7/7 three times: MAWS 40316175010, 40316176207, 40316176658 (maws-app 40316228913, 40316269166, 40316269931). :186 and :493 passed in all three; no undo line was logged.

Review

doperpowers:reviewer-medium returned two P2 findings:

  • An attach waiting behind the undo whose connection closed meanwhile still retried, and could reload a suspended tab for nobody. Fixed in 5662a4c with a reproducing test. A re-review found the fix correct.
  • readsViewSize's fixed 24-DIP scrollbar allowance accepts an override within 24 DIP of the view's size as restored, and makes a page with a custom scrollbar wider than that wait out the bounds (1 s release, logged). Deferred as residue: Page.getLayoutMetrics has no scrollbar-inclusive reading. A main-world innerWidth read can be shadowed by the page ([Replaceable]), and an isolated world's context event would reach the agent's lease. The reviewer agreed the deferral is coherent, noting that a near-size miss weakens the restoration guarantee (a few pixels can cross a responsive breakpoint).

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)

…gain, and the tab's next lease waits for it

browser-cua :186 (the 2026-10-24 P4-W row): Chromium 152 answers Emulation.clearDeviceMetricsOverride before the
view's restored size reaches the page. Measured on the mini and three hosted Macs (2026-10-26, a throwaway diag
branch): the undo answered in 0 to 10 ms, never near RESET_BOUND_MS, while the page (innerWidth and
Page.getLayoutMetrics alike) still read the override's 800 for up to 83 ms after the clear's reply, in 1 to 9 of 30
tries per run; one hosted run reproduced :186 itself with the undo answered in 1 ms. So the release bound was not the
cause, and awaiting the reply is not enough.

- The undo of a cleared override now waits until the page's layout viewport is its view's size (a scrollbar and the
  page's zoom allowed), polling Page.getLayoutMetrics through the lease's attachment, never once it has ended.
- The release still answers the host's detach within RESET_BOUND_MS, and logs the tab and what is still out (method
  names, or the page size; never params) when the bound passes first.
- The tab's next lease, from this connection or another, waits for that undo (TabClaims `undoing`), which settles by
  UNDO_WAIT_MS (2 s) from the letting go, logged when it does unfinished: a hung undo cannot wedge later attaches.
  This also closes the E13 row of 2026-10-08 (an undo answering late after the next lease's toggles).

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
The review's finding: an attach queued behind the previous lease's undo (or behind its own connection's release)
resumed after its connection had closed and went on to load a suspended tab and lease its debugger for nobody,
taking a loaded-tab slot. The retry now refuses at once on a closed connection. The two timed cases gain upper
bounds.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-10-26T11:37:21.143085Z 5662a4c 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.

@SSFSKIM
SSFSKIM merged commit c2af92b into master Oct 26, 2026
SSFSKIM added a commit that referenced this pull request Oct 26, 2026
…ndo, the page's size included; PR #166); gate-offload Decision Log 114 (browser-cua meets the hosting rule); tracker: three browser-cua and E13 rows closed, four logged, :493's row rewritten

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
@SSFSKIM
SSFSKIM deleted the cua-undo-fence branch October 26, 2026 11:52
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