The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 16:00 UTC
Add clickable PR status tooltip in sidebar threads
- Show PR number/title in a tooltip on each thread PR icon - Open PR links externally from the sidebar and show error toasts on failure - Improve thread row keyboard handling after switching to a non-button render Co-authored-by: codex <codex@users.noreply.github.com>
Julius Marminge committed
Feb 28, 2026 at 16:14 UTC
483702df77c6231f4f0755b23a316c12630bb36a
1 file changed
+69
-18
apps/web/src/components/Sidebar.tsx
+69
-18
@@ -22,6 +22,7 @@ import { serverConfigQueryOptions } from "../lib/serverReactQuery";
22
import { readNativeApi } from "../nativeApi";
23
import { toastManager } from "./ui/toast";
24
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./ui/collapsible";
25
+import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
26
import {
27
SidebarContent,
28
SidebarFooter,
@@ -67,9 +68,11 @@ interface TerminalStatusIndicator {
68
interface PrStatusIndicator {
69
label: "PR open" | "PR closed" | "PR merged";
70
colorClass: string;
71
+ tooltip: string;
72
+ url: string;
73
}
74
72
-type ThreadPrState = NonNullable<GitStatusResult["pr"]>["state"] | null;
75
+type ThreadPr = GitStatusResult["pr"];
76
77
function hasUnseenCompletion(thread: Thread): boolean {
78
if (!thread.latestTurn?.completedAt) return false;
@@ -133,23 +136,31 @@ function terminalStatusIndicator(thread: Thread): TerminalStatusIndicator | null
136
};
137
}
138
136
-function prStatusIndicator(prState: ThreadPrState): PrStatusIndicator | null {
137
- if (prState === "open") {
139
+function prStatusIndicator(pr: ThreadPr): PrStatusIndicator | null {
140
+ if (!pr) return null;
141
+
142
+ if (pr.state === "open") {
143
return {
144
label: "PR open",
145
colorClass: "text-emerald-600 dark:text-emerald-300/90",
146
+ tooltip: `#${pr.number} PR open: ${pr.title}`,
147
+ url: pr.url,
148
};
149
}
143
- if (prState === "closed") {
150
+ if (pr.state === "closed") {
151
return {
152
label: "PR closed",
153
colorClass: "text-zinc-500 dark:text-zinc-400/80",
154
+ tooltip: `#${pr.number} PR closed: ${pr.title}`,
155
+ url: pr.url,
156
};
157
}
149
- if (prState === "merged") {
158
+ if (pr.state === "merged") {
159
return {
160
label: "PR merged",
161
colorClass: "text-violet-600 dark:text-violet-300/90",
162
+ tooltip: `#${pr.number} PR merged: ${pr.title}`,
163
+ url: pr.url,
164
};
165
}
166
return null;
@@ -272,7 +283,7 @@ export default function Sidebar() {
283
refetchInterval: 60_000,
284
})),
285
});
275
- const prStateByThreadId = useMemo(() => {
286
+ const prByThreadId = useMemo(() => {
287
const statusByCwd = new Map<string, GitStatusResult>();
288
for (let index = 0; index < threadGitStatusCwds.length; index += 1) {
289
const cwd = threadGitStatusCwds[index];
@@ -283,16 +294,38 @@ export default function Sidebar() {
294
}
295
}
296
286
- const map = new Map<ThreadId, ThreadPrState>();
297
+ const map = new Map<ThreadId, ThreadPr>();
298
for (const target of threadGitTargets) {
299
const status = target.cwd ? statusByCwd.get(target.cwd) : undefined;
300
const branchMatches =
301
target.branch !== null && status?.branch !== null && status?.branch === target.branch;
291
- map.set(target.threadId, branchMatches ? status?.pr?.state ?? null : null);
302
+ map.set(target.threadId, branchMatches ? status?.pr ?? null : null);
303
}
304
return map;
305
}, [threadGitStatusCwds, threadGitStatusQueries, threadGitTargets]);
306
307
+ const openPrLink = useCallback((event: React.MouseEvent<HTMLElement>, prUrl: string) => {
308
+ event.preventDefault();
309
+ event.stopPropagation();
310
+
311
+ const api = readNativeApi();
312
+ if (!api) {
313
+ toastManager.add({
314
+ type: "error",
315
+ title: "Link opening is unavailable.",
316
+ });
317
+ return;
318
+ }
319
+
320
+ void api.shell.openExternal(prUrl).catch((error) => {
321
+ toastManager.add({
322
+ type: "error",
323
+ title: "Unable to open PR link",
324
+ description: error instanceof Error ? error.message : "An error occurred.",
325
+ });
326
+ });
327
+ }, []);
328
+
329
const handleNewThread = useCallback(
330
(
331
projectId: ProjectId,
@@ -714,13 +747,13 @@ export default function Sidebar() {
747
thread,
748
pendingApprovalByThreadId.get(thread.id) === true,
749
);
717
- const prStatus = prStatusIndicator(prStateByThreadId.get(thread.id) ?? null);
750
+ const prStatus = prStatusIndicator(prByThreadId.get(thread.id) ?? null);
751
const terminalStatus = terminalStatusIndicator(thread);
752
753
return (
754
<SidebarMenuSubItem key={thread.id} className="w-full">
755
<SidebarMenuSubButton
723
- render={<button type="button" />}
756
+ render={<div role="button" tabIndex={0} />}
757
size="sm"
758
isActive={isActive}
759
className={`h-7 w-full translate-x-0 justify-start px-2 text-left hover:bg-accent hover:text-foreground ${
@@ -734,6 +767,14 @@ export default function Sidebar() {
767
params: { threadId: thread.id },
768
});
769
}}
770
+ onKeyDown={(event) => {
771
+ if (event.key !== "Enter" && event.key !== " ") return;
772
+ event.preventDefault();
773
+ void navigate({
774
+ to: "/$threadId",
775
+ params: { threadId: thread.id },
776
+ });
777
+ }}
778
onContextMenu={(event) => {
779
event.preventDefault();
780
void handleThreadContextMenu(thread.id, {
@@ -761,14 +802,24 @@ export default function Sidebar() {
802
</div>
803
<div className="ml-auto flex shrink-0 items-center gap-1.5">
804
{prStatus && (
764
- <span
765
- role="img"
766
- aria-label={prStatus.label}
767
- title={prStatus.label}
768
- className={`inline-flex items-center justify-center ${prStatus.colorClass}`}
769
- >
770
- <GitPullRequestIcon className="size-3" />
771
- </span>
805
+ <Tooltip>
806
+ <TooltipTrigger
807
+ render={
808
+ <button
809
+ type="button"
810
+ aria-label={prStatus.tooltip}
811
+ title={prStatus.tooltip}
812
+ className={`inline-flex items-center justify-center ${prStatus.colorClass} cursor-pointer rounded-sm outline-hidden focus-visible:ring-1 focus-visible:ring-ring`}
813
+ onClick={(event) => {
814
+ openPrLink(event, prStatus.url);
815
+ }}
816
+ >
817
+ <GitPullRequestIcon className="size-3" />
818
+ </button>
819
+ }
820
+ />
821
+ <TooltipPopup side="top">{prStatus.tooltip}</TooltipPopup>
822
+ </Tooltip>
823
)}
824
{terminalStatus && (
825
<span