diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index dee60353ad..135841e79d 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -13,6 +13,7 @@ import { } from "lucide-react"; import { prStatusIndicator, + PrStatusTooltipContent, resolveThreadPr, terminalStatusFromRunningIds, ThreadStatusLabel, @@ -566,7 +567,9 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP } /> - {prStatus.tooltip} + + + )} {threadStatus && } diff --git a/apps/web/src/components/ThreadStatusIndicators.test.ts b/apps/web/src/components/ThreadStatusIndicators.test.ts index 2cf471afa7..217100ad66 100644 --- a/apps/web/src/components/ThreadStatusIndicators.test.ts +++ b/apps/web/src/components/ThreadStatusIndicators.test.ts @@ -1,7 +1,7 @@ import type { GitStatusResult } from "@t3tools/contracts"; import { describe, expect, it } from "vitest"; -import { resolveThreadPr } from "./ThreadStatusIndicators"; +import { prStatusIndicator, resolveThreadPr } from "./ThreadStatusIndicators"; function status(overrides: Partial = {}): GitStatusResult { return { @@ -61,3 +61,13 @@ describe("resolveThreadPr", () => { ).toBe(gitStatus.pr); }); }); + +describe("prStatusIndicator", () => { + it("formats PR tooltips with number, uppercase status, and title", () => { + expect(prStatusIndicator(status().pr)).toMatchObject({ + tooltip: "PR #42 - Open: PR branch", + tooltipLead: "PR #42 - Open", + tooltipTitle: "PR branch", + }); + }); +}); diff --git a/apps/web/src/components/ThreadStatusIndicators.tsx b/apps/web/src/components/ThreadStatusIndicators.tsx index e7d8bb173d..0bfde7399f 100644 --- a/apps/web/src/components/ThreadStatusIndicators.tsx +++ b/apps/web/src/components/ThreadStatusIndicators.tsx @@ -19,6 +19,8 @@ export interface PrStatusIndicator { label: "PR open" | "PR closed" | "PR merged"; colorClass: string; tooltip: string; + tooltipLead: string; + tooltipTitle: string; url: string; } @@ -30,14 +32,27 @@ export interface TerminalStatusIndicator { export type ThreadPr = GitStatusResult["pr"]; +function formatPrState(state: NonNullable["state"]): string { + return state.charAt(0).toUpperCase() + state.slice(1); +} + +function formatPrStatusTooltip(pr: NonNullable): string { + return `PR #${pr.number} - ${formatPrState(pr.state)}: ${pr.title}`; +} + export function prStatusIndicator(pr: ThreadPr): PrStatusIndicator | null { if (!pr) return null; + const tooltip = formatPrStatusTooltip(pr); + const tooltipLead = `PR #${pr.number} - ${formatPrState(pr.state)}`; + if (pr.state === "open") { return { label: "PR open", colorClass: "text-emerald-600 dark:text-emerald-300/90", - tooltip: `#${pr.number} PR open: ${pr.title}`, + tooltip, + tooltipLead, + tooltipTitle: pr.title, url: pr.url, }; } @@ -45,7 +60,9 @@ export function prStatusIndicator(pr: ThreadPr): PrStatusIndicator | null { return { label: "PR closed", colorClass: "text-zinc-500 dark:text-zinc-400/80", - tooltip: `#${pr.number} PR closed: ${pr.title}`, + tooltip, + tooltipLead, + tooltipTitle: pr.title, url: pr.url, }; } @@ -53,13 +70,25 @@ export function prStatusIndicator(pr: ThreadPr): PrStatusIndicator | null { return { label: "PR merged", colorClass: "text-violet-600 dark:text-violet-300/90", - tooltip: `#${pr.number} PR merged: ${pr.title}`, + tooltip, + tooltipLead, + tooltipTitle: pr.title, url: pr.url, }; } return null; } +export function PrStatusTooltipContent({ status }: { status: PrStatusIndicator }) { + return ( + + {status.tooltipLead} + + ); +} + export function resolveThreadPr(input: { threadBranch: string | null; gitStatus: GitStatusResult | null; @@ -186,7 +215,9 @@ export function ThreadRowLeadingStatus({ thread }: { thread: SidebarThreadSummar > - {prStatus.tooltip} + + + ) : null} {threadStatus ? : null}