fix(cua-driver): filter daemon overlay from window-change events + guard type_text against stale focus - #1700
Conversation
…ard type_text against stale focus Fixes trycua#1592 Bug 2 and Bug 3. Bug 2 — WindowChangeDetector reports own overlay as new window: Every click appended '🪟 Action opened new window(s): Cua Driver' because WindowChangeDetector.detectChanges() saw the AgentCursorOverlayWindow as a newly-appeared window. Fix: filter newEvents by daemonPid (ProcessInfo.processInfo.processIdentifier) so windows owned by the daemon itself are never reported as side-effects. Bug 3 — type_text inserts into wrong AX element in modal sheet context: With a macOS Open dialog showing a 'Go to Folder' sheet, type_text inserted text into the sidebar AXOutline instead of the sheet's text field. AX focus tracking lags in sheet hierarchies — the previous focused element retains focus status even after the sheet appears. Fix: after focusedElement(), check the role. If it is AXOutline, AXTable, AXList, AXBrowser, AXScrollArea, or AXSplitGroup (non-text containers), return an actionable error suggesting element_index targeting via get_window_state instead of silently writing to the wrong element.
|
@nishantpurohit04 is attempting to deploy a commit to the Cua Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR addresses two bugs in the CUA driver: TypeTextTool now validates that a focused AX element is text-editable before writing, returning an error if focus has landed on a non-text container; WindowChangeDetector filters out overlay windows owned by the daemon process itself to prevent false "new window" reports. ChangesAX Focus Validation and Daemon Window Filtering
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks @hippoley — closing as part of the Swift-backend retirement (see PR #1738 — cua-driver-rs is now the default backend, the Swift port is no longer the supported integration path). For Bug 1 specifically (screenshot ↔ click coord mismatch): the Rust port doesn't have a standalone For Bugs 2 + 3 (daemon overlay as new window, type_text stale focus on modal sheets): I've filed a follow-up to audit the Rust port for parity gaps in tracking issue #1753. If those bugs exist in the Rust path we'll address them there. Appreciate the patch — sorry we can't land this one. If you'd like to help port the fix to |
Fixes Bug 2 and Bug 3 from #1592.
Bug 2 — WindowChangeDetector reports own overlay as new window
Every click appended
🪟 Action opened new window(s): Cua DriverbecausedetectChanges()sawAgentCursorOverlayWindowas a newly-appeared window.Fix: filter
newEventsbyProcessInfo.processInfo.processIdentifierso windows owned by the daemon itself are never reported as side-effects.Bug 3 — type_text inserts into wrong AX element in modal sheet context
With a macOS Open dialog showing a 'Go to Folder' sheet,
type_textinserted text into the sidebarAXOutlineinstead of the sheet's text field. AX focus tracking lags in sheet hierarchies.Fix: after
focusedElement(), check the role. If it isAXOutline,AXTable,AXList,AXBrowser,AXScrollArea, orAXSplitGroup, return an actionable error suggestingelement_indextargeting viaget_window_state.Fixes #1592 (Bug 2, Bug 3)
Summary by CodeRabbit