Skip to content

#244: a fresh Electron app's first observation holds its page (write-once enablement + the app role read) - #247

Merged
SSFSKIM merged 9 commits into
mainfrom
fix/244-chromium-first-observation
Nov 1, 2026
Merged

SSFSKIM merged 9 commits into
mainfrom
fix/244-chromium-first-observation

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

On cua's own macOS engine, the first observation of a freshly launched Electron app was missing the page: the window and its frame came back, the web content did not. The vendor's first observation had it. This PR makes cua's first observation contain the page, as the vendor's does. It also stops an accessibility event that cua fired inside Electron apps on every observation.

Cause. The cause analysis is in the Decision Log entries; the details:

  • Electron delays complete accessibility mode. Setting AXManualAccessibility schedules complete accessibility mode 2 s later, and every further set restarts the countdown (enableScreenReaderCompleteModeAfterDelay: in Electron 44.9.0's electron_application.mm). The getter reads mode == kAXModeComplete, which stays false even after complete mode lands, because complete mode is created with kFromPlatform | kScreenReader added.
  • cua re-wrote the attribute at every observation. Its rule was to set the attribute whenever it didn't read true, and this getter never reads true. In the run that found the bug, cua's first three observations wrote three times, about 1.3 s apart. Each one waited the full 1.1 s for a web area and found none. Complete mode came only after cua stopped observing for 2 s.
  • cua had no faster route to the page. It never read the application element's role. In Chromium and Electron, -accessibilityRole on NSApp turns on Basic mode (native APIs + web contents), and that alone exposes the page.
  • The vendor does both. It reads the role at the start of every observation, because its ApplicationUIElement.init(pid:) fetches the role eagerly. And it writes the attribute once, under a refcounted per-(app, kind) assertion.

Fix (native/engine/Sources/Engine/Enablement.swift, Skyshot.swift, Settle.swift):

  • Write once per owned process generation. After the engine has set and owns the attribute, later observations neither read nor write it until the release writes it back. After a write-back, the next observation writes again. A value that reads true, or can't be read, is not owned and is still read every time. This reverses the A3 critique's withdrawal of the once-per-process memory (Decision Log 2026-11-01). It also fixes the release. Electron counts requests (+1 per true, −1 per false) and resets the count only when complete mode fires, so after a burst of writes the release's single false didn't release.
  • Read the role first. On apps eligible for enablement, every observation first makes one AXUIElementCopyMultipleAttributeValues call on the application element for AXRole, AXSubrole and AXRoleDescription, before the enablement step. It is never cached. It is timed as appRoleRead, which rides in cua/observation as appRoleReadMs.
  • The settle-tree rule (from review). With write-once, a tree the settle read before another connection enabled the process could be adopted, missing its page. A per-process enablement count, which counts writes and successful write-backs, is now read before the settles and again after the enable step. The settled tree is adopted only if the two match.
  • enablementPrior now reads owned on an observation that touched nothing.

Plugin 0.20.3 (its own commit, d7a99ed).

Measured (live, MacBook, 2026-11-01; docs/evidence/2026-10-30-macos-agent-cursor/item-244/)

Build ed8521553753 on a freshly launched Electron fixture, with the session binding nothing, so the first cell makes the first engine observation:

variant engine button in the first observation writes: in the session / after the close complete mode on off after the close verdict
plain cua yes (index 13; web area found after 116 ms; observation 324 ms) 1 / 1 2077 ms after the write on the release's own write PASS
sonoma cua no (14 lines, no page) 1 / 1 2052 ms on the release's write recorded (#246)
plain vendor yes 1 / 0 2013 ms stays on until the vendor's teardown recorded

Limits

Tests

  • Engine: ObservationRulesTests (enablement: N observations give 1 write; a release writes false once; a released process is enabled again; a true read is never owned; an unreadable value is written every time; the role read comes before the write and runs on every observation; none on an ineligible app; an interleaved second-connection enablement rejects the settled tree; the enablement count moves with every write). WalkTests covers the adoption rule. Engine suite 648/648.
  • Services: appRoleReadMs in the observation diagnostics (test/services-engine-service.test.mjs).
  • Kit: scripts/cursor-sitting/first-observation.mjs and scripts/repl-parity/scenes-mac.mjs's --electron-arg, with 206 kit tests and 94 scenes/spike tests. Runbook section "Item 244".
  • Reviews: the engine at reviewer-high (one P2, the settle-tree rule, fixed and re-reviewed: correct). The kit at reviewer-medium (two false-pass P2s, then the off-detection defect from the slot, each fixed and re-reviewed: correct).
  • CI: ci-gate on d7a99ed: plugin, engine-swift, sandbox-live and test PASS (run 41285392239). parity-browser went red there on the known racy waitfor cell alone (parity-browser hosted gate: fix the two racy parity cells (waitfor deadline race, drag ended wait), then run it on PRs #168) and passed on its re-run (run 41286183578, GREEN). The PR's own checks are green (run 41285432843).

Docs

Closes #244

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

… app's role before enabling

A. Once the engine has set and owns a process's enablement attribute, later
observations neither read nor write it until the release writes it back (or
the process ends). Electron's getter is computed and always reads false, so the
per-observation re-read wrote at every observation, restarting Electron's 2 s
countdown to complete mode and firing accessibility-support-changed each time.
The first step, the 2026-10-22 re-enable after a write-back, and the release
are unchanged; a true or unreadable value is still not owned and is re-read
(an unreadable one still written) at every observation. An owned observation
reports enablementPrior "owned".

B. On eligible apps, every observation first reads the application element's
AXRole, AXSubrole and AXRoleDescription in one request (never cached), which
gives Chromium/Electron Basic mode and the page's tree at once, as the vendor's
eager ApplicationUIElement.init does. The step is WebAccessibility
.observeEnablement on the EnablementAccess seam (readRole), timed as
appRoleRead; the service passes appRoleReadMs through cua/observation so the
live run can report its warm cost.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…d; F §1.3 corrected

Two dated entries (2026-11-01): the write-once rule, reversing A3's withdrawal
of the once-per-process memory, and the role read with its declared difference
(Basic mode lasts the app's lifetime, including in the person's own Chrome).
The Observation paragraph, A3 and M2a.4's enablement item are amended to match,
and F §1.3 now records FUN_1007542cc as the eager construction-time fetch
outside a transaction, not only the prefetch fallback.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…s since the settles

The review of 5986286 (P2): with write-once enablement, connection A's
enablement step finds the attribute owned by connection B, which enabled the
process and saw its web area after A's settle, so A was not enabledNow, skipped
the wait, and adopted a settled tree read before the page existed. The
per-observation write had hidden this.

WebAccessibility now counts the engine's writes of each process's attribute
(true or false, any connection, kept past the entry's retirement), and
getAppState reads the count before its settles and after its enablement step;
adoptsSettledTree takes the two counts in place of enabledNow and adopts only
when they match. Interleaved regression test and the rule's unit test added;
the Decision Log entry records the rule.

Sminos-Session: cursor235#b93055dd (cua on macbook)
`up electron --electron-arg <switch>` (repeatable) launches the fixture with
those Chromium switches after its own and keeps them in the scene's record as
`extraArgs`; a non-switch argument, or the flag on another scene, is refused
before anything launches. The live check's sonoma variant uses it to turn on
SonomaAccessibilityActivationRefinements.

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

Per variant (plain; sonoma, the fixture launched with
SonomaAccessibilityActivationRefinements on), on cua's or the vendor's engine:
the Electron fixture relaunched fresh (#200's fixture-relaunch, now taking the
variant's switch, which `ps` must show on the new process), a session opened
with the fixture as its scene but not bound (binding observes twice), its first
cell the session's first engine observation (one cua.computer.get_app_state,
its text inspected in the cell: the button by index, line and character
counts, the page), five warm observations, a hold for complete mode, the
close, and the fixture's accessibility record read past the release. The
judge slices the record to this launch and counts write events before the
open, in the session and after the close. Pass, for cua on plain: the button
in the first observation, one write, complete mode on before the close, off
within 2.5 s of it; sonoma and the vendor are recorded. Replies now keep
cua/observation, and openDriven takes bind: false. Runbook: "Item 244".

Sminos-Session: cursor235#b93055dd (cua on macbook)
…e record's final mode

Two false-pass paths (review of c786dc9..603e490):
- The warm observations were not judged, so five failed ones still passed and
  write-once went unexercised. Now every warm observation must have answered,
  and on cua's engine carried appRoleReadMs, or the run is INCOMPLETE; each
  one's enablementPrior is reported in order.
- The off check took the first false poll after the close even when a later
  poll turned complete mode on again. Now a poll on after the off, or more than
  one write after the close (the release's own), fails the verdict, named; the
  live release poll waits for the record's latest mode to be off (offSince).

Sminos-Session: cursor235#b93055dd (cua on macbook)
The live slot's plain cua run judged FAIL on "complete mode did not go off"
although it had: the release's write cleared complete mode at once, so its own
event line says enabled false, and the fixture's poll, which writes only a
change from the last line, never wrote a poll line after it. The mode at any
time is now the enabled of the record's latest line of any source: complete
mode on, the off after the close (a line turning on to off) and its time, the
mode the record ends in, the re-enable rule and the live hold and release
polls all read it so. Writes are still event lines. Tests: the live record
passes; an off by a poll line after an event still works; a true line of
either source after the off fails, also as the last line past 2.5 s. The
report says appRoleReadMs was recorded under ordinary load (no timing bar)
and cites #246 for the fallback sonoma's row informs.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…nd vendor recorded

The first observation of a fresh Electron fixture holds the page; one enablement write per session, released on close.
The sonoma row (role read gives native APIs only) is #246's evidence. appRoleReadMs recorded under ordinary load.

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

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 ⚠️ Failed 2026-11-01T07:35:59.141637Z
We couldn’t complete this review. Comment @codex review to try again.
d7a99ed 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

SSFSKIM added a commit that referenced this pull request Nov 1, 2026
Brings main's #235 (cua's own macOS agent cursor, #240), #236's fix
(#241), #200 (#243) and #244 (#247) under M3, so M3's gate judges the
tree that ships. A merge, not a rebase: the spec and the evidence cite
this branch's commit SHAs.

The overlapping files and how each was resolved:
- src/runtime/launch.mjs (conflict): both sides kept. M3's Linux branch
  (cua's own service: CUA_SKY_SERVICE, CUA_ENGINE_BIN and
  CUA_DESKTOP_MODE for the cua selection, the vendor service and helper
  otherwise) beside #240's macOS branch, which adds the agent cursor's
  environment (cursorEnv) to cua's engine. The env header comment merged
  cleanly with both sides' entries.
- src/runtime/doctor-engine.mjs (auto-merged): #240's macOS row (the
  cursor switch in factsReport, cursorWords, settingsOf's cursor check)
  and M3's Linux row (service cua, capabilities, the IsEnabled row)
  touch separate functions; kept as merged.
- src/cua-api/sky.mjs and test/cua-api/sky.test.mjs (auto-merged):
  #241's fix for #236 (setupError exported, then/toJSON/symbols read
  undefined after a failed setup, the declared vendor difference and
  its settle test) beside M3.2's truncated-field scenario. Compatible
  by design: cua's Linux service's setup always resolves with the 20
  methods and keeps a failure for each method to refuse with, so the
  facade's setupError stays unset there; a setup that does throw now
  fails the bootstrap with its own error instead of hanging.
- tech-debt-tracker.md (conflict): every row from both sides kept,
  main's five newer rows first (74 at the base, +2 M3, +6 main = 82).
- .claude-plugin/plugin.json, marketplace.json (conflict): main's
  0.20.3 here; M3's own bump follows in its own commit.

Focused suites (services, facade, doctor, selection, harness, accept,
cursor) on the merged tree: 1948 pass, 8 fail; the same 8 fail on both
parents in this VM (umask 077 modes, macOS-only and env tests).

Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
@SSFSKIM
SSFSKIM merged commit f1bc48e into main Nov 1, 2026
6 checks passed
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: the first observation of a freshly enabled Chromium/Electron app returns an incomplete tree (vendor's is complete)

1 participant