Skip to content

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.

Show worktree name in thread delete confirmation

Julius Marminge4f5eb3be4d97
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index 349034fdc..ae2b6fb66 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -12,7 +12,7 @@ import {
type Thread,
} from "../types";
import { useNativeApi } from "../hooks/useNativeApi";
-import { getOrphanedWorktreePathForThread } from "../worktreeCleanup";
+import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "../worktreeCleanup";
const THEME_CYCLE = { system: "light", light: "dark", dark: "system" } as const;
function formatRelativeTime(iso: string): string {
@@ -265,12 +265,15 @@ export default function Sidebar() {
if (!thread) return;
const threadProject = state.projects.find((project) => project.id === thread.projectId);
const orphanedWorktreePath = getOrphanedWorktreePathForThread(state.threads, threadId);
+ const displayWorktreePath = orphanedWorktreePath
+ ? formatWorktreePathForDisplay(orphanedWorktreePath)
+ : null;
const shouldDeleteWorktree =
orphanedWorktreePath !== null &&
(await api.dialogs.confirm(
[
"This thread is the only one linked to this worktree:",
- orphanedWorktreePath,
+ displayWorktreePath ?? orphanedWorktreePath,
"",
"Delete the worktree too?",
].join("\n"),
diff --git a/apps/web/src/worktreeCleanup.test.ts b/apps/web/src/worktreeCleanup.test.ts
index cc86d7e8a..606717a02 100644
--- a/apps/web/src/worktreeCleanup.test.ts
+++ b/apps/web/src/worktreeCleanup.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import { DEFAULT_THREAD_TERMINAL_HEIGHT, DEFAULT_THREAD_TERMINAL_ID, type Thread } from "./types";
-import { getOrphanedWorktreePathForThread } from "./worktreeCleanup";
+import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "./worktreeCleanup";
function makeThread(overrides: Partial<Thread> = {}): Thread {
return {
@@ -69,3 +69,29 @@ describe("getOrphanedWorktreePathForThread", () => {
expect(result).toBe("/tmp/repo/worktrees/feature-a");
});
});
+
+describe("formatWorktreePathForDisplay", () => {
+ it("shows only the last path segment for unix-like paths", () => {
+ const result = formatWorktreePathForDisplay(
+ "/Users/julius/.t3/worktrees/codething-mvp/codething-4e609bb8",
+ );
+ expect(result).toBe("codething-4e609bb8");
+ });
+
+ it("normalizes windows separators before selecting the final segment", () => {
+ const result = formatWorktreePathForDisplay(
+ "C:\\Users\\julius\\.t3\\worktrees\\codething-mvp\\codething-4e609bb8",
+ );
+ expect(result).toBe("codething-4e609bb8");
+ });
+
+ it("uses the final segment even when outside ~/.t3/worktrees", () => {
+ const result = formatWorktreePathForDisplay("/tmp/custom-worktrees/my-worktree");
+ expect(result).toBe("my-worktree");
+ });
+
+ it("ignores trailing slashes", () => {
+ const result = formatWorktreePathForDisplay("/tmp/custom-worktrees/my-worktree/");
+ expect(result).toBe("my-worktree");
+ });
+});
diff --git a/apps/web/src/worktreeCleanup.ts b/apps/web/src/worktreeCleanup.ts
index b11481400..0bebd0835 100644
--- a/apps/web/src/worktreeCleanup.ts
+++ b/apps/web/src/worktreeCleanup.ts
@@ -31,3 +31,15 @@ export function getOrphanedWorktreePathForThread(
return isShared ? null : targetWorktreePath;
}
+
+export function formatWorktreePathForDisplay(worktreePath: string): string {
+ const trimmed = worktreePath.trim();
+ if (!trimmed) {
+ return worktreePath;
+ }
+
+ const normalized = trimmed.replace(/\\/g, "/").replace(/\/+$/, "");
+ const parts = normalized.split("/");
+ const lastPart = parts[parts.length - 1]?.trim() ?? "";
+ return lastPart.length > 0 ? lastPart : trimmed;
+}