Skip to content

fix(claude-accounts): keep /model and effort choices on managed Claude accounts - #38219

Merged
AmoabaKelvin merged 5 commits into
mainfrom
fix/claude-profile-model-persist
Nov 4, 2026
Merged

AmoabaKelvin merged 5 commits into
mainfrom
fix/claude-profile-model-persist

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

Each saved Claude account in Orca has its own copy of your Claude settings. Orca refreshed that copy from ~/.claude/settings.json before every launch and threw away anything Claude had saved in it, so a model or effort picked with /model or /effort was gone by the next session. Now Orca only brings over the settings you actually changed in ~/.claude, and keeps the rest of the account's copy.

Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​40
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​86 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​57

What Changed

  • Before: on a managed account, /model opus plus /effort high lasted one session. The next session started at whatever ~/.claude/settings.json said, because the account's settings.json was replaced whenever it differed from ~/.claude's.
  • After: the choice sticks for that account. Edits to ~/.claude/settings.json still reach every account on the next launch.
  • Mechanism: Orca keeps a small record, claude-profiles/<id>/settings-sync.json next to profile.json and outside the folder Claude reads. It holds a sha256 digest for each top-level key of ~/.claude/settings.json as of the last sync. On each launch, a key whose digest changed is copied over (or removed if it was deleted). Every other key in the account's copy stays as it is. If there's no record (the first launch after updating, or a new account), ~/.claude wins the whole file, which matches the old behaviour.
  • Orca's hook entries are compared like any other key, so a hook change in ~/.claude still reaches WSL accounts, which get their hooks only through this copy. On the host, the hook installer runs after the sync, same as before.
  • If ~/.claude/settings.json can't be read or parsed, that step now fails with a warning and the account's copy stays as it was. Before, the broken bytes were copied in. If the account's own file can't be read (a permissions error or a lock), it is also left alone. An account file that doesn't parse is still replaced.

Why

Keys like model and effortLevel often exist in both files, so merging the two can't tell whether you changed a key in ~/.claude or Claude changed it in the account. That takes a record of the last sync. Per-key digests are the smallest record that works, and storing digests instead of values means proxy keys in env aren't kept in a second file. I chose this over writing Claude's saves back into ~/.claude/settings.json because write-back means Orca editing your real global settings while other Claude sessions may be writing the same file. It would also change every account and System default at once. With this approach, a /model choice applies only to the account it was made in.

Linked Issue

Fixes #36850

Visual Proof

N/A. No Orca UI changes. The visible difference is Claude's own startup banner in a terminal, recorded as text under Testing.

Testing

Ran on macOS with the real Claude CLI 2.1.318, using a throwaway HOME, CLAUDE_CONFIG_DIR and default home under /private/tmp, with a fake API key and a dead base URL. No real login and no API calls. The steps: run the real provisionClaudeProfile, then in a TTY run /model opus and /effort high (Claude writes model, modelSettings.claude-opus-5-5.effortLevel: high and keeps effortLevel: medium), provision again, start a new session, then edit ~/.claude/settings.json and provision once more.

after the second provision new session banner after editing ~/.claude/settings.json
main {"effortLevel":"medium"} ◐ medium · /effort edit arrives, choice still gone
this branch model, modelSettings and effortLevel kept Opus 5.5 with high effort, ● high · /effort edit arrives, choice kept

Focused tests: claude-profile-provisioning, claude-profile-setup, claude-credential-persistence-ratchet, claude-profile-hooks and the rest of src/main/claude-accounts. The changed-file code-quality gate passes. Not run on Linux, Windows or WSL directly. The code there is the same function with posix paths.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

The account-settings regression test fails on main. The WSL hooks test fails if the digest strips Orca's hooks, a mistake an earlier version of this branch made.

Risk

The riskiest part is the merge rule itself. A key changed in both places takes the ~/.claude value. A key you delete from ~/.claude is removed from accounts. A key only the account has stays. If the record goes missing, the next launch falls back to copying the whole file, so the worst case is the old behaviour, not stale proxy settings. Saved data: a new settings-sync.json per account, holding digests only, which goes away when the account is removed. A plain revert works. Accounts would go back to being overwritten on the next launch, and the leftover record files are harmless.

Level: Low

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…nt across launches

Profile settings.json was overwritten from ~/.claude/settings.json on every
launch. Apply only the top-level keys the default home changed since the
last sync, tracked by per-key digests beside the profile marker, and keep
the rest of the profile copy.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

Profile provisioning now synchronizes profile settings with default-home settings using a per-key digest record. The sync preserves target values for keys whose defaults have not changed and updates or removes keys when their defaults change. It treats linked settings as user-owned and writes changed settings atomically. Tests cover these outcomes and the settings persistence allowlist.

Severity of issue fixed: Medium

Merge Risk: Low · up to f9fee

A malformed or unreadable sync record can reset saved account settings; handle this case or accept the risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the fix and its scope: it keeps /model and effort choices on managed Claude accounts. The changeset adds per-key digest-based settings sync (syncClaudeProfileSettings) so account-saved…
Description check Passed The description follows the repository template closely. It includes ELI5, What Changed (before/after and mechanism), Why (including alternatives considered), Linked Issue (Fixes #36850), Visual Proof…
Linked Issues check Passed Issue #36850 requires managed Claude account settings to retain account-side /model and effort changes while later changes from ~/.claude/settings.json still propagate. syncClaudeProfileSettings…
Out of Scope Changes check Passed The changed production code is limited to the settings synchronizer and its integration into managed Claude profile provisioning. The changed tests and filesystem allowlist validate this behavior, inc…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check

Explanation

The title names the fix and its scope: it keeps /model and effort choices on managed Claude accounts. The changeset adds per-key digest-based settings sync (syncClaudeProfileSettings) so account-saved model and effortLevel values survive the next launch, which matches the title's main point. The title uses the conventional fix(scope) form, is one sentence, and is 79 characters, which is within a reasonable length.

Full details: Description check

Explanation

The description follows the repository template closely. It includes ELI5, What Changed (before/after and mechanism), Why (including alternatives considered), Linked Issue (Fixes #36850), Visual Proof (N/A with a reason), Testing (manual steps, platforms, and checklist items), Risk (level Low, with rollback), Agent skill boundary, Notes, and Checklist. The AI Disclosure and Review sections are empty, which the template allows for the team-member case. The Linked Issue line is 'Fixes #36850', which is complete. The Notes section and Testing section are detailed and specific, so the description is substantially complete.

Full details: Linked Issues check

Explanation

Issue #36850 requires managed Claude account settings to retain account-side /model and effort changes while later changes from ~/.claude/settings.json still propagate. syncClaudeProfileSettings records per-key SHA-256 digests and merges only default-home keys that changed since the last sync. It preserves account-side keys, removes keys deleted from the default settings, and falls back to whole-file replacement without a record. provisionClaudeProfile uses this synchronizer. Tests cover account-side model and effort retention, later default-home edits, hook propagation, linked files, and missing default settings.

Full details: Out of Scope Changes check

Explanation

The changed production code is limited to the settings synchronizer and its integration into managed Claude profile provisioning. The changed tests and filesystem allowlist validate this behavior, including hook propagation and error handling. No unrelated product behavior is changed.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 5 files.

Finishing Touches
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

@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
  • 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: 239614d6-ff8f-4e0f-b617-b99962ad9c5b
Commits

Reviewing files that changed from the base of the PR and between 05f674a and f9feeef.

Files selected for processing: 5
  • src/main/claude-accounts/claude-credential-persistence-ratchet.test.ts
  • src/main/claude-accounts/claude-profile-provisioning.test.ts
  • src/main/claude-accounts/claude-profile-provisioning.ts
  • src/main/claude-accounts/claude-profile-settings.ts
  • src/main/claude-accounts/claude-profile-setup.test.ts

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

const digests = digestSettings(defaults)
// Without a record the default home wins whole, as every sync did before records.
let settings = { ...defaults }
if (current.kind === 'present' && lastSync.kind === 'present') {

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.

Minor · Data Integrity & Integration · Quick win

Preserve account settings when the sync record is unavailable.

If settings-sync.json is unreadable or malformed, readClaudeProfileObject(record) returns unavailable. This condition then takes the no-record path and replaces valid account settings with defaults. Saved /model and /effort choices can be lost. Apply whole-file initialization only when the record is absent; report an unavailable record without overwriting the account file. (raw.githubusercontent.com)

@AmoabaKelvin
AmoabaKelvin merged commit 000ca24 into main Nov 4, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant