Repository navigation
feat(native-chat): apply per-agent Auto permission defaults - #30853
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
94d8e8d to
fd2fd50
Compare
brennanb2025
left a comment
There was a problem hiding this comment.
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.
fd2fd50 to
44b8980
Compare
There was a problem hiding this comment.
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.tssrc/main/codex/codex-structured-real-cli-permissions.test.tssrc/main/persistence/applying-settings/settings-update-normalization.test.tssrc/main/persistence/applying-settings/settings-update.tssrc/main/persistence/loading-store/normalize-loaded-global-settings.test.tssrc/main/persistence/loading-store/normalize-loaded-global-settings.tssrc/main/runtime/agent-launch-settings-rollback.tssrc/main/runtime/runtime-client-agent-launch-settings-durability.test.tssrc/main/runtime/runtime-client-agent-launch-settings.test.tssrc/main/runtime/runtime-client-settings-shape.tssrc/main/runtime/runtime-client-settings.tssrc/main/runtime/runtime-store-contract.tssrc/renderer/src/components/native-chat/use-native-chat-host-permission-gate.tssrc/renderer/src/components/settings/AgentLaunchSettingsCatalog.tsxsrc/renderer/src/components/settings/AgentLaunchSettingsSection.tsxsrc/renderer/src/components/settings/ChatPermissionSetting.tsxsrc/renderer/src/components/settings/HostAgentLaunchSettings.test.tsxsrc/renderer/src/components/settings/HostAgentLaunchSettings.tsxsrc/renderer/src/components/settings/agent-launch-settings-transport.test.tssrc/renderer/src/components/settings/agent-launch-settings-transport.tssrc/renderer/src/components/settings/chat-permission-search.tssrc/renderer/src/i18n/en-runtime-required.jsonsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/structured-agent-session-launch-permission-notice.tssrc/renderer/src/runtime/structured-chat-host-permission.test.tssrc/renderer/src/runtime/structured-chat-host-permission.tssrc/renderer/src/web/preload-api/web-chat-permission-normalization.test.tssrc/renderer/src/web/preload-api/web-preference-normalization.tssrc/renderer/src/web/preload-api/web-preferences-store.tssrc/shared/agent-chat-permission-mode.test.tssrc/shared/agent-chat-permission-mode.tssrc/shared/agent-launch-runtime-capability.tssrc/shared/agent-launch-settings-permissions.test.tssrc/shared/agent-launch-settings.tssrc/shared/agent-scoped-permission-defaults.test.tssrc/shared/global-settings-types.tssrc/shared/native-chat-session-option-defaults.tssrc/shared/rpc-contract/agent-launch-settings-params.tstests/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.
| ...(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' } |
There was a problem hiding this comment.
🗄️ 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.
| ...(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' | |
| } |
ea80de8 to
7915f77
Compare
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.
Codex independently starts in Approve for me and completes a real reply:
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
On macOS, with background launches, Claude Code 2.1.303 and Codex CLI 0.163.0:
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
Notes
Auto requires CLI/model support. The new settings field is optional; no stream opcode or git-provider behavior changed.
Checklist