Skip to content

Commit b760a44

Browse files
fix(web): keep queued and waiting threads subscribed
The keep-alive check only treated preparing, starting, and running as active, so queued and waiting threads closed their detail stream while the composer still showed working. Include queued and waiting to match run status and phase mapping.
1 parent cfdff56 commit b760a44

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎apps/web/src/state/threads.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { createRunningThreadKeepAliveAtom } from "./threads";
1919
const LOCAL = EnvironmentId.make("local");
2020
const REMOTE = EnvironmentId.make("remote");
2121

22-
type Status = "running" | "starting" | "idle";
22+
type Status = "running" | "starting" | "preparing" | "queued" | "waiting" | "idle";
2323
function shell(id: string, status: Status | null) {
2424
return { id: ThreadId.make(id), status: status ?? "idle" } satisfies Pick<
2525
OrchestrationV2ThreadShell,
@@ -159,6 +159,12 @@ describe("createRunningThreadKeepAliveAtom", () => {
159159
expect(h.openStreams()).toEqual([]);
160160
});
161161

162+
it("keeps queued and waiting threads open", () => {
163+
const h = makeHarness();
164+
h.registry.set(h.threads(LOCAL), [shell("a", "queued"), shell("b", "waiting")]);
165+
expect(h.openStreams()).toEqual(["local:a", "local:b"]);
166+
});
167+
162168
it("follows environments that connect and go away", () => {
163169
const h = makeHarness();
164170
h.registry.set(h.environmentIds, [LOCAL]);

‎apps/web/src/state/threads.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ export function useEnvironmentThread(
5151
}
5252

5353
const isRunning = (status: string) =>
54-
status === "preparing" || status === "starting" || status === "running";
54+
status === "preparing" ||
55+
status === "queued" ||
56+
status === "starting" ||
57+
status === "running" ||
58+
status === "waiting";
5559

5660
type KeptThreads = ReadonlyMap<EnvironmentId, ReadonlySet<ThreadId>>;
5761

0 commit comments

Comments
 (0)