web: activate gateway subscription for rehydrated subagent streams

This commit is contained in:
kumarabhirup 2026-02-19 21:52:15 -08:00
parent a0cc5834f2
commit ec561894cb
No known key found for this signature in database
GPG Key ID: DB7CA2289CAB0167

View File

@ -1,4 +1,4 @@
import { subscribeToSubagent, hasActiveSubagent, isSubagentRunning, ensureRegisteredFromDisk } from "@/lib/subagent-runs";
import { subscribeToSubagent, hasActiveSubagent, isSubagentRunning, ensureRegisteredFromDisk, ensureSubagentStreamable } from "@/lib/subagent-runs";
import type { SseEvent } from "@/lib/subagent-runs";
import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";
@ -51,6 +51,10 @@ export async function GET(req: Request) {
return new Response("Subagent not found", { status: 404 });
}
// For still-running subagents rehydrated from disk, activate the gateway
// WebSocket subscription so new events arrive in real time.
ensureSubagentStreamable(sessionKey);
const isActive = isSubagentRunning(sessionKey);
const encoder = new TextEncoder();
let closed = false;