Skip to content

feat(native-chat): apply per-agent Auto permission defaults - #30853

Merged
nwparker merged 2 commits into
mainfrom
nwparker/auto-permissions-native-chat
Oct 20, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/auto-permissions-native-chat

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​747 $\color{#cf222e}{\Huge{\mathbf{−}}}$​64 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​683
Prod 25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​251 $\color{#cf222e}{\Huge{\mathbf{−}}}$​43 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​208

ELI5

After choosing Auto in Settings → Agents, new native chats use that agent’s Auto mode too. Existing chats keep their own permissions.

#30677 is merged. This PR is rebased onto main and preserves its global controls and per-agent exceptions while adding native-chat integration.

What Changed

Previously, the agent’s terminal arguments and native-chat default could disagree. Save a per-agent new-chat default alongside an explicitly requested permission preset, and reuse the native launch resolver to seed fresh sessions. Changing the shared Chat default clears scoped overrides; selecting the same agent preset again resynchronizes it.

Auto updates only supporting agents’ scoped native defaults. The Other agents control preserves those Auto defaults, unrelated agents, and custom argument exceptions. Normalize and persist the optional defaults on desktop and web, project them to paired clients, and roll them back with terminal settings when a durable save fails. A separate capability and optional mutation field preserve terminal-only behavior for older clients and hosts.

Claude still checks model support for Auto. Codex uses its automatic reviewer and workspace sandbox. Saved sessions retain their modes.

Why

One explicit choice should configure future terminal and native sessions consistently. Scoped defaults avoid changing other agents, and reusing existing native permission handling preserves model checks and session persistence.

Linked Issue

Refs #13081 — Claude Code Auto and Codex Approve for me.

Refs #25559 — Auto missing from native Claude chat.

Visual Proof

Actual hidden Orca Electron renderers, captured through Playwright CDP and inspected directly. The earlier chat keeps Ask after changing Claude’s default; a new chat starts in Auto and successfully writes and reads a file.

Existing Claude chat New Claude chat after choosing Auto
Existing chat keeps Ask New Auto chat completes a real file write and read

Codex independently starts in Approve for me and completes a real reply:

Codex native Auto

Rebased Electron verification of the merged global controls, Other agents selection, and reload persistence (three passing repetitions; the recording is one passing run):

page@4b910f1d5eca3b1cae8a26fbd1b79c3d.webm

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

On macOS, with background launches, Claude Code 2.1.303 and Codex CLI 0.163.0:

  • 216 targeted tests across 15 files, with the corrected runtime assertion and scoped-default suite rerun successfully (34 tests), covering scoped defaults, persistence, failed-save rollback, model fallback, both directions of mixed-version pairing, and strict mutation schemas.
  • Rebased Electron settings test passed three consecutive runs: global Auto updates Claude/Codex only, Other agents Manual preserves Auto, and terminal/native defaults persist after reload.
  • Real Claude CLI suites passed 15 tests, including an Auto file-write/read turn.
  • Real Codex app-server test passed fresh-process Auto → Full access → Auto → Ask with inherited bypass configuration.
  • Real native Codex Auto, Claude Ask, and Claude Auto sessions passed in a folder workspace; an existing Claude chat retained Ask after its default changed to Auto.
  • Final application typechecks, changed-code quality, formatting, RPC catalog, localization catalogs, Electron build, and CLI build passed.
  • Fixed the host bookkeeping test’s capability mock and rebased onto test(node-runtime): stop the refused-download test hanging under the bun runner (fix red main) #30967, which fixes the inherited download test’s fake-timer race. The related suites pass locally.

The updated CI run covers full repository lint/tests, Windows and Linux packaging, changed Electron E2E specs, WSL, and headless server checks. Live Windows/Linux/SSH UI validation was not performed locally.

Review

#30677 is merged; this PR now targets main and retains its revised settings design. #14745 adds Claude’s live permission picker for terminal-backed native chat; cross-review live mode persistence against these launch defaults. #19244 also changes permission mappings and settings; reconcile default seeding and capability checks before merging both implementations.

An adversarial split review identified version-skew risks in both directions; native synchronization now requires an explicit opt-in supported by the host.

Agent skill upstream boundary

  • Not applicable: no upstream skill-installer material copied or translated.

Notes

Auto requires CLI/model support. The new settings field is optional; no stream opcode or git-provider behavior changed.

Checklist

  • This PR is small and focused
  • Explained before/after, mechanism, and approach
  • Visual proof attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and compatibility impact considered
  • Local checks listed above; CI covers remaining repository gates

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b4850b4-b1a0-4610-818a-1a500c701cbf
📥 Commits

Reviewing files that changed from the base of the PR and between 44b8980cff06ecedfb8465b0700b85d79a08ce07 and 7915f77.

📒 Files selected for processing: 1
  • tests/e2e/host-agent-launch-settings-hook-bookkeeping.unit.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

📝 Walkthrough

The change adds per-agent native-chat permission defaults and resolves them against a shared default. Agent permission presets can synchronize these defaults when the host supports the capability. Persistence, runtime projections, rollback handling, renderer permission checks, and web preference normalization now handle scoped modes. The changes also add unit, end-to-end, and real CLI integration coverage.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 7915f

A failed settings update can silently remove a newer per-agent permission default; fix rollback handling before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 38 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: applying per-agent Auto permission defaults to native chat.
Description check Passed The description follows the repository template and includes the user impact, implementation details, rationale, linked issues, visual proof, testing results, compatibility notes, review context, and …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description follows the repository template and includes the user impact, implementation details, rationale, linked issues, visual proof, testing results, compatibility notes, review context, and completed checklist items.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker force-pushed the nwparker/auto-permissions-native-chat branch from 94d8e8d to fd2fd50 Compare October 20, 2026 01:28

@brennanb2025 brennanb2025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Light code review: no blocking findings. The new defaults apply when creating chats, existing sessions retain their permission choices, and older hosts keep their existing behavior. I inspected the relevant changes and tests; I could not rerun tests because this checkout has no installed dependencies. CI currently fails formatting in three files outside this diff, so this approval does not mean the PR is ready to merge.

@nwparker
nwparker force-pushed the nwparker/auto-permissions-native-chat branch from fd2fd50 to 44b8980 Compare October 20, 2026 02:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8a299fa5-c6aa-4665-81fa-41275bcfc672
📥 Commits

Reviewing files that changed from the base of the PR and between 11b925d and 44b8980cff06ecedfb8465b0700b85d79a08ce07.

📒 Files selected for processing: 39
  • src/main/claude/claude-structured-real-cli.test.ts
  • src/main/codex/codex-structured-real-cli-permissions.test.ts
  • src/main/persistence/applying-settings/settings-update-normalization.test.ts
  • src/main/persistence/applying-settings/settings-update.ts
  • src/main/persistence/loading-store/normalize-loaded-global-settings.test.ts
  • src/main/persistence/loading-store/normalize-loaded-global-settings.ts
  • src/main/runtime/agent-launch-settings-rollback.ts
  • src/main/runtime/runtime-client-agent-launch-settings-durability.test.ts
  • src/main/runtime/runtime-client-agent-launch-settings.test.ts
  • src/main/runtime/runtime-client-settings-shape.ts
  • src/main/runtime/runtime-client-settings.ts
  • src/main/runtime/runtime-store-contract.ts
  • src/renderer/src/components/native-chat/use-native-chat-host-permission-gate.ts
  • src/renderer/src/components/settings/AgentLaunchSettingsCatalog.tsx
  • src/renderer/src/components/settings/AgentLaunchSettingsSection.tsx
  • src/renderer/src/components/settings/ChatPermissionSetting.tsx
  • src/renderer/src/components/settings/HostAgentLaunchSettings.test.tsx
  • src/renderer/src/components/settings/HostAgentLaunchSettings.tsx
  • src/renderer/src/components/settings/agent-launch-settings-transport.test.ts
  • src/renderer/src/components/settings/agent-launch-settings-transport.ts
  • src/renderer/src/components/settings/chat-permission-search.ts
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/structured-agent-session-launch-permission-notice.ts
  • src/renderer/src/runtime/structured-chat-host-permission.test.ts
  • src/renderer/src/runtime/structured-chat-host-permission.ts
  • src/renderer/src/web/preload-api/web-chat-permission-normalization.test.ts
  • src/renderer/src/web/preload-api/web-preference-normalization.ts
  • src/renderer/src/web/preload-api/web-preferences-store.ts
  • src/shared/agent-chat-permission-mode.test.ts
  • src/shared/agent-chat-permission-mode.ts
  • src/shared/agent-launch-runtime-capability.ts
  • src/shared/agent-launch-settings-permissions.test.ts
  • src/shared/agent-launch-settings.ts
  • src/shared/agent-scoped-permission-defaults.test.ts
  • src/shared/global-settings-types.ts
  • src/shared/native-chat-session-option-defaults.ts
  • src/shared/rpc-contract/agent-launch-settings-params.ts
  • tests/e2e/agent-auto-permissions.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Comment on lines +38 to +44
...(Object.hasOwn(updates, 'agentNativeChatPermissionModes') &&
Object.is(current.agentNativeChatPermissionModes, applied.agentNativeChatPermissionModes)
? { agentNativeChatPermissionModes: before.agentNativeChatPermissionModes ?? {} }
: {}),
...(Object.hasOwn(updates, 'nativeChatPermissionMode') &&
Object.is(current.nativeChatPermissionMode, applied.nativeChatPermissionMode)
? { nativeChatPermissionMode: before.nativeChatPermissionMode ?? 'ask' }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

A rollback that restores only nativeChatPermissionMode deletes newer per-agent overrides.

Take a synced global Manual or Yolo mutation. Its updates contain both nativeChatPermissionMode and agentNativeChatPermissionModes: {}. Suppose a newer write changes only the map before the durable write fails. One example is a local desktop scoped preset, because LocalAgentLaunchSettings writes through updateSettings directly. The rollback then skips the map, because Object.is sees that the map changed. The rollback still emits nativeChatPermissionMode. updateSettings (settings-update.ts lines 89-93) treats any update that contains nativeChatPermissionMode as a shared choice and resets the map to {}. The newer scoped default is lost. This breaks the stated rule "A newer full-field write supersedes this mutation and must survive its rollback."

When the rollback restores the shared mode without the map, include the current map so normalization keeps it.

🐛 Proposed fix
-    ...(Object.hasOwn(updates, 'nativeChatPermissionMode') &&
-    Object.is(current.nativeChatPermissionMode, applied.nativeChatPermissionMode)
-      ? { nativeChatPermissionMode: before.nativeChatPermissionMode ?? 'ask' }
-      : {})
+    ...(Object.hasOwn(updates, 'nativeChatPermissionMode') &&
+    Object.is(current.nativeChatPermissionMode, applied.nativeChatPermissionMode)
+      ? {
+          // updateSettings clears overrides on a bare shared-mode write; keep newer ones.
+          agentNativeChatPermissionModes: current.agentNativeChatPermissionModes ?? {},
+          nativeChatPermissionMode: before.nativeChatPermissionMode ?? 'ask'
+        }
+      : {})

Put this spread after the map rollback entry. Then the restored before map still wins when the map was not changed by a newer write. To make that explicit, compute the map value once (before map if unchanged, otherwise the current map) and emit it whenever either key is rolled back.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
...(Object.hasOwn(updates, 'agentNativeChatPermissionModes') &&
Object.is(current.agentNativeChatPermissionModes, applied.agentNativeChatPermissionModes)
? { agentNativeChatPermissionModes: before.agentNativeChatPermissionModes ?? {} }
: {}),
...(Object.hasOwn(updates, 'nativeChatPermissionMode') &&
Object.is(current.nativeChatPermissionMode, applied.nativeChatPermissionMode)
? { nativeChatPermissionMode: before.nativeChatPermissionMode ?? 'ask' }
...(Object.hasOwn(updates, 'agentNativeChatPermissionModes') &&
Object.is(current.agentNativeChatPermissionModes, applied.agentNativeChatPermissionModes)
? { agentNativeChatPermissionModes: before.agentNativeChatPermissionModes ?? {} }
: {}),
...(Object.hasOwn(updates, 'nativeChatPermissionMode') &&
Object.is(current.nativeChatPermissionMode, applied.nativeChatPermissionMode)
? {
// updateSettings clears overrides on a bare shared-mode write; keep newer ones.
agentNativeChatPermissionModes: current.agentNativeChatPermissionModes ?? {},
nativeChatPermissionMode: before.nativeChatPermissionMode ?? 'ask'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants