cotabby icon indicating copy to clipboard operation
cotabby copied to clipboard

Chromium AX wake via AXManualAccessibility

Open Jam-Cai opened this issue 7 months ago • 1 comments

Chromium-based apps lazy-load accessibility trees; until something triggers population, their text fields appear as empty AX leaves. Setting AXManualAccessibility = true on the AXUIElement wakes the tree.

The naive "set once per app launch" approach isn't enough. Per @m13v's comment below, the real-world implementation also needs:

  1. Per-PID tracking, not per-bundle. The flag gets reset when a renderer process crashes and restarts (frequent in Electron). Track wake state by process ID and re-apply when an unfamiliar PID shows up under the same bundle.
  2. Confirm the wake actually took effect. Setting too early — before the app's window is fully shown — is a silent no-op on Arc and VS Code. Poll for AXChildren to become non-empty before treating the wake as successful.
  3. Reach into the renderer for Electron 28+. The flag on the top-level app element doesn't propagate to webview text fields. Walk down to the renderer AXUIElement and set it there too.

Acceptance

  • [ ] Bundle list covers Chrome, Edge, Brave, Arc, and common Electron shells (Slack, VS Code, Discord, Cursor, Linear).
  • [ ] Wake state is cached by processIdentifier, not by bundle ID. Re-applied when a new PID appears for a tracked bundle.
  • [ ] After setting the flag, poll AXChildren for non-empty with a tunable timeout (~200ms range) before treating the wake as successful. Until then, fall through to the key-event prefix tracker (#17).
  • [ ] For Electron 28+ apps, the renderer AXUIElement is located and the flag set on it too. Defensive renderer-walk on every Chromium-family bundle is acceptable if version detection isn't reliable.
  • [ ] No-op for non-Chromium apps.
  • [ ] Diagnostics: when wake is attempted but AXChildren stays empty past timeout, log it (debug build only) so we can spot apps where this approach is not working.

Effort: ~half a day of careful AX work plus testing across Chromium variants (originally pitched as smaller before the gotchas above).

Parent: #16

Jam-Cai avatar Apr 22 '26 17:04 Jam-Cai

the AXManualAccessibility flag gets reset in some cases, notably when the app crashes and restarts a renderer process (happens a lot in Electron). we track it per-PID instead of per-bundle and re-set when we detect the renderer PID changed. also worth noting: setting it too early before the app window is actually shown is a silent no-op on Arc and VS Code, we poll for AXChildren non-empty before considering the wake successful. electron 28+ also needs it set on the renderer AXUIElement, not just the top-level app element, or text fields in webviews stay empty.

m13v avatar Apr 23 '26 05:04 m13v