Skip to content

feat(gestures): add settle to swipe and gesture - #5109

Open
thymikee wants to merge 4 commits into
mainfrom
t3/gesture-settle-single-loop
Open

thymikee wants to merge 4 commits into
mainfrom
t3/gesture-settle-single-loop

Conversation

@thymikee

@thymikee thymikee commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #4571. Add opt-in --settle to swipe and supported gesture actions across CLI, SDK, and MCP. The quiet wait starts after the final successful repetition and compares against the last observed tree. Plain gestures keep their capture budget. Gesture timeouts use the existing settle-capable daemon recovery policy.

Before / after

agent-device swipe 200 550 200 250 --count 3 --settle --json

Base refuses the flag. Head keeps the completed action result if the observation fails. When a settle diff issues refs, it includes their generation.

Validation

  • At 06c26989b4, pnpm check:affected --run --head HEAD passed at the exact commit (run-AEDA1F). The routed regression reproduces the false action failure before the fix.
  • Live at 0e198907d0 on iOS 27.0 and Android 17. With matched 500 ms quiet windows, median no-effect iOS fling time fell from 4,975 ms and 16 tree reads on c0b1d7a4a8 to 2,235 ms and five reads (eight trials per arm). Changing pan returned usable refs on both targets. Repeated swipes retained stabilization.
  • The current-surface fix has routed coverage. Split View exit and sheet dismissal still need live evidence.

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

View guided diff Turn on auto-fix

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.61 MB 6.61 MB +3.1 kB
Package (unpacked) 6.61 MB 6.61 MB +3.1 kB
Package (download) 2.02 MB 2.02 MB +1.0 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 23.0 ms 25.6 ms +2.7 ms
CLI --help 42.9 ms 47.3 ms +4.4 ms

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 1 new finding on b2b339d. The verdict and the full list are in the summary comment.

@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.

1 issue found across 29 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/contracts/src/interaction.ts">

<violation number="1" location="packages/contracts/src/interaction.ts:331">
P3: `SwipeCommandResponseData.pattern` is typed `string`, which accepts values the swipe command never returns. Use the existing `SwipePattern` type from `scroll-gesture.ts`, as the sibling contract files do.</violation>
</file>

Reply with feedback, questions, or to request a fix.

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

Comment thread packages/contracts/src/interaction.ts Resolved
Comment thread docs/adr/0013-unified-gesture-plans.md Resolved
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 1 finding moved to a new line on f3113f6. The verdict and the full list are in the summary comment.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 06c2698

Since the review of f3113f6: 0 new · 0 still open · 1 no longer raised (1 marked fixed)

No open findings.

1 new finding away from what changed since f3113f6 not shown. Comment @apex-sentinel-staging review for a full review.

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

💬 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 blocking code problem was found at 06c2698, but readiness evidence is still pending: the Body rules check was cancelled and has not passed.

Not blocking: these can be taken or left: share one owner for the baseline and observe steps and generic settle, including its cancel, session-ended and Android-overlay rules; accept that plain swipes and gestures now preserve the daemon on timeout, as the PR body states, or apply that policy only with --settle; return an unsettled settle result with a hint, and no diff or refs, when any observation fails; drop the repeated outer presence checks around settle fields and the settle flag guard; remove "supported" from the help and command docs, since every gesture kind accepts --settle; and quote an Android swipe … --settle --json response from this head that shows settle.diff and refsGeneration.

Could scroll, back, swipe and gesture share one settle baseline helper and one observe helper, in generic-settle.ts or a shared module, so they answer the same way on cancel, session end, observation failure and Android-overlay baselines? That first needs a decision on whether the overlay suppression and the cancel and session-ended results belong on all of these routes; if not, they could be removed from the gesture route.

None of the earlier threads still applies, so they can be resolved: help now says the wait follows the final repetition; result map typing no longer includes swipe or gesture; open record types are gone from that map; outdated surface handling now matches generic settle; the swipe schema uses an enum; ADR 0013 now defines the behavior; and a failed observation now keeps the completed action result.

The cancelled Body rules job checks the PR body and is likely unrelated to the code change; the other 21 checks pass.

Not verified here: tests and device behavior were not run. The reported live run used 0e198907d0, which is not an ancestor of this head, and its match with this head was judged only from the diff of the gesture handler. The SDK swipe settle flags were not traced end to end, and no SDK or MCP swipe settle test was read. The skill routing-card requirement in #4571 was not checked. Whether generic scroll and back also need the Android-overlay suppression was not checked.

Before merge, Body rules needs a passing run. The two design choices above, shared settle ownership and the plain-gesture timeout policy, are open for a maintainer decision and do not block.

@thymikee

Copy link
Copy Markdown
Member Author

Body rules passed on 06c2698. All 21 checks are green at that head.

I’d keep the route adapters separate here. They already share baseline selection, the settle engine, and ref issuance. Back and scroll can bind capture after the action, while swipe and gesture reuse the gesture’s binding. Sharing the result projection also needs an explicit decision about how back and scroll should report cancellation, session end, and Android overlays. Expected observation failures already return an unsettled verdict. If the observation itself unexpectedly rejects, this PR returns the completed action result without inventing capture counts.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks, that settles both points at 06c2698. Body rules now passes, so all 21 checks are green. The design answer gives the reason to keep the route adapters separate: they already share baseline selection, the settle engine and ref issuance, and a shared result projection would first need a decision on how back and scroll report cancellation, session end and Android overlays. Nothing else blocks this review.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 25, 2026

This branch has not been deployed

No deployments
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.

Ref errors after --settle cost agents commands, and swipe/gesture reject --settle

1 participant