Skip to content

fix: always accept 'auto' in defaultMode settings schema#599

Open
luoxk wants to merge 1 commit into
NanmiCoder:mainfrom
luoxk:fix/settings-schema-auto-mode
Open

fix: always accept 'auto' in defaultMode settings schema#599
luoxk wants to merge 1 commit into
NanmiCoder:mainfrom
luoxk:fix/settings-schema-auto-mode

Conversation

@luoxk
Copy link
Copy Markdown
Contributor

@luoxk luoxk commented May 24, 2026

Summary

  • Fix SettingsSchema to always accept 'auto' as a valid permissions.defaultMode value, regardless of the TRANSCRIPT_CLASSIFIER feature flag state.

Problem

When TRANSCRIPT_CLASSIFIER is disabled (sidecar/desktop builds), defaultMode: 'auto' in ~/.claude/settings.json causes Zod validation to fail. This silently discards the entire user settings file, resulting in:

  • enabledPlugins lost → all plugin skills unavailable → "Unknown skill" errors
  • hooks, env, extraKnownMarketplaces all lost
  • Only project-local .claude/settings.local.json is loaded

Users who configured "defaultMode": "auto" in the upstream CLI (where the flag is on) cannot use their settings in sidecar builds.

Fix

Replace the feature-flag-gated enum:

// Before
defaultMode: z.enum(
  feature('TRANSCRIPT_CLASSIFIER') ? PERMISSION_MODES : EXTERNAL_PERMISSION_MODES,
)

// After
defaultMode: z.enum([...EXTERNAL_PERMISSION_MODES, 'auto'])

The schema should accept all valid mode values for file compatibility. Runtime behavior for auto mode is separately gated by the feature flag — the schema just needs to not reject the file.

Test plan

  • Verified: sidecar CLI subprocess with defaultMode: 'auto' in user settings now correctly loads enabledPlugins and all plugin skills
  • Verified: SettingsSchema().safeParse() no longer returns success: false for files containing defaultMode: 'auto'

When TRANSCRIPT_CLASSIFIER feature flag is disabled (e.g., in sidecar
builds), the SettingsSchema rejects 'auto' as a valid defaultMode value.
This causes the entire ~/.claude/settings.json to fail Zod validation
and be silently discarded — losing enabledPlugins, hooks, env, and all
other user settings.

Users who set permissions.defaultMode to 'auto' in the upstream Claude
Code CLI (where the feature flag is enabled) then open the same
settings.json in a sidecar or desktop build (where the flag may be off)
hit "Unknown skill" errors because plugin discovery reads empty
enabledPlugins from the failed parse.

Fix: always include 'auto' in the defaultMode enum regardless of the
TRANSCRIPT_CLASSIFIER feature flag. The schema should accept all valid
mode values for settings file compatibility, even if the runtime doesn't
activate auto-mode behavior when the flag is off.
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels May 24, 2026
@github-actions
Copy link
Copy Markdown

PR quality triage

Changed areas: area:cli-core

CLI core policy: Blocked by policy until a maintainer applies allow-cli-core-change and approves the PR.

Missing-test policy: Blocked by policy until a maintainer applies allow-missing-tests or matching tests are added.

Coverage baseline policy: No coverage-baseline policy block detected.

CLI core files:

  • src/utils/settings/types.ts

Coverage policy files:

  • none

Expected checks:

  • change-policy
  • server-checks
  • coverage-checks

Test coverage signals:

  • BLOCKING unless allow-missing-tests is applied: Agent/runtime product files changed without a tools/utils test file in the PR.
  • Agent/model runtime path changed: use mock/request-shape tests in PR and maintainer live-model smoke before release.

Risk notes:

  • No special risk notes from changed paths.

Hard merge gates still come from GitHub Actions, not AI review.

Dosu handoff: Dosu can be used as the AI reviewer for risk explanation, missing-test prompts, and maintainer Q&A. If it does not comment automatically from the PR template, ask:

@dosubot review this PR for changed-area risk, missing tests, docs impact, desktop startup risk, and CLI core impact.

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

Labels

area:cli-core bug Something isn't working needs-maintainer-approval size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant