The best way to control Claude Code, Codex and more from any computer or phone
Add test for listGitBranches from worktree cwd
Verifies that querying branches from a worktree directory correctly reports the worktree's branch as current, while the main repo still shows its own branch — the assumption the BranchToolbar fix relies on. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Julius Marminge committed
Feb 9, 2026 at 14:24 UTC
647449069dc5348b1dffe406b71210d7c988b881
1 file changed
+30
apps/desktop/src/git.test.ts
+30
@@ -262,6 +262,36 @@ describe("git integration", () => {
262
).rejects.toThrow();
263
});
264
265
+ it("listGitBranches from worktree cwd reports worktree branch as current", async () => {
266
+ await using tmp = await makeTmpDir();
267
+ await initRepoWithCommit(tmp.path);
268
+
269
+ const wtPath = path.join(tmp.path, "wt-list-dir");
270
+ const mainBranch = (await listGitBranches({ cwd: tmp.path })).branches.find(
271
+ (b) => b.current,
272
+ )!.name;
273
+
274
+ await createGitWorktree({
275
+ cwd: tmp.path,
276
+ branch: mainBranch,
277
+ newBranch: "wt-list",
278
+ path: wtPath,
279
+ });
280
+
281
+ // listGitBranches from the worktree should show wt-list as current
282
+ const wtBranches = await listGitBranches({ cwd: wtPath });
283
+ expect(wtBranches.isRepo).toBe(true);
284
+ const wtCurrent = wtBranches.branches.find((b) => b.current);
285
+ expect(wtCurrent!.name).toBe("wt-list");
286
+
287
+ // Main repo should still show the original branch as current
288
+ const mainBranches = await listGitBranches({ cwd: tmp.path });
289
+ const mainCurrent = mainBranches.branches.find((b) => b.current);
290
+ expect(mainCurrent!.name).toBe(mainBranch);
291
+
292
+ await removeGitWorktree({ cwd: tmp.path, path: wtPath });
293
+ });
294
+
295
it("removeGitWorktree cleans up the worktree", async () => {
296
await using tmp = await makeTmpDir();
297
await initRepoWithCommit(tmp.path);