Skip to content

Taps on a foldable simulator land on the panel in use #1535

Closed

Description

@V3RON

Part of #1531.

Scope

A lease holder's app that sends taps over WS /v1/leases/{id}/input to an iPhone Duo simulator has each tap land at its fraction of the panel in use, folded or unfolded, and keeps landing after a fold with the socket left open: the socket gets a new screen config naming the new panel's size. A one-panel device takes taps as today.

If it goes wrong, taps on a Duo miss (folded) or land turned a quarter (unfolded), or a client keeps the cover's size after an unfold.

Technical spec

Commit 84c85b1.

Rows

Behaviours: B8, B9, B10, B11
Interfaces: I5, I6, I7, I9
Existing code: X5, X6, X7, X8 (unchanged, confirm), X12 (the src/drivers/ios/input/AGENTS.md rule), X15 (PanelTouch.swift if split), X17

Facts

# Fact Source
F1 On an iOS 27.1 Duo, through today's helper: folded, target 0x32 lands nowhere; unfolded, 0x32 and 0x40000003 land turned (sent (0.2, 0.1) → (0.9, 0.2)); target 0x40000001 lands exactly on the cover; with the inner fraction sent as (v, 1 − u) to 0x40000003, (0.2, 0.1), (0.8, 0.3), (0.5, 0.9) landed exactly on the upright inner panel the spec session's tap run: /private/tmp/claude-501/-Users-aitwar--t3-worktrees-simlock-t3-ee5a475d-67e086bd42be8963/636e892f-9e78-4d1c-8677-025fb0eccee9/scratchpad/ unf3-32.png, folded-cover-target.png, patched-inner.png, patched-cover.png
F2 The tested patch (reverted after the run) is in the details below. It proves the targets and the turn only: it takes the panel from a panel field in the message, which the rows do not have; here the panel comes from the follower (I5, I6) and the touch stays {type, x, y} the tap run's helper.diff
F3 On an iPhone 17 Pro (iOS 26.5), target 0x32 lands (0.2, 0.1), (0.8, 0.3), (0.5, 0.9) exactly the tap run, ctl-iphone.png in the same folder
F4 A minimal touch-probe app (draws a dot, prints the fraction of its window) was built for the run app/ in the same folder
F5 The repo commits a built simulator app with its build commands as a fixture e2e/fixtures/appduct/README.md, e2e/fixtures/appduct/ios/AppductPlayground.app
F6 simctl get_app_container <udid> <bundle> data gives an app's data container xcrun simctl help get_app_container
F2: the patch the tap run tested
diff --git a/vendor/screen-capture/Sources/simlock-screen-capture/HIDInjector.swift b/vendor/screen-capture/Sources/simlock-screen-capture/HIDInjector.swift
index 934c83c9..622869e9 100644
--- a/vendor/screen-capture/Sources/simlock-screen-capture/HIDInjector.swift
+++ b/vendor/screen-capture/Sources/simlock-screen-capture/HIDInjector.swift
@@ -197,6 +197,22 @@ actor HIDInjector {
         if let msg = touchMessage(type: type, x: x, y: y, edge: edge) { rawSend(msg) }
     }
 
+    /// A Duo panel's digitizer: SimulatorKit targets screenID | 0x40000000. The cover (screen 1) reads
+    /// fractions upright; the inner (screen 3, nativeRotation 270) reads them in its sideways
+    /// framebuffer, so an upright (u, v) is sent as (v, 1 - u).
+    func sendPanelTouch(type: String, x: Double, y: Double, panel: String) {
+        let saved = touchTarget
+        defer { touchTarget = saved }
+        var px = x, py = y
+        switch panel {
+        case "cover": touchTarget = 0x4000_0001
+        case "inner": touchTarget = 0x4000_0003; px = y; py = 1 - x
+        default: return
+        }
+        guard let msg = touchMessage(type: type, x: px, y: py, edge: 0) else { return }
+        rawSend(msg)
+    }
+
     func sendTouch(type: String, x: Double, y: Double, screenWidth: Int, screenHeight: Int, edge: UInt32 = 0) {
         guard let msg = touchMessage(type: type, x: x, y: y, edge: edge) else { return }
         hidLog("[hid] Sending \(type) at (\(String(format:"%.3f",x)),\(String(format:"%.3f",y)))\(edge > 0 ? " edge=\(edge)" : "")")
diff --git a/vendor/screen-capture/Sources/simlock-screen-capture/InputMode.swift b/vendor/screen-capture/Sources/simlock-screen-capture/InputMode.swift
index f7811dd3..d86557eb 100644
--- a/vendor/screen-capture/Sources/simlock-screen-capture/InputMode.swift
+++ b/vendor/screen-capture/Sources/simlock-screen-capture/InputMode.swift
@@ -81,7 +81,11 @@ func runInput(udid: String) async -> Never {
         case tagTouch:
             guard let type = fields["type"] as? String,
                   let x = fields["x"] as? Double, let y = fields["y"] as? Double else { continue }
-            await injector.sendTouch(type: type, x: x, y: y, screenWidth: size.width, screenHeight: size.height)
+            if let panel = fields["panel"] as? String {
+                await injector.sendPanelTouch(type: type, x: x, y: y, panel: panel)
+            } else {
+                await injector.sendTouch(type: type, x: x, y: y, screenWidth: size.width, screenHeight: size.height)
+            }
         case tagKey:
             guard let type = fields["type"] as? String, let usage = fields["usage"] as? Int, usage >= 0 else { continue }
             await injector.sendKey(type: type, usage: UInt32(usage))

Modules touched

Searches: touchTarget, nativeScreenSizes(for: device).first, readConfig, onConfig, INPUT_TAG.config. vendor/screen-capture (InputMode.swift, HIDInjector.swift, the panel follower from the first task, its tests), src/drivers/ios/input/ (device-input.ts and its test), e2e/: adds e2e/fixtures/touch-probe/, extends e2e/slow-ios-foldable.test.ts (added by #1534); docs.

Rules in play

  • ADR 0075 §4: taps follow the same panel as the capture, through the same follower.
  • ADR 0049 §3: input speaks serve-sim's messages, positions stay fractions; a later 0x82 goes to every socket, which src/input/sessions.ts:135-138 already does.
  • src/drivers/ios/input/AGENTS.md: the open still waits for the first size frame within READY_DEADLINE_MS; the rule "the config is … sent once" is rewritten.
  • vendor-and-third-party-code.md rules 6 and 11: a new Swift file is listed in NOTICE.md.
  • documentation.md rule 9: watching-the-screen.mdx's input section (:152, :169, :184) changes in this PR.
  • testing.md rule 3: a tap's landing is tested at the input route in the slow lane; the mapping at its Swift seam; the config handoff at the driver's device input with a fake helper.

Tests

Seam: swift test --package-path vendor/screen-capture for B9, src/drivers/ios/input/device-input.test.ts (existing) for B10, and e2e/slow-ios-foldable.test.ts (from the first task) for B8.

  • B8: a lease holder's taps on a leased Duo with the touch-probe app in front, read from touches.txt within 0.02: folded (0.2, 0.1), (0.8, 0.3), (0.5, 0.9) → those points of the cover; unfolded → those points of the upright inner panel; unfolded after a fold with the socket left open → the same; an iPhone 16 → those points, in its own describe that needs only the iOS check.
  • B11: the input helper's log children end with it: stdin closed; SIGTERM; SIGKILL; each within 5 s.
  • B9: a fraction to a touch: cover → 0x40000001, (u, v); inner → 0x40000003, (v, 1 − u); one panel → 0x32, (u, v); the corners (0, 0) and (1, 1) on each.
  • B10: a socket left open across a fold: a second size frame → the device input's onConfig listeners get it; a listener added later gets the latest; the same size again → nothing; a malformed later frame → kept config, one warn.

Done when

  • swift test --package-path vendor/screen-capture passes with B9 in it.
  • pnpm test:changed passes, with B10 in src/drivers/ios/input/device-input.test.ts.
  • Slow lane, iOS foldable (toolchain.md row, added by A foldable simulator's stream shows the panel in use and switches on a fold #1534): scripts/slow-e2e.sh e2e/slow-ios-foldable.test.ts passes, with no case skipped (B8 on the Duo, B11).
  • Slow lane, iOS: the iPhone 16 case of B8 in e2e/slow-ios-foldable.test.ts passes (scripts/slow-e2e.sh e2e/slow-ios-foldable.test.ts).
  • e2e/fixtures/touch-probe/ holds the app's source, its README with the build commands, and the built .app.
  • website/src/content/docs/docs/using-devices/watching-the-screen.mdx, src/drivers/ios/input/AGENTS.md and vendor/screen-capture/NOTICE.md say what the rows say.

Out of scope

  • Multi-touch, scroll and edge gestures on the inner panel are sent through the same mapping, but are not checked here.
  • Keys, Home and rotation on a Duo (as today).

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    platform:ios
    on Nov 11, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Nov 11, 2026
  3. self-assigned this
    on Nov 15, 2026
  4. V3RON commented on Nov 15, 2026

    @V3RON
    ContributorAuthor

    Handoff

    Done: build, audit, review rounds 1 and 2 (R1–R6 fixed, round 2 clean) on PR #1559. A second audit added 7384c19 (stricter B10 bound cases), and its fix-check passed with no findings. Unit and Swift tests pass. Stack linked: #1532 → #1536 → #1559. The PR is ready and labelled needs-hardware.

    Not done: the slow lane. e2e/slow-ios-foldable.test.ts (B8 on the Duo and iPhone 16, B11, the touch-probe install) never ran, and the gate has not run.

    Findings: none open. One review note is posted on the PR.

    Blocked on: disk. 14 GiB is free and the lane needs 15. Free about 1 GiB, or approve SIMLOCK_SLOW_MIN_FREE_GIB=10 for this run, then run scripts/slow-e2e.sh e2e/slow-ios-foldable.test.ts on 7384c19. On a pass, flip ADR 0075 to Accepted and merge the stack.

    Written by an agent.

  5. removed their assignment
    on Nov 15, 2026
  6. added
    task:blocked
    and removed
    task:ready
    on Nov 15, 2026
  7. added
    task:ready
    and removed
    task:blocked
    on Nov 15, 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

    platform:iostask:ready

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions