fix: address review findings (#5139)
This commit is contained in:
@@ -403,4 +403,31 @@ describe('source-control AI action recipes', () => {
|
||||
error: 'Command template is empty for commit messages.'
|
||||
})
|
||||
})
|
||||
|
||||
it('lists supported agents when a text action uses an unsupported saved agent', () => {
|
||||
const base = settings()
|
||||
base.sourceControlAi = {
|
||||
...base.sourceControlAi!,
|
||||
actions: {
|
||||
...base.sourceControlAi!.actions,
|
||||
commitMessage: {
|
||||
agentId: 'aider',
|
||||
commandInputTemplate: '{basePrompt}'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expect(
|
||||
resolveSourceControlAiForOperation({
|
||||
settings: base,
|
||||
repo: null,
|
||||
operation: 'commitMessage',
|
||||
discoveryHostKey: 'local'
|
||||
})
|
||||
).toEqual({
|
||||
ok: false,
|
||||
error:
|
||||
'Agent "aider" does not support Source Control AI commit messages. Supported agents: Claude, Codex, OpenCode, Pi, Amp, Cursor, Kimi, GitHub Copilot, Antigravity, or Custom command.'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
CUSTOM_AGENT_ID,
|
||||
getCommitMessageAgentSpec,
|
||||
getCommitMessageModel,
|
||||
listCommitMessageAgentCapabilities,
|
||||
type CustomAgentId,
|
||||
isCustomAgentId,
|
||||
resolveCommitMessageAgentChoice
|
||||
@@ -104,6 +105,12 @@ const PR_CREATION_DEFAULT_KEYS = [
|
||||
'openAfterCreate'
|
||||
] as const
|
||||
|
||||
function supportedSourceControlAiAgentSummary(): string {
|
||||
return `Supported agents: ${listCommitMessageAgentCapabilities()
|
||||
.map((capability) => capability.label)
|
||||
.join(', ')}, or Custom command.`
|
||||
}
|
||||
|
||||
function copyRecord<T>(value: T | undefined): T | undefined {
|
||||
return value === undefined ? undefined : structuredClone(value)
|
||||
}
|
||||
@@ -1171,8 +1178,7 @@ export function resolveSourceControlAiForOperation(
|
||||
if (!agentChoice) {
|
||||
return {
|
||||
ok: false,
|
||||
error:
|
||||
'Choose a supported Source Control AI agent for this action in Settings -> Git -> Source Control AI.'
|
||||
error: `Choose a supported Source Control AI agent for this action in Settings -> Git -> Source Control AI. ${supportedSourceControlAiAgentSummary()}`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1220,14 +1226,14 @@ export function resolveSourceControlAiForOperation(
|
||||
if (!resolvedActionAgentId || isCustomAgentId(resolvedActionAgentId)) {
|
||||
return {
|
||||
ok: false,
|
||||
error: 'Choose a supported Source Control AI agent for this action.'
|
||||
error: `Choose a supported Source Control AI agent for this action. ${supportedSourceControlAiAgentSummary()}`
|
||||
}
|
||||
}
|
||||
const spec = getCommitMessageAgentSpec(resolvedActionAgentId)
|
||||
if (!spec) {
|
||||
return {
|
||||
ok: false,
|
||||
error: `Agent "${resolvedActionAgentId}" does not support Source Control AI ${OPERATION_LABEL[input.operation]}.`
|
||||
error: `Agent "${resolvedActionAgentId}" does not support Source Control AI ${OPERATION_LABEL[input.operation]}. ${supportedSourceControlAiAgentSummary()}`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user