Skip to content

Computer use CLI for AI agents

fix: center horizontal scroll targets without oscillation

Lahfir44b573fc488c
diff --git a/crates/windows/src/actions/scroll_ladder.rs b/crates/windows/src/actions/scroll_ladder.rs
index 77c60a0ec..a7ca7468b 100644
--- a/crates/windows/src/actions/scroll_ladder.rs
+++ b/crates/windows/src/actions/scroll_ladder.rs
@@ -296,29 +296,28 @@ mod imp {
));
}
};
- if matches!(direction, Direction::Left | Direction::Right) {
- let amount = if matches!(direction, Direction::Left) {
- uiautomation::types::ScrollAmount::LargeDecrement
- } else {
- uiautomation::types::ScrollAmount::LargeIncrement
- };
- return match pattern.scroll(amount, uiautomation::types::ScrollAmount::NoAmount) {
- Ok(()) => classify_success().map(|_| ()),
- Err(error) => {
- require_scroll_delivery(classify_write("Scroll", LADDER_SCROLL_LABEL, &error))
- }
- };
- }
let bounds = crate::actions::scroll::known_bounds(element).ok_or_else(|| {
AdapterError::new(ErrorCode::ActionFailed, "Missing scroll target bounds")
})?;
let viewport = viewport_bounds(ancestor)?.ok_or_else(|| {
AdapterError::new(ErrorCode::ActionFailed, "Missing scroll viewport bounds")
})?;
- let current = pattern.get_vertical_scroll_percent();
- let size = pattern.get_vertical_view_size();
- let extent = viewport.height;
- let offset = bounds.y + bounds.height / 2.0 - viewport.y - viewport.height / 2.0;
+ let horizontal = matches!(direction, Direction::Left | Direction::Right);
+ let (current, size, extent, offset) = if horizontal {
+ (
+ pattern.get_horizontal_scroll_percent(),
+ pattern.get_horizontal_view_size(),
+ viewport.width,
+ bounds.x + bounds.width / 2.0 - viewport.x - viewport.width / 2.0,
+ )
+ } else {
+ (
+ pattern.get_vertical_scroll_percent(),
+ pattern.get_vertical_view_size(),
+ viewport.height,
+ bounds.y + bounds.height / 2.0 - viewport.y - viewport.height / 2.0,
+ )
+ };
let percent = centered_scroll_percent(
current.map_err(|error| uia_error(&error, "read scroll position"))?,
size.map_err(|error| uia_error(&error, "read scroll view size"))?,
@@ -327,7 +326,12 @@ mod imp {
)?;
ensure_budget(deadline)?;
corroborate_verified_process(ancestor)?;
- match pattern.set_scroll_percent(-1.0, percent) {
+ let (x, y) = if horizontal {
+ (percent, -1.0)
+ } else {
+ (-1.0, percent)
+ };
+ match pattern.set_scroll_percent(x, y) {
Ok(()) => {
classify_success()?;
Ok(())
diff --git a/docs/phases.md b/docs/phases.md
index 478cd4725..dc0a7082f 100644
--- a/docs/phases.md
+++ b/docs/phases.md
@@ -1380,7 +1380,7 @@ System tray interaction is built from scratch here.
- Full-branch multi-agent review — the whole assembled branch, not only this sub-phase's own diff
- **Make `cursor-overlay` tell its caller the truth on Windows.** Today `cursor-overlay enable` returns `ok: true` and renders nothing: `update_cursor_overlay` has no Windows override, and both call sites discard the adapter's answer — `src/dispatch/cursor_overlay.rs` logs a `tracing::warn!` and falls through to success, and `crates/core/src/cursor_overlay/submit.rs` does the same. A Windows-only adapter override returning `not_supported()` therefore changes nothing observable; §2.13 deliberately did not add one. **This gate owns only the honesty half — making the command report what the adapter answered. Rendering the overlay on Windows is §2.16's, which implements against whatever response shape this gate defines.** The candidate fix is to carry the adapter's answer into the response as a machine-readable field (a `rendered: false` on the success envelope) so the tool reports reality in the channel its caller actually reads — with the caveat that this changes a cross-platform command's response shape, which is a contract decision this gate is allowed to make. Two accepted risks inherited from §2.13's npm work are decided alongside, not rediscovered: (1) the install path's checksum verification is same-origin (`checksums.txt` comes from the same release as the tarball) and no consumer verifies the Sigstore provenance the release produces — surfacing `gh attestation verify` to manual-download users was the cheap half; (2) `optionalDependencies` per-platform packages were rejected on scope rather than merit, leaving `npm install --ignore-scripts` a permanent loud failure on every platform. Measured at 2.13's dogfood on npm 12.0.1 (node 24.18): that release's new install-scripts allowlist blocks the postinstall even with `--allow-scripts=agent-desktop` passed, so the wrapper's loud binary-not-found failure is increasingly the first thing a Windows user sees; the wrapper already names the cause, but this gate should weigh publishing the allowScripts configuration in the README before Phase 2 closes
- **Decide whether a shell surface's returned handle is rootable, or the `--surface` round trip is the contract.** `open-system-surface` returns `w-<hwnd>` identities, and `snapshot --window-id` refuses them `WINDOW_NOT_FOUND` — measured live at the dogfood for the promoted tray toolbar's handle — because the window inventory deliberately excludes shell windows (KTD1's correct behaviour); the shell round trip routes through `snapshot --surface <kind>` while the exit criteria's "an identity `snapshot --window` consumes" reads only through that path. What closes it: either `snapshot --window-id` roots shell handles through the shell-surface resolver, or the contract states that shell identities are surface-kind-scoped and the identity wording is corrected beside it. **Evidence:** dogfood 2026-08-28 leg 2; KTD1
-- **The local native gate passes `headed-double-click` and `interaction-scroll-to-visibility`.** The click fixture counts physical mouse releases once; a double-click must not satisfy its triple-click target. Scroll verification uses the native client viewport, contains targets that fit, and uses vertical `SetScrollPercent` to avoid page-step oscillation. The full native suite passed 110 checks with zero failures and five absent-Chromium skips. Evidence: `tests/e2e-windows/InteractionHeaded.ps1`, `tests/e2e-windows/scenarios/Interaction.ps1`, `crates/windows/src/actions/scroll_ladder_tests.rs`.
+- **The local native gate passes `headed-double-click` and `interaction-scroll-to-visibility`.** The click fixture counts physical mouse releases once; a double-click must not satisfy its triple-click target. Scroll verification uses the native client viewport, contains targets that fit, and uses horizontal or vertical `SetScrollPercent` to avoid page-step oscillation. The full native suite passed 110 checks with zero failures and five absent-Chromium skips. Evidence: `tests/e2e-windows/InteractionHeaded.ps1`, `tests/e2e-windows/scenarios/Interaction.ps1`, `crates/windows/src/actions/scroll_ladder_tests.rs`.
- **`agent-desktop-windows` is not built for non-Windows targets, and that is the decision rather than an oversight.** Nothing links the crate on a Linux target: the binary and the FFI crate declare their platform crates under `[target.'cfg(target_os = "windows")'.dependencies]`, so a Linux build never compiles `agent-desktop-windows`. What is gated in its place is core's platform neutrality — `agent-desktop-core` cross-compiles to `x86_64-unknown-linux-gnu` and `x86_64-pc-windows-msvc`, and `cargo tree -p agent-desktop-core` proves core carries no platform crate. Those are the invariants that matter, and both hold. Repairing the non-Windows build instead needs `#[cfg(not(target_os = "windows"))]` stubs across roughly twenty files that no lane executes — the exact shape `docs/solutions/best-practices/never-ship-platform-code-that-ci-cannot-execute.md` records the repository paying for once. This gate's scope offered a lane **or** a recorded exclusion with its reason; this is that exclusion. **Evidence:** `docs/solutions/best-practices/never-ship-platform-code-that-ci-cannot-execute.md`
- **The A26-13 nameless-leaf classification is taken, and both rows are closed.** A30-2 (`c9aed40e`) produced it through the product's own stack with `--include-bounds`: a Chromium host answers 3 nameless leaves split 1 positive-area to 2 zero-extent, and a Win32 host answers 29 nameless leaves split 14 positive-area to 15 zero-extent, with no nameless leaf lacking bounds. A nameless positive-area content leaf exists, so R20's dependency is real. The Chromium sample was thin (19 refs against A24-11's 262-ref content precondition), so the classification is settled and the density is not. The zero-identity resolution fix (A24-11's half) is live-verified, and A26-13 and A24-11 are closed. **Evidence:** A30-2, A26-13, A24-11, A28-3, A1-5, A1-6
- **The three ledger rows this gate owns are closed here, by measurement.** `A27-2` recorded a child enumeration that could not see a window the product's identical call did see, and deliberately handed the cause to a reproduction rather than asserting one. `A28-4` and `A28-5` are that reproduction: three `ToolbarWindow32` windows sit under `Shell_TrayWnd`, two of them collapsed zero-extent placeholders whose automation elements genuinely have no children, and the shipped class chain stopped one hop short and resolved one of the placeholders. All three rows are **closed** by adding the missing `SysPager` hop, after which `--surface system-tray` returns three refs and a click on one is delivered. The descend-the-taskbar-tree approach an earlier attempt built is **disposed of** as unnecessary and removed, and the claim that it improved the overflow surface is corrected in the rows themselves - overflow already read five refs without it.
diff --git a/docs/plans/2026-08-07-001-feat-windows-semantic-action-tier-plan.md b/docs/plans/2026-08-07-001-feat-windows-semantic-action-tier-plan.md
index ac9afd922..1d5c04dff 100644
--- a/docs/plans/2026-08-07-001-feat-windows-semantic-action-tier-plan.md
+++ b/docs/plans/2026-08-07-001-feat-windows-semantic-action-tier-plan.md
@@ -104,7 +104,7 @@ Evidence:
11. `TypeText`/`PressKey`/`DoubleClick`/`TripleClick`/`RightClick` → `AdapterError::not_supported("<capability>")` naming the missing machinery (key synthesis; multi-click; physical context-menu click) — `PLATFORM_NOT_SUPPORTED`, the honest cross-cutting-DoD arm, discriminable by message (the 2.6 dogfood J2 rule). `RightClick` is physical-only on Windows: UIA has no context-menu pattern, so no semantic rung can exist.
12. `KeyDown`/`KeyUp`/`Hover`/`Drag` → macOS's rejection verbatim (`ActionNotSupported`, "requires adapter-level handling, not element action", `dispatch.rs:184-193`).
13. Null handle (the `press` path) → `PressKey` reports the missing key-synthesis capability as in arm 11; every other variant → the crate's `invalid_native_handle` error. Checked before the downcast so the honest arm is reachable.
-- KTD5. **The ancestor ladder is macOS's algorithm with 2.6's visibility predicate.** On `ScrollTo`, rung 1 is the shipped `ScrollItemPattern` spine unchanged; when the gate says unavailable, or the invoke completes with geometry unchanged, rung 2 runs (this replaces 2.6's terminal `scroll_into_view_unsupported`/not-delivered arms exactly where a scrollable ancestor exists — no ancestor → those arms remain): up to 10 iterations (`MAX_ANCESTOR_SCROLLS`, macOS `scroll_into_view.rs:35-60`); per iteration, compute the scroll direction from the target's fresh bounds against the nearest `ScrollPattern`-available ancestor's viewport bounds (vertical before horizontal, before-edge before after-edge — macOS `direction_for_visibility` parity; the ancestor walk reuses `walker_source::nearest_scroll_viewport`, deadline-checked per step); one classified semantic scroll write on that ancestor: vertical `SetScrollPercent` centers the target using fresh viewport bounds and view size; horizontal scrolling uses `LargeIncrement`/`LargeDecrement`; direction resolves to none → visible: at iteration 0 `SatisfiedNoDelivery`, later `DeliveredVerified`; exhausted → `ACTION_FAILED` with `delivered_unverified` (real scrolls fired; macOS parity). Visibility requires `IsOffscreen` false and positive-area bounds. A target that fits must be contained by the native client viewport; an oversized target must intersect it. `scroll_ladder_tests.rs` and the local native E2E scroll leg verify that unclipped provider rectangles cannot prove visibility for a small clipped target. The 2.6 KTD6 disposition divergence (`not_delivered` where macOS reported `delivered_unverified` after real ancestor scrolling) closes itself: once the ladder scrolls, the exhausted arm reports macOS's disposition.
+- KTD5. **The ancestor ladder is macOS's algorithm with 2.6's visibility predicate.** On `ScrollTo`, rung 1 is the shipped `ScrollItemPattern` spine unchanged; when the gate says unavailable, or the invoke completes with geometry unchanged, rung 2 runs (this replaces 2.6's terminal `scroll_into_view_unsupported`/not-delivered arms exactly where a scrollable ancestor exists — no ancestor → those arms remain): up to 10 iterations (`MAX_ANCESTOR_SCROLLS`, macOS `scroll_into_view.rs:35-60`); per iteration, compute the scroll direction from the target's fresh bounds against the nearest `ScrollPattern`-available ancestor's viewport bounds (vertical before horizontal, before-edge before after-edge — macOS `direction_for_visibility` parity; the ancestor walk reuses `walker_source::nearest_scroll_viewport`, deadline-checked per step); one classified semantic scroll write on that ancestor: `SetScrollPercent` centers the target on the selected horizontal or vertical axis using fresh viewport bounds and view size; direction resolves to none → visible: at iteration 0 `SatisfiedNoDelivery`, later `DeliveredVerified`; exhausted → `ACTION_FAILED` with `delivered_unverified` (real scrolls fired; macOS parity). Visibility requires `IsOffscreen` false and positive-area bounds. A target that fits must be contained by the native client viewport; an oversized target must intersect it. `scroll_ladder_tests.rs` and the local native E2E scroll leg verify that unclipped provider rectangles cannot prove visibility for a small clipped target. The 2.6 KTD6 disposition divergence (`not_delivered` where macOS reported `delivered_unverified` after real ancestor scrolling) closes itself: once the ladder scrolls, the exhausted arm reports macOS's disposition.
- KTD6. **Verification is a per-action re-read, and a completed observation outranks the classifier.** Post-write verification (all within the lease deadline, macOS analogs cited): Toggle/Check/Uncheck → `ToggleState` re-read; SetValue → pattern value re-read equals the requested string exactly (via the KTD7 gate); RangeValue → value re-read equals the parsed number, with U1 recording provider rounding before an epsilon is invented; Expand/Collapse → `ExpandCollapseState` re-read; Select → `is_selected`/container-value re-read; Scroll/ScrollTo → geometry (2.6's spine); Click/Invoke rungs → no state to re-read, `verified: false`. Re-reads go through fresh reads, never a value retained from before the write (A3-2's re-acquire discipline). Post-state: for `Toggle`/`Check`/`Uncheck`/`SetValue`/`Clear`/`Expand`/`Collapse`, after any delivery and inside budget, read the full `ElementState` through the existing live-read machinery (secure withholding inherited from `ElementProperties`) and attach it — macOS `post_state.rs` parity, including its action table (pointer/scroll/focus actions attach none). Any post-delivery read failure — including A14-9's succeeding-empty corpse shape and its environment-divergent CI twin — maps through an `after_delivery` wrapper to `delivered_unverified`, never `not_delivered`, never a bare read error. Precedence rule, pinned: where an action's delivery is judged by geometric observation (the scroll family), a completed observation's verdict overrides the classifier's disposition — bounds unchanged across a completed observation is `not_delivered` even when the invoke's HRESULT was transport-uncertain; the classifier supplies code, message, and `platform_detail`. Where no geometric observation exists (Invoke, Toggle, value writes), the classifier's disposition stands.
- KTD7. **Secure fields: never read the secret, never claim what was not observed.** `ValuePattern.SetValue` into an `IsPassword` element proceeds under the same headless policy as any field (KTD10, `docs/phases.md:1108`), and then diverges from macOS deliberately: macOS skips the readback and reports the write trusted (`chain_verify.rs:60` returns `true` for secure fields — a `verified: true` no observation backs); §2.7's own contract says no step claims an effect it did not observe (`docs/phases.md:1105`), so Windows reports `verified: None` and the result stays `delivered_unverified`. Mechanics: every value-verification re-read routes through one helper that checks the element's `IsPassword` tri-state first — `Known(false)` reads and compares; `Known(true)` skips the read entirely; `Unknown` fails toward withholding (skips the read, `verified: None`) per the tri-state learning's asymmetric-cost rule — and a scan pins that `UIValuePattern::get_value`/`UIRangeValuePattern::get_value` appear nowhere in `actions/` outside that helper. Error echoes carry `value_chars` counts, never text (the trace-reachable-messages convention); post-state flows through `ElementProperties`, whose `IsPassword` gate already withholds value-bearing fields fail-closed (`element_properties.rs:64-88`). Core's `Clear` postcondition compares a withheld (absent) value — vacuously passing on secure fields — which is the honest reading: emptiness of a secret is itself withheld.
- KTD8. **Placement, scan governance, and the preamble discipline.** New modules under `crates/windows/src/actions/`, mirroring the real macOS layout (the chain-family shape, not `CLAUDE.md`'s stale `activate.rs` listing — U10 corrects the map): `dispatch.rs` (the match), `chain.rs` (engine + step recording), `mutation.rs` (+ `mutation_tests.rs` — the classifier and its per-arm pins), `value_write.rs` (SetValue/Clear/RangeValue + the KTD7 gate), `toggle_state.rs` (Toggle/Check/Uncheck), `disclosure.rs` (Expand/Collapse), `select.rs`, `scroll.rs` (`Action::Scroll`), `scroll_ladder.rs` (KTD5 rung 2, sibling of the existing `scroll_into_view.rs`), `focus.rs` (KTD4.10), `post_state.rs` — each with a `*_tests.rs` sibling, each under the 400-line cap from birth (the tightest neighbors are `properties.rs` at 348 and `live_read.rs` at 351 — new code goes in new files, not those). Entry preamble in every path, in order: null-handle arm (KTD4.13), `uia_element` downcast, `ensure_budget(lease.deadline())`, `corroborate_verified_process` before the first write and again around post-write reads (the 2.6 precedent — a write against a corpse must not report observation-judged outcomes). Scan governance: `hit_test_scan_tests.rs`'s `PATTERN_ALLOWLIST` becomes a slice covering exactly the `actions/` files that invoke patterns, its covers-a-live-call-site tripwire generalizes to every entry, and the write-path ban (`scroll_into_view_tests.rs:211-231`'s shape — the three read-classifier names never appear) generalizes to one test scanning every mutation file; `get_pattern` stays banned everywhere else, `tree/` included. The advertise↔dispatch consistency of R2 is its own test: every capability `resolve_actions` can emit maps to a chain whose first gate can accept it. Test-double mechanism, stated because no COM mock exists or is wanted: the engine's rungs and gated reads are injected closures (KTD3's design), which is also the unit-test seam — call-count and outcome pins drive pure chain/dispatch logic with counting closures, the `scroll_into_view_judged_for` injected-observe precedent (`actions/scroll_into_view.rs:105-139`); live whole-pipeline coverage rides the crate's `tree/fixture.rs` harness, extended with the control shapes these chains need (checkbox incl. tri-state, slider, combobox, scrollable list) — as a sibling module, because `fixture_window.rs` sits at 393 of 400 lines.
diff --git a/tests/e2e-windows/InteractionPress.ps1 b/tests/e2e-windows/InteractionPress.ps1
index 4495774df..9b49e269a 100644
--- a/tests/e2e-windows/InteractionPress.ps1
+++ b/tests/e2e-windows/InteractionPress.ps1
@@ -26,16 +26,20 @@ function Invoke-PressLegs {
try {
$textInput = Require-Target -Target (Find-Target -App $App -NativeId 'text-input' -TimeoutSeconds 10) -Description 'text-input'
- Invoke-Target -Target $textInput -Action 'focus' -Headed -RequireOk -Description 'text-input (keyboard focus)' | Out-Null
- if (-not (Test-Target -Target $textInput -Property 'focused')) { throw 'text-input was not focused before shift+tab; the leg would prove nothing' }
+ $secureInput = Require-Target -Target (Find-Target -App $App -NativeId 'secure-input' -TimeoutSeconds 10) -Description 'secure-input'
+ Invoke-Target -Target $secureInput -Action 'focus' -Headed -RequireOk -Description 'secure-input (plain Tab control)' | Out-Null
+ Assert-Envelope -Envelope (Invoke-AgentDesktop -Arguments @('--headed', 'press', 'tab', '--app', $App)) -Ok
+ if (Test-Target -Target $textInput -Property 'focused') { throw 'plain Tab moved backward to text-input; the Shift direction check would prove nothing' }
+ Invoke-Target -Target $secureInput -Action 'focus' -Headed -RequireOk -Description 'secure-input (keyboard focus)' | Out-Null
+ if (-not (Test-Target -Target $secureInput -Property 'focused')) { throw 'secure-input was not focused before shift+tab; the leg would prove nothing' }
Assert-Envelope -Envelope (Invoke-AgentDesktop -Arguments @('--headed', 'press', 'shift+tab', '--app', $App)) -Ok
$clock = [System.Diagnostics.Stopwatch]::StartNew()
- $stillFocused = Test-Target -Target $textInput -Property 'focused'
- while ($stillFocused -and $clock.Elapsed.TotalSeconds -lt 5) {
+ $previousFocused = Test-Target -Target $textInput -Property 'focused'
+ while (-not $previousFocused -and $clock.Elapsed.TotalSeconds -lt 5) {
Start-Sleep -Milliseconds 150
- $stillFocused = Test-Target -Target $textInput -Property 'focused'
+ $previousFocused = Test-Target -Target $textInput -Property 'focused'
}
- if ($stillFocused) { throw 'text-input still reports focused after shift+tab' }
+ if (-not $previousFocused) { throw 'shift+tab did not focus the previous control text-input' }
Add-Pass -Leg 'press-shift-tab-moves-focus'
} catch { Add-Fail -Leg 'press-shift-tab-moves-focus' -Reason $_.Exception.Message }
diff --git a/tests/e2e-windows/InteractionScroll.ps1 b/tests/e2e-windows/InteractionScroll.ps1
new file mode 100644
index 000000000..88f049b8a
--- /dev/null
+++ b/tests/e2e-windows/InteractionScroll.ps1
@@ -0,0 +1,27 @@
+#Requires -Version 5.1
+
+Set-StrictMode -Version 2.0
+
+function Invoke-HorizontalScrollToLeg {
+ param([Parameter(Mandatory = $true)][string]$App)
+ try {
+ Enter-Stage -Lock DesktopLease -Body {
+ $area = Require-Target -Target (Find-Target -App $App -NativeId 'horizontal-scroll-area' -TimeoutSeconds 10) -Description 'horizontal-scroll-area'
+ Invoke-Target -Target $area -Action 'scroll-to' -RequireOk -Description 'horizontal-scroll-area' | Out-Null
+ $viewport = Get-Target -Target $area -Property 'bounds' -Raw
+ $target = Require-Target -Target (Find-Target -App $App -NativeId 'horizontal-edge-target' -TimeoutSeconds 10) -Description 'horizontal-edge-target'
+ $before = Get-Target -Target $target -Property 'bounds' -Raw
+ $right = [double]$viewport['x'] + [double]$viewport['width']
+ if ([double]$before['x'] -ge $right -or ([double]$before['x'] + [double]$before['width']) -le $right) {
+ throw 'horizontal-edge-target was not partially clipped before scroll-to'
+ }
+ Invoke-Target -Target $target -Action 'scroll-to' -RequireOk -Description 'horizontal-edge-target' | Out-Null
+ $fresh = Require-Target -Target (Find-Target -App $App -NativeId 'horizontal-edge-target' -TimeoutSeconds 10) -Description 'horizontal-edge-target after scroll'
+ $after = Get-Target -Target $fresh -Property 'bounds' -Raw
+ if ([double]$after['x'] -lt [double]$viewport['x'] -or ([double]$after['x'] + [double]$after['width']) -gt $right) {
+ throw 'horizontal-edge-target remained clipped after scroll-to'
+ }
+ }
+ Add-Pass -Leg 'interaction-horizontal-scroll-to-containment'
+ } catch { Add-Fail -Leg 'interaction-horizontal-scroll-to-containment' -Reason $_.Exception.Message }
+}
diff --git a/tests/e2e-windows/scenarios/Interaction.ps1 b/tests/e2e-windows/scenarios/Interaction.ps1
index 72b92e407..d8b7b1a33 100644
--- a/tests/e2e-windows/scenarios/Interaction.ps1
+++ b/tests/e2e-windows/scenarios/Interaction.ps1
@@ -29,6 +29,7 @@ Set-StrictMode -Version 2.0
file's own header for why. #>
. (Join-Path (Split-Path -Parent $PSScriptRoot) 'InteractionHeaded.ps1')
. (Join-Path (Split-Path -Parent $PSScriptRoot) 'InteractionPress.ps1')
+. (Join-Path (Split-Path -Parent $PSScriptRoot) 'InteractionScroll.ps1')
function Get-InteractionHeadlessLegTable {
@(
@@ -77,17 +78,19 @@ function Get-InteractionRefusalLegTable {
function Assert-RefusalLeg {
param($Leg, [Parameter(Mandatory = $true)][string]$App)
- $target = Require-Target -Target (Find-Target -App $App -NativeId $Leg.TargetId -TimeoutSeconds 10) -Description $Leg.TargetId
- if ($Leg.Action -eq 'drag') {
- $callArgs = @('drag', '--from', $target.RefId) + $Leg.ActionArgs
- $envelope = Invoke-AgentDesktop -Arguments $callArgs
+ Enter-Stage -Lock DesktopLease -Body {
+ $target = Require-Target -Target (Find-Target -App $App -NativeId $Leg.TargetId -TimeoutSeconds 10) -Description $Leg.TargetId
+ if ($Leg.Action -eq 'drag') {
+ $callArgs = @('drag', '--from', $target.RefId) + $Leg.ActionArgs
+ $envelope = Invoke-AgentDesktop -Arguments $callArgs
+ Assert-Envelope -Envelope $envelope -ErrorCode 'POLICY_DENIED' -Delivery 'not_delivered' -Retry 'safe'
+ return
+ }
+ Invoke-Target -Target $target -Action 'scroll-to' -RequireOk -Description $Leg.TargetId | Out-Null
+ $statusTarget = Require-Target -Target (Find-Target -App $App -NativeId $Leg.StatusId -TimeoutSeconds 10) -Description $Leg.StatusId
+ $envelope = Assert-NoEffect -Target $target -StatusTarget $statusTarget -Property 'value' -Action $Leg.Action
Assert-Envelope -Envelope $envelope -ErrorCode 'POLICY_DENIED' -Delivery 'not_delivered' -Retry 'safe'
- return
}
- Invoke-Target -Target $target -Action 'scroll-to' -RequireOk -Description $Leg.TargetId | Out-Null
- $statusTarget = Require-Target -Target (Find-Target -App $App -NativeId $Leg.StatusId -TimeoutSeconds 10) -Description $Leg.StatusId
- $envelope = Assert-NoEffect -Target $target -StatusTarget $statusTarget -Property 'value' -Action $Leg.Action
- Assert-Envelope -Envelope $envelope -ErrorCode 'POLICY_DENIED' -Delivery 'not_delivered' -Retry 'safe'
}
function Invoke-InteractionScenario {
@@ -102,7 +105,7 @@ function Invoke-InteractionScenario {
'headed-drag', 'headed-type', 'headed-press-app',
'press-ctrl-a-backspace-clears-text', 'press-shift-tab-moves-focus',
'press-return-activates-focused-button', 'press-blocked-combo-refused',
- 'interaction-scroll-to-visibility', 'interaction-focus-refused-headless', 'interaction-focus-headed-oracle'
+ 'interaction-scroll-to-visibility', 'interaction-horizontal-scroll-to-containment', 'interaction-focus-refused-headless', 'interaction-focus-headed-oracle'
))
foreach ($leg in $headlessLegs) {
@@ -155,7 +158,7 @@ function Invoke-InteractionScenario {
foreach ($leg in $refusalLegs) {
try {
- Enter-Stage -Lock DesktopLease -Body { Assert-RefusalLeg -Leg $leg -App $App }
+ Assert-RefusalLeg -Leg $leg -App $App
Add-Pass -Leg $leg.Name
} catch {
Add-Fail -Leg $leg.Name -Reason $_.Exception.Message
@@ -168,6 +171,7 @@ function Invoke-InteractionScenario {
Invoke-HeadedInteractionLegs -App $App
Invoke-PressLegs -App $App
Invoke-ScrollToVisibilityLeg -App $App
+ Invoke-HorizontalScrollToLeg -App $App
Invoke-FocusRefusalLeg -App $App
Invoke-FocusOracleLeg -App $App
}
diff --git a/tests/fixture-app-windows/FixtureCardsClicks.cs b/tests/fixture-app-windows/FixtureCardsClicks.cs
index 21749de88..12993ecbb 100644
--- a/tests/fixture-app-windows/FixtureCardsClicks.cs
+++ b/tests/fixture-app-windows/FixtureCardsClicks.cs
@@ -34,7 +34,6 @@ namespace AgentDeskFixtureApp
BuildTwinControls(card, CardLayout.RowY(5));
}
- // Count physical releases once; WinForms can raise Click twice for one press.
private static void BuildCountedClickTarget(
GroupBox card, string id, string label, int y, string statusId, string statusValue, int targetCount)
{
@@ -171,7 +170,6 @@ namespace AgentDeskFixtureApp
};
}
- // Preserve native double-click messages while counting each physical release.
internal sealed class CountedClickButton : Button
{
internal CountedClickButton()
diff --git a/tests/fixture-app-windows/FixtureCardsScroll.cs b/tests/fixture-app-windows/FixtureCardsScroll.cs
index 540ae80f5..b3c6aab61 100644
--- a/tests/fixture-app-windows/FixtureCardsScroll.cs
+++ b/tests/fixture-app-windows/FixtureCardsScroll.cs
@@ -62,6 +62,22 @@ namespace AgentDeskFixtureApp
scrollOffset.Text = (-scrollArea.AutoScrollPosition.Y).ToString();
};
scrollOffset.Text = "0";
+
+ Panel horizontal = new Panel();
+ FixtureIdentity.Assign(horizontal, "horizontal-scroll-area");
+ horizontal.Location = new Point(432, CardLayout.RowY(2));
+ horizontal.Size = new Size(160, 60);
+ horizontal.AutoScroll = true;
+ horizontal.AutoScrollMinSize = new Size(500, 20);
+ card.Controls.Add(horizontal);
+
+ Label edgeTarget = new Label();
+ FixtureIdentity.Assign(edgeTarget, "horizontal-edge-target");
+ edgeTarget.Text = "Edge";
+ edgeTarget.Location = new Point(150, 0);
+ edgeTarget.Size = new Size(30, 20);
+ horizontal.Controls.Add(edgeTarget);
+ new ControlTypeOverrideHost("horizontal-edge-target", ControlType.Text.Id, delegate { }).Hook(edgeTarget);
}
/// <summary>