Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion config/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"settings": {
"agentBackend": "codex",
"checkForUpdates": true,
"claudeModel": "claude-sonnet-4-6",
"claudeModel": "sonnet",
"codeFontFamily": "",
"codeFontSize": 13,
"copyCommentsOnClose": false,
Expand Down
4 changes: 2 additions & 2 deletions core/config/codiff-config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 12 additions & 1 deletion electron/__tests__/claude.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
19 changes: 12 additions & 7 deletions electron/claude.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.';
Expand All @@ -40,16 +40,16 @@ const CLAUDE_NOT_LOGGED_IN_MESSAGE =
/** @type {ReadonlyArray<ClaudeModel>} */
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));
Expand Down Expand Up @@ -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) =>
Expand Down