Repository navigation
Description
What
With the macOS agent cursor (#235) on screen, the engine's requests get slower. The owner accepted two of these as stated limits on 2026-10-31 (#235's spec, Decision Log; Acceptance 12 and 13 amended):
press_key: about +1 ms a key while the cursor moves. +32 ms per 30 keys at the judged run, up to +53 on a grown TextEdit document, +6 (undetermined) on a fresh one.type_textand element clicks pass.- Coordinate click (+1.87 ms) and drag (+0.99 ms) on 4–6 ms actions: undetermined at 40 samples a side against a 1 ms bound. Accepted as "within about 2 ms, not proven within 1 ms".
This ticket is the work to remove them, if we want to.
What is known (attribution, 2026-10-31)
The extra time is inside the engine's request, as waits on other processes that slow while the cursor's panel is on screen (WindowServer runs 19–30 points busier). REPL leg, socket and the cursor hooks add ≤ 0.1 ms. For press_key, most of it is the AX keyboard-target read into TextEdit (+17.6 ms median per 30 keys, Input.swift), then the request prologue's two WindowServer round trips (+6.7): screenIsLocked() = CGSessionCopyCurrentDictionary (Methods.swift:276) and hidIdleMilliseconds() = CGEventSource.secondsSinceLastEventType(.hidSystemState, …) (:279). For coordinate click and drag, the only part placed is the prologue (+2.0 / +1.0 between receipt and first post). The cost grows with TextEdit's document size, so it is the target app's redraw under a busier compositor rather than the cursor's own frames. The 60 fps cap (default since #235) helps only on an otherwise idle display: typing itself keeps the display redrawing.
Records: docs/evidence/2026-10-30-macos-agent-cursor/sitting-2026-10-31* on feat/235-macos-cursor, the spec's 2026-10-31 Decision Log entries, tech-debt-tracker.md (2026-10-31). The signposts themselves are on the MacBook only (~/.local/share/cua-235/sitting-2026-10-31*/signposts/, SHA-256 sums committed).
Levers, cheapest first
- Lock-state cache. Seed once with
CGSessionCopyCurrentDictionary, then followcom.apple.screenIsLocked/screenIsUnlockeddistributed notifications. Re-read before any refusal decision, so a missed notification can't leave a stale "unlocked". This takes one WindowServer round trip off every request, cursor or not. - HID idle without WindowServer. IORegistry
IOHIDSystemHIDIdleTimein place ofCGEventSource. First measure whether the engine's ownCGEventPost(tap: .cghidEventTap)events reset either counter. The intervention ledger depends on that semantics. - Panel area. The cursor's panel spans the display. At rest, a cursor-sized panel might lower the compositor's load. This needs a measurement first (
--stillshowed +15 ms per 30 keys at rest, undetermined).
Done when
The levers taken are measured with #235's kit (scripts/cursor-sitting/, timing typing / timing clicks, cursor on against off, interleaved, the noise rule). Each lever's effect is shown on its own series. Any that pass the original bound restore Acceptance 12/13 to pass. The timed runs need the MacBook unattended (owner's ok, other sessions held off GUI and local CPU).
Constraints
Levers 1–2 change Methods.swift's prologue, which #211 (#117 M4) also touches: coordinate with it. Parity: refusal semantics must stay the vendor's.
Activity
#235: a visible agent cursor drawn by cua's own macOS engine (#240)