Skip to content

refactor: rename rotate command to orientation (rotate kept as deprecated alias)#1252

Open
thymikee wants to merge 2 commits into
mainfrom
fix/orientation-command-rename
Open

refactor: rename rotate command to orientation (rotate kept as deprecated alias)#1252
thymikee wants to merge 2 commits into
mainfrom
fix/orientation-command-rename

Conversation

@thymikee

Copy link
Copy Markdown
Member

Why

The top-level rotate command sets device orientation (portrait / landscape). That name collided with the gesture rotate two-finger rotation gesture — agent-device rotate landscape-left (rotate the screen) vs agent-device gesture rotate 35 … (rotate app content). This renames the orientation command to orientation and keeps rotate working as a minimal, silent alias for a few versions.

What

  • New canonical command: orientationagent-device orientation <portrait|portrait-upside-down|landscape-left|landscape-right>.
  • rotate → deprecated alias: one line in cli-command-aliases.ts, exactly the mechanism used by tappress / launchopen. It normalizes at CLI parse time (so everything internal only ever sees orientation) and is silent — it does not appear in --help.

Renamed across every layer so nothing is half-migrated:

Layer Before After
CLI command / daemon dispatch / registry name rotate orientation
Client SDK method client.command.rotate client.command.orientation
Runtime family device.system.rotate device.system.orientation
Result type / action RotateCommandResult / 'rotate' OrientationCommandResult / 'orientation'
Client options type RotateCommandOptions OrientationCommandOptions
Interactor + backend method rotate setOrientation
Android helper rotateAndroid setAndroidOrientation
Capability keys (Apple plugin / cloud-webdriver) rotate orientation
Docs (commands.md, client-api.md) rotate orientation (+ alias note)

Naming rationale (each layer follows its own existing convention):

  • Command + client method → orientation (client method = camelCase of the command name, matching back/home/appSwitcher/tvRemote).
  • Interactor + backend → setOrientation (imperative, matching the backend's setKeyboard/setClipboard/pressHome family and unambiguously not a gesture).

Deliberately unchanged (scoped, not oversights)

  • Swift runner wire protocol keeps command: 'rotate'. The runner has its own command namespace where rotate (orientation) and gesture are already distinct — no collision there. Renaming it would only risk CLI ↔ installed runner version skew on physical devices for zero user benefit. The Apple interactor's setOrientation() sends { command: 'rotate', … } with an inline comment; apple-runner/ is untouched.
  • DeviceRotation / parseDeviceRotation / DEVICE_ROTATIONS — these name the orientation values, don't collide, and renaming them is unrelated scope creep.
  • docs/agents/contract-projection-output-economy-spike.md — historical spike report (point-in-time record), left as-is.

⚠️ Breaking for SDK consumers (CLI stays compatible)

client.command.rotate / device.system.rotate and the RotateCommand* exported types are removed — the alias only rewrites CLI tokens, it does not add a client method. Node SDK consumers must switch to orientation. The JSON action value changes rotateorientation. CLI users are unaffected (rotate … still works via the alias).

Verification

  • typecheck, lint, check:layering, check:production-exports, check:mcp-metadata, check:tooling
  • ✅ Full unit suite green except 4 runtime-hints Android tests that hit live emulators on the dev machine (adb run-as) — outside this diff.
  • ✅ New/updated tests: end-to-end alias-dispatch test (rotate → daemon orientation) mirroring the tap convention; parser + usage + capability + dispatch + contract tests all moved to orientation; the true-alias regression guard now covers rotate.
  • ✅ Drove the real CLI: orientation shows in --help ("Set device orientation…"), orientation --help renders, and rotate silently resolves to it.
  • ✅ Independent adversarial review pass (its findings on the maintained website/docs are folded into this PR).

Closes the naming collision noted while reviewing #105.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.7 MB 1.7 MB +220 B
JS gzip 542.7 kB 542.8 kB +53 B
npm tarball 653.4 kB 653.4 kB +38 B
npm unpacked 2.3 MB 2.3 MB +270 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 29.5 ms 28.6 ms -0.9 ms
CLI --help 59.9 ms 60.4 ms +0.6 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/internal/daemon.js +41 B +15 B
dist/src/cli.js +39 B +14 B
dist/src/sdk-batch.js +5 B +5 B
dist/src/registry.js +44 B -4 B
dist/src/tv-remote.js +5 B +2 B

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://callstack.github.io/agent-device/pr-preview/pr-1252/

Built to branch gh-pages at 2026-07-14 06:13 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@thymikee

Copy link
Copy Markdown
Member Author

This branch is now conflicted with current main after #1243 merged. The semantic conflicts are in src/platforms/android/input-actions.ts and src/platforms/android/__tests__/input-actions.test.ts: preserve #1243's touch-executor/long-press refactor while renaming only the device-orientation function to setAndroidOrientation. Please rebase before review; current green checks predate resolution against the new main. No reviewer or fixer was dispatched.

thymikee added 2 commits July 14, 2026 08:11
…ecated alias

The top-level `rotate` command (device orientation: portrait/landscape) shared
a name with the `gesture rotate` two-finger rotation gesture. Rename the
orientation command to `orientation` and keep `rotate` working as a minimal,
silent CLI alias (same mechanism as `tap`->`press`) for a few versions.

The rename is applied across every layer:
- command-descriptor registry `name`, daemon dispatch handler, and the typed
  system facet (metadata/cliReader/daemonWriter/schema/output formatter)
- navigation projection + `CommandResultMap` (`OrientationCommandResult`,
  `action: 'orientation'`), client types (`OrientationCommandOptions`), and the
  runtime family (`device.system.orientation`)
- interactor + backend methods -> `setOrientation` (matching the backend's
  `setKeyboard`/`setClipboard` verb convention); Android helper
  `rotateAndroid` -> `setAndroidOrientation`
- Apple/cloud-webdriver capability keys and plugin gate
- user-facing docs (commands.md, client-api.md)

Client SDK method is `orientation` (client convention = camelCase of the
command name, matching `back`/`home`/`appSwitcher`); execution layers use the
imperative `setOrientation`.

Deliberately unchanged:
- the Swift runner wire protocol keeps `command: 'rotate'` — the runner has its
  own command namespace with no gesture collision, so renaming it would only
  risk CLI<->installed-runner version skew on physical devices
- the `DeviceRotation` value type / `parseDeviceRotation` (names the orientation
  values, no collision)

Note: `client.command.rotate` / `device.system.rotate` and the `RotateCommand*`
exported types are removed (the alias only rewrites CLI tokens); SDK consumers
must use `orientation`. The JSON `action` value changes `rotate` -> `orientation`.
@thymikee thymikee force-pushed the fix/orientation-command-rename branch from df0b1c6 to a4dd4ac Compare July 14, 2026 06:12
@thymikee

Copy link
Copy Markdown
Member Author

Rebased onto current main (past #1243). The only real conflict was the import block in src/platforms/android/__tests__/input-actions.test.ts; resolved by keeping #1243's set (longPressAndroid, no swipeAndroid) and applying only the orientation rename (rotateAndroidsetAndroidOrientation). src/platforms/android/input-actions.ts auto-merged correctly — #1243's touch-executor/longPress refactor is preserved and only the device-orientation function was renamed.

Re-verified on the new base: typecheck, lint, format:check, check:layering, check:production-exports, check:mcp-metadata all green; affected Android + orientation test files pass (147 tests). Ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant