GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): reuse pull request list data while loading (#9467) · incognitojam/styal@21d5d3f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src
    • components/pullRequest
      • PullRequestDetailPanel.tsx
      • PullRequestGhosts.tsx
    • routes
      • _chat.pull-requests.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
type PullRequestAction,
66
type PullRequestInvalidationScope,
77
type PullRequestMergeMethod,
8+
type PullRequestListEntry,
89
type PullRequestUpdateMethod,
910
type PullRequestRef,
1011
type PullRequestState,
@@ -464,6 +465,8 @@ type PullRequestDetailPanelProps = {
464465
*/
465466
threadRef?: ScopedThreadRef | null;
466467
reference: PullRequestRef;
468+
/** Row fields already loaded by the pull-request list, used while richer detail arrives. */
469+
listEntry?: PullRequestListEntry | null;
467470
/**
468471
* Bumped by whatever holds the panel when a reader asks for everything on screen to be read
469472
* again. The panel owns its own reads, so the page cannot refresh them for it — it says when,
@@ -520,6 +523,7 @@ function PullRequestDetailPanelBody({
520523
environmentId,
521524
threadRef: explicitThreadRef,
522525
reference,
526+
listEntry = null,
523527
refreshToken: forcedRefreshToken = 0,
524528
onActed,
525529
onClose,
@@ -532,6 +536,12 @@ function PullRequestDetailPanelBody({
532536
explicitThreadRef ??
533537
(typeof composerDraftTarget === "string" ? null : (composerDraftTarget ?? null));
534538
const pullRequestKey = `${reference.projectId}:${reference.repository}#${reference.number}`;
539+
const matchingListEntry =
540+
listEntry?.projectId === reference.projectId &&
541+
listEntry.repository.toLowerCase() === reference.repository.toLowerCase() &&
542+
listEntry.number === reference.number
543+
? listEntry
544+
: null;
535545
const [tab, setTab] = useState<DetailTab>("summary");
536546
const [timelineOrder, setTimelineOrder] = useState<"newest" | "oldest">("newest");
537547
const [codeCommitScope, setCodeCommitScope] = useState<{
@@ -1360,10 +1370,10 @@ function PullRequestDetailPanelBody({
13601370
/>
13611371
) : null;
13621372

1363-
// A reopen already has last time's title, author, and counts. Keep them on screen
1364-
// and let the live read replace fields — especially the diff counts — in place.
1373+
// The list already has the pull request's identity and summary. Keep them on screen
1374+
// and let the richer detail read replace the remaining placeholders in place.
13651375
if (detailQuery.isPending && !detail) {
1366-
return <PullRequestDetailGhost />;
1376+
return <PullRequestDetailGhost seed={matchingListEntry} />;
13671377
}
13681378

13691379
return (
Collapse file

‎apps/web/src/components/pullRequest/PullRequestGhosts.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/PullRequestGhosts.tsx
+127-14Lines changed: 127 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@
77
* both themes) and the single `animate-skeleton` pulse, applied once on the container so any
88
* number of bars costs one opacity animation.
99
*/
10+
import type { PullRequestListEntry } from "@t3tools/contracts";
11+
import { ArrowLeftIcon } from "lucide-react";
12+
1013
import { cn } from "~/lib/utils";
14+
import { formatRelativeTimeLabel } from "~/timestampFormat";
15+
16+
import { pullRequestLabelColor } from "./pullRequestList.logic";
17+
import {
18+
PullRequestActorLabel,
19+
PullRequestDiffStat,
20+
pullRequestChecksStatePresentation,
21+
resolvePullRequestState,
22+
} from "./pullRequestPresentation";
1123

1224
function GhostBar({ className }: { className?: string | undefined }) {
1325
return <div aria-hidden className={cn("h-3 rounded bg-muted-foreground/15", className)} />;
@@ -60,18 +72,46 @@ export function PullRequestListGhost({
6072
* boundaries in the ghost prevents the loaded pull request from replacing one layout with
6173
* another a moment later.
6274
*/
63-
export function PullRequestDetailGhost() {
75+
export function PullRequestDetailGhost({ seed }: { seed?: PullRequestListEntry | null }) {
76+
const statePresentation = seed
77+
? resolvePullRequestState({
78+
state: seed.state,
79+
isDraft: seed.isDraft,
80+
})
81+
: null;
82+
const checksPresentation = seed?.checksState
83+
? pullRequestChecksStatePresentation(seed.checksState)
84+
: null;
85+
6486
return (
6587
<div
6688
role="status"
6789
aria-label="Loading pull request"
68-
className="motion-safe:animate-skeleton flex h-full min-h-0 flex-col overflow-hidden bg-background"
90+
className={cn(
91+
"flex h-full min-h-0 flex-col overflow-hidden bg-background",
92+
!seed && "motion-safe:animate-skeleton",
93+
)}
6994
>
7095
<div className="shrink-0 border-b border-border/60">
7196
<div className="flex h-7 items-center justify-between gap-3 px-4">
7297
<div className="flex min-w-0 flex-1 items-center gap-1.5">
73-
<GhostBar className="w-24" />
74-
<GhostBar className="w-9" />
98+
{seed && statePresentation ? (
99+
<>
100+
<span className="min-w-0 truncate text-xs font-medium text-muted-foreground">
101+
{seed.repository}
102+
</span>
103+
<span
104+
className={cn("shrink-0 text-xs font-medium", statePresentation.toneClassName)}
105+
>
106+
#{seed.number}
107+
</span>
108+
</>
109+
) : (
110+
<>
111+
<GhostBar className="w-24" />
112+
<GhostBar className="w-9" />
113+
</>
114+
)}
75115
</div>
76116
<div className="flex shrink-0 items-center gap-1">
77117
<GhostBar className="h-5 w-16 rounded-md" />
@@ -80,18 +120,58 @@ export function PullRequestDetailGhost() {
80120
</div>
81121

82122
<div className="px-4 pb-4 pt-1">
83-
<GhostBar className="h-5 w-4/5 max-w-md" />
123+
{seed ? (
124+
<h1 className="truncate text-base font-semibold leading-snug">{seed.title}</h1>
125+
) : (
126+
<GhostBar className="h-5 w-4/5 max-w-md" />
127+
)}
84128
<div className="mt-2 flex items-center gap-1.5">
85-
<GhostBar className="size-4 rounded-full" />
86-
<GhostBar className="w-24" />
129+
{seed ? (
130+
<>
131+
<PullRequestActorLabel
132+
actor={seed.author}
133+
className="font-medium"
134+
tooltip={false}
135+
/>
136+
<span className="text-xs text-muted-foreground">
137+
updated {formatRelativeTimeLabel(seed.updatedAt)}
138+
</span>
139+
</>
140+
) : (
141+
<>
142+
<GhostBar className="size-4 rounded-full" />
143+
<GhostBar className="w-24" />
144+
</>
145+
)}
87146
</div>
88147
<div className="mt-4 flex min-w-0 items-center gap-2">
89-
<GhostBar className="h-6 w-24 rounded-md" />
90-
<GhostBar className="size-3 rounded-full" />
91-
<GhostBar className="h-6 w-32 rounded-md" />
148+
{seed ? (
149+
<span className="flex min-w-0 flex-1 items-center gap-1.5 font-mono text-xs text-muted-foreground/70">
150+
<code className="min-w-0 max-w-[40%] shrink-0 truncate">{seed.baseBranch}</code>
151+
<ArrowLeftIcon
152+
aria-label="receives changes from"
153+
className="size-3.5 shrink-0 opacity-60"
154+
/>
155+
<code className="min-w-0 flex-1 truncate">{seed.headBranch}</code>
156+
</span>
157+
) : (
158+
<>
159+
<GhostBar className="h-6 w-24 rounded-md" />
160+
<GhostBar className="size-3 rounded-full" />
161+
<GhostBar className="h-6 w-32 rounded-md" />
162+
</>
163+
)}
92164
<div className="ml-auto flex shrink-0 items-center gap-2">
93165
<GhostBar className="w-10" />
94-
<GhostBar className="w-20" />
166+
{seed ? (
167+
<PullRequestDiffStat
168+
additions={seed.additions}
169+
deletions={seed.deletions}
170+
className="font-mono text-xs"
171+
/>
172+
) : (
173+
<GhostBar className="w-20" />
174+
)}
95175
</div>
96176
</div>
97177
</div>
@@ -102,7 +182,19 @@ export function PullRequestDetailGhost() {
102182
<GhostBar className="h-6 w-16 rounded-md" />
103183
<GhostBar className="h-6 w-12 rounded-md" />
104184
</div>
105-
<GhostBar className="w-20" />
185+
{checksPresentation ? (
186+
<span
187+
className={cn(
188+
"inline-flex items-center gap-1.5 text-xs",
189+
checksPresentation.toneClassName,
190+
)}
191+
>
192+
<checksPresentation.Icon aria-hidden className="size-3.5" />
193+
{checksPresentation.label}
194+
</span>
195+
) : (
196+
<GhostBar className="w-20" />
197+
)}
106198
</div>
107199
</div>
108200

@@ -125,8 +217,29 @@ export function PullRequestDetailGhost() {
125217
<GhostBar className="w-10" />
126218
</div>
127219
<div className="flex items-center gap-1">
128-
<GhostBar className="h-5 w-24 rounded-full" />
129-
<GhostBar className="h-5 w-20 rounded-full" />
220+
{seed ? (
221+
seed.labels.slice(0, 3).map((label) => {
222+
const color = pullRequestLabelColor(label.color);
223+
return (
224+
<span
225+
key={label.name}
226+
className="inline-flex h-5 max-w-32 items-center gap-1 truncate rounded-full border border-border/70 bg-muted/40 px-2 text-[10px] text-muted-foreground"
227+
>
228+
<span
229+
aria-hidden
230+
className="size-2 shrink-0 rounded-full bg-muted-foreground"
231+
{...(color ? { style: { backgroundColor: color } } : {})}
232+
/>
233+
<span className="truncate">{label.name}</span>
234+
</span>
235+
);
236+
})
237+
) : (
238+
<>
239+
<GhostBar className="h-5 w-24 rounded-full" />
240+
<GhostBar className="h-5 w-20 rounded-full" />
241+
</>
242+
)}
130243
</div>
131244
</div>
132245
<div className="grid min-h-8 grid-cols-[6rem_minmax(0,1fr)] items-center gap-2">
Collapse file

‎apps/web/src/routes/_chat.pull-requests.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/routes/_chat.pull-requests.tsx
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ const EMPTY_TERMINAL_LABELS = new Map<string, string>();
225225
const EMPTY_PENDING_SURFACES = new Set<string>();
226226
const MAX_SEARCH_LABEL_CANDIDATES = 100;
227227

228+
const pullRequestListEntryId = (target: Parameters<typeof pullRequestSurfaceId>[0]) =>
229+
pullRequestSurfaceId({ ...target, repository: target.repository.toLowerCase() });
230+
228231
function pullRequestSearchLabels(raw: unknown): Partial<Pick<PullRequestsSearch, "labels">> {
229232
const values = (Array.isArray(raw) ? raw : typeof raw === "string" ? [raw] : []).slice(
230233
0,
@@ -1447,6 +1450,15 @@ function PullRequestsRouteView() {
14471450
entry.additions + entry.deletions > 0 || statsByRow.has(pullRequestDiffStatKey(entry)),
14481451
);
14491452
}, [groups, sort, statsByRow, typedParsed.text]);
1453+
const listedPullRequestsBySurface = useMemo(
1454+
() =>
1455+
new Map(
1456+
displayGroups.flatMap((group) =>
1457+
group.entries.map((entry) => [pullRequestListEntryId(entry), entry] as const),
1458+
),
1459+
),
1460+
[displayGroups],
1461+
);
14501462

14511463
const linkedSelection = useMemo(
14521464
() =>
@@ -1953,6 +1965,11 @@ function PullRequestsRouteView() {
19531965
repository: renderedPullRequestSurface.repository,
19541966
number: renderedPullRequestSurface.number,
19551967
}}
1968+
listEntry={
1969+
listedPullRequestsBySurface.get(
1970+
pullRequestListEntryId(renderedPullRequestSurface),
1971+
) ?? null
1972+
}
19561973
refreshToken={detailRefreshToken}
19571974
// Merging, closing or reopening changes the row this panel was opened from, so
19581975
// the list behind it is out of date the moment the host takes the action.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.