Skip to content

fix(native-chat): resume a Claude chat with its saved permission mode - #33587

Closed
nwparker wants to merge 1 commit into
mainfrom
nwparker/agint-structured-claude-resume-permission-mode
Closed

nwparker wants to merge 1 commit into
mainfrom
nwparker/agint-structured-claude-resume-permission-mode

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​19 $\color{#cf222e}{\Huge{\mathbf{−}}}$​201 $\color{#cf222e}{\Huge{\mathbf{−}}}$​182
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4 $\color{#cf222e}{\Huge{\mathbf{−}}}$​50 $\color{#cf222e}{\Huge{\mathbf{−}}}$​46

ELI5

If you set a Claude chat to Approve for me, Orca could reopen it later (after an update, restart, or terminal-host restart) asking you to approve everything. The picker still said Approve for me. That happened because Orca checked its cached model list before passing your choice to Claude, and when the cache was empty or didn't list the chat's model, it quietly fell back to Ask. Now Orca passes the saved choice straight to Claude. Claude already falls back by itself when a model can't run auto mode.

Root cause

structuredAgentSessionLaunchPermission (structured-agent-session-launch-permission.ts) read the saved-only model catalog and downgraded auto to ask (--permission-mode default) unless a catalog row matched record.options.model exactly and had supportsAutoMode: true. The row can be missing for reasons that have nothing to do with the model:

  • the catalog hasn't been probed yet after a restart or update (launch uses savedOnly, so it never waits for the probe)
  • the fingerprint doesn't match (account home or folder scope)
  • the chat saved a resolved or full model id (for example claude-opus-5-5[1m]) instead of the listed alias

The explicit --permission-mode default also overrides the user's permissions.defaultMode.

The downgrade isn't needed. Claude Code 2.1.310 handles it at startup: initialPermissionModeFromCLI resolves the CLI mode through its auto gate, which sets fromAutoFallback and then notifies "auto mode unavailable for this model". It doesn't fail. I checked this with the real binary against a fake Anthropic server: --permission-mode auto --model claude-sonnet-4-20250514 and --model claude-3-5-haiku-20241022 both start and report "permissionMode":"default" in init, with exit status success. --model opus reports "permissionMode":"auto".

What changed

  • The launch permission is the saved choice (savedChatPermissionMode), with no catalog read. The picker, the mobile options read, and the outgrown-child restart check all read this same function, so they stay consistent with each other.
  • Removed the now-unused effectiveChatPermissionMode and chatPermissionModeNeedsModelSupport, plus the tests that pinned the catalog downgrade.
  • The menu still offers Approve for me only on models the catalog lists as supporting it (offeredChatPermissionModes). That part is unchanged.

This is a smaller alternative to #30914, which also takes the catalog out of launch policy but goes further: it restarts the session on a model change when the opened mode differs, and keeps per-turn option retention (+2388/−531, 59 files). This PR takes only the launch-policy part, credited to @brennanb2025.

How I verified it

Isolated dev Electron (separate userData, HOME, and CLAUDE_CONFIG_DIR), real Claude Code 2.1.310, fake Anthropic server, native Claude chat set to Approve for me (permissionMode: auto, model opus):

Step origin/main this branch
First send (catalog present) --permission-mode auto --permission-mode auto
Restart the app, catalog not yet available (cache removed, probe delayed), send --resume=… --permission-mode default, picker shows "Ask for approval" --resume=… --permission-mode auto, picker shows "Approve for me"
Send again later – same child, no restart loop
  • pnpm tc passes.
  • pnpm test passes on 26 related native-chat, Claude, and permission test files (397 tests).
  • check:code-quality:changed passes.
  • The new regression test (launches Claude auto without consulting a model list) fails on main.

Risk

Low. The diff is about 25 lines added and 250 removed, nearly all of it tests and dead helpers.

  • On a model that can't run auto, the picker now shows the saved Approve for me while Claude runs in default. Main showed Ask there. Showing the mode Claude actually opened with is tracked separately (STA-11280).
  • A very old Claude CLI without the auto choice would reject --permission-mode auto. Structured chat already depends on recent stream-json SDK flags.
  • Remote, mobile, and Windows: no wire or format change. The host computes the same value it already sent.

Fixes #30032

A chat saved as Approve for me (auto) relaunched with --permission-mode default
whenever the saved model catalog had no row confirming auto support for the
chat's model (catalog not yet probed after an update/restart, a fingerprint
miss, or a full model id). Claude Code already falls back from auto by itself
on a model that can't run it, so launch the saved choice as is.

Fixes #30032

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d9546687-885a-462c-815e-376ba99aa1b4
Commits

Reviewing files that changed from the base of the PR and between 6808f4b and 976ddea.

Files selected for processing: 5
  • src/main/native-chat/agent-session-wire/structured-agent-session-launch-permission.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-launch-permission.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-outgrown-child.test.ts
  • src/shared/agent-chat-permission-mode.test.ts
  • src/shared/agent-chat-permission-mode.ts
  • 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 marked this pull request as draft October 25, 2026 17:04
@nwparker

Copy link
Copy Markdown
Contributor Author

Closing in favour of #30914 (merged), which covers native Claude resume permission mode more completely.

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.

[Bug]: Resumed Structured Native Chat launches Claude with --permission-mode default although the session's stored permissionMode is auto

1 participant