Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 45 additions & 3 deletions vscode/webview/plan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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[];
};

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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));
Expand Down