Skip to content

Commit b6952a1

Browse files
thymikeeclaude
andcommitted
refactor(kernel): read the Action Button leaf from isHandheldAppleDevice
hasAppleActionButton repeated isHandheldAppleDevice without its Apple-family gate. Its callers are the Apple navigation runtime and the provider fixture that mirrors it, so they read the same rule now and the duplicate goes away. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 21f3f50 commit b6952a1

3 files changed

Lines changed: 15 additions & 28 deletions

File tree

‎packages/kernel/src/device.ts‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,6 @@ export function resolveDeviceAppleOs(
288288
return 'ios';
289289
}
290290

291-
/**
292-
* The Apple leaves that carry a physical Action Button: iPhone and iPad, in a simulator or on
293-
* hardware. tvOS and visionOS have no such control. Which *model* inside an admitted leaf has one
294-
* is not something `DeviceInfo` records — discovery fills platform, kind, and Apple OS, never a
295-
* model identifier — so a runner answers that with `XCUIDevice.hasHardwareButton(.action)`.
296-
*/
297-
export function hasAppleActionButton(
298-
device: Pick<DeviceInfo, 'platform' | 'target' | 'appleOs'>,
299-
): boolean {
300-
const appleOs = resolveDeviceAppleOs(device);
301-
return appleOs === 'ios' || appleOs === 'ipados';
302-
}
303-
304291
/**
305292
* @internal Type guard exposed for unit tests.
306293
*/

‎packages/platform-apple/src/navigation/runtime.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { systemButtonRuntimeOperationFacts } from '@agent-device/contracts/syste
88
import { tvRemoteRuntimeOperationFacts } from '@agent-device/contracts/tv-remote-runtime';
99
import { tvRemoteButtonsForPlatform } from '@agent-device/contracts/tv-remote';
1010
import {
11-
hasAppleActionButton,
11+
isHandheldAppleDevice,
1212
isTvOsDevice,
1313
resolveDeviceAppleOs,
1414
type DeviceInfo,
@@ -149,15 +149,15 @@ const actionButtonOsUnavailable = Object.freeze({
149149
hint: 'The Action Button is iPhone and iPad hardware; tvOS, macOS, watchOS and visionOS have no such control.',
150150
} as const);
151151
/**
152-
* The leaf reading is {@link hasAppleActionButton}, the same rule a provider owner reads; what this
153-
* owner adds is its kind gate. The leaf is the whole claim: which model inside it carries the button
154-
* is a hardware question the runner answers with `hasHardwareButton(.action)`, never a guess here.
155-
* iPhone and iPad is deliberately not {@link appleMobileInputEligible}, which is `orientation`'s
156-
* reading and admits visionOS — a headset has a Digital Crown and no Action Button.
152+
* The leaf reading is {@link isHandheldAppleDevice}, the same rule a provider owner reads; what
153+
* this owner adds is its kind gate. `DeviceInfo` records no model identifier, so which iPhone or
154+
* iPad carries the button is a hardware question the runner answers with
155+
* `hasHardwareButton(.action)`. iPhone and iPad is deliberately not
156+
* {@link appleMobileInputEligible}, which is `orientation`'s reading and admits visionOS.
157157
*/
158158
function appleActionButtonFact(device: DeviceInfo): RuntimeOperationFact {
159159
if (device.kind !== 'simulator' && device.kind !== 'device') return actionButtonKindUnavailable;
160-
return hasAppleActionButton(device) ? available : actionButtonOsUnavailable;
160+
return isHandheldAppleDevice(device) ? available : actionButtonOsUnavailable;
161161
}
162162

163163
const volumeButtonOsUnavailable = Object.freeze({
@@ -173,11 +173,11 @@ const volumeButtonSimulatorUnavailable = Object.freeze({
173173
/**
174174
* `XCUIDevice.press(.volumeUp/.volumeDown)` is simulator-unavailable in the XCUITest header, so
175175
* the local runner presses volume on a physical iPhone or iPad only. The iPhone/iPad leaf read is
176-
* {@link hasAppleActionButton}; tvOS, macOS, watchOS and visionOS have no volume key to press and
177-
* hear that refusal, not the simulator one (#3848 review).
176+
* {@link isHandheldAppleDevice}; tvOS, macOS, watchOS and visionOS have no volume key to press and
177+
* hear that refusal, not the simulator one.
178178
*/
179179
function appleVolumeButtonFact(device: DeviceInfo): RuntimeOperationFact {
180-
if (!hasAppleActionButton(device)) return volumeButtonOsUnavailable;
180+
if (!isHandheldAppleDevice(device)) return volumeButtonOsUnavailable;
181181
if (device.kind !== 'device') return volumeButtonSimulatorUnavailable;
182182
return available;
183183
}

‎test/integration/provider-scenarios/provider-device-runtime.fixtures.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import type {
4646
} from '@agent-device/contracts/platform-runtime-operations';
4747
import { bindAdmittedProviderInteractorOperations } from '@agent-device/contracts/interactor-operation-catalog';
4848
import { unavailableDeploymentSnapshotAndShutdownOperationFacts } from '@agent-device/test-kit';
49-
import { deviceShape, hasAppleActionButton, type DeviceInfo } from '@agent-device/kernel/device';
49+
import { deviceShape, isHandheldAppleDevice, type DeviceInfo } from '@agent-device/kernel/device';
5050
import { AppError } from '@agent-device/kernel/errors';
5151
import { createProviderScenarioHarness } from './harness.ts';
5252

@@ -269,16 +269,16 @@ function providerScenarioRuntimeFacts(
269269
// The press rides the same interactor transport as every other catalog operation, but the
270270
// hardware exists on the iPhone/iPad leaf only, so the fixture reads the same kernel rule the
271271
// Apple owner's fact reads instead of restating it (#2699).
272-
actionButton: hasAppleActionButton(device) ? fakeProviderAvailable : fakeProviderUnavailable,
272+
actionButton: isHandheldAppleDevice(device) ? fakeProviderAvailable : fakeProviderUnavailable,
273273
// The hardware-button volume press rides the same runner transport, and the XCUITest
274274
// volume key exists on a physical iPhone/iPad only, so the fixture reads the same kind and
275-
// leaf rule the Apple owner's fact reads (#3848). No Apple leaf presses power.
275+
// leaf rule the Apple owner's fact reads. No Apple leaf presses power.
276276
volumeUp:
277-
device.kind === 'device' && hasAppleActionButton(device)
277+
device.kind === 'device' && isHandheldAppleDevice(device)
278278
? fakeProviderAvailable
279279
: fakeProviderUnavailable,
280280
volumeDown:
281-
device.kind === 'device' && hasAppleActionButton(device)
281+
device.kind === 'device' && isHandheldAppleDevice(device)
282282
? fakeProviderAvailable
283283
: fakeProviderUnavailable,
284284
power: fakeProviderUnavailable,

0 commit comments

Comments
 (0)