From 81c71c6cbb8d0044d89a8e2a755bbd922d3ed3f0 Mon Sep 17 00:00:00 2001 From: Badcuban <108198679+badcuban@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:26:02 -0500 Subject: [PATCH] fix(devices): list the iPhone Duo and draw its cover's camera hole where it is The iPhone Duo runs on a runtime made for it (iOS-27-2-iPhone19-4), and the never-booted simulator listing only accepted plain iOS-27-2 names, so a fresh Duo never appeared in the Device tab. The listing now accepts a model suffix and still reports iOS 27.2. The Duo's cover was drawn with the iPhones' centered Dynamic Island; the real cover has a round camera hole near the top right. Measured on the live simulator and drawn there. --- apps/server/src/device/DeviceHubOperations.test.ts | 8 ++++++++ apps/server/src/device/DeviceHubOperations.ts | 10 ++++++++-- apps/web/src/components/device/DeviceBody.tsx | 10 +++++++++- apps/web/src/components/device/deviceShapes.ts | 13 +++++++++++-- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/apps/server/src/device/DeviceHubOperations.test.ts b/apps/server/src/device/DeviceHubOperations.test.ts index f3c1fd489..5965b0ec6 100644 --- a/apps/server/src/device/DeviceHubOperations.test.ts +++ b/apps/server/src/device/DeviceHubOperations.test.ts @@ -52,6 +52,12 @@ describe("DeviceHubOperations list", () => { devices: [ { device: "aaaa-1", name: "iPhone 17", runtime: "iOS-27-2", state: "Booted" }, { device: "BBBB-2", name: "iPhone 17e", runtime: "iOS-27-2", state: "Shutdown" }, + { + device: "DDDD-4", + name: "iPhone Duo", + runtime: "iOS-27-2-iPhone19-4", + state: "Shutdown", + }, { device: "CCCC-3", name: "Apple Watch", runtime: "watchOS-12-0", state: "Shutdown" }, ], }, @@ -71,6 +77,8 @@ describe("DeviceHubOperations list", () => { expect(listed.devices.map((device) => [device.id, device.version, device.booted])).toEqual([ ["AAAA-1", "iOS 27.2", true], ["BBBB-2", "iOS 27.2", false], + // A runtime made for one model (the iPhone Duo's) is still iOS 27.2. + ["DDDD-4", "iOS 27.2", false], ]); }).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer)), ); diff --git a/apps/server/src/device/DeviceHubOperations.ts b/apps/server/src/device/DeviceHubOperations.ts index 457317acc..07aec9791 100644 --- a/apps/server/src/device/DeviceHubOperations.ts +++ b/apps/server/src/device/DeviceHubOperations.ts @@ -55,6 +55,9 @@ const HubDeviceList = Schema.Struct({ Schema.Array(Schema.Struct({ message: Schema.String, error: Schema.optional(Schema.String) })), ), }); +/** An iOS simulator runtime's name: its version, then a model for a device-specific build. */ +const IOS_RUNTIME = /^iOS-(\d+(?:-\d+)*)(?:-[A-Za-z][A-Za-z0-9-]*)?$/; + /** serve-sim's grid inventory, which, unlike `/api/devices`, includes simulators never booted. */ const IosGridDeviceList = Schema.Struct({ devices: Schema.Array( @@ -423,11 +426,14 @@ export const makeDeviceHubOperations = (options: DeviceHubOperationsOptions): De (listed) => listed.platform === "ios" && listed.id.toUpperCase() === device.device.toUpperCase(), ); - if (known || !/^iOS-\d+(?:-\d+)*$/.test(device.runtime)) continue; + // `iOS-27-2`, or a runtime made for one model, such as the iPhone + // Duo's `iOS-27-2-iPhone19-4`. + const iosVersion = IOS_RUNTIME.exec(device.runtime)?.[1]; + if (known || iosVersion === undefined) continue; devices.push({ id: device.device, name: device.name, - version: device.runtime.replace("iOS-", "iOS ").replaceAll("-", "."), + version: `iOS ${iosVersion.replaceAll("-", ".")}`, platform: "ios", booted: device.state === "Booted", physical: false, diff --git a/apps/web/src/components/device/DeviceBody.tsx b/apps/web/src/components/device/DeviceBody.tsx index 4e35b2d29..f3c2455a2 100644 --- a/apps/web/src/components/device/DeviceBody.tsx +++ b/apps/web/src/components/device/DeviceBody.tsx @@ -1,5 +1,6 @@ import type { CSSProperties, ReactNode } from "react"; +import { cn } from "~/lib/utils"; import { type BodyBox, DEVICE_BUTTON_DEPTH, type QuarterTurn } from "./deviceFrameLayout"; import type { DeviceBody } from "./deviceShapes"; @@ -175,11 +176,18 @@ export function DeviceBodyView(props: { ) : cutout?.kind === "punch" ? ( ) : null} diff --git a/apps/web/src/components/device/deviceShapes.ts b/apps/web/src/components/device/deviceShapes.ts index be31e5807..297ebafb7 100644 --- a/apps/web/src/components/device/deviceShapes.ts +++ b/apps/web/src/components/device/deviceShapes.ts @@ -25,7 +25,13 @@ export type DeviceCutout = readonly top: number; } | { readonly kind: "notch"; readonly width: number; readonly height: number } - | { readonly kind: "punch"; readonly diameter: number; readonly top: number }; + | { + readonly kind: "punch"; + readonly diameter: number; + readonly top: number; + /** The hole's center from the screen's left edge; centered when left out. */ + readonly centerX?: number; + }; export interface DeviceBody { /** The screen, upright. The simulator's reported aspect replaces `height` when it differs. */ @@ -142,7 +148,10 @@ const DUO_COVER: DeviceBody = { { edge: "top", offset: 316, length: 66 }, { edge: "right", offset: 202, length: 113 }, ], - cutout: ISLAND, + // A round camera hole near the top right, as the simulator draws it into the + // cover's framebuffer (measured on iOS 27.2 24B91016s: 111 px across, centered + // at 1254 × 143 px of 1398 × 2034, at 3x), not the iPhones' island. + cutout: { kind: "punch", diameter: 37, top: 29.2, centerX: 418 }, }; const DUO_INNER: DeviceBody = { screen: { width: 951, height: 669 },