Skip to content
TypeScript

feat(web): use the linked pull request row layout on the pull requests page (#12536)

maria411da2a7356d
diff --git a/apps/server/src/pullRequest/gitHubPullRequestJson.test.ts b/apps/server/src/pullRequest/gitHubPullRequestJson.test.ts
index 05796283b9b..81033e2e0d9 100644
--- a/apps/server/src/pullRequest/gitHubPullRequestJson.test.ts
+++ b/apps/server/src/pullRequest/gitHubPullRequestJson.test.ts
@@ -97,6 +97,40 @@ describe("pull request list decoding", () => {
]);
});
+ it("takes the verdict from the latest reviews when GitHub summarizes none, as for a bot's approval", () => {
+ const batch = expectSuccess(
+ decodePullRequestListJson(
+ listJson([
+ {
+ reviewDecision: null,
+ latestReviews: [{ author: { login: "macroscopeapp" }, state: "APPROVED" }],
+ },
+ {
+ reviewDecision: "REVIEW_REQUIRED",
+ latestReviews: [
+ { author: { login: "octocat" }, state: "APPROVED" },
+ { author: { login: "hubot" }, state: "CHANGES_REQUESTED" },
+ ],
+ },
+ {
+ reviewDecision: "APPROVED",
+ latestReviews: [{ author: { login: "hubot" }, state: "CHANGES_REQUESTED" }],
+ },
+ {
+ reviewDecision: null,
+ latestReviews: [{ author: { login: "octocat" }, state: "COMMENTED" }],
+ },
+ ]),
+ ),
+ );
+ expect(batch.items.map((entry) => entry.reviewDecision)).toEqual([
+ "approved",
+ "changes-requested",
+ "approved",
+ null,
+ ]);
+ });
+
it("rolls the head commit's checks up to the one word a row has space for", () => {
const batch = expectSuccess(
decodePullRequestListJson(
diff --git a/apps/server/src/pullRequest/gitHubPullRequestJson.ts b/apps/server/src/pullRequest/gitHubPullRequestJson.ts
index 8a1434224ad..eaaa4e34da8 100644
--- a/apps/server/src/pullRequest/gitHubPullRequestJson.ts
+++ b/apps/server/src/pullRequest/gitHubPullRequestJson.ts
@@ -68,6 +68,12 @@ const RawReviewRequestSchema = Schema.Struct({
name: Schema.optional(Schema.NullOr(Schema.String)),
});
+/** One reviewer's most recent review: the state is all the verdict needs, the author is for who. */
+const RawLatestReviewSchema = Schema.Struct({
+ author: Schema.optional(Schema.NullOr(RawActorSchema)),
+ state: Schema.optional(Schema.NullOr(Schema.String)),
+});
+
const RawCheckSchema = Schema.Struct({
__typename: Schema.optional(Schema.String),
name: Schema.optional(Schema.NullOr(Schema.String)),
@@ -106,6 +112,7 @@ const RawListItemSchema = Schema.Struct({
updatedAt: Schema.String,
mergedAt: Schema.optional(Schema.NullOr(Schema.String)),
reviewRequests: Schema.optional(Schema.Array(RawReviewRequestSchema)),
+ latestReviews: Schema.optional(Schema.NullOr(Schema.Array(RawLatestReviewSchema))),
labels: Schema.optional(Schema.Array(RawLabelSchema)),
/**
* Every check of the head commit, which is the only rollup `gh pr list --json` can give: there
@@ -143,6 +150,9 @@ const RawSearchItemSchema = Schema.Struct({
isDraft: Schema.optional(Schema.Boolean),
mergeable: Schema.optional(Schema.NullOr(Schema.String)),
reviewDecision: Schema.optional(Schema.NullOr(Schema.String)),
+ latestReviews: Schema.optional(
+ Schema.NullOr(Schema.Struct({ nodes: Schema.Array(Schema.NullOr(RawLatestReviewSchema)) })),
+ ),
createdAt: Schema.String,
updatedAt: Schema.String,
mergedAt: Schema.optional(Schema.NullOr(Schema.String)),
@@ -514,13 +524,7 @@ const RawReviewThreadsSchema = Schema.Struct({
),
),
latestReviews: Schema.optional(
- Schema.NullOr(
- Schema.Struct({
- nodes: Schema.Array(
- Schema.Struct({ author: Schema.optional(Schema.NullOr(RawActorSchema)) }),
- ),
- }),
- ),
+ Schema.NullOr(Schema.Struct({ nodes: Schema.Array(RawLatestReviewSchema) })),
),
reviewDismissals: Schema.optional(
Schema.NullOr(
@@ -698,7 +702,7 @@ export function decodeActorAvatarsJson(
}
export const PULL_REQUEST_LIST_JSON_FIELDS =
- "number,title,url,author,headRefName,baseRefName,state,isDraft,mergeable,reviewDecision,additions,deletions,createdAt,updatedAt,mergedAt,reviewRequests,labels,statusCheckRollup";
+ "number,title,url,author,headRefName,baseRefName,state,isDraft,mergeable,reviewDecision,additions,deletions,createdAt,updatedAt,mergedAt,reviewRequests,latestReviews,labels,statusCheckRollup";
export const PULL_REQUEST_DETAIL_JSON_FIELDS = `${PULL_REQUEST_LIST_JSON_FIELDS},body,changedFiles,closedAt,isCrossRepository,headRepositoryOwner,headRefOid,autoMergeRequest`;
@@ -817,6 +821,7 @@ export function pullRequestSearchGraphQlQuery(rows: number, includeStacks = fals
isDraft
mergeable
reviewDecision
+ latestReviews(first: 20) { nodes { state author { login } } }
createdAt
updatedAt
mergedAt
@@ -891,7 +896,7 @@ export const REVIEW_THREADS_GRAPHQL_QUERY = `query($owner: String!, $name: Strin
}
}
latestReviews(first: 50) {
- nodes { author { __typename login avatarUrl } }
+ nodes { state author { __typename login avatarUrl } }
}
reviewDismissals: timelineItems(itemTypes: [REVIEW_DISMISSED_EVENT], first: ${GRAPHQL_PAGE_SIZE}) {
pageInfo { hasNextPage endCursor }
@@ -1325,6 +1330,35 @@ function toMergeMethod(value: string | null | undefined): PullRequestMergeMethod
}
}
+/**
+ * GitHub's own `reviewDecision` counts only reviews that satisfy the branch rules, so an
+ * approval from an app (a review bot) or from anyone without the required permission leaves it
+ * empty. The reviewers still said something, and a row should show it: when GitHub reports no
+ * verdict, the latest review per reviewer decides, changes requested outranking approval.
+ */
+function toReviewDecisionWithReviews(
+ value: string | null | undefined,
+ // `gh pr list` hands the reviews as an array; the GraphQL reads hand a connection.
+ latestReviews:
+ | ReadonlyArray<Schema.Schema.Type<typeof RawLatestReviewSchema>>
+ | { readonly nodes: ReadonlyArray<Schema.Schema.Type<typeof RawLatestReviewSchema>> }
+ | null
+ | undefined,
+): PullRequestReviewDecision | null {
+ const summarized = toReviewDecision(value);
+ if (summarized === "approved" || summarized === "changes-requested") return summarized;
+ const reviews =
+ latestReviews === null || latestReviews === undefined
+ ? []
+ : "nodes" in latestReviews
+ ? latestReviews.nodes
+ : latestReviews;
+ const states = new Set(reviews.map((review) => review.state?.trim().toUpperCase() ?? ""));
+ if (states.has("CHANGES_REQUESTED")) return "changes-requested";
+ if (states.has("APPROVED")) return "approved";
+ return summarized;
+}
+
function toReviewDecision(value: string | null | undefined): PullRequestReviewDecision | null {
switch (value?.trim().toUpperCase()) {
case "APPROVED":
@@ -1558,7 +1592,7 @@ function toListItem(raw: Schema.Schema.Type<typeof RawListItemSchema>): GitHubPu
state: toState(raw),
isDraft: raw.isDraft ?? false,
mergeability: toMergeability(raw.mergeable),
- reviewDecision: toReviewDecision(raw.reviewDecision),
+ reviewDecision: toReviewDecisionWithReviews(raw.reviewDecision, raw.latestReviews),
additions: raw.additions ?? 0,
deletions: raw.deletions ?? 0,
createdAt: raw.createdAt,
@@ -1681,6 +1715,9 @@ export function decodePullRequestSearchJson(
items.push({
...toListItem({
...node,
+ latestReviews: (node.latestReviews?.nodes ?? []).flatMap((review) =>
+ review === null ? [] : [review],
+ ),
reviewRequests: (node.reviewRequests?.nodes ?? []).flatMap((request) => {
const login = trimmed(request?.requestedReviewer?.login);
return login === null ? [] : [{ login }];
diff --git a/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx b/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
index 98d172f53eb..44b70f2e18f 100644
--- a/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
@@ -50,6 +50,7 @@ import {
useMemo,
useRef,
useState,
+ type ReactNode,
} from "react";
import { type DraftId, useComposerDraftStore } from "~/composerDraftStore";
@@ -344,6 +345,8 @@ function PullRequestBaseFreshnessWarning({
pending,
onUpdate,
iconClassName,
+ className,
+ children,
}: {
readonly baseBranch: string;
readonly freshness: {
@@ -353,6 +356,9 @@ function PullRequestBaseFreshnessWarning({
readonly pending: boolean;
readonly onUpdate: (method: PullRequestUpdateMethod) => void;
readonly iconClassName?: string;
+ readonly className?: string;
+ /** What the warning is about, drawn in the same amber before the mark: the base branch. */
+ readonly children?: ReactNode;
}) {
const behind =
freshness.behindBy === null
@@ -371,11 +377,15 @@ function PullRequestBaseFreshnessWarning({
<button
type="button"
aria-label={summary}
- className="inline-flex shrink-0 cursor-help items-center rounded-sm text-amber-600 outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ className={cn(
+ "inline-flex min-w-0 shrink-0 cursor-help items-center gap-1 rounded-sm text-amber-600 outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-amber-400/90",
+ className,
+ )}
/>
}
>
- <TriangleAlertIcon aria-hidden className={cn("size-3.5", iconClassName)} />
+ {children}
+ <TriangleAlertIcon aria-hidden className={cn("size-3.5 shrink-0", iconClassName)} />
</PopoverTrigger>
<PopoverPopup
align="start"
@@ -2239,26 +2249,9 @@ export function PullRequestDetailPanel({
</span>
<span aria-hidden className="h-3 w-px shrink-0 bg-border/70" />
<span className="flex min-w-0 flex-1 items-center gap-1.5 font-mono text-[11px] text-muted-foreground/65">
- <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="min-w-0 truncate">{detail.baseBranch}</code>
- </span>
- }
- />
- <TooltipPopup side="top">
- {isStackedPullRequest
- ? `Stacked on ${detail.baseBranch}`
- : detail.baseBranch}
- </TooltipPopup>
- </Tooltip>
+ {/* 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}
@@ -2266,8 +2259,38 @@ export function PullRequestDetailPanel({
pending={actionPending}
onUpdate={(method) => void perform("update-branch", undefined, method)}
iconClassName="size-3"
- />
- ) : null}
+ className="max-w-[40%]"
+ >
+ {isStackedPullRequest ? (
+ <PullRequestGlyph.stack
+ aria-label="Stacked pull request"
+ className="size-3 shrink-0"
+ />
+ ) : null}
+ <code className="min-w-0 truncate">{detail.baseBranch}</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="min-w-0 truncate">{detail.baseBranch}</code>
+ </span>
+ }
+ />
+ <TooltipPopup side="top">
+ {isStackedPullRequest
+ ? `Stacked on ${detail.baseBranch}`
+ : detail.baseBranch}
+ </TooltipPopup>
+ </Tooltip>
+ )}
<ArrowLeftIcon
aria-label="receives changes from"
className="size-3 shrink-0 opacity-60"
@@ -2412,34 +2435,47 @@ export function PullRequestDetailPanel({
<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">
- <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="min-w-0 truncate">{detail.baseBranch}</code>
- </span>
- }
- />
- <TooltipPopup side="top">
- {isStackedPullRequest
- ? `Stacked on ${detail.baseBranch}`
- : detail.baseBranch}
- </TooltipPopup>
- </Tooltip>
+ {/* 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)}
- />
- ) : null}
+ className="max-w-[40%]"
+ >
+ {isStackedPullRequest ? (
+ <PullRequestGlyph.stack
+ aria-label="Stacked pull request"
+ className="size-3 shrink-0"
+ />
+ ) : null}
+ <code className="min-w-0 truncate">{detail.baseBranch}</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="min-w-0 truncate">{detail.baseBranch}</code>
+ </span>
+ }
+ />
+ <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"
diff --git a/apps/web/src/components/pullRequest/PullRequestGhosts.tsx b/apps/web/src/components/pullRequest/PullRequestGhosts.tsx
index 90f88da9366..40a0af103bc 100644
--- a/apps/web/src/components/pullRequest/PullRequestGhosts.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestGhosts.tsx
@@ -28,10 +28,10 @@ import { formatRelativeTimeLabel } from "~/timestampFormat";
import { Button, InlineButton } from "../ui/button";
import { Toggle, ToggleGroup } from "../ui/toggle-group";
import { PullRequestCopyableCode } from "./PullRequestCopyableCode";
-import { pullRequestLabelColor } from "./pullRequestList.logic";
import {
PullRequestActorLabel,
PullRequestDiffStat,
+ PullRequestLabelChip,
PullRequestMetaLine,
pullRequestChecksStatePresentation,
resolvePullRequestState,
@@ -71,12 +71,12 @@ export function PullRequestListGhost({
{Array.from({ length: rows }, (_, index) => (
<div
key={index}
- className="grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 rounded-lg px-3 py-2"
+ className="grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 rounded-md px-3 py-2.5"
>
<GhostBar className="size-4 rounded-full" />
<div className="min-w-0 space-y-1.5">
- <GhostBar className={cn("h-3.5", TITLE_WIDTHS[index % TITLE_WIDTHS.length])} />
- <GhostBar className={META_WIDTHS[index % META_WIDTHS.length]} />
+ <GhostBar className={cn("h-4", TITLE_WIDTHS[index % TITLE_WIDTHS.length])} />
+ <GhostBar className={cn("h-3.5", META_WIDTHS[index % META_WIDTHS.length])} />
</div>
<div className="flex flex-col items-end gap-1.5">
<GhostBar className="w-12" />
@@ -356,29 +356,21 @@ export function PullRequestDetailGhost({
<span className="flex min-w-0 flex-wrap items-center gap-1 text-foreground">
{entry?.labels ? (
entry.labels.length > 0 ? (
- entry.labels.map((label) => {
- const color = pullRequestLabelColor(label.color);
- return (
- <span
- key={label.name}
- className="inline-flex max-w-48 items-center gap-1.5 truncate rounded-full bg-muted/40 py-0.5 pl-1.5 pr-2 text-xs"
- >
- <span
- aria-hidden
- className="size-2 shrink-0 rounded-full bg-muted-foreground"
- {...(color ? { style: { backgroundColor: color } } : {})}
- />
- <span className="truncate">{label.name}</span>
- </span>
- );
- })
+ entry.labels.map((label) => (
+ <PullRequestLabelChip
+ key={label.name}
+ label={label}
+ size="default"
+ className="max-w-48"
+ />
+ ))
) : (
<span className="text-muted-foreground">None</span>
)
) : (
<>
- <GhostBar className="h-4 w-24 rounded-full" />
- <GhostBar className="h-4 w-20 rounded-full" />
+ <GhostBar className="h-4.5 w-24" />
+ <GhostBar className="h-4.5 w-20" />
</>
)}
<Button size="icon-xs" variant="ghost" disabled aria-label="Labels loading">
diff --git a/apps/web/src/components/pullRequest/PullRequestListRow.tsx b/apps/web/src/components/pullRequest/PullRequestListRow.tsx
new file mode 100644
index 00000000000..e77f8271769
--- /dev/null
+++ b/apps/web/src/components/pullRequest/PullRequestListRow.tsx
@@ -0,0 +1,158 @@
+import type {
+ PullRequestActor,
+ PullRequestMergeability,
+ PullRequestState,
+} from "@t3tools/contracts";
+import type { ReactNode } from "react";
+
+import { cn } from "~/lib/utils";
+import { formatRelativeTimeLabel } from "~/timestampFormat";
+
+import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
+import {
+ PullRequestActorAvatar,
+ PullRequestConflictGlyph,
+ PullRequestStateGlyph,
+} from "./pullRequestPresentation";
+
+/**
+ * The one row shape both pull request lists share: the full page and a thread's linked panel.
+ * A status column, then two lines — number and title with the diff counts on the right;
+ * author and whatever else the caller shows under them with the time on the right. The column
+ * stacks the lifecycle glyph over the checks glyph, so what a pull request is and how it is
+ * doing read top to bottom at the left edge, and the right edge is only numbers and time. The
+ * page puts repository and labels there, the panel puts the branches there. The caller owns
+ * the wrapper (a link on the panel, a button on the page) and hands in the slots.
+ */
+export const PULL_REQUEST_ROW_CLASS =
+ "group/pr-row flex w-full items-center gap-2 rounded-md py-1 pr-1 text-left";
+
+export const PULL_REQUEST_ROW_NUMBER_CLASS =
+ "shrink-0 font-mono text-xs tabular-nums text-muted-foreground";
+
+/**
+ * The conflict warning rides the corner of the lifecycle glyph, over the arrow's merge circle,
+ * so the leading slot stays one icon wide and titles line up whether or not a row is blocked.
+ * The background fill cuts it out of the glyph beneath.
+ */
+export function PullRequestRowGlyph({
+ state,
+ isDraft,
+ mergeability,
+ baseBranch,
+ below,
+ className,
+}: {
+ state: PullRequestState;
+ isDraft: boolean;
+ mergeability?: PullRequestMergeability | undefined;
+ baseBranch?: string | undefined;
+ /** Under the lifecycle glyph, level with the second line: the checks glyph. */
+ below?: ReactNode;
+ className?: string;
+}) {
+ return (
+ <span className={cn("flex w-4 shrink-0 flex-col items-center gap-0.5", className)}>
+ <span className="relative inline-flex">
+ <PullRequestStateGlyph state={state} isDraft={isDraft} />
+ {/* The wrapper takes the offset, not the icon, so the tooltip trigger inside keeps the
+ badge's size and anchors the popup to it. */}
+ <span className="absolute -right-1 -bottom-1 inline-flex">
+ <PullRequestConflictGlyph
+ state={state}
+ isDraft={isDraft}
+ {...(mergeability === undefined ? {} : { mergeability })}
+ {...(baseBranch === undefined ? {} : { baseBranch })}
+ className="size-3 fill-background [stroke-width:2.5]"
+ />
+ </span>
+ </span>
+ {below ? <span className="inline-flex text-[11px]">{below}</span> : null}
+ </span>
+ );
+}
+
+export function PullRequestRowLines({
+ number,
+ title,
+ status,
+ signals,
+ meta,
+ metaClassName,
+ updatedAt,
+}: {
+ /** The `#n` reference, already wrapped in whatever tooltip or menu the caller wants on it. */
+ number: ReactNode;
+ title: ReactNode;
+ /** Right end of the first line: stack, diff counts. */
+ status?: ReactNode;
+ /** Right after the title text: checks and review verdict glyphs. */
+ signals?: ReactNode;
+ /** Left of the second line: author, then repository and labels or the branches. */
+ meta?: ReactNode;
+ metaClassName?: string;
+ updatedAt?: string | null | undefined;
+}) {
+ return (
+ <span className="min-w-0 flex-1">
+ <span className="flex min-w-0 items-center gap-1.5">
+ {number}
+ <span className="min-w-0 truncate text-sm">{title}</span>
+ {signals ? (
+ <span className="flex shrink-0 items-center gap-1 text-[11px]">{signals}</span>
+ ) : null}
+ {status ? (
+ <span className="ml-auto flex shrink-0 items-center gap-1.5 text-[11px]">{status}</span>
+ ) : null}
+ </span>
+ <span
+ className={cn(
+ "flex min-w-0 items-center gap-1.5 overflow-hidden text-[11px] text-muted-foreground",
+ metaClassName,
+ )}
+ >
+ {meta}
+ {updatedAt ? (
+ <span className="ml-auto shrink-0 whitespace-nowrap tabular-nums">
+ {formatRelativeTimeLabel(updatedAt)}
+ </span>
+ ) : null}
+ </span>
+ </span>
+ );
+}
+
+/** Avatar and login at the meta line's own size, with the actor's full name on hover. */
+export function PullRequestRowAuthor({
+ actor,
+ className,
+ labelClassName,
+}: {
+ actor: PullRequestActor | null;
+ className?: string;
+ labelClassName?: string;
+}) {
+ const login = actor?.login ?? "ghost";
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ render={<span className={cn("inline-flex min-w-0 items-center gap-1", className)} />}
+ >
+ <PullRequestActorAvatar actor={actor} className="size-3.5" />
+ <span className={cn("truncate", labelClassName)}>{login}</span>
+ </TooltipTrigger>
+ <TooltipPopup side="top">
+ {actor?.name && actor.name !== login ? `${actor.name} (@${login})` : login}
+ </TooltipPopup>
+ </Tooltip>
+ );
+}
+
+/** `head → base`, in the mono the branches are typed in. */
+export function PullRequestRowBranches({ head, base }: { head: string; base: string }) {
+ return (
+ <span className="truncate font-mono">
+ {head} → {base}
+ </span>
+ );
+}
diff --git a/apps/web/src/components/pullRequest/PullRequestRow.tsx b/apps/web/src/components/pullRequest/PullRequestRow.tsx
index e209ed01830..e32decde136 100644
--- a/apps/web/src/components/pullRequest/PullRequestRow.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestRow.tsx
@@ -4,19 +4,22 @@ import { memo, type RefCallback } from "react";
import { cn } from "~/lib/utils";
import { getSourceControlPresentationForKind } from "~/sourceControlPresentation";
-import { formatRelativeTimeLabel } from "~/timestampFormat";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { PullRequestChecksPopover } from "./PullRequestChecksPopover";
-import { pullRequestLabelColor, type EnvironmentPullRequestEntry } from "./pullRequestList.logic";
+import type { EnvironmentPullRequestEntry } from "./pullRequestList.logic";
import { openOnHostLabel, showPullRequestLinkContextMenu } from "./pullRequestLinkContextMenu";
import {
- PullRequestActorLabel,
- PullRequestConflictGlyph,
+ PULL_REQUEST_ROW_CLASS,
+ PULL_REQUEST_ROW_NUMBER_CLASS,
+ PullRequestRowAuthor,
+ PullRequestRowGlyph,
+ PullRequestRowLines,
+} from "./PullRequestListRow";
+import {
PullRequestDiffStat,
- PullRequestMetaLine,
- PullRequestApprovalGlyph,
- PullRequestStateGlyph,
+ PullRequestLabelChip,
+ PullRequestReviewDecisionGlyph,
} from "./pullRequestPresentation";
/**
@@ -37,32 +40,26 @@ function PullRequestRowLabels({ labels }: { labels: EnvironmentPullRequestEntry[
{LABEL_SLOTS.map((slot, index) => {
const label = labels[index];
if (!label) return null;
- const dot = pullRequestLabelColor(label.color);
const remaining = labels.length - index - 1;
return (
- <span
- key={label.name}
- className={cn(
- "inline-flex max-w-40 min-w-0 items-center gap-1 rounded-full border border-border/70 bg-muted/40 py-0 pl-1 pr-1.5 text-[10px] leading-3.5 text-muted-foreground",
- slot.pill,
- )}
- >
- <span
- aria-hidden
- className="size-2 shrink-0 rounded-full bg-muted-foreground"
- {...(dot ? { style: { backgroundColor: dot } } : {})}
- />
- <span className="truncate">{label.name}</span>
+ <PullRequestLabelChip key={label.name} label={label} className={slot.pill}>
{remaining > 0 ? (
<span className={cn("shrink-0", slot.overflow)}>+{remaining}</span>
) : null}
- </span>
+ </PullRequestLabelChip>
);
})}
</span>
);
}
+/**
+ * The page row keeps a little more room around the shared lines than the panel, which sits in
+ * a narrow column. The intrinsic size is the content box a skipped row reserves, which is the
+ * two lines without the padding: a 56px row less 20px of `py-2.5`.
+ */
+const PAGE_ROW_CLASS = "px-3 py-2.5 [contain-intrinsic-block-size:36.5px]";
+
export type PullRequestRowTarget = Pick<
EnvironmentPullRequestEntry,
"environmentId" | "projectId" | "host" | "repository" | "number"
@@ -105,95 +102,109 @@ function PullRequestRowImpl({
aria-current={selected ? "true" : undefined}
onClick={() => onSelect(entry)}
className={cn(
- "@container/pr-row grid w-full cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-3 rounded-lg px-3 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
+ PULL_REQUEST_ROW_CLASS,
+ PAGE_ROW_CLASS,
+ "cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
// Offscreen rows are skipped for style, layout and paint: a long list costs what the
// viewport shows, not what the pages have loaded. The intrinsic size keeps the
// scrollbar honest while a row is skipped.
- "[contain-intrinsic-block-size:66px] [content-visibility:auto]",
+ "[content-visibility:auto]",
selected ? "bg-accent" : "hover:bg-accent/60",
)}
>
- {/* The conflict warning rides the corner of the lifecycle glyph, over the arrow's
- merge circle, so the leading slot stays one icon wide and titles line up whether or
- not a row is blocked. The background fill cuts it out of the glyph beneath. */}
- <span className="relative inline-flex self-start mt-0.75 shrink-0">
- <PullRequestStateGlyph state={entry.state} isDraft={entry.isDraft} />
- {/* The wrapper takes the offset, not the icon, so the tooltip trigger inside keeps the
- badge's size and anchors the popup to it. */}
- <span className="absolute -right-1 -bottom-1 inline-flex">
- <PullRequestConflictGlyph
- state={entry.state}
- isDraft={entry.isDraft}
- mergeability={entry.mergeability}
- baseBranch={entry.baseBranch}
- className="size-3 fill-background [stroke-width:2.5]"
- />
- </span>
- </span>
- <span className="grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1.5">
- <span className="col-start-1 row-start-1 block truncate text-sm font-medium text-foreground">
- {entry.title}
- </span>
- <span className="col-start-2 row-start-1 flex items-center justify-self-end gap-2 text-xs">
- {entry.stack ? (
- <PullRequestStackPopover
- environmentId={entry.environmentId}
- reference={{
- projectId: entry.projectId,
- host: entry.host,
- repository: entry.repository,
- number: entry.number,
- }}
- membership={entry.stack}
- onSelect={(target) =>
- onSelect({ ...target, host: entry.host, environmentId: entry.environmentId })
- }
- />
- ) : null}
- {/* Only a verdict somebody has actually given: "review required" is the absence of
- one, and saying so on every unreviewed row would say nothing. */}
- {entry.reviewDecision === "approved" ? (
- <PullRequestApprovalGlyph />
- ) : entry.reviewDecision === "changes-requested" ? (
- <span className="min-w-0 truncate text-amber-600/90 dark:text-amber-400/80">
- Changes requested
- </span>
- ) : null}
- {entry.checksState === undefined ? null : (
- <PullRequestChecksPopover
- checksState={entry.checksState}
- environmentId={entry.environmentId}
- reference={{
- projectId: entry.projectId,
- repository: entry.repository,
- number: entry.number,
- }}
- />
- )}
- <PullRequestDiffStat
- additions={entry.additions}
- deletions={entry.deletions}
- className="shrink-0 whitespace-nowrap text-[11px]"
- />
- </span>
- <PullRequestMetaLine className="@container/pr-row-meta col-start-1 row-start-2 overflow-hidden text-xs text-muted-foreground/70">
- {matchedElsewhere ? (
- <Tooltip>
- <TooltipTrigger
- render={
- <span className="flex min-w-6 items-center gap-1 overflow-hidden rounded-full border border-border/60 px-1 text-[10px]" />
+ <PullRequestRowGlyph
+ state={entry.state}
+ isDraft={entry.isDraft}
+ mergeability={entry.mergeability}
+ baseBranch={entry.baseBranch}
+ // On the title line rather than between the lines, as main aligns it.
+ className="mt-0.75 self-start"
+ />
+ <PullRequestRowLines
+ number={
+ // The number carries the link, here as much as on the detail: a right-click on it
+ // copies the pull request's own address rather than opening the editing menu.
+ <span
+ className={PULL_REQUEST_ROW_NUMBER_CLASS}
+ onContextMenu={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ void showPullRequestLinkContextMenu({
+ url: entry.url,
+ openLabel: openOnHostLabel(entry.provider),
+ position: { x: event.clientX, y: event.clientY },
+ });
+ }}
+ >
+ #{entry.number}
+ </span>
+ }
+ title={entry.title}
+ signals={
+ <>
+ {entry.checksState === undefined ? null : (
+ <PullRequestChecksPopover
+ checksState={entry.checksState}
+ environmentId={entry.environmentId}
+ reference={{
+ projectId: entry.projectId,
+ repository: entry.repository,
+ number: entry.number,
+ }}
+ />
+ )}
+ {/* Only a verdict the host actually reports: an approval, a request for changes,
+ or a review the branch rules still require. No glyph on the common case of a
+ pull request nobody has reviewed, so a row only wears a person when the person
+ has said something. */}
+ {entry.reviewDecision === undefined ? null : (
+ <PullRequestReviewDecisionGlyph decision={entry.reviewDecision} />
+ )}
+ </>
+ }
+ status={
+ <>
+ {entry.stack ? (
+ <PullRequestStackPopover
+ environmentId={entry.environmentId}
+ reference={{
+ projectId: entry.projectId,
+ host: entry.host,
+ repository: entry.repository,
+ number: entry.number,
+ }}
+ membership={entry.stack}
+ onSelect={(target) =>
+ onSelect({ ...target, host: entry.host, environmentId: entry.environmentId })
}
- >
- <span className="sr-only">matched in the description</span>
- <SearchIcon aria-hidden className="size-3 shrink-0" />
- <span aria-hidden className="hidden truncate @xs/pr-row-meta:block">
- matched in the description
- </span>
- </TooltipTrigger>
- <TooltipPopup side="top">Matched in the description</TooltipPopup>
- </Tooltip>
- ) : null}
- <span className="flex shrink-0 items-center gap-1">
+ />
+ ) : null}
+ <PullRequestDiffStat
+ additions={entry.additions}
+ deletions={entry.deletions}
+ className="font-mono"
+ />
+ </>
+ }
+ metaClassName="@container/pr-row-meta"
+ meta={
+ <>
+ {matchedElsewhere ? (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <span className="flex min-w-6 items-center gap-1 overflow-hidden rounded-full border border-border/60 px-1 text-[10px]" />
+ }
+ >
+ <span className="sr-only">matched in the description</span>
+ <SearchIcon aria-hidden className="size-3 shrink-0" />
+ <span aria-hidden className="hidden truncate @xs/pr-row-meta:block">
+ matched in the description
+ </span>
+ </TooltipTrigger>
+ <TooltipPopup side="top">Matched in the description</TooltipPopup>
+ </Tooltip>
+ ) : null}
{showProvider ? (
<Tooltip>
<TooltipTrigger render={<span className="inline-flex shrink-0" />}>
@@ -202,39 +213,20 @@ function PullRequestRowImpl({
<TooltipPopup>{providerName}</TooltipPopup>
</Tooltip>
) : null}
- {/* The number carries the link, here as much as on the detail: a right-click on it
- copies the pull request's own address rather than opening the editing menu. */}
- <span
- onContextMenu={(event) => {
- event.preventDefault();
- event.stopPropagation();
- void showPullRequestLinkContextMenu({
- url: entry.url,
- openLabel: openOnHostLabel(entry.provider),
- position: { x: event.clientX, y: event.clientY },
- });
- }}
- >
- #{entry.number}
- </span>
- </span>
- {showProjectTitle ? <span className="truncate">{entry.repository}</span> : null}
- {environmentLabel ? (
- <span className="min-w-0 max-w-32 truncate">{environmentLabel}</span>
- ) : null}
- <PullRequestActorLabel
- actor={entry.author}
- className="min-w-4 max-w-40"
- labelClassName="sr-only @xs/pr-row-meta:not-sr-only @xs/pr-row-meta:truncate"
- />
- {entry.labels.length > 0 ? <PullRequestRowLabels labels={entry.labels} /> : null}
- </PullRequestMetaLine>
- <span className="col-start-2 row-start-2 flex items-center justify-self-end gap-3 whitespace-nowrap text-[11px] text-muted-foreground/70 tabular-nums">
- <span className="hidden @sm/pr-row:inline">
- {formatRelativeTimeLabel(entry.updatedAt)}
- </span>
- </span>
- </span>
+ <PullRequestRowAuthor
+ actor={entry.author}
+ className="min-w-3.5 max-w-40"
+ labelClassName="sr-only @xs/pr-row-meta:not-sr-only @xs/pr-row-meta:truncate"
+ />
+ {showProjectTitle ? <span className="truncate">{entry.repository}</span> : null}
+ {environmentLabel ? (
+ <span className="min-w-0 max-w-32 truncate">{environmentLabel}</span>
+ ) : null}
+ {entry.labels.length > 0 ? <PullRequestRowLabels labels={entry.labels} /> : null}
+ </>
+ }
+ updatedAt={entry.updatedAt}
+ />
</button>
);
}
diff --git a/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx b/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx
index 4470e6c307c..b461e4d5859 100644
--- a/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx
@@ -30,8 +30,9 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import {
PullRequestActorLabel,
PullRequestCheckStatusIcon,
- PullRequestReviewOutcomeBadge,
pullRequestCheckStatusLabel,
+ PullRequestLabelChip,
+ PullRequestReviewOutcomeBadge,
pullRequestReviewOutcomeLabel,
pullRequestReviewOutcomeRingClassName,
pullRequestReviewOutcomeStaleLabel,
@@ -56,7 +57,6 @@ import { PullRequestCommentBody } from "./PullRequestCommentBody";
import { PullRequestMarkdownEditor } from "./PullRequestMarkdownEditor";
import { PullRequestReactionBar } from "./PullRequestReactions";
import { PullRequestConversationGhost } from "./PullRequestGhosts";
-import { pullRequestLabelColor } from "./pullRequestList.logic";
import { sectionCollapseAnchorScrollTop } from "./pullRequestSummaryScroll.logic";
/** One reviewer, however a host happens to have cased their login this time. */
@@ -809,22 +809,14 @@ export function PullRequestSummaryTab({
{detail.labels.length === 0 ? (
<span className="text-muted-foreground">None</span>
) : (
- detail.labels.map((label) => {
- const dot = pullRequestLabelColor(label.color);
- return (
- <span
- key={label.name}
- className="inline-flex max-w-48 items-center gap-1.5 rounded-full bg-muted/40 py-0.5 pl-1.5 pr-2 text-xs"
- >
- <span
- aria-hidden
- className="size-2 shrink-0 rounded-full bg-muted-foreground"
- {...(dot ? { style: { backgroundColor: dot } } : {})}
- />
- <span className="truncate">{label.name}</span>
- </span>
- );
- })
+ detail.labels.map((label) => (
+ <PullRequestLabelChip
+ key={label.name}
+ label={label}
+ size="default"
+ className="max-w-48"
+ />
+ ))
)}
{detail.capabilities.labels === true ? (
<PullRequestLabelPicker
diff --git a/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx b/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx
index 05bb598e11d..15221f26e63 100644
--- a/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx
+++ b/apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx
@@ -21,11 +21,16 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { openLinkPullRequestDialog } from "./LinkPullRequestDialog";
import { pullRequestListLines, type PullRequestListLine } from "./pullRequestListLines";
import {
- PullRequestActorAvatar,
- PullRequestConflictGlyph,
+ PULL_REQUEST_ROW_CLASS,
+ PULL_REQUEST_ROW_NUMBER_CLASS,
+ PullRequestRowAuthor,
+ PullRequestRowBranches,
+ PullRequestRowGlyph,
+ PullRequestRowLines,
+} from "./PullRequestListRow";
+import {
PullRequestDiffStat,
- PullRequestApprovalGlyph,
- PullRequestStateGlyph,
+ PullRequestReviewDecisionGlyph,
pullRequestChecksStatePresentation,
} from "./pullRequestPresentation";
import { PullRequestGlyph } from "./pullRequestIcons";
@@ -72,7 +77,7 @@ function LinkRow({
const snapshot = link.snapshot;
return (
<div
- className="group/pr-row flex items-center gap-2 rounded-md py-1 pr-1 hover:bg-accent/60"
+ className={cn(PULL_REQUEST_ROW_CLASS, "relative hover:bg-accent/60")}
// Each layer steps in under the one it targets. The step is capped: beyond a few layers
// the indent only says "still in the stack", which the connector line already does, and
// a sixteen-layer stack would otherwise stair-step off the right edge.
@@ -85,122 +90,132 @@ function LinkRow({
className="size-4 shrink-0 text-muted-foreground"
/>
) : (
- <span className="flex shrink-0 items-center gap-1">
- <PullRequestStateGlyph state={snapshot.state} isDraft={snapshot.isDraft} />
- <PullRequestConflictGlyph
- state={snapshot.state}
- isDraft={snapshot.isDraft}
- baseBranch={snapshot.baseBranch}
- {...(snapshot.mergeability ? { mergeability: snapshot.mergeability } : {})}
- />
- </span>
+ <PullRequestRowGlyph
+ state={snapshot.state}
+ isDraft={snapshot.isDraft}
+ mergeability={snapshot.mergeability}
+ baseBranch={snapshot.baseBranch}
+ />
)}
<a
href={link.url}
onClick={(event) => openPrLink(event, link.url, threadRef)}
- className="min-w-0 flex-1"
+ className="flex min-w-0 flex-1"
>
- <span className="flex min-w-0 items-center gap-1.5">
- <Tooltip>
- <TooltipTrigger
- render={
- <span className="shrink-0 font-mono text-xs tabular-nums text-muted-foreground" />
- }
- >
- #{link.number}
- </TooltipTrigger>
- <TooltipPopup>
- {SOURCE_LABELS[link.source]} · {formatRelativeTimeLabel(link.linkedAt)}
- </TooltipPopup>
- </Tooltip>
- <span className="min-w-0 flex-1 truncate text-sm">
- {snapshot?.title ?? link.repository}
- </span>
- {/* Match the full PR list: review verdict, checks, then diff counts.
- Each is absent rather than neutral when the
- host said nothing, so a row without them reads as unknown, not as fine. */}
- <span className="ml-auto flex shrink-0 items-center gap-1.5 text-[11px]">
- {snapshot?.state === "open" &&
- (snapshot.reviewDecision === "approved" ||
- snapshot.reviewDecision === "changes-requested") ? (
- snapshot.reviewDecision === "approved" ? (
- <PullRequestApprovalGlyph />
- ) : (
- <span className="text-amber-600/90 dark:text-amber-400/80">Changes requested</span>
- )
- ) : null}
- {snapshot?.checksState ? <ChecksGlyph state={snapshot.checksState} /> : null}
- <PullRequestDiffStat
- additions={snapshot?.additions ?? 0}
- deletions={snapshot?.deletions ?? 0}
- className="font-mono"
- />
- </span>
- </span>
- <span className="flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground">
- {stack ? (
+ <PullRequestRowLines
+ number={
<Tooltip>
- <TooltipTrigger
- render={
- <span className="inline-flex shrink-0 items-center gap-0.5 text-foreground/70" />
- }
- >
- <PullRequestGlyph.stack aria-hidden className="size-3" />
- {stack.size}
+ <TooltipTrigger render={<span className={PULL_REQUEST_ROW_NUMBER_CLASS} />}>
+ #{link.number}
</TooltipTrigger>
<TooltipPopup>
- {stack.kind === "native"
- ? `GitHub stack of ${stack.size}: merging a layer lands the ones below it.`
- : `${stack.size} pull requests chained by base branch.`}
+ {SOURCE_LABELS[link.source]} · {formatRelativeTimeLabel(link.linkedAt)}
</TooltipPopup>
</Tooltip>
- ) : null}
- {snapshot?.author ? (
- <span className="inline-flex shrink-0 items-center gap-1">
- <PullRequestActorAvatar actor={snapshot.author} className="size-3.5" />
- <span className="max-w-28 truncate">{snapshot.author.login}</span>
- </span>
- ) : null}
- <span className="truncate font-mono">
- {snapshot !== null
- ? `${snapshot.headBranch} → ${snapshot.baseBranch}`
- : `${link.host}/${link.repository}`}
- </span>
- {snapshot?.updatedAt ? (
- <span className="ml-auto shrink-0">{formatRelativeTimeLabel(snapshot.updatedAt)}</span>
- ) : null}
- </span>
- </a>
- <Menu>
- <MenuTrigger
- render={
- <Button
- variant="ghost"
- size="icon-xs"
- aria-label={`Actions for #${link.number}`}
- className={cn(
- "opacity-0 group-hover/pr-row:opacity-100 data-[popup-open]:opacity-100",
+ }
+ title={snapshot?.title ?? link.repository}
+ signals={
+ snapshot?.state === "open" ? (
+ <>
+ {snapshot.checksState ? <ChecksGlyph state={snapshot.checksState} /> : null}
+ {snapshot.reviewDecision ? (
+ <PullRequestReviewDecisionGlyph decision={snapshot.reviewDecision} />
+ ) : null}
+ </>
+ ) : null
+ }
+ // Match the full PR list: diff counts up top, checks under the lifecycle glyph, the
+ // verdict by the author. Each is absent rather than neutral when the host said
+ // nothing, so a row without them reads as unknown, not as fine.
+ status={
+ <PullRequestDiffStat
+ additions={snapshot?.additions ?? 0}
+ deletions={snapshot?.deletions ?? 0}
+ className="font-mono"
+ />
+ }
+ meta={
+ <>
+ {stack ? (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <span className="inline-flex shrink-0 items-center gap-0.5 text-foreground/70" />
+ }
+ >
+ <PullRequestGlyph.stack aria-hidden className="size-3" />
+ {stack.size}
+ </TooltipTrigger>
+ <TooltipPopup>
+ {stack.kind === "native"
+ ? `GitHub stack of ${stack.size}: merging a layer lands the ones below it.`
+ : `${stack.size} pull requests chained by base branch.`}
+ </TooltipPopup>
+ </Tooltip>
+ ) : null}
+ {snapshot?.author ? (
+ <PullRequestRowAuthor
+ actor={snapshot.author}
+ className="shrink-0"
+ labelClassName="max-w-28"
+ />
+ ) : null}
+ {snapshot !== null ? (
+ <PullRequestRowBranches head={snapshot.headBranch} base={snapshot.baseBranch} />
+ ) : (
+ <span className="truncate font-mono">
+ {link.host}/{link.repository}
+ </span>
)}
- >
- <MoreHorizontalIcon className="size-3.5" />
- </Button>
+ </>
}
+ updatedAt={snapshot?.updatedAt}
/>
- <MenuPopup align="end" side="bottom">
- <MenuItem onClick={() => void writeTextToClipboard(link.url, "link")}>
- <LinkIcon className="size-3.5" />
- Copy link
- </MenuItem>
- <MenuItem onClick={(event) => openPrLink(event, link.url, threadRef)}>
- <ArrowUpRightIcon className="size-3.5" />
- Open
- </MenuItem>
- <MenuItem onClick={() => onUnlink(link)}>
- <PullRequestGlyph.unlink className="size-3.5" />
- {link.source === "stack" ? "Dismiss from thread" : "Unlink from thread"}
- </MenuItem>
- </MenuPopup>
- </Menu>
+ </a>
+ {/* Out of the row's flow, so no row reserves a column for a button only the hovered one
+ shows. It sits over the right end of the second line on the row's own hover color,
+ fading in from the left, so it covers the time and leaves the diff counts alone. */}
+ <span
+ className={cn(
+ "absolute right-0 bottom-0.5 flex items-center rounded-r-md bg-background pr-1 pl-5",
+ "[mask-image:linear-gradient(to_right,transparent,black_1rem)]",
+ // Hidden means untouchable too: on a touch screen there is no hover, and an invisible
+ // layer over the right of the row would otherwise swallow the tap meant for the link.
+ "pointer-events-none opacity-0 group-hover/pr-row:pointer-events-auto group-hover/pr-row:opacity-100",
+ "has-[[data-popup-open]]:pointer-events-auto has-[[data-popup-open]]:opacity-100",
+ "has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100",
+ )}
+ >
+ <span aria-hidden className="absolute inset-0 bg-accent/60" />
+ <Menu>
+ <MenuTrigger
+ render={
+ <Button
+ variant="ghost"
+ size="icon-micro"
+ aria-label={`Actions for #${link.number}`}
+ className="relative"
+ >
+ <MoreHorizontalIcon className="size-3.5" />
+ </Button>
+ }
+ />
+ <MenuPopup align="end" side="bottom">
+ <MenuItem onClick={() => void writeTextToClipboard(link.url, "link")}>
+ <LinkIcon className="size-3.5" />
+ Copy link
+ </MenuItem>
+ <MenuItem onClick={(event) => openPrLink(event, link.url, threadRef)}>
+ <ArrowUpRightIcon className="size-3.5" />
+ Open
+ </MenuItem>
+ <MenuItem onClick={() => onUnlink(link)}>
+ <PullRequestGlyph.unlink className="size-3.5" />
+ {link.source === "stack" ? "Dismiss from thread" : "Unlink from thread"}
+ </MenuItem>
+ </MenuPopup>
+ </Menu>
+ </span>
</div>
);
}
diff --git a/apps/web/src/components/pullRequest/pullRequestChecks.test.tsx b/apps/web/src/components/pullRequest/pullRequestChecks.test.tsx
index a2b8e92d86f..48a371a7a9c 100644
--- a/apps/web/src/components/pullRequest/pullRequestChecks.test.tsx
+++ b/apps/web/src/components/pullRequest/pullRequestChecks.test.tsx
@@ -52,13 +52,20 @@ describe("pullRequestChecksState", () => {
});
});
-/** Every element of the tree the row returned, so a nested indicator can be looked for. */
+/**
+ * Every element of the tree the row returned, so a nested indicator can be looked for. The row
+ * hands its slots to the shared row lines as props rather than children, so every prop that
+ * holds an element is walked too.
+ */
function flatten(node: ReactNode): ReadonlyArray<ReturnType<typeof Object>> {
const found: unknown[] = [];
for (const child of Children.toArray(node)) {
if (!isValidElement(child)) continue;
found.push(child);
- found.push(...flatten((child.props as { readonly children?: ReactNode }).children));
+ for (const value of Object.values(child.props as Record<string, unknown>)) {
+ if (isValidElement(value)) found.push(...flatten(value));
+ else if (Array.isArray(value)) found.push(...flatten(value.filter(isValidElement)));
+ }
}
return found as ReadonlyArray<ReturnType<typeof Object>>;
}
diff --git a/apps/web/src/components/pullRequest/pullRequestPresentation.tsx b/apps/web/src/components/pullRequest/pullRequestPresentation.tsx
index 65caae761ce..d46cad36622 100644
--- a/apps/web/src/components/pullRequest/pullRequestPresentation.tsx
+++ b/apps/web/src/components/pullRequest/pullRequestPresentation.tsx
@@ -4,7 +4,9 @@ import type {
PullRequestCheck,
PullRequestCheckStatus,
PullRequestChecksState,
+ PullRequestLabel,
PullRequestMergeability,
+ PullRequestReviewDecision,
PullRequestState,
} from "@t3tools/contracts";
import {
@@ -13,14 +15,17 @@ import {
CircleDotIcon,
CircleXIcon,
UserCheckIcon,
+ UserRoundIcon,
+ UserRoundXIcon,
} from "lucide-react";
-import { Children, isValidElement, type ReactNode, useState } from "react";
+import { Children, type CSSProperties, isValidElement, type ReactNode, useState } from "react";
import { cn } from "~/lib/utils";
import { Badge } from "../ui/badge";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import type { PullRequestReviewOutcome } from "./pullRequestDetail.logic";
+import { pullRequestLabelColor } from "./pullRequestList.logic";
import {
PULL_REQUEST_STATE_PRESENTATION,
PullRequestGlyph,
@@ -28,17 +33,87 @@ import {
type PullRequestGlyphIcon,
} from "./pullRequestIcons";
-export function PullRequestApprovalGlyph() {
+/**
+ * A host label as a flat tinted tag in the label's own color: a wash of it behind, the name
+ * in a mix of it and the theme foreground. The mix leans to the foreground because hosts hand
+ * out any color at all: at 30% of the label on light and 45% on dark, white, black and
+ * GitHub's pale yellows all clear 4.5:1 on their wash, selected row included, and
+ * saturated colors sit well above.
+ * A label with no usable color falls back to the muted tag. Children ride after the name,
+ * for an overflow count. The height is pinned so a labeled row is as tall as one without.
+ */
+export function PullRequestLabelChip({
+ label,
+ size = "sm",
+ className,
+ children,
+}: {
+ label: Pick<PullRequestLabel, "name" | "color">;
+ size?: "sm" | "default";
+ className?: string;
+ children?: ReactNode;
+}) {
+ const color = pullRequestLabelColor(label.color);
+ return (
+ <Badge
+ size={size}
+ variant="secondary"
+ className={cn(
+ "min-w-0 max-w-40 shrink justify-start gap-1 rounded-full px-2",
+ size === "sm" && "h-4 text-[.625rem]",
+ color &&
+ "bg-[color-mix(in_srgb,var(--label)_8%,transparent)] text-[color-mix(in_srgb,var(--label)_30%,var(--color-foreground))] dark:bg-[color-mix(in_srgb,var(--label)_12%,transparent)] dark:text-[color-mix(in_srgb,var(--label)_45%,var(--color-foreground))]",
+ className,
+ )}
+ {...(color ? { style: { "--label": color } as CSSProperties } : {})}
+ >
+ <span className="truncate">{label.name}</span>
+ {children}
+ </Badge>
+ );
+}
+
+/**
+ * The review verdict as one glyph beside the checks glyph, so a row answers both "does it
+ * build" and "did someone say yes" in the same spot. "Awaiting review" is only drawn when the
+ * host reports it, which on GitHub means the branch rules require a review nobody has given.
+ */
+function reviewDecisionPresentation(decision: PullRequestReviewDecision) {
+ switch (decision) {
+ case "approved":
+ return {
+ Icon: UserCheckIcon,
+ label: "Approved",
+ toneClassName: CHECK_STATUS_PRESENTATION.success.toneClassName,
+ };
+ case "changes-requested":
+ return {
+ Icon: UserRoundXIcon,
+ label: "Changes requested",
+ toneClassName: "text-amber-600/90 dark:text-amber-400/80",
+ };
+ case "review-required":
+ return {
+ Icon: UserRoundIcon,
+ label: "Awaiting review",
+ toneClassName: "text-muted-foreground/60",
+ };
+ }
+}
+
+export function PullRequestReviewDecisionGlyph({
+ decision,
+}: {
+ decision: PullRequestReviewDecision;
+}) {
+ const presentation = reviewDecisionPresentation(decision);
return (
<Tooltip>
<TooltipTrigger render={<span className="inline-flex shrink-0" />}>
- <UserCheckIcon
- aria-hidden
- className={cn("size-3.5", CHECK_STATUS_PRESENTATION.success.toneClassName)}
- />
- <span className="sr-only">Approved</span>
+ <presentation.Icon aria-hidden className={cn("size-3.5", presentation.toneClassName)} />
+ <span className="sr-only">{presentation.label}</span>
</TooltipTrigger>
- <TooltipPopup>Approved</TooltipPopup>
+ <TooltipPopup>{presentation.label}</TooltipPopup>
</Tooltip>
);
}
diff --git a/apps/web/src/routes/_chat.pull-requests.tsx b/apps/web/src/routes/_chat.pull-requests.tsx
index f54415b1986..485fa7718e3 100644
--- a/apps/web/src/routes/_chat.pull-requests.tsx
+++ b/apps/web/src/routes/_chat.pull-requests.tsx
@@ -24,11 +24,13 @@ import {
LayersIcon,
ListChecksIcon,
PenLineIcon,
+ UsersIcon,
Plug2Icon,
Maximize2Icon,
Minimize2Icon,
SearchIcon,
UserLockIcon,
+ type LucideIcon,
} from "lucide-react";
import {
useCallback,
@@ -146,6 +148,7 @@ import {
} from "../state/pullRequests";
import { useAtomCommand } from "../state/use-atom-command";
import { cn } from "~/lib/utils";
+import { Separator } from "~/components/ui/separator";
import { primaryServerKeybindingsAtom } from "~/state/server";
import { getSourceControlPresentationForKind } from "~/sourceControlPresentation";
import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons";
@@ -188,6 +191,32 @@ export interface PullRequestsSearch extends PullRequestListPreferences {
readonly selectedEnvironmentId?: EnvironmentId;
}
+/**
+ * A group reads like the sidebar's shelves: its glyph, its name, how many, then a rule out
+ * to the edge. The glyph is the one the involvement filter uses for the same idea.
+ */
+const GROUP_ICONS: Record<string, LucideIcon> = {
+ authored: PenLineIcon,
+ reviewRequested: EyeIcon,
+ others: UsersIcon,
+};
+
+function PullRequestGroupHeader({
+ group,
+}: {
+ group: { key: string; label: string; entries: ReadonlyArray<unknown> };
+}) {
+ const Icon = GROUP_ICONS[group.key] ?? LayersIcon;
+ return (
+ <div className="flex items-center gap-2 px-3 pb-1 text-xs font-medium text-muted-foreground/70">
+ <Icon aria-hidden className="size-3.5 shrink-0" />
+ <h2 className="shrink-0">{group.label}</h2>
+ <span className="shrink-0 tabular-nums text-muted-foreground/50">{group.entries.length}</span>
+ <Separator className="min-w-2 flex-1 bg-border/60" />
+ </div>
+ );
+}
+
// The state filters wear the same glyphs the rows do, so the two read as one vocabulary.
const INVOLVEMENT_TABS = [
{ value: "all", label: "All", Icon: LayersIcon },
@@ -1659,11 +1688,7 @@ function PullRequestsRouteView() {
<div className="space-y-3">
{displayGroups.map((group) => (
<div key={group.key} className="space-y-0.5">
- {group.label ? (
- <h2 className="px-3 pb-0.5 text-xs font-medium text-muted-foreground/70">
- {group.label}
- </h2>
- ) : null}
+ {group.label ? <PullRequestGroupHeader group={group} /> : null}
{group.entries.map((entry) => {
const entryKey = pullRequestEntryKey(entry);
return (