@devries-cameron20 / t3code Mirror · read-only / commits / 8a9d0e0dd5
Fork 0

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 22, 20:45 UTC

fix(web): thread search shows the same PR badge as the sidebar (#22627)

maria committed Oct 21, 2026 at 04:41 UTC 8a9d0e0dd553c5b0bd943ddfd9741d6bab0e486f
1 file changed +57 -56
apps/web/src/components/ThreadStatusIndicators.tsx
+57 -56
@@ -23,18 +23,13 @@ import { useProject } from "../state/entities";
23 import {
24 pullRequestListLines,
25 resolveThreadCurrentPullRequestLink,
26 + resolveThreadPullRequestBadge,
27 resolveThreadPullRequestChains,
28 type ThreadPullRequestBadge,
29 visibleThreadPullRequests,
30 } from "@t3tools/shared/threadPullRequests";
31 import { useRender } from "@base-ui/react/use-render";
31 -import {
32 - type ReactNode,
33 - type AnimationEvent,
34 - type MouseEvent,
35 - type ReactElement,
36 - type ComponentProps,
37 -} from "react";
32 +import { type ReactNode, type AnimationEvent, type MouseEvent, type ReactElement } from "react";
33 import { cn } from "../lib/utils";
34 import { revealThreadTerminal } from "../lib/revealThreadTerminal";
35
@@ -1019,24 +1014,11 @@ export function ThreadRowTrailingStatus({ thread }: { thread: SidebarThreadSumma
1014 );
1015 }
1016
1022 -function ThreadPullRequestNumber({
1023 - number,
1024 - className,
1025 - ...props
1026 -}: ComponentProps<"span"> & { number: number }) {
1027 - return (
1028 - <span {...props} className={cn("shrink-0 text-xs tabular-nums", className)}>
1029 - #{number}
1030 - </span>
1031 - );
1032 -}
1033 -
1034 -function settledPrHoverColorClass(state: NonNullable<ThreadPr>["state"], isDraft = false): string {
1017 +function settledPrHoverColorClass(state: ThreadPullRequestBadge["state"]): string {
1018 switch (state) {
1019 + case "draft":
1020 + return "group-hover/sidebar-row:text-zinc-500 dark:group-hover/sidebar-row:text-zinc-400/80";
1021 case "open":
1037 - if (isDraft) {
1038 - return "group-hover/sidebar-row:text-zinc-500 dark:group-hover/sidebar-row:text-zinc-400/80";
1039 - }
1022 return "group-hover/sidebar-row:text-emerald-600 dark:group-hover/sidebar-row:text-emerald-300/90";
1023 case "merged":
1024 return "group-hover/sidebar-row:text-violet-600 dark:group-hover/sidebar-row:text-violet-300/90";
@@ -1045,6 +1027,7 @@ function settledPrHoverColorClass(state: NonNullable<ThreadPr>["state"], isDraft
1027 }
1028 }
1029
1030 +// Search rows are already buttons, so this renders the sidebar badge's look without its controls.
1031 export function ThreadSearchPullRequestNumber({
1032 thread,
1033 query,
@@ -1056,40 +1039,58 @@ export function ThreadSearchPullRequestNumber({
1039 enabled?: boolean;
1040 settled?: boolean;
1041 }) {
1059 - const matchedLink = visibleThreadPullRequests(thread.pullRequests).find((pr) =>
1060 - pullRequestMatchesSearchQuery({ pullRequests: [pr] }, query),
1061 - );
1062 - const fallbackCandidates =
1063 - thread.pullRequests.length === 0
1064 - ? [thread.linkedPullRequest, thread.branchPullRequest]
1065 - : [thread.branchPullRequest];
1066 - const legacyReference = matchedLink
1067 - ? undefined
1068 - : fallbackCandidates.find(
1069 - (pr) => pr != null && pullRequestMatchesSearchQuery({ linkedPullRequest: pr }, query),
1070 - );
1071 - const legacyStatus = useLinkedThreadPullRequest(
1042 + const matched = pullRequestMatchesSearchQuery(thread, query);
1043 + const supportsMultiplePullRequests = useSupportsMultiplePullRequests(thread.environmentId);
1044 + const linked = useLinkedThreadPullRequest(
1045 thread.environmentId,
1073 - legacyReference,
1074 - enabled,
1075 - undefined,
1076 - legacyReference,
1046 + thread.linkedPullRequest,
1047 + enabled && matched,
1048 + thread.pullRequests,
1049 + thread.branchPullRequest,
1050 );
1078 - const reference = matchedLink ?? legacyReference;
1079 - const linked = matchedLink ? linkedPullRequestSnapshotStatus(matchedLink) : legacyStatus;
1080 - const status = prStatusIndicator(linked?.pr ?? null, linked?.sourceControlProvider);
1081 - return reference ? (
1082 - <ThreadPullRequestNumber
1083 - number={reference.number}
1084 - className={
1051 + if (!matched) return null;
1052 + const badge = supportsMultiplePullRequests
1053 + ? resolveThreadPullRequestBadge(thread.pullRequests)
1054 + : null;
1055 + const current = supportsMultiplePullRequests
1056 + ? resolveThreadCurrentPullRequestLink(thread.pullRequests)
1057 + : null;
1058 + const pr = linked?.pr ?? null;
1059 + // Stored references already carry a number, so the badge shows before PR details load.
1060 + const stored =
1061 + current ??
1062 + [thread.linkedPullRequest, thread.branchPullRequest].find(
1063 + (reference) =>
1064 + reference != null && pullRequestMatchesSearchQuery({ linkedPullRequest: reference }, query),
1065 + );
1066 + const presentation = resolveThreadPullRequestBadgePresentation({
1067 + badge,
1068 + number: pr?.number ?? stored?.number,
1069 + url: pr?.url ?? stored?.url,
1070 + status: prStatusIndicator(pr, linked?.sourceControlProvider),
1071 + });
1072 + if (presentation === null) return null;
1073 + const aggregate = badge !== null && (badge.kind === "stack" || badge.others > 0);
1074 + const state = aggregate
1075 + ? badge.state
1076 + : pr === null
1077 + ? null
1078 + : pr.state === "open" && pr.isDraft
1079 + ? "draft"
1080 + : pr.state;
1081 + return (
1082 + <span
1083 + aria-label={presentation.label}
1084 + className={cn(
1085 + "inline-flex shrink-0 items-center gap-0.5 text-xs tabular-nums",
1086 settled
1086 - ? cn(
1087 - "text-secondary-label transition-colors",
1088 - linked?.pr && settledPrHoverColorClass(linked.pr.state, linked.pr.isDraft),
1089 - )
1090 - : (status?.colorClass ?? "text-secondary-label")
1091 - }
1092 - aria-label={status?.tooltip ?? `Pull request #${reference.number}`}
1093 - />
1094 - ) : null;
1087 + ? cn("text-secondary-label transition-colors", state && settledPrHoverColorClass(state))
1088 + : presentation.toneClassName,
1089 + )}
1090 + >
1091 + {/* text-current opts out of the command palette's muted icon color. */}
1092 + <presentation.Icon aria-hidden className="size-3 shrink-0 text-current" />
1093 + <span>{presentation.text}</span>
1094 + </span>
1095 + );
1096 }