Skip to content

Commit 0a1f9e6

Browse files
committed
fix(threads): mark GUI threads launching when reopening
1 parent a386e6c commit 0a1f9e6

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

src/renderer/actions/threadActions.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
22
import { waitFor } from "@testing-library/react";
33
import type { Thread } from "@/shared/contracts";
44
import { useAppStore } from "@/renderer/state/appStore";
5-
import { openThread, toggleMarkThreadDone } from "./threadActions";
5+
import { openThread, reopenStoredThread, toggleMarkThreadDone } from "./threadActions";
66

77
const { bridge } = vi.hoisted(() => ({
88
bridge: {
@@ -126,6 +126,25 @@ describe("threadActions", () => {
126126
});
127127
});
128128

129+
it("marks inactive GUI threads launching when reopening", () => {
130+
const thread = makeThread({
131+
presentationMode: "gui",
132+
status: "inactive",
133+
sessionRef: {
134+
providerSessionId: "session-1",
135+
discoveredAt: "2026-03-22T00:00:00.000Z",
136+
},
137+
});
138+
useAppStore.setState((state) => ({ ...state, threads: [thread] }));
139+
140+
reopenStoredThread(thread.id);
141+
142+
const reopened = useAppStore.getState().threads[0];
143+
expect(reopened?.status).toBe("launching");
144+
expect(reopened?.attention).toBe("none");
145+
expect(useAppStore.getState().pendingThreadLaunches[thread.id]).toBe("");
146+
});
147+
129148
it("closes a live CLI thread when marking done even before a session ref is known", async () => {
130149
const project = useAppStore.getState().addProject({
131150
kind: "posix",

src/renderer/actions/threadActions.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,14 @@ export function reopenStoredThread(threadId: string): void {
117117
return;
118118
}
119119

120-
if (thread.presentationMode !== "gui") {
121-
startTransition(() => {
122-
store.updateThreadRuntime(thread.id, {
123-
status: "launching",
124-
attention: "none",
125-
...(thread.sessionRef ? { sessionRef: thread.sessionRef } : {}),
126-
canResumeWithConfig: thread.canResumeWithConfig || thread.sessionRef !== undefined,
127-
});
120+
startTransition(() => {
121+
store.updateThreadRuntime(thread.id, {
122+
status: "launching",
123+
attention: "none",
124+
...(thread.sessionRef ? { sessionRef: thread.sessionRef } : {}),
125+
canResumeWithConfig: thread.canResumeWithConfig || thread.sessionRef !== undefined,
128126
});
129-
}
127+
});
130128
store.queueThreadLaunch(thread.id, "");
131129
}
132130

0 commit comments

Comments
 (0)