From 02f5c8a88b18de99fc174db5f93e04b5fe65482e Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Thu, 12 Nov 2026 12:55:02 +0000 Subject: [PATCH] fix(computer): move the macOS caret only after the text write lands (#41541) When a field accepted the AX value write but kept its old value, the helper had already moved the caret, so the fallback keys or Cmd+V went in at the wrong place. --- .../Sources/OrcaComputerUseMacOS/main.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift b/native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift index 254767be44c..1b47ed97355 100644 --- a/native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift +++ b/native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift @@ -2978,14 +2978,15 @@ private enum TextInput { guard result == .success else { return nil } - setSelectedTextRange(element, CFRange(location: startOffset + text.utf16.count, length: 0)) // Why: a cached, out-of-process AX tree can show the old value for a moment; any other value is final. let readback = settledValueReadback(element) { next == current || ($0 as? String) != current } as? String + // Why: typing the text as keys after a write that landed enters it twice, so only an unchanged field falls back. + if readback == current && next != current { + return nil + } + // Why: moving the caret before a refused write would send the fallback keys to the wrong place. + setSelectedTextRange(element, CFRange(location: startOffset + text.utf16.count, length: 0)) guard readback == next else { - // Why: typing the text as keys after a write that landed enters it twice, so only an unchanged field falls back. - if readback == current { - return nil - } return unverifiedAction(reason: "accessibility_action_unasserted") } return verifiedAction(property: "focusedText")