feat: 实现计划管理工具和进度条实时更新

- 添加 plan_step_add/remove/update 和 plan_summary_update 事件支持
- 添加 onPhaseProgress 回调,联动独立进度条组件
- 扩展 MessageSegment 接口支持 progress 类型
- 映射 phaseId (sim -> simulation) 适配进度条
This commit is contained in:
XiaoFeng
2026-01-09 19:26:55 +08:00
parent 5546791549
commit 5c19be22d3
5 changed files with 504 additions and 10 deletions

View File

@ -288,6 +288,36 @@ async function handleUserMessageWithBackend(
percentage: data.percentage,
});
},
onPhaseProgress: (phaseId, status) => {
// 发送阶段进度更新到 WebView
// 映射 phaseId: sim -> simulation
const stepMap: Record<string, string> = {
spec: "spec",
design: "design",
sim: "simulation",
done: "done",
};
const step = stepMap[phaseId] || phaseId;
if (status === "current") {
// 显示进度条并更新到当前步骤
panel.webview.postMessage({ type: "showProgress" });
panel.webview.postMessage({ type: "updateProgress", step });
} else if (status === "completed") {
// 更新到下一步(或完成)
const steps = ["spec", "design", "simulation", "done"];
const currentIndex = steps.indexOf(step);
if (currentIndex < steps.length - 1) {
panel.webview.postMessage({
type: "updateProgress",
step: steps[currentIndex + 1],
});
} else {
panel.webview.postMessage({ type: "completeProgress" });
}
}
},
},
mode,
serviceTier // 传递服务等级