Enable AI commit messages by default (#2060)

* test commit

* fix: address review findings
This commit is contained in:
Jinjing
2026-05-15 21:33:59 -07:00
committed by GitHub
parent 6a960a855e
commit e9bf07643e
11 changed files with 206 additions and 113 deletions
+4 -4
View File
@@ -18,9 +18,9 @@ describe('COMMIT_MESSAGE_AGENT_SPECS', () => {
expect(ids).toEqual(['claude', 'codex'])
})
it('uses the smallest model as the default for each agent', () => {
expect(COMMIT_MESSAGE_AGENT_SPECS.claude?.defaultModelId).toBe('claude-haiku-4-5')
expect(COMMIT_MESSAGE_AGENT_SPECS.codex?.defaultModelId).toBe('gpt-5.4-mini')
it('uses the smartest model as the default for each agent', () => {
expect(COMMIT_MESSAGE_AGENT_SPECS.claude?.defaultModelId).toBe('claude-opus-4-7')
expect(COMMIT_MESSAGE_AGENT_SPECS.codex?.defaultModelId).toBe('gpt-5.5')
})
it('defaults the agent picker to Claude', () => {
@@ -86,7 +86,7 @@ describe('COMMIT_MESSAGE_AGENT_SPECS', () => {
expect(codex).toMatchObject({
id: 'codex',
label: 'Codex',
defaultModelId: 'gpt-5.4-mini'
defaultModelId: 'gpt-5.5'
})
expect(codex).not.toHaveProperty('binary')
expect(codex).not.toHaveProperty('buildArgs')
+16 -3
View File
@@ -94,7 +94,7 @@ export const COMMIT_MESSAGE_AGENT_SPECS: Partial<Record<TuiAgent, CommitMessageA
defaultThinkingLevel: 'low'
}
],
defaultModelId: 'claude-haiku-4-5'
defaultModelId: 'claude-opus-4-7'
},
codex: {
id: 'codex',
@@ -118,7 +118,6 @@ export const COMMIT_MESSAGE_AGENT_SPECS: Partial<Record<TuiAgent, CommitMessageA
],
// Why: ordered to match the official `codex` model picker — descending
// by version so the frontier model lands on top and legacy models trail.
// Default still resolves by id (`gpt-5.4-mini`), independent of order.
models: [
{
id: 'gpt-5.5',
@@ -191,7 +190,7 @@ export const COMMIT_MESSAGE_AGENT_SPECS: Partial<Record<TuiAgent, CommitMessageA
defaultThinkingLevel: 'low'
}
],
defaultModelId: 'gpt-5.4-mini'
defaultModelId: 'gpt-5.5'
}
}
@@ -205,6 +204,7 @@ export const DEFAULT_COMMIT_MESSAGE_AGENT_ID: TuiAgent = 'claude'
export const CUSTOM_AGENT_ID = 'custom' as const
export type CustomAgentId = typeof CUSTOM_AGENT_ID
export type CommitMessageAgentChoice = TuiAgent | CustomAgentId
export type DefaultTuiAgentPreference = TuiAgent | 'blank' | null | undefined
export function isCustomAgentId(id: string | null | undefined): id is CustomAgentId {
return id === CUSTOM_AGENT_ID
@@ -214,6 +214,19 @@ export function getCommitMessageAgentSpec(agentId: TuiAgent): CommitMessageAgent
return COMMIT_MESSAGE_AGENT_SPECS[agentId]
}
export function resolveCommitMessageAgentChoice(
configuredAgentId: CommitMessageAgentChoice | null | undefined,
defaultTuiAgent: DefaultTuiAgentPreference
): CommitMessageAgentChoice | null {
if (configuredAgentId) {
return configuredAgentId
}
if (defaultTuiAgent && defaultTuiAgent !== 'blank') {
return getCommitMessageAgentSpec(defaultTuiAgent) ? defaultTuiAgent : null
}
return DEFAULT_COMMIT_MESSAGE_AGENT_ID
}
export function getCommitMessageModel(
agentId: TuiAgent,
modelId: string
+1 -1
View File
@@ -45,7 +45,7 @@ export function buildCommitMessagePrompt(
'- Optional body: blank line, then short wrapped bullet points or prose explaining WHY.',
'- Capture the primary user-visible or developer-visible change.',
'- Use only the staged changes below as context.',
'- Do not include "Co-authored-by" trailers - Orca appends them after generation when configured.',
'- Do not include "Co-authored-by" or other git trailers.',
'',
`Branch: ${context.branch ?? '(detached)'}`,
'',
+8
View File
@@ -9,4 +9,12 @@ describe('getDefaultSettings', () => {
it('enables separate light terminal theme by default', () => {
expect(getDefaultSettings('/tmp').terminalUseSeparateLightTheme).toBe(true)
})
it('enables AI commit messages by default without pinning a separate agent', () => {
expect(getDefaultSettings('/tmp').commitMessageAi).toMatchObject({
enabled: true,
agentId: null,
selectedModelByAgent: {}
})
})
})
+5 -5
View File
@@ -274,12 +274,12 @@ export function getDefaultSettings(homedir: string): GlobalSettings {
lastViewByProject: {},
activeProject: null
},
// Why: opt-in feature — `enabled: false` keeps the Generate button hidden
// for existing users until they discover and turn it on in Settings. The
// per-agent / per-model maps stay empty until the user activates the
// toggle, at which point the pane fills them with the spec defaults.
// Why: default-on uses the user's default agent when it supports
// non-interactive commit-message generation. Keep agent/model maps empty
// so first use follows the default agent's configured default model instead
// of freezing a stale choice into new profiles.
commitMessageAi: {
enabled: false,
enabled: true,
agentId: null,
selectedModelByAgent: {},
selectedThinkingByModel: {},