@devries-cameron20 / t3code-1 / commits / 005e13089a
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Preserve draft branch/worktree when update options are undefined

- Keep existing `branch` and `worktreePath` values when `setProjectDraftThreadId` receives `undefined` - Add a regression test covering the undefined-update case

Julius Marminge committed Mar 1, 2026 at 19:16 UTC 005e13089a4a8f44cb25452cb4b8d9b18184a1b7
2 files changed +24 -6
apps/web/src/composerDraftStore.test.ts
+18
@@ -275,6 +275,24 @@ describe("composerDraftStore project draft thread mapping", () => {
275 worktreePath: "/tmp/feature-next",
276 });
277 });
278 +
279 + it("preserves existing branch and worktree when setProjectDraftThreadId receives undefined", () => {
280 + const store = useComposerDraftStore.getState();
281 + store.setProjectDraftThreadId(projectId, threadId, {
282 + branch: "main",
283 + worktreePath: "/tmp/main-worktree",
284 + });
285 + store.setProjectDraftThreadId(projectId, threadId, {
286 + branch: undefined,
287 + worktreePath: undefined,
288 + });
289 +
290 + expect(useComposerDraftStore.getState().getDraftThread(threadId)).toMatchObject({
291 + projectId,
292 + branch: "main",
293 + worktreePath: "/tmp/main-worktree",
294 + });
295 + });
296 });
297
298 describe("composerDraftStore setModel", () => {
apps/web/src/composerDraftStore.ts
+6 -6
@@ -460,13 +460,13 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
460 projectId,
461 createdAt: options?.createdAt ?? existingThread?.createdAt ?? new Date().toISOString(),
462 branch:
463 - options && "branch" in options
464 - ? (options.branch ?? null)
465 - : (existingThread?.branch ?? null),
463 + options?.branch === undefined
464 + ? (existingThread?.branch ?? null)
465 + : (options.branch ?? null),
466 worktreePath:
467 - options && "worktreePath" in options
468 - ? (options.worktreePath ?? null)
469 - : (existingThread?.worktreePath ?? null),
467 + options?.worktreePath === undefined
468 + ? (existingThread?.worktreePath ?? null)
469 + : (options.worktreePath ?? null),
470 };
471 const hasSameProjectMapping = previousThreadIdForProject === threadId;
472 const hasSameDraftThread =