diff --git a/README.md b/README.md index 245204e0..3e6ed357 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ counts; when it is `false`, Codiff hides those changes from the working-tree rev "$schema": "https://raw.githubusercontent.com/nkzw-tech/codiff/main/core/config/codiff-config.schema.json", "settings": { "agentBackend": "codex", - "claudeModel": "claude-sonnet-4-6", + "claudeModel": "sonnet", "codeFontFamily": "", "codeFontSize": 13, "copyCommentsOnClose": false, diff --git a/config/defaults.json b/config/defaults.json index 4af3b337..ef4dfae8 100644 --- a/config/defaults.json +++ b/config/defaults.json @@ -2,7 +2,7 @@ "settings": { "agentBackend": "codex", "checkForUpdates": true, - "claudeModel": "claude-sonnet-4-6", + "claudeModel": "sonnet", "codeFontFamily": "", "codeFontSize": 13, "copyCommentsOnClose": false, diff --git a/core/config/codiff-config.schema.json b/core/config/codiff-config.schema.json index 010bfc77..03740de5 100644 --- a/core/config/codiff-config.schema.json +++ b/core/config/codiff-config.schema.json @@ -27,8 +27,8 @@ }, "claudeModel": { "type": "string", - "default": "claude-sonnet-4-6", - "description": "The Claude Code model to use for review assistance and walkthroughs when agentBackend is 'claude'." + "default": "sonnet", + "description": "The Claude Code model alias ('opus', 'sonnet', or 'haiku') to use for review assistance and walkthroughs when agentBackend is 'claude'. The Claude Code CLI resolves each alias to its latest model." }, "codeFontFamily": { "type": "string", diff --git a/electron/__tests__/claude.test.ts b/electron/__tests__/claude.test.ts index cced1a89..841efec0 100644 --- a/electron/__tests__/claude.test.ts +++ b/electron/__tests__/claude.test.ts @@ -52,8 +52,19 @@ beforeEach(() => { }); test('normalizes Claude Code model preferences to known models', () => { - expect(normalizeClaudeModel('claude-opus-4-8')).toBe('claude-opus-4-8'); + expect(normalizeClaudeModel('opus')).toBe('opus'); + expect(normalizeClaudeModel('haiku')).toBe('haiku'); expect(normalizeClaudeModel('gpt-4o')).toBe(DEFAULT_CLAUDE_MODEL); + expect(normalizeClaudeModel(undefined)).toBe(DEFAULT_CLAUDE_MODEL); + expect(DEFAULT_CLAUDE_MODEL).toBe('sonnet'); +}); + +test('maps legacy pinned Claude model ids to CLI aliases', () => { + expect(normalizeClaudeModel('claude-opus-4-8')).toBe('opus'); + expect(normalizeClaudeModel('claude-sonnet-4-6')).toBe('sonnet'); + expect(normalizeClaudeModel('claude-haiku-4-5')).toBe('haiku'); + expect(normalizeClaudeModel('claude-haiku-4-5-20251001')).toBe('haiku'); + expect(normalizeClaudeModel('claude-sonnetx')).toBe(DEFAULT_CLAUDE_MODEL); }); test('rejects invalid explicit Claude CLI overrides', async () => { diff --git a/electron/claude.cjs b/electron/claude.cjs index 78ea976e..c7681e96 100644 --- a/electron/claude.cjs +++ b/electron/claude.cjs @@ -13,8 +13,8 @@ const { // Claude Code can be slower to first token than Codex, so allow a longer budget. const CLAUDE_TIMEOUT_MS = 90_000; -const DEFAULT_CLAUDE_MODEL = 'claude-sonnet-4-6'; -const FALLBACK_CLAUDE_MODEL = 'claude-haiku-4-5'; +const DEFAULT_CLAUDE_MODEL = 'sonnet'; +const FALLBACK_CLAUDE_MODEL = 'haiku'; const CLAUDE_NOT_FOUND_CODE = 'CLAUDE_NOT_FOUND'; const CLAUDE_NOT_FOUND_MESSAGE = 'Claude Code CLI was not found. Install Claude Code and verify `claude --version` works in Terminal. Codiff searches PATH, ~/.local/bin/claude, /opt/homebrew/bin/claude, and /usr/local/bin/claude. If Claude Code is installed somewhere else, launch Codiff with `CODIFF_CLAUDE_PATH=/absolute/path/to/claude codiff -w`.'; @@ -40,16 +40,16 @@ const CLAUDE_NOT_LOGGED_IN_MESSAGE = /** @type {ReadonlyArray} */ const CLAUDE_MODELS = Object.freeze([ { - id: 'claude-opus-4-8', - label: 'Best: Claude Opus 4.8', + id: 'opus', + label: 'Best: Claude Opus', }, { id: DEFAULT_CLAUDE_MODEL, - label: 'Balanced: Claude Sonnet 4.6', + label: 'Balanced: Claude Sonnet', }, { id: FALLBACK_CLAUDE_MODEL, - label: 'Fast: Claude Haiku 4.5', + label: 'Fast: Claude Haiku', }, ]); const CLAUDE_MODEL_IDS = new Set(CLAUDE_MODELS.map((model) => model.id)); @@ -108,9 +108,14 @@ const isClaudeNotLoggedInError = (value) => value, ); +// Legacy configs store pinned ids like `claude-sonnet-4-6`; map them to the CLI alias. /** @param {unknown} value @returns {string} */ const normalizeClaudeModel = (value) => - normalizeEnum(value, CLAUDE_MODEL_IDS, DEFAULT_CLAUDE_MODEL); + normalizeEnum( + typeof value === 'string' ? value.replace(/^claude-(opus|sonnet|haiku)\b.*$/, '$1') : value, + CLAUDE_MODEL_IDS, + DEFAULT_CLAUDE_MODEL, + ); /** @param {string} value */ const isClaudeModelAvailabilityError = (value) =>