fix: always accept 'auto' in defaultMode settings schema

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.
This commit is contained in:
luoxk 2026-05-24 22:22:45 +08:00
parent 98a0b5a7dc
commit d4e4ecd639

View File

@ -57,11 +57,7 @@ export const PermissionsSchema = lazySchema(() =>
'List of permission rules that should always prompt for confirmation',
),
defaultMode: z
.enum(
feature('TRANSCRIPT_CLASSIFIER')
? PERMISSION_MODES
: EXTERNAL_PERMISSION_MODES,
)
.enum([...EXTERNAL_PERMISSION_MODES, 'auto'])
.optional()
.describe('Default permission mode when Claude Code needs access'),
disableBypassPermissionsMode: z