Skip to content

orientation: a foldable in a scoped simulator set is refused, and the fold helper's rotate lands one command late #4343

Closed

Description

@sittingmongoose

Summary

orientation <portrait|landscape-left|landscape-right> on a foldable iOS simulator in a scoped simulator set (the set simlock leases into) is refused before anything is sent:

Error (UNSUPPORTED_OPERATION): <device> cannot rotate in a scoped simulator set
Hint: CoreDevice resolves only simulators in the default device set, so the rotation of a foldable simulator in a scoped set cannot be verified. Rotate it in the default device set.

So an agent driving a leased iPhone Duo can fold and unfold it, but cannot see the unfolded screen upright (portrait). fold closed|half-open|open works in the same set.

Environment

  • agent-device 0.21.35 (also present in 0.21.31), driven through simlock 0.4.0
  • macOS 27.3 arm64, Xcode 27.3 (27C5020n), iPhone Duo simulator, iOS 27.3

What we found

  • The refusal is the simulatorSetPath guard at the top of the foldable rotation path (the function that calls the fold helper's rotate and then polls devicectl device orientation get). Only the verification needs CoreDevice. The dispatch goes through the fold helper (simctl spawn <udid> <helper> rotate <orientation>), which already honours the scoped set; that is why fold works there.
  • A local patch that, in a scoped set, sends the rotation through the fold helper and confirms it from the fold helper's panel table (currentOrientation: rot0/rot90/rot180/rot270) instead of CoreDevice does rotate the device: after unfolding, the screen went from 951 x 669 (landscape) to 669 x 951 (portrait).
  • But the rotation lands one command late: after the first orientation portrait the screen stayed landscape and the panel table still read landscape-right; the next orientation landscape-left produced the portrait screen, and the panel table then read portrait. A second orientation landscape-left again reported the previous value. It looks like the orientation HID event is only applied when the next event arrives. A workaround we are testing is to dispatch the same rotation twice, about 400 ms apart.

Expected

In a scoped set, a foldable rotates on the first command, and the command confirms the new orientation from a source that works in that set (the fold helper's panel table), or says plainly that it was sent but could not be confirmed.

Suggested fix

  1. Replace the up-front refusal for simulatorSetPath with: dispatch through the fold helper, then confirm from the panel table (it already reports currentOrientation).
  2. Find out why the orientation event is applied one event late (flush after the rotate, or follow it with a no-op event), so one command is enough.

Activity

  1. sittingmongoose commented on Nov 8, 2026

    @sittingmongoose
    ContributorAuthor

    Update after testing the workaround: dispatching the same rotation twice (about 400 ms apart) does not fix the lag. The second dispatch sometimes fails with Unable to send the simulator orientation (reason orientation-hid-dispatch-failed), and the screen still shows the orientation from the previous command. A tap after the rotate did not apply it either in one try (standalone web app in front). The panel table's currentOrientation also tracks one step behind, and once read portrait-upside-down while the screen was upright portrait (669 x 951), so the rotN mapping for the Duo's inner panel may differ from the outer one. We reverted to a single dispatch.

  2. sittingmongoose commented on Nov 8, 2026

    @sittingmongoose
    ContributorAuthor

    Root cause found and fixed locally (agent-device 0.21.35, iPhone Duo, iOS 27.3, Xcode 27.3):

    1. The orientation picker value is relative, not absolute. Each orientation-picker-control event rotates the lit display by (new value - previous value). On the Duo's inner panel the screen orientation equals the picker value plus 90 degrees. Measured over 7 transitions including 180-degree flips. That is why a rotation appeared to land one command late and why repeating the same value did nothing.
    2. The upside-down picker value is spelled pud on the wire. portrait-upside-down is ignored. (The same token appears in serve-sim's Duo HID code.)

    Local fix: the fold helper maps portrait-upside-down to pud. The scoped-set rotation path reads the panel table's currentOrientation, dispatches the picker value that produces the needed delta, and re-reads until it matches, so CoreDevice is not needed. Verified on a fresh scoped-set lease: after fold open, orientation portrait gives 669 x 951 on the first command (exit 0), landscape-left and landscape-right give 951 x 669 (panel rot270 / rot90), and a repeated portrait is a no-op success.

    Ruled out on the device: devicectl (cannot see a scoped set), Purple GSEvent orientation from guest and host (sent, no effect on the Duo), guest accelerometer HID, and hinge nudges.

  3. added
    bug
    on Nov 9, 2026
  4. thymikee commented on Nov 9, 2026

    @thymikee
    Member

    Triage: bug; actionable without more input from you. Confirmed on main: the simulatorSetPath guard in packages/platform-apple/src/foldable/orientation.ts refuses before dispatch, although the fold helper already works in a scoped set. Thanks for the measurements: a relative orientation-picker-control value and the pud spelling explain the one-command lag. An agent can pick this up, and a PR with your local fix would also work. It needs the delta dispatch, confirmation from the panel table, and a re-read until the orientation matches.

  5. added
    in-progress
    on Nov 11, 2026
  6. thymikee commented on Nov 11, 2026

    @thymikee
    Member

    We started on this and stopped where your measurements end. The picker value is relative, and you measured the inner panel's offset (screen = picker + 90°), but we don't have the outer panel's offset, or what happens to the relationship when the active panel changes. Guessing those could rotate to the wrong orientation. Since you already have a local fix verified on a scoped-set lease, a PR with it would be the fastest path. If that's not possible, please post the outer-panel offset and one transition across a fold/unfold, measured the same way, and we'll implement from that.

  7. removed
    in-progress
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions