#39 Phase 1.3: thread.ts 适配统一存储 #42

Closed
opened 2026-06-04 06:04:55 +00:00 by xiaoju · 0 comments
Owner

Parent: #39
Depends on: #40, #41

目标

thread.ts 中所有使用 deleteThread + addHistoryEntry 模式的地方,改为调用 completeThread。list/show 命令适配新的查询方式。

改动

packages/cli/src/commands/thread.ts

complete/cancel 逻辑(约 L1039 和 L1554):

// 现在
deleteThread(uwf.varStore, threadId);
addHistoryEntry(uwf.varStore, { thread: threadId, workflow, head, completedAt, reason });

// 改为
completeThread(uwf.varStore, threadId, reason);

list 命令(cmdThreadList):

  • active list: 调用 loadActiveThreads() 代替 loadAllThreads()
  • history list: 调用 loadHistoryThreads() 代替 loadAllHistory()
  • 返回的 ThreadListItemThreadHistoryLine 统一为从 ThreadIndexEntry 构造

show 命令(cmdThreadShow):

  • 查找 thread 时先查 getThread(),不再 fallback 到 findHistoryEntry()
  • 因为现在所有 thread 都在同一个 prefix 下,getThread() 已经能找到 completed thread

shared.ts (resolveActiveThreadWorkflowHash):

  • 去掉 findHistoryEntry fallback,统一用 getThread()

import 清理:

  • 删除 addHistoryEntry, deleteThread, findHistoryEntry, loadAllHistory 的 import
  • 新增 completeThread, loadActiveThreads, loadHistoryThreads 的 import

注意

  • resolveActiveThreadStatus() 可能需要适配——现在可以直接从 entry.status 读取,不再需要 background marker 推断(但 background marker 检测 running 状态仍保留)
  • dashboard 的适配(如需要)单独 issue
  • proman build && proman test 通过
Parent: #39 Depends on: #40, #41 ## 目标 thread.ts 中所有使用 `deleteThread + addHistoryEntry` 模式的地方,改为调用 `completeThread`。list/show 命令适配新的查询方式。 ## 改动 ### `packages/cli/src/commands/thread.ts` **complete/cancel 逻辑(约 L1039 和 L1554):** ```typescript // 现在 deleteThread(uwf.varStore, threadId); addHistoryEntry(uwf.varStore, { thread: threadId, workflow, head, completedAt, reason }); // 改为 completeThread(uwf.varStore, threadId, reason); ``` **list 命令(`cmdThreadList`):** - active list: 调用 `loadActiveThreads()` 代替 `loadAllThreads()` - history list: 调用 `loadHistoryThreads()` 代替 `loadAllHistory()` - 返回的 `ThreadListItem` 从 `ThreadHistoryLine` 统一为从 `ThreadIndexEntry` 构造 **show 命令(`cmdThreadShow`):** - 查找 thread 时先查 `getThread()`,不再 fallback 到 `findHistoryEntry()` - 因为现在所有 thread 都在同一个 prefix 下,`getThread()` 已经能找到 completed thread **shared.ts (`resolveActiveThreadWorkflowHash`):** - 去掉 `findHistoryEntry` fallback,统一用 `getThread()` **import 清理:** - 删除 `addHistoryEntry`, `deleteThread`, `findHistoryEntry`, `loadAllHistory` 的 import - 新增 `completeThread`, `loadActiveThreads`, `loadHistoryThreads` 的 import ### 注意 - `resolveActiveThreadStatus()` 可能需要适配——现在可以直接从 `entry.status` 读取,不再需要 background marker 推断(但 background marker 检测 running 状态仍保留) - dashboard 的适配(如需要)单独 issue - `proman build && proman test` 通过
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#42