fix: resolve workflow from CAS chain in collectCompletedThreads #47

Merged
xiaomo merged 1 commits from fix/completed-thread-workflow into main 2026-06-04 08:38:06 +00:00
+5 -4
View File
@@ -585,19 +585,20 @@ async function collectActiveThreads(
} }
function collectCompletedThreads( function collectCompletedThreads(
varStore: VarStore, uwf: UwfStore,
activeIds: Set<ThreadId>, activeIds: Set<ThreadId>,
): ThreadListItemWithStatus[] { ): ThreadListItemWithStatus[] {
const items: ThreadListItemWithStatus[] = []; const items: ThreadListItemWithStatus[] = [];
const history = loadHistoryThreads(varStore); const history = loadHistoryThreads(uwf.varStore);
const seen = new Set<ThreadId>(); // Deduplication (issue #470) const seen = new Set<ThreadId>(); // Deduplication (issue #470)
for (const [threadId, entry] of Object.entries(history)) { for (const [threadId, entry] of Object.entries(history)) {
if (!activeIds.has(threadId as ThreadId) && !seen.has(threadId as ThreadId)) { if (!activeIds.has(threadId as ThreadId) && !seen.has(threadId as ThreadId)) {
seen.add(threadId as ThreadId); seen.add(threadId as ThreadId);
const status = entry.status; const status = entry.status;
const workflow = resolveWorkflowFromHead(uwf, entry.head);
items.push({ items.push({
thread: threadId as ThreadId, thread: threadId as ThreadId,
workflow: "", // Will be resolved later if needed workflow: workflow ?? "",
head: entry.head, head: entry.head,
status, status,
currentRole: null, currentRole: null,
@@ -662,7 +663,7 @@ export async function cmdThreadList(
statusFilter.includes("cancelled"); statusFilter.includes("cancelled");
if (includeCompleted) { if (includeCompleted) {
const activeIds = new Set(items.map((i) => i.thread)); const activeIds = new Set(items.map((i) => i.thread));
const completedItems = collectCompletedThreads(uwf.varStore, activeIds); const completedItems = collectCompletedThreads(uwf, activeIds);
items = items.concat(completedItems); items = items.concat(completedItems);
} }