Skip to content

macOS engine: a Chromium app is acted on only once its accessibility is ready, and cua holds it on for 5 minutes idle (#366) - #399

Merged
SSFSKIM merged 12 commits into
mainfrom
fix/366-chromium-ax-ready
Nov 17, 2026
Merged

SSFSKIM merged 12 commits into
mainfrom
fix/366-chromium-ax-ready

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 17, 2026

Copy link
Copy Markdown
Owner

What changes

On macOS, the first action on a background Chromium-based app (Chrome, Chrome for Testing, Electron apps) could reach nothing.

  • What went wrong: cua turns on the app's accessibility (AXManualAccessibility in Electron, AXEnhancedUserInterface in Chrome) when it first observes the app. Chromium then rebuilds its tree in complete accessibility mode after a debounce of about 2 s, and every write restarts the debounce.
  • What main did: an action sent before then got one of two answers. In Electron it answered success while no handler ran. In Chrome it was refused with backgroundClickRefused, because the cached element still carried basic mode's action list.
  • Placeholder: set_value could write the value and then answer elementNoLongerValid, because the field's placeholder only appears in complete mode and the identity re-check compares it (Engine: element identity compares the placeholder, so a field whose placeholder changes reads as a different element #398).

Now, in native/engine:

  • The observation waits until 2.5 s have passed since cua's last accessibility write to that app, before it records element tokens (awaitObservationReadiness, Skyshot.swift; ruling 1ea561bc:772). So the tokens it hands out already belong to complete mode.
  • Element actions wait too, as a backstop (waitForChromiumReadiness, ChromiumReadiness.swift; Methods.swift's action gate). An entry recorded before readiness is first re-read from its own live handle, pinned to that handle (Lineage.resolve(readiness:), refreshFromHandle). It never falls back to an identity search that could adopt another element.
  • set_value answers a new valueUnconfirmed when the value was written and accepted but the field can't be found again afterwards, in place of elementNoLongerValid (ValueSetting.swift).
  • The idle grace: cua's enablement is now released after 5 minutes idle instead of 30 s (Enablement.swift, ruling 775). end_task and the engine stop still release at once. Without this, every observation after a 30 s pause paid the 2.5 s again: after a real release, the attribute reads false and cua must write it again.

agent-cursor.md (and its two copies) says the first observation of a Chromium-based app in each task, and again after 5 minutes idle, may take up to about 2.5 s longer. It also documents valueUnconfirmed. Unchanged: non-Chromium apps, and any observation or action once the window has passed.

Evidence

The tables are in docs/evidence/2026-11-17-chromium-ax-ready/README.md. Every cell is judged by the fixture page's own handler count and its DOM/React value, never by AX or by an RPC answer.

The full qualification, 44080159451 (fix 22f4d30 against main c7eee72; default Electron, parity Electron and CfT):

  • The fix delivered every executed action exactly once: 299/299 valid launches.
  • Main's cold group delivered 0/60: 40 Electron false successes and 20 CfT refusals.
  • valueUnconfirmed 0, wrong-target 0.
cold cpu:2 load set_value
fix delivery 60/60 60/60 29/29 (+1 recovered, below)
observation wait, p50 (ms) 2518–2530 2529–2555 2515–2520
worst overshoot past 2.5 s 148 ms (CfT) 77 ms 76 ms
  • The action gate after a full observation waits 0.003–0.04 ms.
  • Early tokens (a deadline-cut observation, then an action): 30/30 delivered to the same target. The action waited out the rest of the window, 2.16–2.34 s.
  • After a real 30 s release (on 22f4d30), the next observation read false 30/30, wrote again and waited about 2.53 s. That cost led to the 5-minute grace.

Raises, the matched supplement, 44085341355 (green, 80/80 launches):

  • Default Electron's route-3 click raises the window briefly on both heads equally: warm 10/10 against 10/10, post-hold 10/10 against 10/10, p50 18–27 ms, max under 38 ms.
  • None activated the app, outlived the hold or stayed raised.
  • Parity Electron and CfT: 0 on both heads.
  • The fix adds neither incidence nor a new kind.

The 5-minute grace, 44086986242 (head 3bb77a9, 9 launches):

  • After 36 s idle the enablement stays owned, nothing is written, and the wait is 0.004–0.028 ms.
  • After end_task the new task reads false, writes again, waits about 2.5 s and delivers.
  • The cold path delivers.
  • 27/27 actions delivered.

Two red runs, both in the test kit

  • The full run is red on one setup-invalid launch. The kit's direct socket connect raced the engine's listen (ECONNREFUSED), so that launch made no observation and no action. cua's own client retries connect-and-ping until its deadline (src/services/engine/client.mjs, attempt/establish), so production can't hit this. Kit 8cda5b9 bounds the kit's connect, and recovery run 44087018258 measured the missing cell: delivered once, wait 2574 ms. The invalid attempt stays on record.
  • The lifecycle smoke is red on the result reader. It compared the engine's fractional-millisecond timestamps with the test's whole-millisecond request bounds, so four auxiliary checks failed by 0.15–0.54 ms. Reader 9632bef compares them at the shared resolution. The retained artifacts replay as 9/9 complete and 9/9 passing, without a GUI rerun.

Limits

Verification

  • swift test (native/engine), after merging main 4a3e26e: 1,235 tests, 0 failures, 1 skipped (pre-existing).
  • Node: docs-oracle, core-documentation, repl-parity inventory and package-contents, 31/31. agent-cursor.md and its copies are byte-identical.
  • Mutation checks: 13/13 on the readiness gate and resolver, and 2/2 on the grace constant (30 000 and 299 000).
  • Review: doperpowers:reviewer-medium over six rounds. Rounds 1, 2 and 4 found the stale timestamp after a wake, the unbounded deadline and the identity fallback adopting another handle; all three were fixed. Round 5 (22f4d30) and round 6 on the 5-minute grace (22f4d30..3bb77a9) came back correct.
  • ci-gate on 020e45b, gates plugin, test and engine-swift: GREEN, https://github.com/SSFSKIM/cua/actions/runs/44092049344. The sandbox and browser-parity gates were not run: the change touches neither the sandbox nor the browser extension path.

Plugin 0.28.6.

Closes #366

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

…he enablement write (refs #366)

A first AX element action into Electron or Chrome answered success and ran no
handler when it landed under about 2.25 s after the engine's enablement write
(the spike's runs 44032504512 and 44052940748): every AXManualAccessibility
write restarts Electron's debounce to its complete mode, and nothing signals
the mode's arrival.

Per ruling 766, execute's prologue now waits, for click, set_value,
select_text, perform_secondary_action and scroll on an app whose page engine
is .chromium, for what remains of chromiumActionWindowMs (2.5 s) since the
engine's last accepted enablement write of the process
(WebAccessibility.lastEnablementWrite). Past the window, or with no write,
it waits 0. The wait runs after the input's own enablement step and the
holds' steps and before the method takes any hold; a focus hold the
connection still keeps on the app ends first, and a press inside a recorded
menu's held span (AppKit's menu, not the renderer) does not wait. The answer
is unchanged: a dispatch stays a dispatch.

The engine and its web enablement take an injectable monotonic clock and
sleeper. An enablement that reads true is not rewritten (unchanged: owned
attributes are neither read nor written, another client's true is left
alone), so it never restarts the window; the tests pin that, Chrome's
-25208 write counting, the hold rules and the gated method set.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…ay wait up to 2.5 s (refs #366)

agent-cursor.md's second paragraph, which describes the element actions cua
takes in a background web page, gains one closing sentence. The docs oracle
and the core-documentation test carry it byte for byte; PROVENANCE.md and the
surface inventory's new "Table 3 addition (2026-11-17, #366)" record where it
came from.

The native engine spec's Decision Log gains the #366 entry (ruling 766): the
gate and its window, no hold through the wait (a focus hold ends first, an
in-menu press keeps its span and does not wait), read before write as it
already stood, where the first enablement write lives and why it is not
moved ahead of the open settle, "accepted" and "owned" as read here, and the
per-method over-approximation.

Sminos-Session: cursor235#b93055dd (cua on macbook)
… deadline, and scroll waits only with an element (refs #366)

The review of c7eee72..d94039e found two P2s, both accepted:

- A stale window after waking. A write over a value that could not be read
  is not owned, so another connection could write true again while the
  request slept, and the request woke inside the new window. The wait now
  re-reads lastEnablementWrite after every sleep and waits out what remains,
  until none does, before any hold or dispatch.
- The deadline. The wait ignored it, so a request could dispatch after its
  client had timed out. A window that would end at or past the remaining
  deadline is now refused before the sleep as timeoutReached, with the input
  meta and nothing dispatched; the holds stay as they were.

Scope: a scroll at a point or the window's centre only posts a wheel and reads
back, and its #328 bar write never targets a web page's bar, so it no longer
waits. A scroll that names an element still waits, because its
AXScrollToVisible goes to the page first. The Decision Log records all three.

Tests: a write landing mid-wait is waited out (2.5 s, then the 1.0 s left);
a 100 ms deadline on a fresh write times out with nothing slept and the focus
hold untouched; readiness exactly at the deadline is refused; a mid-wait
write that pushes readiness past the deadline times out at the wake.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…ing (refs #366)

The re-review found the deadline was checked only while a positive wait
remained. A sleep that overshot (a 2,600 ms budget, a 2,500 ms sleep waking
at 3,000 ms) found the window passed and returned ready, so the action went
out after the client had timed out. Every wake now checks the deadline before
the ready path returns and throws timeoutReached once it has passed.

The probe is now a test with an overshooting sleeper, beside the same
oversleep inside a roomier budget, which stays ready. Dropping the post-wake
check fails it. The Decision Log's "#366's review" entry, item 2, records the
rule.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…eadiness, the action backstop re-reads its target's own handle, and set_value answers valueUnconfirmed (refs #366)

Ruling 772, on the live smoke and diagnostic run 44068144650: after the
switch to complete mode the AX handles survive, but cua's cached metadata
goes stale. Chrome's buttons gain AXPress, so a click planned from recorded
actions refused noAction even after the action's wait. Fields gain their
placeholder, so set_value's re-fetch after an accepted write threw
elementNoLongerValid.

- get_app_state, after its enablement step, waits out what remains of the
  2.5 s window since the process's last accepted write (any request's),
  bounded by the deadline, with the action's loop
  (waitForChromiumReadiness: re-read after every sleep, no sleep past the
  deadline, an oversleep ends it). The wait is the chromiumReady phase and
  signpost. A settled tree read before readiness is not adopted.
- A deadline-short observation reads anyway. Every entry records its read
  time (LineageEntry.recordedAt), and one read before the process's
  readiness counts as recorded before it.
- The action backstop: after the action's wait, a target recorded before
  readiness is re-read from its cached handle (identity, actions, read
  time), never re-found by identity. An invalid or unreadable handle is
  elementNoLongerValid before any write.
- set_value: a re-fetch that fails after an accepted write answers
  valueUnconfirmed in place of elementNoLongerValid.

The tests cover the observation waiting and then recording complete-mode
metadata, a deadline-short observation's marks, the backstop's refresh of a
marked entry from the same handle with an unmarked one left alone, another
handle never adopted (valid, invalid or unreadable own handle), and
valueUnconfirmed after a placeholder change between write and re-fetch. The
Decision Log records ruling 772.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…to 2.5 s, and set_value's valueUnconfirmed (refs #366)

Ruling 772 moved the wait to the observation. agent-cursor.md's background-
click paragraph now ends: the first observation of a Chromium-based app cua
has just started reading may take up to 2.5 s longer, and an action sent
before then waits for it. The fourth paragraph closes with valueUnconfirmed:
a setValue whose value was sent and accepted but whose field could not be
found again fails with it, so observe before any retry.

The docs oracle and the core-documentation test carry both byte for byte.
PROVENANCE.md, the surface inventory's new "(2026-11-17, #366, ruling 772)"
addition and the engine service's header comment record them.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…t's own handle (refs #366)

Review round 4 found a P2. A marked entry was refreshed from its own handle,
then went on into the ordinary resolver. If the handle went between the two
reads, the resolver fell through to the identity re-fetch and adopted
another element matching the identity the refresh had just read (the probe
moved t1 from handle 1 to 6).

The refreshed resolution now ends at the refresh. It never enters the
ordinary re-read or the identity re-fetch. The handle is validated before
its read and again after it, and the entry changes only once both pass, so a
refusal (elementNoLongerValid, before any write) leaves the entry as
recorded and still marked.

Regression, in the probe's shape and for each refetch mode: a marked entry
whose handle validates for the refresh and then goes, with another element
matching the refreshed identity. It is refused, with no walk, no adopted
handle and the entry unchanged. Restoring the fall-through fails it. The
Decision Log's ruling 772 entry records this.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…; end_task and the stop still release at once (refs #366)

Ruling 775, on the live qualification: after a real release the Chromium
attribute reads false, so the next observation writes it again and waits
out #366's 2.5 s readiness window. With the 30 s grace, every agent pause
over 30 s paid that. enablementReleaseGraceMs is now 300 000 ms, and its
comments say why. end_task and the engine's stop are unchanged and release
at once.

The grace now outlasts the focus hold's 120 s bound, so an action after a
grace release no longer meets a focus hold left from before it. The trade is
#292's side effect (Chrome's complete mode, its screen-reader flag, animated
window moves and resizes), which now lasts up to 5 minutes after cua's last
step on an app whose task has not ended.

The grace tests now run on the default grace on the fake timers: armed 5
minutes out, nothing at 30 s or 299 999 ms, released at 300 000 ms;
re-observations and inputs restart it; end_task and the stop release at once
with it pending. The Decision Log records ruling 775 and its limit.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…nutes idle, may take up to about 2.5 s longer (refs #366)

Ruling 775. agent-cursor.md's background-click paragraph now says plainly
when the wait comes: the first observation of a Chromium-based app in each
task (each end_task ends one), and again after 5 minutes without observing
or acting on it, may take up to about 2.5 s longer, and an action sent before
then waits for it.

The docs oracle and the core-documentation test carry it byte for byte;
PROVENANCE.md and the surface inventory's "(2026-11-17, #366, ruling 775)"
addition record it.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…6-chromium-ax-ready (refs #366)

Conflicts resolved, keeping both sides:

- agent-cursor.md and its copies (docs-oracle.mjs, core-documentation
  test): the background-click paragraph keeps #360's Firefox arrow-key
  sentence, then #366's first-observation wait as its last sentence. The
  fourth paragraph ends with #366's valueUnconfirmed. #354's sixth paragraph
  (typeText's read-back, typeUnconfirmed) stays as main has it. The copies
  are byte-identical, and their comments name both sides' sentences.
- PROVENANCE.md: both sides' provenance and contents for agent-cursor.md.
- The surface inventory: main's #360 and #354 additions first, then #366's
  three. #366's quotes of the background-click paragraph now carry #360's
  sentence, so the last one equals the merged paragraph.
- The native engine spec's Decision Log: chronological, so main's #360
  entry (2026-11-16) before #366's four (2026-11-17).

Methods.swift and service.mjs merged cleanly.

Sminos-Session: cursor235#b93055dd (cua on macbook)
… is ready (refs #366)

#366's fix in the plugin's engine. The first observation of a Chromium-
family app after cua enables it waits for the complete accessibility mode
before reading the tree. An element action waits too, re-reading a target
recorded earlier from its own handle. set_value answers valueUnconfirmed
when its field cannot be found again after an accepted write, and the
enablement's idle release now comes after 5 minutes.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…n and the five-minute lifecycle smoke (refs #366)

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

chatgpt-codex-connector Bot commented Nov 17, 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-17T13:37:51.625105Z 020e45b 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.

macOS engine: in a background Electron app, an AX press on a modal dialog's button closes the dialog without running the button, and answers success

1 participant