Skip to content

fix(settings): accept union-valued permission targets without mode - #5075

Merged
thymikee merged 2 commits into
mainfrom
fix/permission-union-input
Nov 24, 2026
Merged

thymikee merged 2 commits into
mainfrom
fix/permission-union-input

Conversation

@thymikee

@thymikee thymikee commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Restore mode-free settings.update calls with union-valued permissions, fixing the downstream E2E build after #5026. A separate call overload accepts the union. The exported SettingsUpdateOptions preserves photos narrowing. Six files cover SDK types and tests. Runtime behavior is unchanged.

Before / after

declare const permission: 'camera' | 'photos';
client.settings.update({ setting: 'permission', permission, state: 'grant' });

At base, the call fails typecheck. At head, it compiles without a cast. Adding an explicit mode to the union still fails. A photos-specific handler still accepts a SettingsUpdateOptions value guarded by permission === 'photos'.

Validation

  • Base: 8a29aea9a820. The original union-call regression failed there. The new narrowing regression fails on 29fb4b9.
  • Head: 1cbe1eaeb6fa3ea90a95a7e6836b935739638192. TypeScript build and all 59 focused tests passed.
  • pnpm check:affected --run --head HEAD passed at the exact commit (receipt run-q29RJ2). Hosted CI covers the remaining lanes.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.56 MB 6.56 MB +293 B
Package (unpacked) 6.56 MB 6.56 MB +293 B
Package (download) 2.00 MB 2.00 MB +45 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 36.2 ms 26.8 ms -9.4 ms
CLI --help 63.2 ms 61.4 ms -1.8 ms

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Reviewed 29fb4b9. The union-valued permission call is fixed, but the widened options type breaks narrowing for existing TypeScript callers.

In packages/contracts/src/client-settings.ts#L101 (https://github.com/callstack/agent-device/blob/29fb4b9/packages/contracts/src/client-settings.ts#L101), the new mode-free arm also contains photos. After if (options.permission === "photos"), the object no longer narrows to the photos member, because the mode-free arm stays in the type. Passing the guarded object to a handler typed as Extract<SettingsUpdateOptions, { setting: "permission"; permission: "photos" }> compiles on base and fails with TS2345 on this head. Existing SDK callers that dispatch to a photos-specific helper after this check can no longer compile.

The rule the type must satisfy: every arm of SettingsUpdateOptions that existing callers narrow on stays disjoint by its permission value. Could the existing discriminated options type stay as it is, with the mode-free shape defined as a separate call input and accepted through an overload on the public settings.update signature? That would widen the call without removing the narrowing. The test should cover both the union-valued call and control-flow narrowing of the existing options.

The code has no other problems. Two Body rules jobs show as cancelled, not failed. The diff changes a contracts type and its test, so it does not touch PR-body validation, and the other 21 checks pass. Those two jobs need a re-run before merge. No conflicts. Not verified here: tsc and vitest were not run locally, and the findings rest on static assignability reasoning plus the failing-at-base and passing-at-head run reported in the PR body.

@thymikee

Copy link
Copy Markdown
Member Author

Fixed in 1cbe1eaeb6. SettingsUpdateOptions is back to its original discriminated shape. A separate settings.update overload accepts mode-free permission unions. The new tests cover the union call, rejection of an explicit mode on the union, and passing the narrowed photos arm to a photos-specific handler. The narrowing test fails on 29fb4b9. On the pushed head, TypeScript, all 59 focused tests, and every runnable affected check passed (run-q29RJ2, exact commit).

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 1cbe1ea

Since the review of 29fb4b9: 0 new · 0 still open · 0 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (fc8726eeca2c).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

The earlier findings from 29fb4b9 (#5075 (comment)) are fixed at 1cbe1ea, and no new problems were found in the diff. All checks pass at this commit, including Body rules, which passed after the earlier cancellation. The only skipped item is the non-required Proof check, and there are no conflicts. The change is type-only, so CI's Lint, Typecheck & Package job is the main coverage for it. Not verified here: the repo's tsconfig and the full vitest typecheck were not run locally. The contracts and kernel type sources were compiled in isolation with strict tsc, and the expectTypeOf assertions were reproduced as compile-time probes against the head. Not verified here: that the new union-call test fails on base. That is inferred from the base type shape and the earlier regression. No inline threads exist on this PR, and nothing else needs to happen before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 24, 2026
@thymikee
thymikee merged commit b2d4ec0 into main Nov 24, 2026
20 of 21 checks passed
@thymikee
thymikee deleted the fix/permission-union-input branch November 24, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant