fix(desktop): 轮询命中终态时同步 phase —— 运行按钮不再永卡「运行中」
attachRun 的状态轮询此前只更新 lifecycle、不动 phase。token 流没收到 done 的场景 (如恢复的在途任务、或任务被外部置终态)→ phase 永卡 streaming → Studio 运行按钮 永远禁用「运行中…」,看似不能跑新编排。 修复:轮询命中终态(done/failed/timeout/rejected)时把 phase 也置 done/error, 释放运行按钮。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -110,7 +110,17 @@ export default function App() {
|
||||
pollRef.current = window.setInterval(async () => {
|
||||
try {
|
||||
const s = await taskStatus(taskId);
|
||||
setRun((r) => (r.taskId === taskId ? { ...r, lifecycle: s.status, detail: s.detail } : r));
|
||||
setRun((r) => {
|
||||
if (r.taskId !== taskId) return r;
|
||||
// 命中终态:同时把 phase 也置终态,否则 token 流没收到 done(如恢复的任务/外部置终态)
|
||||
// 时 phase 会永卡 streaming → 运行按钮永远禁用「运行中…」。
|
||||
const phase = terminal.has(s.status)
|
||||
? s.status === "failed" || s.status === "timeout"
|
||||
? "error"
|
||||
: "done"
|
||||
: r.phase;
|
||||
return { ...r, lifecycle: s.status, detail: s.detail, phase };
|
||||
});
|
||||
if (terminal.has(s.status)) stopPoll();
|
||||
} catch {
|
||||
/* 忽略瞬时失败,下个 tick 再试 */
|
||||
|
||||
Reference in New Issue
Block a user