diff --git a/vscode/webview/plan/index.ts b/vscode/webview/plan/index.ts index a63cd219..b18e4659 100644 --- a/vscode/webview/plan/index.ts +++ b/vscode/webview/plan/index.ts @@ -72,6 +72,18 @@ declare function acquireVsCodeApi(): { postMessage(message: unknown): void }; body: HTMLElement; }; + type SessionCommandType = 'plan' | 'refine' | 'impl'; + + type RefineRunSummary = { + id: string; + status: string; + updatedAt?: number; + }; + + type RerunSummary = { + commandType: SessionCommandType; + }; + type SessionSummary = { id: string; status: string; @@ -83,7 +95,8 @@ declare function acquireVsCodeApi(): { postMessage(message: unknown): void }; prUrl?: string; implStatus?: string; phase?: string; - refineRuns?: Array<{ id: string; status: string; updatedAt?: number }>; + refineRuns?: RefineRunSummary[]; + rerun?: RerunSummary; widgets?: WidgetState[]; }; @@ -196,6 +209,33 @@ declare function acquireVsCodeApi(): { postMessage(message: unknown): void }; } }; + const resolveEffectiveStatus = (session: SessionSummary): string => { + const refineRuns = session.refineRuns ?? []; + const latestRefineStatus = refineRuns.length > 0 ? refineRuns[refineRuns.length - 1].status : undefined; + + if (session.rerun?.commandType) { + if (session.rerun.commandType === 'plan') { + return session.status; + } + if (session.rerun.commandType === 'impl') { + return session.implStatus || session.status; + } + if (session.rerun.commandType === 'refine') { + return latestRefineStatus || session.status; + } + } + + if (session.phase === 'implementing' || session.phase === 'completed') { + return session.implStatus || session.status; + } + + if (session.phase === 'refining') { + return latestRefineStatus || session.status; + } + + return session.status; + }; + const showInputPanel = () => { inputPanel?.classList.remove('hidden'); textarea?.focus(); @@ -576,9 +616,11 @@ declare function acquireVsCodeApi(): { postMessage(message: unknown): void }; sessionCache.set(session.id, session); const node = ensureSessionNode(session); - node.container.dataset.status = session.status; + const effectiveStatus = resolveEffectiveStatus(session); + + node.container.dataset.status = effectiveStatus; node.title.textContent = session.title || 'Untitled'; - node.status.textContent = session.status; + node.status.textContent = effectiveStatus; node.toggleButton.textContent = session.collapsed ? '[▶]' : '[▼]'; node.body.classList.toggle('collapsed', Boolean(session.collapsed));