Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
Surface worktree removal failures after thread deletion
Julius Marminge7de054fa4964
diff --git a/apps/server/src/git.test.ts b/apps/server/src/git.test.tsindex 5c46c27ba..bea0f3a97 100644--- a/apps/server/src/git.test.ts+++ b/apps/server/src/git.test.ts@@ -760,6 +760,24 @@ describe("git integration", () => {expect(dirty.hasWorkingTreeChanges).toBe(true);});+ it("includes command context when worktree removal fails", async () => {+ await using tmp = await makeTmpDir();+ await initRepoWithCommit(tmp.path);+ const core = new GitCoreService();+ const missingWorktreePath = path.join(tmp.path, "missing-worktree");++ const error = await core+ .removeWorktree({ cwd: tmp.path, path: missingWorktreePath })+ .then(() => null)+ .catch((err: unknown) => err);++ expect(error).toBeInstanceOf(Error);+ const message = (error as Error).message;+ expect(message).toContain("git worktree remove");+ expect(message).toContain(`cwd: ${tmp.path}`);+ expect(message).toContain(missingWorktreePath);+ });+it("refreshes upstream before statusDetails so behind count reflects remote updates", async () => {await using remote = await makeTmpDir();await using source = await makeTmpDir();diff --git a/apps/server/src/git.ts b/apps/server/src/git.tsindex c72ea3791..874c4f978 100644--- a/apps/server/src/git.ts+++ b/apps/server/src/git.ts@@ -546,10 +546,18 @@ export class GitCoreService {}async removeWorktree(input: GitRemoveWorktreeInput): Promise<void> {- await executeGit(input.cwd, ["worktree", "remove", input.path], {- timeoutMs: 15_000,- fallbackErrorMessage: "git worktree remove failed",- });+ const args = ["worktree", "remove", input.path] as const;+ try {+ await executeGit(input.cwd, args, {+ timeoutMs: 15_000,+ fallbackErrorMessage: "git worktree remove failed",+ });+ } catch (error) {+ const detail = error instanceof Error ? error.message : String(error);+ throw new Error(`${commandLabel(args)} failed (cwd: ${input.cwd}): ${detail}`, {+ cause: error,+ });+ }}async createBranch(input: GitCreateBranchInput): Promise<void> {diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex 68544c0dd..a8ebff1b4 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -336,8 +336,19 @@ export default function Sidebar() {cwd: threadProject.cwd,path: orphanedWorktreePath,});- } catch {- // Worktree deletion is best-effort and should not block thread deletion.+ } catch (error) {+ const message = error instanceof Error ? error.message : "Unknown error removing worktree.";+ console.error("Failed to remove orphaned worktree after thread deletion", {+ threadId,+ projectCwd: threadProject.cwd,+ worktreePath: orphanedWorktreePath,+ error,+ });+ toastManager.add({+ type: "error",+ title: "Thread deleted, but worktree removal failed",+ description: `Could not remove ${displayWorktreePath ?? orphanedWorktreePath}. ${message}`,+ });}},[api, dispatch, removeWorktreeMutation, state.projects, state.threads],