Skip to content

Commit 6f9ea07

Browse files
committed
fix(desktop): read editor focus after activateFirst brings the app forward
1 parent b9f8cac commit 6f9ea07

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎apps/desktop/native/computer-use/ComputerUse.swift‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ final class Driver {
655655
throw ComputerError("unsupported_action", "This element cannot take keyboard focus. Type into a text field, text area, combo box or other focusable control, or click it first.")
656656
}
657657
if request.method == "input_sequence", p.activateFirst == true { try await activate(app) }
658-
if !isFocused {
658+
// Activation can move focus, so whether the editor holds it is read after activating.
659+
if attribute(root, kAXFocusedUIElementAttribute).map({ CFEqual($0, element) }) != true {
659660
try axCheck(AXUIElementSetAttributeValue(element, kAXFocusedAttribute as CFString, kCFBooleanTrue))
660661
try await Task.sleep(for: .milliseconds(50))
661662
}

0 commit comments

Comments
 (0)