Skip to content

perf(daemon): skip post-gesture stabilization after a scroll --until that never moved - #5225

Merged
thymikee merged 2 commits into
mainfrom
perf/skip-noop-scroll-stabilization
Nov 30, 2026
Merged

thymikee merged 2 commits into
mainfrom
perf/skip-noop-scroll-stabilization

Conversation

@thymikee

@thymikee thymikee commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Summary

A scroll that reports passes: 0 sent no gesture. It now keeps the session's deferred outcome as it was before the command and marks nothing new. The dispatcher holds the record before the ADR 0014 seam. dispatchedGesture reads the typed passes field. The deferred-outcome owner restores a recheck baseline that the seam retired. A pending stabilize record survives on its own. A scroll that moved still arms stabilization.

Nightly perf logs (4 samples): an --until on a target that was already visible armed stabilization. The next iOS press then polled to stale_accept with about 13 captures, warned "scroll produced no visible change", and cost about 3 s.

Help and client-api.md now qualify the post-scroll wait.

Before / after

Android provider scenario, a zero-pass --until followed by snapshot: 2 captures before, 1 after. A scroll that moved still takes 2 captures.

The iOS provider scenario runs press, a zero-pass --until, and a press on a moving target. The second press rechecks and taps the settled rect.

A live iOS Simulator run is recorded in a PR comment.

Validation

pnpm exec vitest run --project provider-integration test/integration/provider-scenarios/scroll-until.test.ts test/integration/provider-scenarios/press-selector-resolution.test.ts passes. src/commands/schema/cli-help-topics.test.ts passes. CI owns the remaining gates.

Follow-up: #5227.

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

…that never moved

A pass-counted scroll that stops on its first capture sends no gesture, so it
no longer marks a deferred stabilization. An earlier owed stabilization stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.70 MB 6.70 MB +443 B
Package (unpacked) 6.70 MB 6.70 MB +443 B
Package (download) 2.05 MB 2.05 MB +163 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 23.2 ms 21.2 ms -2.0 ms
CLI --help 47.9 ms 47.9 ms -0.1 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

View guided diff | Turn on auto-fix | Re-trigger cubic

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Changes are needed at 06d96af: a scroll --until with zero passes can drop the protection that an earlier press left for the next press.

request-generic-dispatch.ts:172: this looks like a regression. press 'text=Next' leaves a 'recheck' moving-target baseline. A following scroll down --until 'text=Submit' may find Submit already in a tree that is still in transition. The command still expires the ref frame, which retires that baseline. Before this change, the scroll then armed a 'stabilize' record. Now nothing is armed, so the next press 'text=Submit' gets no moving-target check and no stability loop, and local iOS Simulator also loses the pending-stabilization bar on the direct selector route. The press can then hit a point that the transition is leaving (the #3471 failure), including in batch and .ad flows, against the no-fixed-delay promise. The rule: a command that sent no gesture keeps whatever the session's deferred surface held before it, 'recheck' as well as 'stabilize', at every case the dispatchedGesture predicate reports as no gesture. One way is to read movingTargetBaseline before expireRefFrame and, when passes is 0, restore it through a function owned by deferred-interaction-outcome.ts. The speed gain stays, because the check waits at most for the rest of the window. Please add a provider scenario: press, zero-pass --until, then press on a target that is still moving. It should show that the second press observes again and taps the settled rect.

cli-help-gestures.ts:39 and client-api.md:343 say that on mobile the next read after a scroll waits for two captures to agree. That is no longer true for scroll --until, top or bottom with passes: 0, and callers act on this help. Please qualify both sentences: such a scroll sent no gesture and adds no wait of its own, while a wait owed by an earlier gesture still applies.

request-generic-dispatch.ts:172: this changes behavior on devices and the motivating symptom is on iOS, but the PR records only an Android provider scenario (device verification). A live run at the final head, at least on an iOS Simulator, is required before merge. First, scroll down --until <visible selector> returns passes: 0, then press <selector> shows a duration without the stale_accept cost and no "scroll produced no visible change" warning. Second, a --until that moves (passes > 0) is followed by a press that still stabilizes. Third, with the first fix in place, press, zero-pass --until, and press across a navigation transition hit the correct control. Please record the device, commands, output and SHA.

Would it be simpler for the deferred-outcome owner to hold the record from before dispatch? The dispatcher would capture it before the ADR 0014 seam and then report whether a gesture went out. If none did, the owner would restore a retired 'recheck' record and mark nothing, since an existing 'stabilize' record already survives. That keeps one predicate and one owner at about the current diff size.

Not blocking: as an older, nearby issue that can be taken or left, recording-gestures.ts:97 draws a swipe during recording for a zero-pass scroll, so a follow-up issue could skip that event using the same predicate as dispatchedGesture.

Not verified here: the first problem was traced in code only, and whether the second press sees a moving rect in a given transition depends on device timing. The nightly performance logs cited in the PR and the scroll output of external provider backends were also not checked.

Checks are green at this head. The two cancelled Body rules runs were replaced by a successful run on the same head.

Before merge, the earlier press's baseline must survive a zero-pass scroll, the two stabilization sentences must be corrected, and the live run must then be recorded.

… zero-pass scroll

A scroll that sent no gesture now keeps whatever deferred surface the session held
before its ADR 0014 seam: the owner holds the record before dispatch and restores a
retired `recheck` baseline. Help and client docs say a zero-pass scroll adds no wait
of its own while an earlier gesture's wait still applies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

Copy link
Copy Markdown
Member Author

Live iOS Simulator run at head 7d75d8e.

Device: new iPhone 17 simulator perf-5225, iOS 27.0 (24A434). It was created for this run and deleted afterwards. The CLI was the checkout's pnpm build + node bin/agent-device.mjs, with its own state dir and runner derived path. The app was Settings (com.apple.Preferences). Durations are from --debug request logs.

Fixes in 7d75d8e

  • Before the ADR 0014 seam, dispatchGenericCommand holds the session's deferred surface (holdDeferredSurface). When dispatchedGesture reports that no gesture went out, markDeferredInteractionOutcome({ noGesture }) restores a retired recheck record and marks nothing. A stabilize record already survives the seam.
  • New provider scenario (press-selector-resolution.test.ts): press, then a zero-pass --until, then a press on a moving target. The second press looks 3 times and taps the settled rect (y=322). With the restore removed, it taps after 1 capture.
  • The help and client-api.md sentences now say the scroll adds no wait of its own and an earlier gesture's wait still applies. The help test pins this text.

(a) Zero-pass --until, then press

scroll down --until 'label="Camera"' --json  -> "passes": 0, "label=\"Camera\" was already visible; no down scroll needed"
press 'label="Camera"' --debug               -> daemon_request durationMs 519
  ios.snapshot-source.acquire 41 ms, then ios_runner_command_send tap 442 ms

The press made one capture, with no stabilization loop, no stale_accept, and no "scroll produced no visible change" warning.

(b) Moving --until, then press

scroll down --until 'label="Privacy & Security"' -> "Scrolled down 1 pass until ... was visible"
press 'label="Privacy & Security"' --debug        -> durationMs 625
  post_gesture_snapshot_stabilized {"action":"scroll","attempts":2,"durationMs":322}

(c) Press, zero-pass --until, press across a push transition (one batch, so the second press falls inside the 500 ms window)

batch: press label="General" -> scroll down --until label="About" -> press label="About"
  press General: tap (201, 406)
  scroll:        "passes": 0
  press About:   snapshot acquires at 33.672, 34.084 (after window), 34.203 (agreeing look) -> tap (201, 434)
snapshot -> navigation-bar "About"

Control: I ran the same batch at 06d96af. The About press made 1 capture and tapped with no recheck. That is the baseline loss this fix restores. In both runs the push had finished by the tap, so both landed on About. The capture count is what differs.

Not blocking, follow-up: #5227. A recording still draws a swipe for a zero-pass scroll.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 7d75d8e

Since the review of 06d96af: 0 new · 0 still open · 0 no longer raised

No open findings.

2 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (d34b2156f45d).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

No new problems were found in the code at 7d75d8e, and all three requests from the earlier review are now addressed. A zero-pass scroll keeps the earlier press's moving-target check and any pending stabilization, the help and client docs now describe the passes: 0 case, and the live iOS Simulator run reported by the author covers the requested cases.

In the live transition case, the push had already finished by the tap in both the new run and the control run. That run therefore shows the restored recheck through the capture count, while tapping the settled position of a still-moving target is covered by the provider scenario. Not verified here: tests, the restore-removal experiment and device runs were not executed, and the scenario and that experiment were assessed from code. The new press scenario also relies on real time, because the second press must be checked within 500 ms of the first.

Checks are green at this head. Nothing further from this review needs to happen before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 29, 2026
@thymikee
thymikee merged commit a4b31e3 into main Nov 30, 2026
23 checks passed
@thymikee
thymikee deleted the perf/skip-noop-scroll-stabilization branch November 30, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant