diff --git a/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx b/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx index 15221f26e63d..cefe5e5bd51d 100644 --- a/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx +++ b/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx @@ -1,5 +1,6 @@ import type { ScopedThreadRef, ThreadPullRequestLink } from "@t3tools/contracts"; import { + normalizeThreadPullRequestKey, resolveThreadPullRequestChains, visibleThreadPullRequests, } from "@t3tools/shared/threadPullRequests"; @@ -66,10 +67,16 @@ function ChecksGlyph({ function LinkRow({ line, threadRef, + repositoryLabel, onUnlink, }: { line: PullRequestListLine; threadRef: ScopedThreadRef; + /** + * How much of the repository identity to show: none when the thread links a single + * repository, the host too when its links span hosts. + */ + repositoryLabel: "none" | "repository" | "host"; onUnlink: (link: ThreadPullRequestLink) => void; }) { const openPrLink = useOpenPrLink(threadRef); @@ -160,6 +167,13 @@ function LinkRow({ labelClassName="max-w-28" /> ) : null} + {repositoryLabel !== "none" && snapshot !== null ? ( + // Never truncated: it is what tells otherwise alike rows apart, and the branches + // beside it already give way with a middle ellipsis. + + {repositoryLabel === "host" ? `${link.host}/${link.repository}` : link.repository} + + ) : null} {snapshot !== null ? ( ) : ( @@ -239,6 +253,13 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread const unlink = useAtomCommand(threadEnvironment.unlinkPullRequest, { reportFailure: true }); const links = useMemo(() => visibleThreadPullRequests(thread?.pullRequests ?? []), [thread]); const lines = useMemo(() => pullRequestListLines(resolveThreadPullRequestChains(links)), [links]); + const repositoryLabel = useMemo(() => { + const keys = links.map(normalizeThreadPullRequestKey); + const repositories = new Set(keys.map((key) => `${key.host}/${key.repository}`)); + if (repositories.size < 2) return "none"; + const hosts = new Set(keys.map((key) => key.host)); + return hosts.size > 1 ? "host" : "repository"; + }, [links]); const handleUnlink = useCallback( (link: ThreadPullRequestLink) => { void unlink({ @@ -292,6 +313,7 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread key={`${line.link.host}/${line.link.repository}#${line.link.number}`} line={line} threadRef={threadRef} + repositoryLabel={repositoryLabel} onUnlink={handleUnlink} /> ))}