baa-conductor

git clone 

commit
825afb9
parent
8809f1c
author
im_wower
date
2026-03-29 02:05:21 +0800 CST
fix: add conversation_id filter to sessions endpoint and fix askStream timeout race

Sessions query endpoint was missing conversation_id filtering that messages
and executions already supported. Also added clearTimeout in askStream's
resolve/reject wrappers to prevent timeout timer from firing after normal
completion.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 files changed,  +17, -8
M apps/claude-coded/src/daemon.ts
+2, -0
 1@@ -305,6 +305,7 @@ export class ClaudeCodedDaemon {
 2           }
 3         },
 4         resolve: (askResult) => {
 5+          clearTimeout(timer as ReturnType<typeof setTimeout>);
 6           done = true;
 7           if (eventResolve) {
 8             eventResolve({ value: undefined as unknown as ClaudeCodedStreamEvent, done: true });
 9@@ -313,6 +314,7 @@ export class ClaudeCodedDaemon {
10           resolve(askResult);
11         },
12         reject: (error) => {
13+          clearTimeout(timer as ReturnType<typeof setTimeout>);
14           done = true;
15           if (eventResolve) {
16             eventResolve({ value: undefined as unknown as ClaudeCodedStreamEvent, done: true });
M apps/conductor-daemon/src/local-api.ts
+3, -2
 1@@ -6146,15 +6146,16 @@ async function handleArtifactExecutionRead(context: LocalApiRequestContext): Pro
 2 async function handleArtifactSessionsList(context: LocalApiRequestContext): Promise<ConductorHttpResponse> {
 3   const store = requireArtifactStore(context.artifactStore);
 4   const platform = readOptionalQueryString(context.url, "platform");
 5+  const conversationId = readOptionalQueryString(context.url, "conversation_id");
 6   const limit = readPositiveIntegerQuery(context.url, "limit", ARTIFACT_DEFAULT_SESSION_LIMIT, ARTIFACT_LIST_MAX_LIMIT);
 7   const offset = readNonNegativeIntegerQuery(context.url, "offset", 0);
 8   const publicBaseUrl = store.getPublicBaseUrl();
 9 
10-  const sessions = await store.listSessions({ platform, limit, offset });
11+  const sessions = await store.listSessions({ platform, conversationId, limit, offset });
12 
13   return buildSuccessEnvelope(context.requestId, 200, {
14     count: sessions.length,
15-    filters: { platform: platform ?? null, limit, offset },
16+    filters: { platform: platform ?? null, conversation_id: conversationId ?? null, limit, offset },
17     sessions: sessions.map((s) => ({
18       id: s.id,
19       platform: s.platform,
M tasks/T-BUG-028.md
+12, -6
 1@@ -2,7 +2,7 @@
 2 
 3 ## 状态
 4 
 5-- 当前状态:`待开始`
 6+- 当前状态:`已完成`
 7 - 规模预估:`S`
 8 - 依赖任务:无(与 T-BUG-027 可并行)
 9 - 建议执行者:`Claude`(需要理解 local-api 查询路由和 daemon ask 生命周期)
10@@ -97,21 +97,27 @@
11 
12 ### 开始执行
13 
14-- 执行者:
15-- 开始时间:
16+- 执行者:Claude
17+- 开始时间:2026-03-29
18 - 状态变更:`待开始` → `进行中`
19 
20 ### 完成摘要
21 
22-- 完成时间:
23+- 完成时间:2026-03-29
24 - 状态变更:`进行中` → `已完成`
25 - 修改了哪些文件:
26+  - `apps/conductor-daemon/src/local-api.ts` — sessions 端点补 conversation_id 过滤
27+  - `apps/claude-coded/src/daemon.ts` — askStream resolve/reject 回调补 clearTimeout
28 - 核心实现思路:
29-- 跑了哪些测试:
30+  1. `handleArtifactSessionsList` 用 `readOptionalQueryString` 读取 `conversation_id`,传给 `store.listSessions()`,并在 filters 对象中返回
31+  2. `askStream` 的 `pendingAsk.resolve` 和 `pendingAsk.reject` 回调首行加 `clearTimeout(timer)`,确保正常完成或手动 reject 时立即取消超时计时器,避免竞争
32+- 跑了哪些测试:`pnpm build` + `pnpm test`(全部通过)
33 
34 ### 执行过程中遇到的问题
35 
36-> 记录执行过程中遇到的阻塞、环境问题、临时绕过方案等。合并时由合并者判断是否需要修复或建新任务。
37+无
38 
39 ### 剩余风险
40 
41+无
42+