Skip to content

feat(shake): add a shake command for iOS simulators and Android emulators - #4741

Merged
thymikee merged 5 commits into
callstack:mainfrom
forever8896:feat/shake
Nov 20, 2026
Merged

thymikee merged 5 commits into
callstack:mainfrom
forever8896:feat/shake

Conversation

@forever8896

@forever8896 forever8896 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a shake command to the CLI, Node client and MCP. e2e needs it for device.shake() (e2e-inc/e2e#1855), where it was asked to land here first.

  • iOS simulator: posts com.apple.UIKit.SimulatorShake through simctl spawn <udid> notifyutil -p, as Device > Shake does. It carries no accelerometer data, so CoreMotion detectors don't see it.
  • Android emulator: ten ±2 g accelerometer swings through the emulator console, then the reading it found.
  • Physical devices, Android TV, tvOS, macOS, web, Linux and remote providers refuse before dispatch.
agent-device shake
await client.command.shake();

54 files. The Android failure reasons come from a typed table (R89). Scope expansion: the session-journal summaries of argumentless system commands now come from one table, which keeps Fallow complexity under the threshold.

Validation

Tested c22b8c1ec on de36d03b7 (rebased onto main), with the branch-built CLI.

  • pnpm check:affected --run --head c22b8c1ec: 43 checks passed, exactCommit: true (Linux).
  • Android emulator, API 35, at af6d39aca (one docs sentence and a rebase since): three shakes moved a shake-detecting app's counter 0→1→2→3; the rest reading was unchanged afterwards.

Recorded at 0ab11ff92, not rerun:

  • Pixel 10a, Android 17: refused with unsupported-device-kind, dispatched: no.
  • iOS 26.2 simulator on a GitHub-hosted Intel Mac: an app counting motionEnded(.motionShake) went 0→1→2→3 (job).

Risks:

  • Apple silicon is not shown end to end (runs at 0ab11ff92). On the hosted macos-26-arm64 image (iOS 26.5) the raw simctl call shook the app (run), but three agent-device attempts timed out: twice inside open, once in shake's 10 s simctl call.
  • The physical iPhone refusal is unit-tested only.
  • CI has not run on this head.

🤖 Generated with Claude Code


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

View guided diff

@forever8896

Copy link
Copy Markdown
Contributor Author

A note on how the iOS evidence was produced:

I'm on Linux with no Mac, so the simulator runs come from GitHub-hosted macOS runners on a branch of my fork (shake-ios-evidence).

It builds this branch's CLI, compiles a tiny app that counts motionEnded(.motionShake), and asserts the counter after each agent-device shake.

The Intel image passes; on the Apple-silicon image the session start times out, as described under Risks. Happy to rerun anything there, or drop in a check you'd rather see

@forever8896 forever8896 changed the title feat: shake an iOS simulator or Android emulator feat(shake): add a shake command for iOS simulators and Android emulators Nov 19, 2026
@thymikee

Copy link
Copy Markdown
Member

Thanks! The code in 0ab11ff looks good, with no changes needed. No conflicts are known. Repository CI has not run on this head yet because the fork workflow needs approval, so it must run and pass before merge. The Android, Pixel 10a and Intel iOS simulator runs in the description are your own reports.

Not blocking, and you can take or leave each: the Apple silicon simulator was not shown end to end (one hosted run hit the 10 s timeout on simctl spawn notifyutil in shake.ts, so a maintainer should run open <app> and shake on a local Apple silicon simulator before approval); the cancellation test at console-shake.test.ts could assert the abort reason instead of a bare .rejects.toThrow(); system-button-runtime.ts could derive the Android cells positively from the hardware button vocabulary instead of excluding non-key members; and after restore, does a rotation still change sensor get acceleration on an emulator, given console-shake.ts leaves an explicit console override in place?

@forever8896

Copy link
Copy Markdown
Contributor Author

Thanks for the quick look. On the rotation question: yes, the reading still follows the device afterwards. On the API 35 emulator at 0ab11ff, sensor get acceleration reads 0:9.81:0 before and after shake, -9.81:-1.9e-06:0 after adb emu rotate, and 0:9.81:0 again once rotated back.

I'll leave the head where it is so CI and the Apple silicon run are against the commit you reviewed. Happy to send the abort-reason assertion and the positive Android cell derivation as a follow-up, or push them here if you'd rather have them in this PR.

@thymikee

Copy link
Copy Markdown
Member

This branch now conflicts with main after recent merges. Please rebase onto main; the earlier review points still apply, and the next review will cover the rebased head.

@thymikee

Copy link
Copy Markdown
Member

Thanks for the update. At af6d39a the earlier conflict is resolved. One docs issue remains.

website/docs/docs/commands.md:150 says that on shake-console-refused the reading found at the start is put back. The code does not always do that. If the console refuses the final restore (console-shake.ts:56), the emulator stays at the last swing reading. If the swing-failure restore at :53 also fails, that error is swallowed. Both cases report the same reason. If the refusal comes from the initial sensor get (:64), no reading was found, so there is nothing to put back. An agent that reads this reason will think the emulator is at rest, when it may still have a tilted accelerometer override. Please change the sentence to the rule the code follows: a restore of the starting reading is attempted after a refused swing, and when the refusal is on the initial read, dispatched: no and nothing changed. Reporting the restore failure as its own detail would also work, but the wording fix is enough.

Apple silicon end to end is still not shown, which is the earlier non-blocking note. The delta does not touch the iOS shake path. The Android live run and local check:affected are from your report. The one reported check passes, but repository CI has not run on this fork head because it needs workflow approval. Once the docs sentence is fixed, repository CI has to run and pass on the fork head before merge.

forever8896 and others added 5 commits November 20, 2026 13:23
Add `agent-device shake` and `client.command.shake()`. On an iPhone or
iPad simulator the Apple owner posts the notification that the Simulator
app's Device > Shake menu posts
(`simctl spawn <udid> notifyutil -p com.apple.UIKit.SimulatorShake`),
which UIKit delivers to the app as a motion-shake event. It injects no
accelerometer data.

`shake` joins the system-button family as one more argumentless cell
that returns nothing, so it adds a row to the family table instead of a
module, a dispatcher arm and a conformance entry. It is served by host
simctl and never waits for the XCTest runner. The result reports that
the shake was sent; what the app did with it is not observed.

Physical iPhones and iPads refuse with `unsupported-device-kind`, the
other Apple leaves with `unsupported-platform-leaf`, and a
provider-owned simulator with `unsupported-provider-mode`, because the
shake is posted by simctl on the daemon host. Android and WebDriver
state their own refusals. Every other owner takes its family denial.

The session journal's fixed summaries for the argumentless system
commands move to one table, which keeps `buildStructuredActionSummary`
under the complexity threshold. The perf suite does not time `shake`,
because the fixture handles none.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`agent-device shake` now also works on an Android emulator. The Android
owner overrides the accelerometer through the emulator console
(`adb emu sensor set acceleration`): ten swings of about 2 g in
alternating directions along the screen's X axis, 80 ms apart, then the
reading it found. A detector that counts direction changes above a force
threshold, as React Native's dev-menu detector does, sees one shake.

The rest reading is restored even when the swings are cancelled or the
console refuses one. A console refusal fails with `COMMAND_FAILED`,
`reason: shake-console-refused`; an unreadable rest reading fails before
any swing with `reason: shake-rest-acceleration-unreadable`. Physical
Android devices refuse with `unsupported-device-kind`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…lure

A TV emulator was admitted by kind alone; it now refuses like the other
handheld-only cells. A console that refuses the rest reading reports
dispatched: no, and a restore that fails after a refused or cancelled
swing no longer replaces that error. Help and docs state the measured
duration and name the provider devices that refuse.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
R89 (callstack#4779) requires a wire-published error reason to come from a declared
table. The two shake reasons now live in SHAKE_FAILURES, and commands.md
documents both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A refused swing is followed by an attempted, unconfirmed restore; a refusal
on the initial read dispatched nothing.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@forever8896

Copy link
Copy Markdown
Contributor Author

You're right, that sentence claimed more than the code does. Fixed in c22b8c1 with the rule you gave:

shake-console-refused means the console refused an accelerometer command, and consoleReason carries its reply. When the refusal is on the initial read, dispatched: no is set and nothing changed. After a refused swing, a restore of the starting reading is attempted but not confirmed, so read adb emu sensor get acceleration before relying on the emulator being at rest.

Wording only; reporting the restore failure as its own detail is a follow-up I can send if you want it.

The head is rebased onto de36d03 and check:affected passes there (43 checks, exactCommit: true). The Android emulator run in the description is from af6d39a; the only changes since are this sentence and the rebase. Apple silicon is still not shown end to end, and CI still needs the workflow approval.

@thymikee

Copy link
Copy Markdown
Member

This PR is ready for maintainer review at c22b8c1. The shake-console-refused sentence in commands.md now matches the code: a refusal on the initial read sets dispatched: no and changes nothing, and after a refused swing the restore is attempted but not confirmed, with the command to check the reading. Nothing else changed in the patch since af6d39a apart from the rebase. Repository CI has not run on this head yet because the workflow run needs maintainer approval, so it still has to run and pass before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee
thymikee merged commit c98eee1 into callstack:main Nov 20, 2026
14 checks passed
thymikee added a commit that referenced this pull request Nov 20, 2026
* origin/main:
  fix(daemon-client): report a newer daemon that won a startup race as daemon-incompatible (#4801)
  feat(shake): add a shake command for iOS simulators and Android emulators (#4741)
thymikee added a commit that referenced this pull request Nov 20, 2026
* origin/main:
  refactor(apple-runner): generate the Swift runner error-code enums from runner-contract.ts (#4810)
  fix(daemon-client): report a newer daemon that won a startup race as daemon-incompatible (#4801)
  feat(shake): add a shake command for iOS simulators and Android emulators (#4741)
  fix(daemon): give a closing daemon its full teardown before anything kills it (#4806)
  fix(android): use typed evidence in the readiness boot poller (#4717)
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.

2 participants