feat: plan_track工具卡片增加自动确认下拉框,支持跳过手动确认步骤
This commit is contained in:
@@ -585,6 +585,12 @@ async function handleRetry(): Promise<void> {
|
||||
},
|
||||
onConfirmTool: async (call) => showToolConfirm(call),
|
||||
onPlanReady: async (plan: string, steps: string[]) => {
|
||||
// 检查是否启用了自动确认计划
|
||||
const autoConfirm = state.get<boolean>('planAutoConfirm', false);
|
||||
if (autoConfirm) {
|
||||
logInfo('Plan Mode: 自动确认计划(用户已启用自动确认)');
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const { showHtmlConfirm } = await import('./prompt-modal.js');
|
||||
const html = buildPlanConfirmHtml(plan, steps);
|
||||
@@ -1305,6 +1311,12 @@ async function sendMessageWithAgentLoop(text: string, currentSession: ChatSessio
|
||||
},
|
||||
/** Plan Mode — 计划生成后等待用户确认(Markdown 渲染) */
|
||||
onPlanReady: async (plan: string, steps: string[]) => {
|
||||
// 检查是否启用了自动确认计划
|
||||
const autoConfirm = state.get<boolean>('planAutoConfirm', false);
|
||||
if (autoConfirm) {
|
||||
logInfo('Plan Mode: 自动确认计划(用户已启用自动确认)');
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const { showHtmlConfirm } = await import('./prompt-modal.js');
|
||||
const html = buildPlanConfirmHtml(plan, steps);
|
||||
|
||||
@@ -32,6 +32,18 @@ function updateToolBadge(toolName: string, mode: ToolMode): void {
|
||||
badge.className = `tool-card-badge ${info.cls}`;
|
||||
}
|
||||
|
||||
function updatePlanBadge(autoConfirm: boolean): void {
|
||||
const badge = modalEl.querySelector('#badge_plan_track') as HTMLElement;
|
||||
if (!badge) return;
|
||||
if (autoConfirm) {
|
||||
badge.textContent = '自动确认';
|
||||
badge.className = 'tool-card-badge auto';
|
||||
} else {
|
||||
badge.textContent = '需确认';
|
||||
badge.className = 'tool-card-badge confirm';
|
||||
}
|
||||
}
|
||||
|
||||
export function initToolsModal(): void {
|
||||
modalEl = document.querySelector('#toolsModal')!;
|
||||
|
||||
@@ -65,6 +77,22 @@ export function initToolsModal(): void {
|
||||
logInfo(`工具模式切换: ${toolName} → ${mode}`);
|
||||
});
|
||||
});
|
||||
|
||||
// Plan 确认模式下拉框
|
||||
const planSelect = modalEl.querySelector<HTMLSelectElement>('#select_plan_confirm');
|
||||
if (planSelect) {
|
||||
planSelect.addEventListener('change', async () => {
|
||||
const autoConfirm = planSelect.value === 'auto';
|
||||
const db = state.get<ChatDB | null>(KEYS.DB);
|
||||
|
||||
state.set('planAutoConfirm', autoConfirm);
|
||||
if (db) await db.saveSetting('planAutoConfirm', autoConfirm);
|
||||
updatePlanBadge(autoConfirm);
|
||||
|
||||
showToast(`计划确认:${autoConfirm ? '自动确认' : '需确认'}`, 'info');
|
||||
logInfo(`计划确认模式切换: → ${autoConfirm ? 'auto' : 'confirm'}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function openToolsModal(): void {
|
||||
@@ -79,6 +107,14 @@ export function openToolsModal(): void {
|
||||
updateToolBadge(toolName, mode);
|
||||
});
|
||||
|
||||
// 同步 Plan 确认模式下拉框
|
||||
const planSelect = modalEl.querySelector<HTMLSelectElement>('#select_plan_confirm');
|
||||
if (planSelect) {
|
||||
const autoConfirm = state.get<boolean>('planAutoConfirm', false);
|
||||
planSelect.value = autoConfirm ? 'auto' : 'confirm';
|
||||
updatePlanBadge(autoConfirm);
|
||||
}
|
||||
|
||||
modalEl.style.display = '';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user