| author | |
| committer | |
| log | 005e13089a4a8f44cb25452cb4b8d9b18184a1b7 |
| tree | 1d6ce8720a00f255ab05b2ac4008ed33cd2fcc89 |
| parent | d9cce6402ae875b24d9ddbe73866eee94ec16ddb |
- Keep existing `branch` and `worktreePath` values when `setProjectDraftThreadId` receives `undefined`
- Add a regression test covering the undefined-update case2 files changed, 24 insertions(+), 6 deletions(-)
apps/web/src/composerDraftStore.test.ts+18| ... | ... | @@ -275,6 +275,24 @@ describe("composerDraftStore project draft thread mapping", () => { |
| 275 | 275 | worktreePath: "/tmp/feature-next", |
| 276 | 276 | }); |
| 277 | 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 | }); | |
| 278 | 296 | }); |
| 279 | 297 | |
| 280 | 298 | describe("composerDraftStore setModel", () => { |
apps/web/src/composerDraftStore.ts+6-6| ... | ... | @@ -460,13 +460,13 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()( |
| 460 | 460 | projectId, |
| 461 | 461 | createdAt: options?.createdAt ?? existingThread?.createdAt ?? new Date().toISOString(), |
| 462 | 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 | 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 | 470 | }; |
| 471 | 471 | const hasSameProjectMapping = previousThreadIdForProject === threadId; |
| 472 | 472 | const hasSameDraftThread = |