Repository navigation
fix(computer-use): follow-ups to #141 — foreground selection and live-test robustness - #142
Conversation
Address PR #141 CodeRabbit second-round item B. Preserve an element Type selection only when the target was originally focused and is still focused at the foreground click decision. A newly focused target still collapses its selection, including Cocoa's select-all behavior on refocus. Keep the click-decision result until selection handling. If no click decision ran, resolve keyboard_target_is_focused again immediately before collapsing. Add a pure decision helper and unit cases for lost, newly acquired, and retained focus. The lost-focus case failed against the old snapshot-only rule before the fix. Checked: stable rustc 1.97.1; cargo +stable fmt -p orca-computer-use; cargo +stable test -p orca-computer-use (221 unit, 3 harness contract, 8 default live tests passed; 92 live tests ignored); cargo +stable clippy -p orca-computer-use --all-targets (existing warnings only); cargo +stable test -p orca-computer-use --test live_macos --no-run; git diff --check. No ignored GUI or runtime native/real tests were run.
Keep the direct click probe in textedit_save_panel_uses_foreground_for_typing, but accept either AX attribution for the test-owned filename field. A refused click must report a covering window and emit no mouse-down; an allowed click must emit exactly one mouse-down. Log which outcome the native guard returned. Check the test filename and focused field before clicking only that field's native point. After either outcome require the same filename field to remain focused with its exact value, proving the panel remains open. Preserve the non-text key no-click assertion, foreground/pointer restoration, and Escape cleanup. Do not change the production ownership guard. Checked: stable rustc 1.97.1; cargo +stable fmt -p orca-computer-use; cargo +stable test -p orca-computer-use (221 unit, 3 harness contract, 8 default live tests passed; 92 live tests ignored); cargo +stable clippy -p orca-computer-use --all-targets (existing warnings only); cargo +stable test -p orca-computer-use --test live_macos --no-run; git diff --check. The ignored TextEdit GUI test was compiled only, never run.
Treat AXError::CannotComplete like InvalidUIElement in the live-test native read helper. A newly launched fixture can be temporarily busy despite its messaging timeout. Retry only these two errors, rediscover the handle before the next read, and retain the five-attempt ceiling and 100ms retry delay. Production accessibility reads and other error handling are unchanged. Extend the existing default stale_ax_reads tests to cover both errors, mixed transient failures, recovery after handle rediscovery, and the exact retry ceiling. Keep immediate returns for successful and non-transient reads. Both CannotComplete regressions failed before updating the retry predicate. Checked: stable rustc 1.97.1; cargo +stable fmt -p orca-computer-use; cargo +stable test -p orca-computer-use (221 unit, 3 harness contract, 8 default live tests passed; 92 live tests ignored); cargo +stable clippy -p orca-computer-use --all-targets (existing warnings only); cargo +stable test -p orca-computer-use --test live_macos --no-run; git diff --check. No ignored GUI or runtime native/real tests were run.
Register every valid started PID from each fixture's private log, arm log tracking before open, and re-read the logs during Drop to catch late starts. Use a separate log sequence so missing or duplicate receipts cannot reuse a previous launch's log. Preserve the preexisting-process and session ownership filters; never discover extra processes globally for termination. Confirm exit with kill(pid, 0) after terminate and forceTerminate, regardless of AppKit's isTerminated state. Use SIGTERM when the native app handle is missing, escalate a still-live owned process to SIGKILL, and confirm again. Bound each wait and late-receipt cleanup rounds. Log each PID's native handle, stop requests, process probes, and final outcome; report inspection or final termination failures through RESTORATION_FAILURES so the suite cannot pass silently with a known survivor. Fail clearly before launching a fixture if a foreign fixture is still alive, without terminating it. Probe the kernel to ignore stale AppKit entries. Keep Live::start permissive so legitimate Live sessions can coexist and the other-session preservation test retains its semantics. Add eight default, GUI-free cleanup contract tests for all/late receipts, ownership isolation, launch conflicts, ordered escalation, missing app handles, confirmed exit, persistent survivors, and probe errors. Five regressions failed against the extracted old first-receipt/native-only cleanup behavior before the fixes; all eight pass now. The exact cause of the reported live leak was not reproduced locally because desktop tests were intentionally not run. Checked: stable rustc 1.97.1; cargo +stable fmt -p orca-computer-use; cargo +stable test -p orca-computer-use (221 unit, 8 cleanup contract, 3 harness contract, 8 default live tests passed; 92 live GUI tests ignored); cargo +stable clippy -p orca-computer-use --all-targets (existing warnings only); cargo +stable test -p orca-computer-use --test live_macos --no-run; git diff --check. No ignored GUI or runtime native/real tests were run, and no existing desktop processes were signalled during these checks.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
d109461 added process-level cleanup checks to live_macos.rs: two libc::kill calls and the SIGTERM and SIGKILL constants. Record the four matches counted by the Windows platform-boundary validator as a windows-test-portability entry named computer-use-live-macos-process-cleanup. ESRCH and EPERM classify probe failures but are not part of that validator's operation pattern. The entire fixture is cfg(target_os = "macos") and is not compiled on Windows. Keep the reviewed boundary explicit without changing the validator or the cleanup behavior. The other inventories need no additions for this branch. Checked: node scripts/validate-windows-platform-boundaries.mjs; node scripts/test-validate-windows-platform-boundaries.mjs; node scripts/validate-runtime-surface-contract.mjs; node scripts/test-validate-runtime-surface-contract.mjs; node scripts/validate-execution-broker-boundary.mjs; node scripts/test-validate-execution-broker-boundary.mjs; node scripts/validate-http-client-boundary.mjs; node scripts/test-validate-http-client-boundary.mjs; node scripts/test-repository-hygiene.mjs; git diff --check. All checks passed. No live GUI tests were run.
Summary
Follow-ups to #141: one driver fix from CodeRabbit's second round, plus three live-test robustness fixes found while verifying #141 on a real Mac.
Approach
fix(computer-use)66dd148: in the foreground path, elementtypekeeps the selection only when the target was focused originally and is still focused at the click decision. Otherwise the selection collapses to the end. This also covers a target that the background attempt has just focused, where Cocoa may select all. It addresses fix(computer-use): live-verified macOS typing, focus and overlay fixes #141's CodeRabbit comment atforeground.rs:318, without the suggested diff, which would have stopped collapsing those freshly focused targets.testa2903af: the direct-click probe intextedit_save_panel_uses_foreground_for_typingaccepts either safe outcome of the ownership check:In both cases the same test-owned filename field must stay focused and unchanged. On macOS 26.6.2 the AX hit test for the Save panel field reports either TextEdit or its view service; 2 of 5 runs refused. This assertion comes from main (30354e5).
test6411938: live helpers retryAXError::CannotCompletethe same way asInvalidUIElement(up to 5 attempts, 100 ms apart). This fixesone_failed_frame_does_not_abort_observationwhen it readsAXMainWindowright after launch.testd109461: live cleanup confirms that every owned process actually exits.kill(pid, 0)and escalates terminate → forceTerminate → SIGKILL, or SIGTERM → SIGKILL when there is no AppKit handle.startedPID in the fixture's private log, including late receipts.In one full run, a fixture left behind by
observe_captures_a_window_covered_by_anothercaused 11 later tests to act on the wrong instance.Related Issue
Follow-up to #141.
Verification
All checks ran on macOS 26.6.2 (Apple Silicon) with stable rustc 1.97.1.
observe_of_an_electron_app_waits_for_its_treeskips withoutORCA_CU_ELECTRON_APP.cargo test -p orca-computer-use --test live_macos --locked -- --ignored --test-threads=1 --nocapture.textedit_save_panel_uses_foreground_for_typingandone_failed_frame_does_not_abort_observationeach passed 4 times: once in a full run and 3 repeats.cargo test -p orca-computer-use --locked: 221 unit, 8 cleanup contract, 3 harness contract and 8 defaultlive_macostests pass.env -u NODE_OPTIONS cargo test -p orca-runtime --lib --locked -- computer_use: 58 pass, 2 ignored.cargo fmt --all -- --checkandgit diff --checkare clean.cargo clippy -p orca-computer-use --all-targets --lockedreports no warnings in changed files.cargo check -p orca-computer-use --tests --lockedpasses forx86_64-unknown-linux-gnuandx86_64-pc-windows-msvc.Impact
User Interface
Not applicable.
Checklist
cargo fmt --all -- --checkpasses.cargo test --workspace --all-targets -- --test-threads=1passes. (Left to CI.)cargo clippy --workspace --all-targetspasses. (Left to CI.)Summary by CodeRabbit