Skip to content

Add an option to disable server-managed settings - #926

Open
mike1858 wants to merge 2 commits into
mainfrom
feat/disable-managed-settings
Open

Add an option to disable server-managed settings#926
mike1858 wants to merge 2 commits into
mainfrom
feat/disable-managed-settings

Conversation

@mike1858

@mike1858 mike1858 commented Jul 27, 2026

Copy link
Copy Markdown
Member

Why

Claude Code can download enterprise settings from Anthropic or a configured gateway and apply them as a high-precedence policy layer. Users of modified Claude Code installations may need an explicit way to prevent that server-delivered settings path from loading.

The remote-settings subsystem uses one eligibility gate across startup loading, cached settings, authentication refreshes, and periodic polling. Disabling that gate avoids patching individual request sites and keeps the behavior consistent across the full lifecycle.

Closes #725.

What changed

  • Add a default-off disableServerManagedSettings miscellaneous setting and expose it in the interactive settings UI.
  • Add the disable-server-managed-settings patch, which short-circuits Claude Code's central remote-settings eligibility helper.
  • Match both minified and formatted Claude Code 2.1.220 syntax without depending on build-specific identifier names.
  • Preserve local endpoint-managed policy loading, including local managed-settings.json, MDM, registry, and policyHelper sources.
  • Keep the pre-apply confirmation plan aligned with the setting so the patch appears only when enabled.
  • Add focused coverage for current syntax, identifier renaming, idempotency, supported delimiters, partial matches, structurally similar false positives, and enabled/disabled apply-plan behavior.
  • Document the new opt-in behavior in the changelog.

Validation

  • pnpm test
  • pnpm lint
  • pnpm build
  • Applied disable-server-managed-settings to native Claude Code 2.1.220 and verified the repacked bundle with node --check.
  • Launched the patched Claude Code with --debug-file, opened /permissions and /status, and exited cleanly.
  • Verified the complete debug log contained no remote-settings loading, cache, polling, or /api/claude_code/settings and /managed/settings endpoint activity.

Summary by CodeRabbit

  • New Features
    • Added an opt-in setting to disable server-managed settings.
    • Added a new “Disable server-managed settings” toggle in Miscellaneous settings.
    • When enabled, supported enterprise settings provided via upstream delivery are not loaded.
  • Bug Fixes
    • Added a patcher to robustly handle different eligible-gate code formats and ensure idempotent behavior.
  • Documentation
    • Updated the unreleased changelog with the new opt-in setting.

Add an opt-in miscellaneous patch that short-circuits Claude Code's
central server-managed-settings eligibility gate. This prevents remote
settings loading, cache use, refreshes, and polling while preserving
local endpoint-managed policy sources.

Register the setting as disabled by default, expose it in the
interactive UI, and cover minified and formatted Claude Code 2.1.220
shapes plus idempotency and false-positive behavior.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an opt-in disableServerManagedSettings setting, a patch that disables Claude Code’s remote settings eligibility gate, UI and patch wiring, tests, and an Unreleased changelog entry.

Changes

Server-managed settings control

Layer / File(s) Summary
Settings contract and UI toggle
src/types.ts, src/defaultSettings.ts, src/ui/components/MiscView.tsx
Adds the boolean setting to the misc configuration, defaults it to false, and exposes a toggle in the misc settings view.
Eligibility gate patch and tests
src/patches/disableServerManagedSettings.ts, src/patches/disableServerManagedSettings.test.ts
Detects the remote settings eligibility gate, injects return !1;, preserves already-patched input, and tests syntax, identifier, delimiter, partial-match, and unrelated-helper cases.
Patch registration and plan validation
src/patches/index.ts, src/applyPlan.ts, src/tests/applyPlan.test.ts, CHANGELOG.md
Registers the configurable patch, applies it when enabled, verifies planned patch inclusion, and documents the change.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: arimu1, bl-ue

Poem

A rabbit toggles settings with care,
Blocking server whispers in the air.
A tiny gate now closes tight,
Tests hop through day and night.
Config, patch, and changelog align—
Thump-thump, the settings are mine!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The patch adds an opt-in setting to stop loading managed settings, matching the request in #725.
Out of Scope Changes check ✅ Passed The changes stay focused on the new setting, patch, UI, tests, and changelog with no obvious unrelated additions.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding an option to disable server-managed settings.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/disable-managed-settings

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.

Gate the new patch in the pre-apply planner with the same setting used by the patch implementation. Add enabled and disabled coverage so confirmation summaries do not advertise a patch that will be skipped.

@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.

🧹 Nitpick comments (1)
src/patches/disableServerManagedSettings.ts (1)

1-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the @/ alias for internal imports.

  • src/patches/disableServerManagedSettings.ts#L1-L2: replace ../utils and ./index with @/-aliased imports.
  • src/patches/disableServerManagedSettings.test.ts#L2-L2: import the patch via @/patches/disableServerManagedSettings.
  • src/patches/index.ts#L67-L67: import the patch implementation via an @/ alias.

As per coding guidelines, internal imports must use the @/ alias.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/patches/disableServerManagedSettings.ts` around lines 1 - 2, Replace the
relative internal imports in src/patches/disableServerManagedSettings.ts lines
1-2 with the appropriate `@/` aliases; update the patch import in
src/patches/disableServerManagedSettings.test.ts line 2 to
`@/patches/disableServerManagedSettings`; and update the implementation import in
src/patches/index.ts line 67 to use an `@/` alias.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/patches/disableServerManagedSettings.ts`:
- Around line 1-2: Replace the relative internal imports in
src/patches/disableServerManagedSettings.ts lines 1-2 with the appropriate `@/`
aliases; update the patch import in
src/patches/disableServerManagedSettings.test.ts line 2 to
`@/patches/disableServerManagedSettings`; and update the implementation import in
src/patches/index.ts line 67 to use an `@/` alias.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d1644a87-bf3f-4cc6-b6aa-cf5f556c89d4

📥 Commits

Reviewing files that changed from the base of the PR and between b36a8ca and 4d68a14.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • src/defaultSettings.ts
  • src/patches/disableServerManagedSettings.test.ts
  • src/patches/disableServerManagedSettings.ts
  • src/patches/index.ts
  • src/types.ts
  • src/ui/components/MiscView.tsx

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.

Disable enterprise managed settings load with tweakcc

1 participant