From d054a39165aa61305471ef12dce00a7be7fb16c3 Mon Sep 17 00:00:00 2001 From: parbez Date: Mon, 23 Nov 2026 18:22:13 +0530 Subject: [PATCH 1/4] fix(settings): keep a parse refusal's typed details and hint on the daemon route Positionals sent straight to the daemon, such as permission deny notifications com.example.app, came back with only the code and message, so the caller lost setting_permission_app_positional and the --app hint that the CLI route shows. Normalize the AppError the way other daemon handlers do. --- .../snapshot-settings-handler.test.ts | 29 +++++++++++++++++++ .../execution/handlers/snapshot-settings.ts | 4 +-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/daemon/src/execution/handlers/__tests__/snapshot-settings-handler.test.ts b/packages/daemon/src/execution/handlers/__tests__/snapshot-settings-handler.test.ts index 5c5ec6890d..caf08db492 100644 --- a/packages/daemon/src/execution/handlers/__tests__/snapshot-settings-handler.test.ts +++ b/packages/daemon/src/execution/handlers/__tests__/snapshot-settings-handler.test.ts @@ -392,6 +392,35 @@ test('settings usage hint documents canonical faceid states', async () => { } }); +// Positionals sent straight to the daemon skip the CLI reader, so the parse refusal must keep its +// typed details and --app hint on this route too. +test('settings permission with an app id in the mode slot keeps the --app hint', async () => { + const sessionStore = makeSessionStore(); + const response = await handleSnapshotCommands({ + createCommandSurface: fakeCreateCommandSurface, + platformServices: daemonPlatformServicesFixture(), + req: snapshotRequest('default', 'settings', { + positionals: ['permission', 'deny', 'notifications', 'com.example.app'], + }), + sessionName: 'default', + logPath: '/tmp/daemon.log', + sessionStore, + }); + + expect(response?.ok).toBe(false); + expect(fixtureSettingsMutations).toHaveLength(0); + if (response && !response.ok) { + expect(response.error.code).toBe('INVALID_ARGS'); + expect(response.error.hint).toBe('Pass the app with --app com.example.app.'); + expect(response.error.details).toMatchObject({ + reason: 'setting_permission_app_positional', + dispatched: 'no', + permission: 'notifications', + app: 'com.example.app', + }); + } +}); + // #3179: an app-scoped change can name an app the session never opened. The app rides the request // input; the owner receives it as the resolved app id whether or not a session is bound. test('settings permission grant targets an explicit app with no session app bound', async () => { diff --git a/packages/daemon/src/execution/handlers/snapshot-settings.ts b/packages/daemon/src/execution/handlers/snapshot-settings.ts index 22e53771aa..56b1befa2d 100644 --- a/packages/daemon/src/execution/handlers/snapshot-settings.ts +++ b/packages/daemon/src/execution/handlers/snapshot-settings.ts @@ -30,7 +30,7 @@ import { recordSessionAction } from '../../core/session-action-recorder.ts'; import { expireRefFrame } from '../../core/ref-frame.ts'; import { emitDiagnostic } from '@agent-device/host-kit/diagnostics'; import { readLocationCoordinate } from '@agent-device/kernel/location-coordinates'; -import { AppError, sessionAppRequiredDetails } from '@agent-device/kernel/errors'; +import { AppError, normalizeError, sessionAppRequiredDetails } from '@agent-device/kernel/errors'; import { successText, withSuccessText } from '@agent-device/kernel/success-text'; import type { @@ -74,7 +74,7 @@ export function parseSettingsArgs( return { ok: true, parsed: { leg: 'write', args: parseSettingsMutation(positionals) } }; } catch (error) { if (!(error instanceof AppError)) throw error; - return errorResponse(error.code, error.message); + return { ok: false, error: normalizeError(error) }; } } From b76d36230aa7946dd2a0452d95787ac108f5595e Mon Sep 17 00:00:00 2001 From: parbez Date: Mon, 23 Nov 2026 18:22:13 +0530 Subject: [PATCH 2/4] fix(settings): type a permission mode for photos only SettingsUpdateOptions accepted mode for every permission target, so { permission: 'camera', mode: 'limited' } compiled and failed at runtime. Read the moded targets from the catalog forms and refuse mode for the rest. --- .../contracts/src/client-settings.test.ts | 8 ++++ packages/contracts/src/client-settings.ts | 39 ++++++++++++------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/packages/contracts/src/client-settings.test.ts b/packages/contracts/src/client-settings.test.ts index faacb34c2b..4599ea3185 100644 --- a/packages/contracts/src/client-settings.test.ts +++ b/packages/contracts/src/client-settings.test.ts @@ -42,6 +42,14 @@ describe('public client permission vocabulary', () => { expectTypeOf().toEqualTypeOf<'grant' | 'deny' | 'reset'>(); expectTypeOf().toEqualTypeOf<'full' | 'limited' | undefined>(); }); + + test('takes a mode only with photos, the one target whose form has modes', () => { + type Grant = { setting: 'permission'; state: 'grant'; permission: Target }; + expectTypeOf & { mode: 'limited' }>().toExtend(); + expectTypeOf>().toExtend(); + expectTypeOf & { mode: 'limited' }>().not.toExtend(); + expectTypeOf & { mode: 'full' }>().not.toExtend(); + }); }); describe('public client settings cover the catalog', () => { diff --git a/packages/contracts/src/client-settings.ts b/packages/contracts/src/client-settings.ts index 102b034243..8759711c28 100644 --- a/packages/contracts/src/client-settings.ts +++ b/packages/contracts/src/client-settings.ts @@ -54,6 +54,26 @@ type DeviceLevelToggleOptions = { }; }[DeviceLevelToggleSetting]; +/** The permission targets whose catalog form declares `modes`; no other target takes a mode. */ +type ModedPermissionTarget = Extract< + (typeof SETTINGS)['permission']['forms'][number], + { modes: readonly string[] } +>['targets'][number]; + +type PermissionUpdateOptions = DeviceCommandBaseOptions & { + setting: 'permission'; + state: PermissionAction; + /** + * The app the permission changes, by bundle id, package name, or app name, resolved as `open` + * resolves it: an iOS simulator, local or Limrun, matches display names and accepts only an + * installed bundle id, and Android accepts only an installed package and refuses a name that + * resolves to an intent with `setting_app_not_package`. Without it the session app is used; + * no app has to be running or open. macOS permissions are host-level TCC grants, so naming an + * app there is refused. + */ + app?: string; +}; + export type SettingsUpdateOptions = | StateOnlySettingOptions | DeviceLevelToggleOptions @@ -75,18 +95,9 @@ export type SettingsUpdateOptions = longitude: number; app?: string; }) - | (DeviceCommandBaseOptions & { - setting: 'permission'; - state: PermissionAction; - permission: PermissionTarget; - mode?: PermissionMode; - /** - * The app the permission changes, by bundle id, package name, or app name, resolved as `open` - * resolves it: an iOS simulator, local or Limrun, matches display names and accepts only an - * installed bundle id, and Android accepts only an installed package and refuses a name that - * resolves to an intent with `setting_app_not_package`. Without it the session app is used; - * no app has to be running or open. macOS permissions are host-level TCC grants, so naming an - * app there is refused. - */ - app?: string; + | (PermissionUpdateOptions & { permission: ModedPermissionTarget; mode?: PermissionMode }) + /** Every other target refuses a mode at runtime, so the type refuses it too. */ + | (PermissionUpdateOptions & { + permission: Exclude; + mode?: never; }); From 6d72b0d1ef6f068e3e04f82dda6eb63a04a71fc1 Mon Sep 17 00:00:00 2001 From: parbez Date: Mon, 23 Nov 2026 18:22:13 +0530 Subject: [PATCH 3/4] docs(settings): say in help that simulator wifi and airplane change only the status bar --- packages/command-surface/src/capture/settings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/command-surface/src/capture/settings.ts b/packages/command-surface/src/capture/settings.ts index 464b02e14c..530d7ae443 100644 --- a/packages/command-surface/src/capture/settings.ts +++ b/packages/command-surface/src/capture/settings.ts @@ -105,7 +105,7 @@ export const settingsCommandFacet = defineCommandFacet({ cliDetail: [ 'A bare readable setting reads the value the target holds. A target that does not serve a setting refuses it with UNSUPPORTED_OPERATION before anything changes.', '', - 'On an iOS simulator, settings wifi and settings airplane wait for screenshots and other status bar writes. The request timeout includes this wait (90 seconds for a standalone CLI request). Once the write starts, its status bar command has a separate 10-second timeout. A request or write that times out may already have changed the bar; check the bar before relying on it. Cancelling while still queued guarantees nothing was written.', + "On an iOS simulator, settings wifi and settings airplane change only the status bar; the simulator keeps using the host Mac's network, so they cannot test offline behavior. They wait for screenshots and other status bar writes. The request timeout includes this wait (90 seconds for a standalone CLI request). Once the write starts, its status bar command has a separate 10-second timeout. A request or write that times out may already have changed the bar; check the bar before relying on it. Cancelling while still queued guarantees nothing was written.", '', 'Settings:', ...settingsHelpLines().map((line) => ` ${line}`), From e15ede08b2bc27f747de154cc767ef6ef7d14b89 Mon Sep 17 00:00:00 2001 From: parbez Date: Mon, 23 Nov 2026 18:22:14 +0530 Subject: [PATCH 4/4] test(apple): assert the status-bar warning names its setting --- packages/platform-apple/src/core/__tests__/app-settings.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/platform-apple/src/core/__tests__/app-settings.test.ts b/packages/platform-apple/src/core/__tests__/app-settings.test.ts index e370699865..ba44053a01 100644 --- a/packages/platform-apple/src/core/__tests__/app-settings.test.ts +++ b/packages/platform-apple/src/core/__tests__/app-settings.test.ts @@ -573,6 +573,8 @@ test.for([ ); assert.ok(Array.isArray(result?.warnings)); assert.equal(result.warnings.length, 1); + assert.match(result.warnings[0], new RegExp(`^settings ${setting} `)); + assert.match(result.warnings[0], /status bar/); }, ); },