From 22a6200b6923edffc09c55c949cf396db09518c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=A9=98?= Date: Sat, 9 May 2026 12:45:58 +0000 Subject: [PATCH] fix: close SSE stream for non-running threads, fix Live badge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - routes-live: check .running marker before keeping SSE open; if thread is not running, emit existing records and close - thread-detail: only show Live badge when connected AND not completed 小橘 --- packages/cli-workflow/src/commands/serve/routes-live.ts | 8 +++++++- .../workflow-dashboard/src/components/thread-detail.tsx | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/cli-workflow/src/commands/serve/routes-live.ts b/packages/cli-workflow/src/commands/serve/routes-live.ts index 47bb134..4fbc5b5 100644 --- a/packages/cli-workflow/src/commands/serve/routes-live.ts +++ b/packages/cli-workflow/src/commands/serve/routes-live.ts @@ -1,4 +1,4 @@ -import { statSync, watch } from "node:fs"; +import { existsSync, statSync, watch } from "node:fs"; import { join } from "node:path"; import { createCasStore, getContentMerklePayload } from "@uncaged/workflow-cas"; import { @@ -307,6 +307,12 @@ export function createLiveRoutes(storageRoot: string): Hono { return; } + // If thread is not actively running, emit all records and close — don't keep SSE open + const runningPath = join(storageRoot, "logs", threadTarget.bundleHash, `${threadId}.running`); + if (!existsSync(runningPath)) { + return; + } + const controller = new AbortController(); let completed = false; diff --git a/packages/workflow-dashboard/src/components/thread-detail.tsx b/packages/workflow-dashboard/src/components/thread-detail.tsx index cb3f516..4127759 100644 --- a/packages/workflow-dashboard/src/components/thread-detail.tsx +++ b/packages/workflow-dashboard/src/components/thread-detail.tsx @@ -80,7 +80,7 @@ export function ThreadDetail({ agent, threadId, onBack }: Props) {

{threadId} - {sse.connected && ( + {sse.connected && !sse.completed && (