Skip to content
TypeScript

refactor(web): PR loading skeleton shares the detail panel's layout (#15583)

oliver843c593ab2df
diff --git a/apps/web/src/components/pullRequest/PullRequestDetailLayout.tsx b/apps/web/src/components/pullRequest/PullRequestDetailLayout.tsx
new file mode 100644
index 00000000000..92bd0ab324d
--- /dev/null
+++ b/apps/web/src/components/pullRequest/PullRequestDetailLayout.tsx
@@ -0,0 +1,130 @@
+import { ArrowLeftIcon, FileDiffIcon } from "lucide-react";
+import type { ComponentProps, ReactNode } from "react";
+
+import { cn } from "~/lib/utils";
+
+import { Toggle, ToggleGroup } from "../ui/toggle-group";
+import { PullRequestMetaLine } from "./pullRequestPresentation";
+
+export function PullRequestDetailHeaderBody({
+ title,
+ author,
+ updated,
+ checkout,
+ base,
+ head,
+ files,
+ diffStat,
+}: {
+ title: ReactNode;
+ author: ReactNode;
+ updated: ReactNode;
+ checkout?: ReactNode;
+ base: ReactNode;
+ head: ReactNode;
+ files: ReactNode;
+ diffStat: ReactNode;
+}) {
+ return (
+ <div className="col-span-2 mt-1 min-w-0 px-4 pb-4">
+ {title}
+ <div className="mt-2 flex min-h-5 min-w-0 items-center gap-2 text-xs text-muted-foreground">
+ <PullRequestMetaLine className="min-w-0 whitespace-nowrap">
+ {author}
+ {updated}
+ </PullRequestMetaLine>
+ {checkout}
+ </div>
+ <div className="mt-4 flex min-h-5 min-w-0 items-center gap-2 text-xs text-muted-foreground">
+ <span className="flex min-w-0 flex-1 items-center gap-1.5 font-mono text-xs text-muted-foreground/70">
+ {base}
+ <ArrowLeftIcon
+ aria-label="receives changes from"
+ className="size-3.5 shrink-0 opacity-60"
+ />
+ {head}
+ </span>
+ <span className="ml-auto inline-flex shrink-0 items-center justify-end gap-2">
+ <span className="inline-flex min-w-16 items-center justify-end gap-1.5 tabular-nums">
+ <FileDiffIcon aria-hidden className="size-3.5" />
+ {files}
+ </span>
+ {diffStat}
+ </span>
+ </div>
+ </div>
+ );
+}
+
+export function PullRequestDetailTitleRow({ className, ...props }: ComponentProps<"div">) {
+ return (
+ <div className={cn("flex min-h-7 min-w-0 items-center sm:min-h-6", className)} {...props} />
+ );
+}
+
+export function PullRequestDetailTabBar<Tab extends string>({
+ tabs,
+ value,
+ onValueChange,
+ onTabIntent,
+ inert,
+ children,
+}: {
+ tabs: ReadonlyArray<{ readonly value: Tab; readonly label: string }>;
+ value: Tab;
+ onValueChange?: (tab: Tab) => void;
+ onTabIntent?: (tab: Tab) => void;
+ inert?: boolean;
+ children?: ReactNode;
+}) {
+ return (
+ <nav
+ className="col-span-2 flex min-w-0 flex-wrap items-center gap-2 border-t border-border/60 px-4 py-2"
+ aria-label="Pull request tabs"
+ inert={inert}
+ >
+ <ToggleGroup
+ className="shrink-0"
+ size="segmented"
+ variant="segmented"
+ value={[value]}
+ onValueChange={(next) => {
+ const nextTab = tabs.find((item) => item.value === next[0])?.value;
+ if (nextTab) onValueChange?.(nextTab);
+ }}
+ >
+ {tabs.map((tab) => (
+ <Toggle
+ key={tab.value}
+ value={tab.value}
+ onPointerEnter={onTabIntent ? () => onTabIntent(tab.value) : undefined}
+ onFocus={onTabIntent ? () => onTabIntent(tab.value) : undefined}
+ >
+ {tab.label}
+ </Toggle>
+ ))}
+ </ToggleGroup>
+ {children}
+ </nav>
+ );
+}
+
+export function PullRequestChecksStatusLine({
+ icon,
+ label,
+ className,
+ ...props
+}: Omit<ComponentProps<"span">, "children"> & { icon: ReactNode; label: ReactNode }) {
+ return (
+ <span
+ className={cn(
+ "ml-auto flex h-4 min-w-0 flex-1 flex-wrap content-start items-center justify-end gap-x-1.5 overflow-hidden text-xs",
+ className,
+ )}
+ {...props}
+ >
+ {icon}
+ <span className="whitespace-nowrap">{label}</span>
+ </span>
+ );
+}
diff --git a/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx b/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
index f4489607398..7f6a4592a0b 100644
--- a/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
@@ -102,7 +102,6 @@ import { Badge } from "../ui/badge";
import { Button } from "../ui/button";
import { PullRequestEditButton } from "./PullRequestEditButton";
import { Input } from "../ui/input";
-import { Toggle, ToggleGroup } from "../ui/toggle-group";
import {
Menu,
MenuItem,
@@ -117,6 +116,12 @@ import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
import { toastManager } from "../ui/toast";
import { Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger } from "../ui/tooltip";
import { MiddleTruncate } from "../ui/middle-truncate";
+import {
+ PullRequestChecksStatusLine,
+ PullRequestDetailHeaderBody,
+ PullRequestDetailTabBar,
+ PullRequestDetailTitleRow,
+} from "./PullRequestDetailLayout";
import { PullRequestDetailGhost, PullRequestTimelineGhost } from "./PullRequestGhosts";
import { PullRequestCopyableCode } from "./PullRequestCopyableCode";
import { PullRequestActivityUnavailableState } from "./PullRequestActivityUnavailableState";
@@ -2373,77 +2378,79 @@ export function PullRequestDetailPanel({
inert={condensed}
>
{detail ? (
- <div className="col-span-2 mt-1 min-w-0 px-4 pb-4">
- {titleDraft === null ? (
- <div className="group flex min-h-7 min-w-0 items-center gap-1 sm:min-h-6">
- <Tooltip>
- <TooltipTrigger
- render={
- <h1 className="min-w-0 flex-1 truncate text-base font-semibold leading-snug">
- {detail.title}
- </h1>
- }
- />
- <TooltipPopup side="top">{detail.title}</TooltipPopup>
- </Tooltip>
- {canEditPullRequestChangeRequest(detail) ? (
- <PullRequestEditButton
- aria-label="Edit title"
- onClick={() => setTitleScope({ pullRequestKey, text: detail.title })}
- />
- ) : null}
- </div>
- ) : (
- // A title is one line of text, not markdown, so it takes an input rather than
- // the editor the description and the remarks share.
- <div className="space-y-2">
- <Input
- autoFocus
- size="sm"
- disabled={titleSaving}
- value={titleDraft}
- aria-label="Pull request title"
- onChange={(event) =>
- setTitleScope({ pullRequestKey, text: event.target.value })
- }
- onKeyDown={(event) => {
- if (event.key === "Enter") {
- event.preventDefault();
- void saveTitle(titleDraft);
- } else if (event.key === "Escape") {
- event.preventDefault();
- setTitleScope(null);
- }
- }}
- />
- <div className="flex justify-end gap-2">
- <Button
- size="xs"
- variant="ghost"
+ <PullRequestDetailHeaderBody
+ title={
+ titleDraft === null ? (
+ <PullRequestDetailTitleRow className="group gap-1">
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <h1 className="min-w-0 flex-1 truncate text-base font-semibold leading-snug">
+ {detail.title}
+ </h1>
+ }
+ />
+ <TooltipPopup side="top">{detail.title}</TooltipPopup>
+ </Tooltip>
+ {canEditPullRequestChangeRequest(detail) ? (
+ <PullRequestEditButton
+ aria-label="Edit title"
+ onClick={() => setTitleScope({ pullRequestKey, text: detail.title })}
+ />
+ ) : null}
+ </PullRequestDetailTitleRow>
+ ) : (
+ // A title is one line of text, not markdown, so it takes an input rather than
+ // the editor the description and the remarks share.
+ <div className="space-y-2">
+ <Input
+ autoFocus
+ size="sm"
disabled={titleSaving}
- onClick={() => setTitleScope(null)}
- >
- Cancel
- </Button>
- <Button
- size="xs"
- variant="outline"
- disabled={
- !canWriteSourceControl || titleSaving || titleDraft.trim().length === 0
+ value={titleDraft}
+ aria-label="Pull request title"
+ onChange={(event) =>
+ setTitleScope({ pullRequestKey, text: event.target.value })
}
- onClick={() => void saveTitle(titleDraft)}
- >
- {titleSaving ? "Saving..." : "Save"}
- </Button>
+ onKeyDown={(event) => {
+ if (event.key === "Enter") {
+ event.preventDefault();
+ void saveTitle(titleDraft);
+ } else if (event.key === "Escape") {
+ event.preventDefault();
+ setTitleScope(null);
+ }
+ }}
+ />
+ <div className="flex justify-end gap-2">
+ <Button
+ size="xs"
+ variant="ghost"
+ disabled={titleSaving}
+ onClick={() => setTitleScope(null)}
+ >
+ Cancel
+ </Button>
+ <Button
+ size="xs"
+ variant="outline"
+ disabled={
+ !canWriteSourceControl || titleSaving || titleDraft.trim().length === 0
+ }
+ onClick={() => void saveTitle(titleDraft)}
+ >
+ {titleSaving ? "Saving..." : "Save"}
+ </Button>
+ </div>
</div>
- </div>
- )}
- <div className="mt-2 flex min-h-5 min-w-0 items-center gap-2 text-xs text-muted-foreground">
- <PullRequestMetaLine className="min-w-0 whitespace-nowrap">
- <PullRequestActorLabel actor={detail.author} profileUrl={authorProfileUrl} />
- <span>updated {formatRelativeTimeLabel(detail.updatedAt)}</span>
- </PullRequestMetaLine>
- {checkoutCommand ? (
+ )
+ }
+ author={
+ <PullRequestActorLabel actor={detail.author} profileUrl={authorProfileUrl} />
+ }
+ updated={<span>updated {formatRelativeTimeLabel(detail.updatedAt)}</span>}
+ checkout={
+ checkoutCommand ? (
<PullRequestCopyableCode
key={checkoutCommand}
value={checkoutCommand}
@@ -2454,159 +2461,127 @@ export function PullRequestDetailPanel({
tooltipSide="bottom"
onError={onCheckoutCommandError}
/>
- ) : null}
- </div>
-
- <div className="mt-4 flex min-h-5 min-w-0 items-center gap-2 text-xs text-muted-foreground">
- <span className="flex min-w-0 flex-1 items-center gap-1.5 font-mono text-xs text-muted-foreground/70">
- {/* An out-of-date base wears the warning on the branch name itself, so the
+ ) : null
+ }
+ base={
+ /* An out-of-date base wears the warning on the branch name itself, so the
name is amber and pointing at either the name or the mark opens the way
- out. Up to date, the name keeps its plain tooltip. */}
- {freshness ? (
- <PullRequestBaseFreshnessWarning
- baseBranch={detail.baseBranch}
- freshness={freshness}
- pending={actionPending}
- onUpdate={(method) => void perform("update-branch", undefined, method)}
- className="max-w-[40%]"
- >
- {isStackedPullRequest ? (
- <PullRequestGlyph.stack
- aria-label="Stacked pull request"
- className="size-3 shrink-0"
- />
- ) : null}
- <code className="flex min-w-0">
- <MiddleTruncate value={detail.baseBranch} showTitle={false} />
- </code>
- </PullRequestBaseFreshnessWarning>
- ) : (
- <Tooltip>
- <TooltipTrigger
- render={
- <span className="inline-flex min-w-0 max-w-[40%] shrink-0 items-center gap-1">
- {isStackedPullRequest ? (
- <PullRequestGlyph.stack
- aria-label="Stacked pull request"
- className="size-3 shrink-0"
- />
- ) : null}
- <code className="flex min-w-0">
- <MiddleTruncate value={detail.baseBranch} showTitle={false} />
- </code>
- </span>
- }
+ out. Up to date, the name keeps its plain tooltip. */
+ freshness ? (
+ <PullRequestBaseFreshnessWarning
+ baseBranch={detail.baseBranch}
+ freshness={freshness}
+ pending={actionPending}
+ onUpdate={(method) => void perform("update-branch", undefined, method)}
+ className="max-w-[40%]"
+ >
+ {isStackedPullRequest ? (
+ <PullRequestGlyph.stack
+ aria-label="Stacked pull request"
+ className="size-3 shrink-0"
/>
- <TooltipPopup side="top">
- {isStackedPullRequest
- ? `Stacked on ${detail.baseBranch}`
- : detail.baseBranch}
- </TooltipPopup>
- </Tooltip>
- )}
- <ArrowLeftIcon
- aria-label="receives changes from"
- className="size-3.5 shrink-0 opacity-60"
- />
- <PullRequestCopyableCode
- key={detail.headBranch}
- value={detail.headBranch}
- target="branch name"
- copyLabel="Copy pull request branch"
- copiedLabel="Branch name copied"
- />
- </span>
- <span className="ml-auto inline-flex shrink-0 items-center justify-end gap-2">
- <span className="inline-flex min-w-16 items-center justify-end gap-1.5 tabular-nums">
- <FileDiffIcon className="size-3.5" />
- {detail.changedFiles.toLocaleString()}{" "}
- {detail.changedFiles === 1 ? "file" : "files"}
- </span>
- <PullRequestDiffStat
- additions={detail.additions}
- deletions={detail.deletions}
- className="shrink-0 font-mono text-xs"
- />
- </span>
- </div>
- </div>
+ ) : null}
+ <code className="flex min-w-0">
+ <MiddleTruncate value={detail.baseBranch} showTitle={false} />
+ </code>
+ </PullRequestBaseFreshnessWarning>
+ ) : (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <span className="inline-flex min-w-0 max-w-[40%] shrink-0 items-center gap-1">
+ {isStackedPullRequest ? (
+ <PullRequestGlyph.stack
+ aria-label="Stacked pull request"
+ className="size-3 shrink-0"
+ />
+ ) : null}
+ <code className="flex min-w-0">
+ <MiddleTruncate value={detail.baseBranch} showTitle={false} />
+ </code>
+ </span>
+ }
+ />
+ <TooltipPopup side="top">
+ {isStackedPullRequest
+ ? `Stacked on ${detail.baseBranch}`
+ : detail.baseBranch}
+ </TooltipPopup>
+ </Tooltip>
+ )
+ }
+ head={
+ <PullRequestCopyableCode
+ key={detail.headBranch}
+ value={detail.headBranch}
+ target="branch name"
+ copyLabel="Copy pull request branch"
+ copiedLabel="Branch name copied"
+ />
+ }
+ files={`${detail.changedFiles.toLocaleString()} ${detail.changedFiles === 1 ? "file" : "files"}`}
+ diffStat={
+ <PullRequestDiffStat
+ additions={detail.additions}
+ deletions={detail.deletions}
+ className="shrink-0 font-mono text-xs"
+ />
+ }
+ />
) : null}
</div>
</div>
{detail ? (
- <nav
- className="col-span-2 flex min-w-0 flex-wrap items-center gap-2 border-t border-border/60 px-4 py-2"
- aria-label="Pull request tabs"
+ <PullRequestDetailTabBar
+ tabs={visibleTabs}
+ value={tab}
+ onValueChange={setTab}
+ onTabIntent={(item) => {
+ if (item === "code") void loadCodeTab();
+ }}
>
- <ToggleGroup
- className="shrink-0"
- size="segmented"
- variant="segmented"
- value={[tab]}
- onValueChange={(next) => {
- const nextTab = visibleTabs.find((item) => item.value === next[0])?.value;
- if (nextTab) setTab(nextTab);
- }}
- >
- {visibleTabs.map((item) => (
- <Toggle
- key={item.value}
- value={item.value}
- onPointerEnter={item.value === "code" ? () => void loadCodeTab() : undefined}
- onFocus={item.value === "code" ? () => void loadCodeTab() : undefined}
- >
- {item.label}
- </Toggle>
- ))}
- </ToggleGroup>
{tab === "summary" ? (
- <span
- className={cn(
- "ml-auto flex items-center justify-end",
- showsApproveWorkflows ? "shrink-0" : "min-w-0 flex-1",
- )}
- >
- {showsApproveWorkflows ? (
- <Tooltip>
- <TooltipTrigger
- render={
- <span className="inline-flex shrink-0">
- <Button
- size="xs"
- variant="warning-outline"
- disabled={actionPending}
- onClick={() =>
- setConfirmation({ open: true, action: "approve-workflows" })
- }
- aria-label={
- pendingAction === "approve-workflows"
- ? "Approving..."
- : "Approve workflows to run"
- }
- >
- <PlayIcon aria-hidden className="size-3.5" />
- <span>
- {pendingAction === "approve-workflows"
- ? "Approving..."
- : "Approve workflows to run"}
- </span>
- </Button>
- </span>
- }
- />
- <TooltipPopup side="top">
- {pendingAction === "approve-workflows"
- ? "Approving..."
- : "Approve workflows to run"}
- </TooltipPopup>
- </Tooltip>
- ) : (
- <span
- className="flex h-4 min-w-0 flex-wrap content-start items-center justify-end gap-x-1.5 overflow-hidden text-xs text-muted-foreground"
- aria-label={checksSummary ? `Checks: ${checksSummary}` : "Checks"}
- >
- {checksState !== null ? (
+ showsApproveWorkflows ? (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <span className="ml-auto inline-flex shrink-0">
+ <Button
+ size="xs"
+ variant="warning-outline"
+ disabled={actionPending}
+ onClick={() =>
+ setConfirmation({ open: true, action: "approve-workflows" })
+ }
+ aria-label={
+ pendingAction === "approve-workflows"
+ ? "Approving..."
+ : "Approve workflows to run"
+ }
+ >
+ <PlayIcon aria-hidden className="size-3.5" />
+ <span>
+ {pendingAction === "approve-workflows"
+ ? "Approving..."
+ : "Approve workflows to run"}
+ </span>
+ </Button>
+ </span>
+ }
+ />
+ <TooltipPopup side="top">
+ {pendingAction === "approve-workflows"
+ ? "Approving..."
+ : "Approve workflows to run"}
+ </TooltipPopup>
+ </Tooltip>
+ ) : (
+ <PullRequestChecksStatusLine
+ className="text-muted-foreground"
+ aria-label={checksSummary ? `Checks: ${checksSummary}` : "Checks"}
+ icon={
+ checksState !== null ? (
<PullRequestChecksPopover
checks={detail.checks}
stale={checksStale}
@@ -2615,11 +2590,11 @@ export function PullRequestDetailPanel({
/>
) : (
<CircleDotIcon aria-hidden className="size-3.5" />
- )}
- <span className="whitespace-nowrap">{checksSummary}</span>
- </span>
- )}
- </span>
+ )
+ }
+ label={checksSummary}
+ />
+ )
) : tab === "timeline" ? (
<div className="ml-auto flex shrink-0 items-center gap-2 text-xs text-muted-foreground">
<PullRequestMetaLine
@@ -2694,7 +2669,7 @@ export function PullRequestDetailPanel({
</Button>
</div>
) : null}
- </nav>
+ </PullRequestDetailTabBar>
) : null}
</div>
diff --git a/apps/web/src/components/pullRequest/PullRequestGhosts.tsx b/apps/web/src/components/pullRequest/PullRequestGhosts.tsx
index 85c9802c217..7e155882a34 100644
--- a/apps/web/src/components/pullRequest/PullRequestGhosts.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestGhosts.tsx
@@ -13,7 +13,6 @@ import {
ChevronRightIcon,
EllipsisIcon,
ExternalLinkIcon,
- FileDiffIcon,
PanelRightIcon,
TagIcon,
UserPlusIcon,
@@ -26,20 +25,24 @@ import { cn } from "~/lib/utils";
import { formatRelativeTimeLabel } from "~/timestampFormat";
import { Button, InlineButton } from "../ui/button";
-import { Toggle, ToggleGroup } from "../ui/toggle-group";
import { MiddleTruncate } from "../ui/middle-truncate";
import { PullRequestCopyableCode } from "./PullRequestCopyableCode";
+import {
+ PullRequestChecksStatusLine,
+ PullRequestDetailHeaderBody,
+ PullRequestDetailTabBar,
+ PullRequestDetailTitleRow,
+} from "./PullRequestDetailLayout";
import {
PullRequestActorLabel,
PullRequestDiffStat,
PullRequestLabelChip,
- PullRequestMetaLine,
pullRequestChecksStatePresentation,
resolvePullRequestState,
} from "./pullRequestPresentation";
function GhostBar({ className }: { className?: string | undefined }) {
- return <div aria-hidden className={cn("h-3 rounded bg-muted-foreground/15", className)} />;
+ return <span aria-hidden className={cn("block h-3 rounded bg-muted-foreground/15", className)} />;
}
/** Widths cycle rather than randomize, so the ghost renders the same on every pass. */
@@ -202,32 +205,35 @@ export function PullRequestDetailGhost({
<div className="col-span-2 grid grid-rows-[1fr]">
<div className="min-h-0 overflow-hidden">
- <div className="col-span-2 mt-1 min-w-0 px-4 pb-4">
- {seed ? (
- <div className="flex min-h-7 min-w-0 items-center sm:min-h-6">
- <h1 className="truncate text-base font-semibold leading-snug">{seed.title}</h1>
- </div>
- ) : (
- <div className="flex min-h-7 min-w-0 items-center sm:min-h-6">
- <GhostBar className="h-5 w-4/5 max-w-md" />
- </div>
- )}
- <div className="mt-2 flex min-h-5 min-w-0 items-center gap-2 text-xs text-muted-foreground">
- {seed ? (
- <PullRequestMetaLine className="min-w-0 whitespace-nowrap">
- <PullRequestActorLabel actor={seed.author ?? null} tooltip={false} />
- <span>updated {formatRelativeTimeLabel(seed.updatedAt)}</span>
- </PullRequestMetaLine>
+ <PullRequestDetailHeaderBody
+ title={
+ <PullRequestDetailTitleRow>
+ {seed ? (
+ <h1 className="truncate text-base font-semibold leading-snug">{seed.title}</h1>
+ ) : (
+ <GhostBar className="h-5 w-4/5 max-w-md" />
+ )}
+ </PullRequestDetailTitleRow>
+ }
+ author={
+ seed ? (
+ <PullRequestActorLabel actor={seed.author ?? null} tooltip={false} />
) : (
- <PullRequestMetaLine className="min-w-0 whitespace-nowrap">
- <span className="flex items-center gap-1.5">
- <GhostBar className="size-4 rounded-full" />
- <GhostBar className="h-3 w-14" />
- </span>
- <GhostBar className="h-3 w-16" />
- </PullRequestMetaLine>
- )}
- {checkout ? (
+ <span className="flex items-center gap-1.5">
+ <GhostBar className="size-4 rounded-full" />
+ <GhostBar className="h-3 w-14" />
+ </span>
+ )
+ }
+ updated={
+ seed ? (
+ <span>updated {formatRelativeTimeLabel(seed.updatedAt)}</span>
+ ) : (
+ <GhostBar className="h-3 w-16" />
+ )
+ }
+ checkout={
+ checkout ? (
<PullRequestCopyableCode
key={checkout}
value={checkout}
@@ -238,94 +244,69 @@ export function PullRequestDetailGhost({
tooltipSide="bottom"
{...(onCheckoutError ? { onError: onCheckoutError } : {})}
/>
- ) : null}
- </div>
-
- <div className="mt-4 flex min-h-5 min-w-0 items-center gap-2 text-xs text-muted-foreground">
- <span className="flex min-w-0 flex-1 items-center gap-1.5 font-mono text-xs text-muted-foreground/70">
- {seed ? (
- <span className="inline-flex min-w-0 max-w-[40%] shrink-0 items-center gap-1">
- <code className="flex min-w-0">
- <MiddleTruncate value={seed.baseBranch} />
- </code>
- </span>
- ) : (
- <span className="inline-flex min-w-0 max-w-[40%] shrink-0 items-center gap-1">
- <GhostBar className="h-3 w-12" />
- </span>
- )}
- <ArrowLeftIcon
- aria-label="receives changes from"
- className="size-3.5 shrink-0 opacity-60"
- />
- {seed ? (
- <PullRequestCopyableCode
- key={seed.headBranch}
- value={seed.headBranch}
- target="branch name"
- copyLabel="Copy pull request branch"
- copiedLabel="Branch name copied"
- className="min-w-0 font-mono"
- />
- ) : (
- <GhostBar className="h-3 w-32 flex-1" />
- )}
- </span>
- <span className="ml-auto inline-flex shrink-0 items-center justify-end gap-2">
- <span className="inline-flex min-w-16 items-center justify-end gap-1.5 tabular-nums">
- <FileDiffIcon aria-hidden className="size-3.5" />
- {changedFiles === null ? (
- <GhostBar className="h-3 w-10" />
- ) : (
- `${changedFiles.toLocaleString()} ${changedFiles === 1 ? "file" : "files"}`
- )}
- </span>
+ ) : null
+ }
+ base={
+ <span className="inline-flex min-w-0 max-w-[40%] shrink-0 items-center gap-1">
{seed ? (
- <PullRequestDiffStat
- additions={seed.additions ?? 0}
- deletions={seed.deletions ?? 0}
- className="shrink-0 font-mono text-xs"
- />
+ <code className="flex min-w-0">
+ <MiddleTruncate value={seed.baseBranch} />
+ </code>
) : (
- <GhostBar className="h-3 w-20" />
+ <GhostBar className="h-3 w-12" />
)}
</span>
- </div>
- </div>
+ }
+ head={
+ seed ? (
+ <PullRequestCopyableCode
+ key={seed.headBranch}
+ value={seed.headBranch}
+ target="branch name"
+ copyLabel="Copy pull request branch"
+ copiedLabel="Branch name copied"
+ className="min-w-0 font-mono"
+ />
+ ) : (
+ <GhostBar className="h-3 w-32 flex-1" />
+ )
+ }
+ files={
+ changedFiles === null ? (
+ <GhostBar className="h-3 w-10" />
+ ) : (
+ `${changedFiles.toLocaleString()} ${changedFiles === 1 ? "file" : "files"}`
+ )
+ }
+ diffStat={
+ seed ? (
+ <PullRequestDiffStat
+ additions={seed.additions ?? 0}
+ deletions={seed.deletions ?? 0}
+ className="shrink-0 font-mono text-xs"
+ />
+ ) : (
+ <GhostBar className="h-3 w-20" />
+ )
+ }
+ />
</div>
</div>
- <nav
- className="col-span-2 flex min-w-0 flex-wrap items-center gap-2 border-t border-border/60 px-4 py-2"
- aria-label="Pull request tabs"
- inert
- >
- <ToggleGroup
- className="shrink-0"
- size="segmented"
- variant="segmented"
- value={[selectedTab]}
- >
- {tabs.map((tab) => (
- <Toggle key={tab.value} value={tab.value} tabIndex={-1}>
- {tab.label}
- </Toggle>
- ))}
- </ToggleGroup>
+ <PullRequestDetailTabBar tabs={tabs} value={selectedTab} inert>
{checksPresentation ? (
- <span
- className={cn(
- "ml-auto inline-flex items-center gap-1.5 text-xs",
- checksPresentation.toneClassName,
- )}
- >
- <checksPresentation.Icon aria-hidden className="size-3.5" />
- {checksPresentation.label}
- </span>
+ <PullRequestChecksStatusLine
+ className={checksPresentation.toneClassName}
+ icon={<checksPresentation.Icon aria-hidden className="size-3.5" />}
+ label={checksPresentation.label}
+ />
) : (
- <GhostBar className="ml-auto h-3 w-32" />
+ <PullRequestChecksStatusLine
+ icon={<GhostBar className="my-px size-3.5 rounded-full" />}
+ label={<GhostBar className="w-28" />}
+ />
)}
- </nav>
+ </PullRequestDetailTabBar>
</div>
<div className="min-h-0 flex-1 overflow-hidden">