feat(sidebar): worktree indicator on session rows (#3057)

Co-authored-by: codex <[email protected]>
This commit is contained in:
Icarus Wingsandcodex authored and GitHub committed 2026-06-19 11:23:47 -07:00
1 parent a4446e263d
commit d9f59be704
3 files changed
+77 -1

No files matched your search

+2
View File
@@ -17,6 +17,7 @@ import {
resolveThreadPr,
terminalStatusFromRunningIds,
ThreadStatusLabel,
ThreadWorktreeIndicator,
} from "./ThreadStatusIndicators";
import { ProjectFavicon } from "./ProjectFavicon";
import { useAtomValue } from "@effect/atom-react";
@@ -743,6 +744,7 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
</TooltipPopup>
</Tooltip>
)}
<ThreadWorktreeIndicator thread={thread} />
{terminalStatus && (
<Tooltip>
<TooltipTrigger
@@ -0,0 +1,39 @@
import { ThreadId } from "@t3tools/contracts";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vite-plus/test";
import { ThreadWorktreeIndicator } from "./ThreadStatusIndicators";
describe("ThreadWorktreeIndicator", () => {
it("renders the worktree folder and branch in an accessible label", () => {
const markup = renderToStaticMarkup(
<ThreadWorktreeIndicator
thread={{
id: ThreadId.make("thread-1"),
branch: "feature/sidebar-indicator",
worktreePath: "/tmp/worktrees/sidebar-indicator",
}}
/>,
);
expect(markup).toContain('role="img"');
expect(markup).toContain(
'aria-label="Worktree: sidebar-indicator (feature/sidebar-indicator)"',
);
expect(markup).toContain('data-testid="thread-worktree-thread-1"');
});
it.each([null, "", " "])("renders nothing for an absent worktree path", (worktreePath) => {
const markup = renderToStaticMarkup(
<ThreadWorktreeIndicator
thread={{
id: ThreadId.make("thread-1"),
branch: "main",
worktreePath,
}}
/>,
);
expect(markup).toBe("");
});
});
@@ -4,7 +4,7 @@ import {
scopeThreadRef,
} from "@t3tools/client-runtime/environment";
import type { VcsStatusResult } from "@t3tools/contracts";
import { CloudIcon, GitPullRequestIcon, TerminalIcon } from "lucide-react";
import { CloudIcon, FolderGit2Icon, GitPullRequestIcon, TerminalIcon } from "lucide-react";
import { useMemo } from "react";
import { useEnvironment, usePrimaryEnvironmentId } from "../state/environments";
import { useProject } from "../state/entities";
@@ -15,6 +15,7 @@ import { useUiStateStore } from "../uiStateStore";
import { resolveChangeRequestPresentation } from "../sourceControlPresentation";
import { resolveThreadStatusPill, type ThreadStatusPill } from "./Sidebar.logic";
import type { SidebarThreadSummary } from "../types";
import { formatWorktreePathForDisplay } from "../worktreeCleanup";
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
export interface PrStatusIndicator {
@@ -94,6 +95,40 @@ export function terminalStatusFromRunningIds(
};
}
export function ThreadWorktreeIndicator({
thread,
}: {
thread: Pick<SidebarThreadSummary, "id" | "branch" | "worktreePath">;
}) {
const worktreePath = thread.worktreePath?.trim();
if (!worktreePath) {
return null;
}
const displayPath = formatWorktreePathForDisplay(worktreePath);
const tooltip = thread.branch
? `Worktree: ${displayPath} (${thread.branch})`
: `Worktree: ${displayPath}`;
return (
<Tooltip>
<TooltipTrigger
render={
<span
role="img"
aria-label={tooltip}
data-testid={`thread-worktree-${thread.id}`}
className="inline-flex items-center justify-center"
/>
}
>
<FolderGit2Icon className="size-3 text-muted-foreground/40" />
</TooltipTrigger>
<TooltipPopup side="top">{tooltip}</TooltipPopup>
</Tooltip>
);
}
export function ThreadStatusLabel({
status,
compact = false,