refactor(copilotcli): update action descriptions and adjust plan path handling (#308954)

This commit is contained in:
Don Jayamanne
2026-04-10 16:58:22 +10:00
committed by GitHub
parent e8b419162f
commit e9aba237c9
3 changed files with 19 additions and 13 deletions

View File

@@ -6106,12 +6106,12 @@
{
"name": "plan",
"description": "%github.copilot.command.cli.plan.description%",
"when": "config.github.copilot.chat.cli.planExitMode.enabled"
"when": "false"
},
{
"name": "fleet",
"description": "%github.copilot.command.cli.fleet.description%",
"when": "config.github.copilot.chat.cli.planExitMode.enabled"
"when": "false"
}
],
"customAgentTarget": "github-copilot",

View File

@@ -473,20 +473,25 @@ export class CopilotCLISession extends DisposableStore implements ICopilotCLISes
this._sdkSession.respondToExitPlanMode(event.data.requestId, { approved: false });
return;
}
const actionDescriptions: Record<ActionType, string> = {
'autopilot': l10n.t('Auto-approve all tool calls and continue until the task is done'),
'interactive': l10n.t('Let the agent continue in interactive mode, asking for user input and approval for each action.'),
'exit_only': l10n.t('Exit plan mode, but do not execute the plan. I will execute the plan myself after reviewing it.'),
'autopilot_fleet': l10n.t('Auto-approve all tool calls, including fleet management actions, and continue until the task is done.'),
};
const actionDescriptions: Record<string, { label: string; description: string }> = {
'autopilot': { label: 'Autopilot', description: l10n.t('Auto-approve all tool calls and continue until the task is done') },
'interactive': { label: 'Interactive', description: l10n.t('Let the agent continue in interactive mode, asking for input and approval for each action.') },
'exit_only': { label: 'Approve and exit', description: l10n.t('Exit planning, but do not execute the plan. I will execute the plan myself.') },
'autopilot_fleet': { label: 'Autopilot Fleet', description: l10n.t('Auto-approve all tool calls, including fleet management actions, and continue until the task is done.') },
} satisfies Record<ActionType, { label: string; description: string }>;
const approved = true;
event.data.actions;
try {
const planPath = this._sdkSession.getPlanPath();
const userInputRequest: IQuestion = {
question: l10n.t('Approve this plan?'),
question: planPath ? l10n.t('Approve this plan {0}?', `[Plan.md](${Uri.file(planPath).toString()})`) : l10n.t('Approve this plan?'),
header: l10n.t('Approve this plan?'),
options: event.data.actions.map(a => ({ label: (actionDescriptions as Record<string, string>)[a] ?? a, recommended: a === event.data.recommendedAction })),
options: event.data.actions.map(a => ({
label: actionDescriptions[a]?.label ?? a,
recommended: a === event.data.recommendedAction,
description: actionDescriptions[a]?.description ?? '',
})),
allowFreeformInput: true,
};
const answer = await this._userQuestionHandler.askUserQuestion(userInputRequest, this._toolInvocationToken as unknown as never, token);
@@ -499,8 +504,8 @@ export class CopilotCLISession extends DisposableStore implements ICopilotCLISes
this._sdkSession.respondToExitPlanMode(event.data.requestId, { approved: false, feedback: answer.freeText });
} else {
let selectedAction: ActionType = answer.selected[0] as ActionType;
Object.entries(actionDescriptions).forEach(([action, description]) => {
if (description === selectedAction) {
Object.entries(actionDescriptions).forEach(([action, item]) => {
if (item.label === selectedAction) {
selectedAction = action as ActionType;
}
});

View File

@@ -132,6 +132,7 @@ class MockSdkSession {
async getSelectedModel() { return this._selectedModel; }
async setSelectedModel(model: string, _reasoningEffort?: string) { this._selectedModel = model; }
async getEvents() { return []; }
getPlanPath(): string | null { return null; }
}
function createWorkspaceService(root: string): IWorkspaceService {