@devries-cameron20 / t3code Mirror · read-only / commits / 5d9a5c9803
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, 17:00 UTC

perf(pull-requests): faster pull request timeline, code tab, summary and search (#22697)

maria committed Oct 25, 2026 at 19:38 UTC 5d9a5c980347418daa84c9ef5bd8082533162a16
21 files changed +518 -169
apps/server/src/pullRequest/PullRequestService.test.ts
+71 -3
@@ -2663,6 +2663,9 @@ it.effect("isolates routed caches for two credentials belonging to the same acco
2663 host: "github.com",
2664 expectedAccountId: "101",
2665 };
2666 + if (operation === "checks") {
2667 + yield* service.withRoutingCredential(reference, service.detail(reference));
2668 + }
2669 yield* service.withRoutingCredential(reference, readOperation(reference));
2670 credential = "restricted";
2671 for (const allowStale of [false, true]) {
@@ -2838,6 +2841,48 @@ it.effect("deduplicates routed PR reports without dropping draft changes", () =>
2841 }),
2842 );
2843
2844 +it.effect(
2845 + "reuses fresh detail checks without extending their refresh interval on detail cache hits",
2846 + () =>
2847 + Effect.gen(function* () {
2848 + let reads = 0;
2849 + const reference = { projectId: "p1" as ProjectId, repository: "acme/web", number: 1 };
2850 + const service = yield* makeService({
2851 + projects: [
2852 + project({ id: "p1", title: "web", workspaceRoot: "/a", repository: "acme/web" }),
2853 + ],
2854 + providers: [
2855 + fakePullRequestProvider(SourceControlProviderKind.make("github"), {
2856 + getChangeRequest: () => Effect.succeed(hostedChangeRequest("Description")),
2857 + getChangeRequestChecks: () =>
2858 + Effect.sync(() => {
2859 + reads += 1;
2860 + return { state: "closed" as const, checks: [] };
2861 + }),
2862 + }),
2863 + ],
2864 + });
2865 + yield* TestClock.setTime(1_000);
2866 + const detail = yield* service.detail(reference);
2867 + expect(yield* service.checks(reference)).toEqual({
2868 + state: detail.state,
2869 + checks: detail.checks,
2870 + observedAt: detail.observedAt,
2871 + });
2872 + expect(reads).toBe(0);
2873 + yield* TestClock.adjust("16 seconds");
2874 + yield* service.detail(reference);
2875 + expect(yield* service.checks(reference)).toMatchObject({
2876 + state: "closed",
2877 + observedAt: 17_000,
2878 + });
2879 + expect(reads).toBe(1);
2880 + yield* service.detail(reference);
2881 + expect((yield* service.checks(reference))?.state).toBe("closed");
2882 + expect(reads).toBe(1);
2883 + }),
2884 +);
2885 +
2886 it.effect("preserves check observation time on cache hits and advances it on refresh", () =>
2887 Effect.gen(function* () {
2888 let reads = 0;
@@ -4260,7 +4305,7 @@ it.effect.each(["commit", "credential"] as const)(
4305 }),
4306 );
4307
4263 -it.effect.each(["expiry", "refresh"] as const)(
4308 +it.effect.each(["expiry", "commit expiry", "cache hit", "commit cache hit", "refresh"] as const)(
4309 "keeps a loaded diff's original membership scope through an in-flight %s",
4310 (boundary) =>
4311 Effect.gen(function* () {
@@ -4284,17 +4329,40 @@ it.effect.each(["expiry", "refresh"] as const)(
4329 nextCursor: null,
4330 };
4331 }),
4287 - getDiffFileContents: () => Effect.die("an expired file must not be read"),
4332 + getDiffFileContents: () => Effect.succeed({ oldContents: "old", newContents: "new" }),
4333 }),
4334 ],
4335 });
4291 - const ref = { projectId: "p1" as ProjectId, repository: "acme/web", number: 1 };
4336 + const ref = {
4337 + projectId: "p1" as ProjectId,
4338 + repository: "acme/web",
4339 + number: 1,
4340 + ...(boundary.includes("commit") ? { commit: "a".repeat(40) } : {}),
4341 + };
4342 const loading = yield* Effect.forkChild(service.diff(ref));
4343 yield* Deferred.await(started);
4344 if (boundary === "expiry") yield* TestClock.adjust("61 seconds");
4345 + else if (boundary === "commit expiry") yield* TestClock.adjust("11 minutes");
4346 + else if (boundary.includes("cache hit")) yield* TestClock.adjust("30 seconds");
4347 else yield* service.invalidate({ reference: ref });
4348 yield* Deferred.succeed(release, undefined);
4349 yield* Fiber.join(loading);
4350 + if (boundary.includes("cache hit")) {
4351 + yield* service.diff(ref);
4352 + yield* service.diff(ref);
4353 + yield* TestClock.adjust(boundary.includes("commit") ? "9 minutes" : "29 seconds");
4354 + assert.deepStrictEqual(
4355 + yield* service.diffFileContents({
4356 + ...ref,
4357 + changeType: "change",
4358 + oldPath: "private.ts",
4359 + newPath: "private.ts",
4360 + }),
4361 + { oldContents: "old", newContents: "new" },
4362 + );
4363 + assert.strictEqual(diffReads, 1);
4364 + yield* TestClock.adjust(boundary.includes("commit") ? "1 minute" : "2 seconds");
4365 + }
4366 const error = yield* service
4367 .diffFileContents({
4368 ...ref,
apps/server/src/pullRequest/PullRequestService.ts
+72 -22
@@ -141,9 +141,23 @@ const LIST_CACHE_CAPACITY = 64;
141 const LIST_STATS_CACHE_CAPACITY = 32;
142 const DETAIL_CACHE_CAPACITY = 128;
143 const DIFF_CACHE_CAPACITY = 128;
144 -const MAX_CACHED_DIFF_PATCH_BYTES = 512 * 1024;
144 +// Each holder stays within this UTF-16 patch budget as well as its entry-count bound.
145 +const DIFF_CACHE_PATCH_BUDGET_BYTES = 32 * 1024 * 1024;
146 const canCacheDiff = (value: PullRequestDiffResult) =>
146 - value.patch.length * 2 <= MAX_CACHED_DIFF_PATCH_BYTES;
147 + value.patch.length * 2 <= DIFF_CACHE_PATCH_BUDGET_BYTES;
148 +const diffCacheEvictions = (entries: Iterable<readonly [string, PullRequestDiffResult]>) => {
149 + let bytes = 0;
150 + const evictions: string[] = [];
151 + for (const [key, value] of Array.from(entries).toReversed()) {
152 + const size = value.patch.length * 2;
153 + if (bytes + size > DIFF_CACHE_PATCH_BUDGET_BYTES) {
154 + evictions.push(key);
155 + } else {
156 + bytes += size;
157 + }
158 + }
159 + return evictions;
160 +};
161 const FILES_VIEWED_CACHE_CAPACITY = 128;
162 const VIEWER_CACHE_CAPACITY = 32;
163
@@ -681,6 +695,7 @@ export const make = Effect.gen(function* () {
695 const rateLimits = yield* SourceControlRateLimit.SourceControlRateLimit;
696 const filesViewedStore = yield* PullRequestFilesViewed.PullRequestFilesViewedRepository;
697 const readCache = yield* PullRequestReadCache.PullRequestReadCache;
698 + const clock = yield* Clock.Clock;
699
700 /**
701 * Where each project's remote is served from, by the remote's recognised base URL: a remote no
@@ -2617,6 +2632,11 @@ export const make = Effect.gen(function* () {
2632 if (oldest !== undefined) held.delete(oldest);
2633 }
2634 held.set(key, { at, value });
2635 + for (const evicted of diffCacheEvictions(
2636 + Array.from(held, ([key, snapshot]) => [key, snapshot.value] as const),
2637 + )) {
2638 + held.delete(evicted);
2639 + }
2640 armDiffSweep();
2641 });
2642 const serve = <E>(key: string, read: Effect.Effect<PullRequestDiffResult, E>) => {
@@ -2964,7 +2984,20 @@ export const make = Effect.gen(function* () {
2984 },
2985 {
2986 capacity: DETAIL_CACHE_CAPACITY,
2967 - timeToLive: (exit) => (Exit.isSuccess(exit) ? CHECKS_CACHE_TTL : Duration.zero),
2987 + // Expire from the read's start so checks seeded from a slow detail read keep their age.
2988 + timeToLive: (exit) =>
2989 + !Exit.isSuccess(exit)
2990 + ? Duration.zero
2991 + : exit.value === null
2992 + ? CHECKS_CACHE_TTL
2993 + : Duration.millis(
2994 + Math.max(
2995 + 0,
2996 + exit.value.observedAt +
2997 + Duration.toMillis(CHECKS_CACHE_TTL) -
2998 + clock.currentTimeMillisUnsafe(),
2999 + ),
3000 + ),
3001 },
3002 );
3003
@@ -2998,6 +3031,18 @@ export const make = Effect.gen(function* () {
3031 return detailUncached(refOfCacheKey(key)).pipe(
3032 Effect.tap(
3033 Effect.fn("PullRequestService.recordDetailStats")(function* (value: PullRequestDetail) {
3034 + // GitHub detail includes the same checks; the checks TTL counts from their observation.
3035 + if (
3036 + value.provider === "github" &&
3037 + value.observedAt !== undefined &&
3038 + !(yield* Cache.has(checksCache, key))
3039 + ) {
3040 + yield* Cache.set(checksCache, key, {
3041 + state: value.state,
3042 + checks: value.checks,
3043 + observedAt: value.observedAt,
3044 + });
3045 + }
3046 recordStats(
3047 statsKey,
3048 {
@@ -3208,10 +3253,10 @@ export const make = Effect.gen(function* () {
3253 ...(commit === null ? {} : { commit }),
3254 } as PullRequestDiffInput).pipe(
3255 observeRead,
3211 - Effect.map(({ value, observedAt }) => {
3256 + Effect.tap(({ value, observedAt }) => {
3257 // Keep the loader's epoch and read time if a refresh occurs during the provider read.
3258 diffFiles.record(JSON.stringify([reference, cursor, commit]), value, observedAt);
3214 - return value;
3259 + return Effect.void;
3260 }),
3261 );
3262 },
@@ -3220,7 +3265,10 @@ export const make = Effect.gen(function* () {
3265 timeToLive: (exit, key) => {
3266 if (!Exit.isSuccess(exit)) return Duration.zero;
3267 const commit = (JSON.parse(key) as ReadonlyArray<unknown>)[2];
3223 - return commit === null ? DIFF_CACHE_TTL : COMMIT_DIFF_CACHE_TTL;
3268 + const ttl = Duration.toMillis(commit === null ? DIFF_CACHE_TTL : COMMIT_DIFF_CACHE_TTL);
3269 + return Duration.millis(
3270 + Math.max(0, exit.value.observedAt + ttl - clock.currentTimeMillisUnsafe()),
3271 + );
3272 },
3273 },
3274 );
@@ -3246,7 +3294,7 @@ export const make = Effect.gen(function* () {
3294 if (held > 0) armDiffSweep();
3295 }),
3296 );
3249 - const diff: PullRequestService["Service"]["diff"] = (input) => {
3297 + const readDiff = (input: PullRequestDiffInput) => {
3298 const key = JSON.stringify([
3299 refCacheKey(input),
3300 input.cursor ?? null,
@@ -3255,22 +3303,24 @@ export const make = Effect.gen(function* () {
3303 ? (lastGoodSummary.peek(refCacheKey(input))?.updatedAt ?? null)
3304 : null,
3305 ]);
3258 - const read = Cache.get(diffCache, key).pipe(
3259 - Effect.tap((value) =>
3260 - canCacheDiff(value)
3261 - ? Effect.void
3262 - : Cache.getSuccess(diffCache, key).pipe(
3263 - Effect.flatMap((current) =>
3264 - Option.isSome(current) && current.value === value
3265 - ? Cache.invalidate(diffCache, key)
3266 - : Effect.void,
3267 - ),
3268 - Effect.uninterruptible,
3269 - ),
3306 + const evictDiffs = Cache.entries(diffCache).pipe(
3307 + Effect.flatMap((entries) =>
3308 + Effect.forEach(
3309 + diffCacheEvictions(Array.from(entries, ([key, read]) => [key, read.value] as const)),
3310 + (evicted) => Cache.invalidate(diffCache, evicted),
3311 + ),
3312 ),
3313 + Effect.uninterruptible,
3314 + );
3315 + const read = Cache.get(diffCache, key).pipe(
3316 + Effect.ensuring(evictDiffs),
3317 Effect.ensuring(Effect.sync(armDiffSweep)),
3318 );
3273 - return staleDiff.serve(key, read);
3319 + return { key, read };
3320 + };
3321 + const diff: PullRequestService["Service"]["diff"] = (input) => {
3322 + const { key, read } = readDiff(input);
3323 + return staleDiff.serve(key, read.pipe(Effect.map((read) => read.value)));
3324 };
3325
3326 const filesViewedCache = yield* Cache.makeWith(
@@ -3524,8 +3574,8 @@ export const make = Effect.gen(function* () {
3574 .pipe(Effect.mapError(toPullRequestError("diffFileContents")));
3575 return recordPaths(key, slice, now);
3576 }
3527 - const slice = yield* diff(input);
3528 - return record(key, slice, now);
3577 + const { value, observedAt } = yield* readDiff(input).read;
3578 + return record(key, value, observedAt);
3579 });
3580 return { read: credentialCached(read), record, fileKey };
3581 })();
apps/web/src/components/DiffWorkerPoolProvider.tsx
+8 -4
@@ -125,9 +125,7 @@ function DiffWorkerReady({ children }: { children?: ReactNode }) {
125 );
126 }
127
128 -export function DiffWorkerPoolProvider({ children }: { children?: ReactNode }) {
129 - const resolvedTheme = useRenderedAppearance();
130 - const diffThemeName = resolveDiffThemeName(resolvedTheme);
128 +export function useDiffWorkerPool(diffThemeName: DiffThemeName) {
129 const [workerPoolSize] = useState(resolveDiffWorkerPoolSize);
130 const subscribe = useStableCallback((onStoreChange: () => void) => {
131 if (typeof window === "undefined") return () => {};
@@ -143,11 +141,17 @@ export function DiffWorkerPoolProvider({ children }: { children?: ReactNode }) {
141 }, DIFF_WORKER_IDLE_TTL_MS);
142 };
143 });
146 - const workerPool = useSyncExternalStore(
144 + return useSyncExternalStore(
145 subscribe,
146 () => sharedWorkerPool?.pool,
147 () => undefined,
148 );
149 +}
150 +
151 +export function DiffWorkerPoolProvider({ children }: { children?: ReactNode }) {
152 + const resolvedTheme = useRenderedAppearance();
153 + const diffThemeName = resolveDiffThemeName(resolvedTheme);
154 + const workerPool = useDiffWorkerPool(diffThemeName);
155
156 return (
157 <WorkerPoolContext value={workerPool}>
apps/web/src/components/RightPanelTabs.tsx
+1
@@ -726,6 +726,7 @@ function PullRequestSurfaceIcon({
726 : {}),
727 repository: surface.repository,
728 number: surface.number,
729 + allowStale: false,
730 },
731 }),
732 ).data;
apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
+11 -3
@@ -8,6 +8,7 @@ import type {
8 EnvironmentId,
9 PullRequestDetailView,
10 PullRequestDiffSide,
11 + PullRequestDiffResult,
12 PullRequestOmittedFileStat,
13 PullRequestRef,
14 PullRequestReviewPosition,
@@ -74,6 +75,7 @@ import { useEnvironmentQuery } from "~/state/query";
75 import { useAtomCommand } from "~/state/use-atom-command";
76
77 import { DiffPanelLoadingState } from "../DiffPanelShell";
78 +import { useDiffWorkerPool } from "../DiffWorkerPoolProvider";
79 import { DiffCommentAnnotation } from "../diffs/DiffCommentAnnotation";
80 import { DiffFileTree } from "../diffs/DiffFileTree";
81 import { useCodeViewFileReveal } from "../diffs/useCodeViewFileReveal";
@@ -132,6 +134,7 @@ const COMMIT_PAGE_SIZE = 10;
134 const PULL_REQUEST_FILE_TREE_STORAGE_KEY = "t3code.pullRequestFileTreeOpen";
135
136 interface DiffSlice {
137 + readonly source: PullRequestDiffResult;
138 readonly cursor: string | null;
139 readonly patch: string;
140 readonly truncated: boolean;
@@ -148,13 +151,15 @@ const REPLACE_FILE_COUNTS_CSS = `
151
152 const NO_SLICES: ReadonlyArray<DiffSlice> = [];
153
151 -const sliceParses = new WeakMap<DiffSlice, Map<string, RenderablePatch | null>>();
154 +// Query results outlive the panel's slices, so their parses survive closing and reopening
155 +// without retaining anything beyond the query cache's lifetime.
156 +const sliceParses = new WeakMap<PullRequestDiffResult, Map<string, RenderablePatch | null>>();
157
158 function parseSlice(slice: DiffSlice, cacheKey: string, ignoreWhitespace: boolean) {
154 - let parses = sliceParses.get(slice);
159 + let parses = sliceParses.get(slice.source);
160 if (parses === undefined) {
161 parses = new Map();
157 - sliceParses.set(slice, parses);
162 + sliceParses.set(slice.source, parses);
163 }
164 if (parses.has(cacheKey)) return parses.get(cacheKey) ?? null;
165 const parsed = getRenderablePatch(slice.patch, cacheKey, {
@@ -272,6 +277,8 @@ function PullRequestCodeTab({
277 revealRequest?: { readonly path: string; readonly nonce: number } | null;
278 }) {
279 const resolvedTheme = useRenderedAppearance();
280 + // Initialize the shared tokenizer and workers while the diff request is still pending.
281 + useDiffWorkerPool(resolveDiffThemeName(resolvedTheme));
282 const settings = useClientSettings((settings) => ({
283 diffFilesCollapsed: settings.diffFilesCollapsed,
284 diffIgnoreWhitespace: settings.diffIgnoreWhitespace,
@@ -353,6 +360,7 @@ function PullRequestCodeTab({
360 setSliceState((previous) => {
361 const slices = previous.key === scopeKey ? previous.slices : NO_SLICES;
362 const next = {
363 + source: data,
364 cursor,
365 patch: data.patch,
366 truncated: data.truncated,
apps/web/src/components/pullRequest/PullRequestCommentBody.tsx
+3 -3
@@ -17,9 +17,9 @@ export function PullRequestCommentBody({
17 useEffect(() => {
18 const element = content.current;
19 if (!element) return;
20 - const measure = () => setOverflowing(element.getBoundingClientRect().height > 240);
21 - measure();
22 - return observeResize(element, measure);
20 + return observeResize(element, ([entry]) => {
21 + if (entry) setOverflowing(entry.contentRect.height > 240);
22 + });
23 }, []);
24
25 return (
apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+17
@@ -1,4 +1,5 @@
1 import { projectChangeRequestUrl } from "@t3tools/client-runtime/change-request-links";
2 +import { normalizeThreadPullRequestKey } from "@t3tools/client-runtime/thread-pull-requests";
3 import { changeRequestReferenceAutolinker } from "@t3tools/client-runtime/pull-request-markdown";
4 import { useAtomValue } from "@effect/atom-react";
5 import { usePullRequestStack } from "~/state/usePullRequestStack";
@@ -315,6 +316,22 @@ export function PullRequestDetailPanel({
316 listEntry.number === reference.number
317 ? listEntry
318 : null;
319 + const linkedReference = sourceControlClients.parseChangeRequestUrl(
320 + matchingListEntry?.url ?? unavailableHostUrl ?? "",
321 + )?.link;
322 + useEnvironmentQuery(
323 + context === "page" &&
324 + supportsThreadPullRequests &&
325 + linkedReference &&
326 + (reference.host === undefined ||
327 + reference.host.toLowerCase() === linkedReference.host.toLowerCase())
328 + ? pullRequestEnvironment.linkedThreads({
329 + environmentId,
330 + input: { ...reference, ...normalizeThreadPullRequestKey(linkedReference) },
331 + })
332 + : null,
333 + );
334 + useEnvironmentQuery(pullRequestEnvironment.changeBreakdown({ environmentId, input: reference }));
335 const [threadPickerOpen, setThreadPickerOpen] = useState(false);
336 const [openReviewRequest, setOpenReviewRequest] = useState(0);
337 const [tab, setTab] = useState<PullRequestDetailTab>(initialTab);
apps/web/src/components/pullRequest/PullRequestListFilters.tsx
+10
@@ -97,10 +97,12 @@ export function PullRequestSearchInput({
97 value,
98 busy,
99 onChange,
100 + onSubmit,
101 }: {
102 value: string;
103 busy?: boolean;
104 onChange: (value: string) => void;
105 + onSubmit: (value: string) => void;
106 }) {
107 const [draft, setDraft] = useState<string | null>(null);
108 return (
@@ -116,6 +118,14 @@ export function PullRequestSearchInput({
118 onChange={(event) => {
119 setDraft(event.currentTarget.value);
120 onChange(event.currentTarget.value);
121 + if ((event.nativeEvent as InputEvent).inputType === "insertFromPaste") {
122 + onSubmit(event.currentTarget.value);
123 + }
124 + }}
125 + onKeyDown={(event) => {
126 + if (event.key === "Enter" && !event.nativeEvent.isComposing) {
127 + onSubmit(event.currentTarget.value);
128 + }
129 }}
130 placeholder="Search pull requests, or label:bug"
131 aria-label="Search pull requests"
apps/web/src/components/pullRequest/PullRequestsPage.tsx
+30
@@ -26,6 +26,7 @@ import {
26 collectPullRequestListFacets,
27 narrowPullRequestsToFilters,
28 mergePullRequestDiffStats,
29 + pullRequestDiffStatKey,
30 pullRequestEntryKey,
31 rankPullRequestMatches,
32 readPullRequestListSnapshot,
@@ -104,6 +105,7 @@ import {
105 usePullRequestList,
106 usePullRequestListStats,
107 usePullRequestTurnRefreshes,
108 + useSharedPullRequestSummary,
109 type EnvironmentQueryTarget,
110 } from "~/state/pullRequests";
111 import { useAtomCommand } from "~/state/use-atom-command";
@@ -195,6 +197,16 @@ export function PullRequestsPage() {
197 (renderedPullRequestSurface?.environmentId as EnvironmentId | undefined) ??
198 selectedProject?.environmentId ??
199 null;
200 + const panelSummary = useSharedPullRequestSummary(
201 + panelEnvironmentId,
202 + renderedPullRequestSurface === null
203 + ? null
204 + : {
205 + ...renderedPullRequestSurface,
206 + projectId: renderedPullRequestSurface.projectId as ProjectId,
207 + },
208 + null,
209 + );
210 const updateSearch = (patch: {
211 [Key in keyof PullRequestsSearch]?: PullRequestsSearch[Key] | undefined;
212 }) =>
@@ -248,6 +260,7 @@ export function PullRequestsPage() {
260 const [filtersOpen, setFiltersOpen] = useState(false);
261 const {
262 sentQuery,
263 + submitQuery,
264 querySettled,
265 typedParsed,
266 sentParsed,
@@ -710,6 +723,22 @@ export function PullRequestsPage() {
723
724 const visibleStatsKeys = useRef({ key: filterKey, values: new Set<string>() });
725 const [statsByRow, setStatsByRow] = useState<PullRequestDiffStats>(() => new Map());
726 + if (
727 + panelEnvironmentId !== null &&
728 + panelSummary?.additions !== undefined &&
729 + panelSummary.deletions !== undefined
730 + ) {
731 + const stat = {
732 + ...panelSummary,
733 + environmentId: panelEnvironmentId,
734 + additions: panelSummary.additions,
735 + deletions: panelSummary.deletions,
736 + };
737 + const previous = statsByRow.get(pullRequestDiffStatKey(stat));
738 + if (previous?.additions !== stat.additions || previous.deletions !== stat.deletions) {
739 + setStatsByRow(mergePullRequestDiffStats(statsByRow, [stat]));
740 + }
741 + }
742 const [statsTargetState, setStatsTargetState] = useState<{
743 readonly key: string;
744 readonly batches: ReadonlyArray<PullRequestStatsBatch>;
@@ -1076,6 +1105,7 @@ export function PullRequestsPage() {
1105 value={search.q ?? ""}
1106 busy={typedQuery.length > 0 && (!querySettled || showingCarried)}
1107 onChange={(query) => updateListScope({ q: query || undefined })}
1108 + onSubmit={submitQuery}
1109 />
1110 );
1111 const panelToggleControls = (
apps/web/src/components/pullRequest/usePullRequestListView.ts
+7 -3
@@ -8,11 +8,10 @@ import {
8 type PullRequestListResult,
9 type PullRequestListState,
10 } from "@t3tools/contracts";
11 -import { useState } from "react";
11 +import { useEffect, useState } from "react";
12
13 import { useAllEnvironmentShellsBootstrapped, useProjects } from "~/state/entities";
14 import { useEnvironments } from "~/state/environments";
15 -import { useDebouncedValue } from "~/state/queries";
15 import {
16 applyPullRequestOverrides,
17 findProjectForRepository,
@@ -185,7 +184,11 @@ export function usePullRequestScope(search: PullRequestsSearch) {
184 }
185
186 export function usePullRequestQueryFilters(search: PullRequestsSearch, typedQuery: string) {
188 - const sentQuery = useDebouncedValue(typedQuery, SEARCH_DEBOUNCE_MS);
187 + const [sentQuery, setSentQuery] = useState(typedQuery);
188 + useEffect(() => {
189 + const timer = window.setTimeout(() => setSentQuery(typedQuery), SEARCH_DEBOUNCE_MS);
190 + return () => window.clearTimeout(timer);
191 + }, [typedQuery]);
192 const typedParsed = parsePullRequestQuery(typedQuery);
193 const sentParsed = parsePullRequestQuery(sentQuery);
194
@@ -203,6 +206,7 @@ export function usePullRequestQueryFilters(search: PullRequestsSearch, typedQuer
206 const hasLocalFilters = Object.keys(localFilters).length > 0;
207 return {
208 sentQuery,
209 + submitQuery: (query: string) => setSentQuery(query.trim()),
210 querySettled: typedQuery === sentQuery,
211 typedParsed,
212 sentParsed,
apps/web/src/hooks/useOpenPanelPullRequestUrl.ts
+1 -1
@@ -75,7 +75,7 @@ export function useOpenPanelPullRequestUrl(threadRef: ScopedThreadRef | null) {
75 reference && environmentId
76 ? pullRequestEnvironment.detail({
77 environmentId,
78 - input: reference,
78 + input: { ...reference, allowStale: false },
79 })
80 : null,
81 ).data;
packages/source-control-github/src/server/GitHubPullRequestApi.test.ts
+70
@@ -694,6 +694,76 @@ it.effect(
694 );
695
696 layer("GitHubPullRequestApi.layer", (it) => {
697 + it.effect.each(["mixed", "merges", "unavailable"] as const)(
698 + "reads stats only for displayed non-merge commits (%s)",
699 + (kind) =>
700 + Effect.gen(function* () {
701 + const oids = kind === "merges" ? ["merge"] : ["regular", "merge"];
702 + mockedExecute.mockReturnValueOnce(
703 + Effect.succeed(
704 + output(
705 + encodeJson({
706 + data: {
707 + repository: {
708 + pullRequest: {
709 + author: null,
710 + comments: { nodes: [], pageInfo: lastPage },
711 + reviews: { nodes: [], pageInfo: lastPage },
712 + commits: {
713 + nodes: oids.map((oid) => ({
714 + commit: {
715 + id: "node-" + oid,
716 + oid,
717 + messageHeadline: oid,
718 + committedDate: "2026-07-05T00:00:00Z",
719 + parents: { totalCount: oid === "merge" ? 2 : 1 },
720 + authors: { nodes: [] },
721 + },
722 + })),
723 + },
724 + },
725 + },
726 + },
727 + }),
728 + ),
729 + ),
730 + );
731 + if (kind === "unavailable") {
732 + mockedExecute.mockReturnValueOnce(Effect.succeed(output("{}", false, false, {}, 503)));
733 + } else if (kind !== "merges") {
734 + mockedExecute.mockReturnValueOnce(
735 + Effect.succeed(
736 + output(
737 + encodeJson({
738 + data: {
739 + nodes: [{ __typename: "Commit", oid: "regular", additions: 18, deletions: 7 }],
740 + },
741 + }),
742 + ),
743 + ),
744 + );
745 + }
746 + const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
747 + const activity = yield* cli.getPullRequestActivity(pullRequestInput);
748 + expect(activity.commits.map((commit) => commit.oid)).toEqual(oids);
749 + expect(activity.commits.find((commit) => commit.oid === "merge")).not.toHaveProperty(
750 + "additions",
751 + );
752 + expect(activity.commits.find((commit) => commit.oid === "merge")).not.toHaveProperty(
753 + "deletions",
754 + );
755 + if (kind === "mixed") {
756 + expect(activity.commits[0]).toMatchObject({ additions: 18, deletions: 7 });
757 + } else if (kind === "unavailable") {
758 + expect(activity.commits[0]).not.toHaveProperty("additions");
759 + }
760 + expect(variablesOf("PullRequestCommitStats")).toEqual(
761 + kind === "merges" ? [] : [{ ids: ["node-regular"] }],
762 + );
763 + expect(mockedExecute).toHaveBeenCalledTimes(kind === "merges" ? 1 : 2);
764 + }),
765 + );
766 +
767 it.effect("loads the complete hover card with one GraphQL request", () =>
768 Effect.gen(function* () {
769 mockedExecute.mockReturnValueOnce(
packages/source-control-github/src/server/GitHubPullRequestApi.ts
+13 -7
@@ -72,6 +72,7 @@ import {
72 toRepositoryAuthors,
73 toRepositoryLabels,
74 toPullRequestActivityPage,
75 + toPullRequestCommitStats,
76 toPullRequestCheckContextsPage,
77 toPullRequestCore,
78 toPullRequestFilesViewedPage,
@@ -1989,6 +1990,7 @@ export const make = Effect.gen(function* () {
1990 const { owner, name } = parseRepositorySelector(input.repository);
1991 let author: PullRequestActor | null = null;
1992 let commits: ReadonlyArray<PullRequestCommit> = [];
1993 + let nonMergeCommitIds: ReadonlyArray<string> = [];
1994 const remarks: PullRequestComment[] = [];
1995 let commentsAfter: string | null = null;
1996 let reviewsAfter: string | null = null;
@@ -2015,6 +2017,7 @@ export const make = Effect.gen(function* () {
2017 if (page === 0) {
2018 author = read.author ?? null;
2019 commits = read.commits ?? [];
2020 + nonMergeCommitIds = read.nonMergeCommitIds;
2021 }
2022 remarks.push(...read.remarks);
2023 commentsAfter = read.nextCommentsCursor;
@@ -2022,12 +2025,21 @@ export const make = Effect.gen(function* () {
2025 withComments = withComments && commentsAfter !== null;
2026 withReviews = withReviews && reviewsAfter !== null;
2027 }
2028 + const emptyStats = toPullRequestCommitStats({ nodes: [] });
2029 + const commitStats =
2030 + nonMergeCommitIds.length === 0
2031 + ? emptyStats
2032 + : yield* client.PullRequestCommitStats({ ids: nonMergeCommitIds }).pipe(
2033 + graphql(target),
2034 + Effect.map(toPullRequestCommitStats),
2035 + Effect.orElseSucceed(() => emptyStats),
2036 + );
2037 return {
2038 author,
2039 comments: remarks.toSorted((left, right) =>
2040 left.createdAt.localeCompare(right.createdAt),
2041 ),
2030 - commits,
2042 + commits: commits.map((commit) => ({ ...commit, ...commitStats.get(commit.oid) })),
2043 } satisfies GitHubPullRequestActivity;
2044 },
2045 ),
@@ -2131,10 +2143,6 @@ export const make = Effect.gen(function* () {
2143 const entries: GitHubReviewThreadEntry[] = [];
2144 const avatarsByLogin = new Map<string, string>();
2145 const botLogins = new Set<string>();
2134 - const commitStats = new Map<
2135 - string,
2136 - { readonly additions: number; readonly deletions: number }
2137 - >();
2146 let reviewers: ReadonlyArray<PullRequestActor> = [];
2147 let reactions: GitHubReviewThreadPage["reactions"] = [];
2148 const reactionsById = new Map<string, ReadonlyArray<PullRequestReaction>>();
@@ -2161,7 +2169,6 @@ export const make = Effect.gen(function* () {
2169 for (const [id, message] of read.dismissalsByReviewId)
2170 dismissalsByReviewId.set(id, message);
2171 dismissalCursor = read.nextDismissalCursor;
2164 - for (const [oid, stat] of read.commitStats) commitStats.set(oid, stat);
2172 }
2173 cursor = read.nextCursor;
2174 page += 1;
@@ -2214,7 +2221,6 @@ export const make = Effect.gen(function* () {
2221 reviewers,
2222 avatarsByLogin,
2223 botLogins,
2217 - commitStats,
2224 commits,
2225 viewer,
2226 };
packages/source-control-github/src/server/GitHubPullRequestProvider.test.ts
+14 -3
@@ -645,7 +645,6 @@ describe("getChangeRequest commits", () => {
645 reviewers: [],
646 avatarsByLogin: new Map<string, string>(),
647 botLogins: new Set<string>(),
648 - commitStats: new Map<string, { readonly additions: number; readonly deletions: number }>(),
648 viewer: { canUpdate: true, didAuthor: false },
649 };
650
@@ -657,6 +656,14 @@ describe("getChangeRequest commits", () => {
656 author: baseDetail.author,
657 comments: baseDetail.comments,
658 commits: [
659 + {
660 + oid: "graphql-newest",
661 + messageHeadline: "Activity metadata",
662 + committedDate: "2026-07-06T00:00:00Z",
663 + additions: 18,
664 + deletions: 7,
665 + authors: [],
666 + },
667 {
668 oid: "view-oldest",
669 messageHeadline: "gh pr view's oldest commit",
@@ -679,6 +686,11 @@ describe("getChangeRequest commits", () => {
686 });
687
688 expect(detail.commits.map((commit) => commit.oid)).toEqual(["graphql-newest"]);
689 + expect(detail.commits[0]).toMatchObject({
690 + messageHeadline: "the newest commit gh pr view drops",
691 + additions: 18,
692 + deletions: 7,
693 + });
694 }).pipe(
695 Effect.provide(
696 layerWith([
@@ -703,7 +715,7 @@ describe("getChangeRequest commits", () => {
715 number: 7,
716 });
717
706 - expect(detail.commits.map((commit) => commit.oid)).toEqual(["view-oldest"]);
718 + expect(detail.commits.map((commit) => commit.oid)).toEqual(["graphql-newest", "view-oldest"]);
719 }).pipe(Effect.provide(layerWith([]))),
720 );
721 });
@@ -732,7 +744,6 @@ describe("getChangeRequestActivity dismissed reviews", () => {
744 reviewers: [],
745 avatarsByLogin: new Map(),
746 botLogins: new Set(["macroscopeapp"]),
735 - commitStats: new Map(),
747 commits: [],
748 viewer: { canUpdate: true, didAuthor: false },
749 };
packages/source-control-github/src/server/GitHubPullRequestProvider.ts
+65 -61
@@ -500,10 +500,6 @@ export const make = Effect.gen(function* () {
500 reviewers: [],
501 avatarsByLogin: new Map<string, string>(),
502 botLogins: new Set<string>(),
503 - commitStats: new Map<
504 - string,
505 - { readonly additions: number; readonly deletions: number }
506 - >(),
503 commits: [],
504 viewer: { canUpdate: true, didAuthor: false },
505 })),
@@ -512,67 +508,75 @@ export const make = Effect.gen(function* () {
508 { concurrency: 2 },
509 ).pipe(
510 Effect.mapError(fail("getChangeRequestActivity")),
515 - Effect.map(([pullRequest, reviewThreads]): ProviderChangeRequestActivity => ({
516 - author: withAvatar(
517 - pullRequest.author,
518 - reviewThreads.avatarsByLogin,
519 - input.host,
520 - reviewThreads.botLogins,
521 - ),
522 - reviewers: reviewThreads.reviewers,
523 - reactions: reviewThreads.reactions,
524 - commits: (reviewThreads.commits.length > 0
525 - ? reviewThreads.commits
526 - : pullRequest.commits
527 - ).map((commit) => ({
528 - ...commit,
529 - ...reviewThreads.commitStats.get(commit.oid),
530 - authors: commit.authors?.map(
531 - (author) =>
532 - withAvatar(
533 - author,
511 + Effect.map(([pullRequest, reviewThreads]): ProviderChangeRequestActivity => {
512 + const commitStats = new Map(
513 + pullRequest.commits.map(({ oid, additions, deletions }) => [
514 + oid,
515 + additions === undefined ? {} : { additions, deletions },
516 + ]),
517 + );
518 + return {
519 + author: withAvatar(
520 + pullRequest.author,
521 + reviewThreads.avatarsByLogin,
522 + input.host,
523 + reviewThreads.botLogins,
524 + ),
525 + reviewers: reviewThreads.reviewers,
526 + reactions: reviewThreads.reactions,
527 + commits: (reviewThreads.commits.length > 0
528 + ? reviewThreads.commits
529 + : pullRequest.commits
530 + ).map((commit) => ({
531 + ...commit,
532 + ...commitStats.get(commit.oid),
533 + authors: commit.authors?.map(
534 + (author) =>
535 + withAvatar(
536 + author,
537 + reviewThreads.avatarsByLogin,
538 + input.host,
539 + reviewThreads.botLogins,
540 + ) ?? author,
541 + ),
542 + })),
543 + comments: [...pullRequest.comments, ...reviewThreads.comments]
544 + .map((comment) => ({
545 + ...comment,
546 + // Dismissal reasons live on timeline events; HTML-only bot reviews need that fallback too.
547 + body:
548 + comment.kind === "review" &&
549 + comment.reviewState?.toUpperCase() === "DISMISSED" &&
550 + rendersEmpty(comment.body)
551 + ? (reviewThreads.dismissalsByReviewId.get(comment.id) ?? comment.body)
552 + : comment.body,
553 + author: withAvatar(
554 + comment.author,
555 reviewThreads.avatarsByLogin,
556 input.host,
557 reviewThreads.botLogins,
537 - ) ?? author,
538 - ),
539 - })),
540 - comments: [...pullRequest.comments, ...reviewThreads.comments]
541 - .map((comment) => ({
542 - ...comment,
543 - // Dismissal reasons live on timeline events; HTML-only bot reviews need that fallback too.
544 - body:
545 - comment.kind === "review" &&
546 - comment.reviewState?.toUpperCase() === "DISMISSED" &&
547 - rendersEmpty(comment.body)
548 - ? (reviewThreads.dismissalsByReviewId.get(comment.id) ?? comment.body)
549 - : comment.body,
550 - author: withAvatar(
551 - comment.author,
552 - reviewThreads.avatarsByLogin,
553 - input.host,
554 - reviewThreads.botLogins,
555 - ),
556 - reactions: comment.reactions ?? reviewThreads.reactionsById.get(comment.id) ?? [],
557 - editedAt: reviewThreads.editedAtById.get(comment.id) ?? comment.editedAt ?? null,
558 - }))
559 - .toSorted((left, right) => left.createdAt.localeCompare(right.createdAt)),
560 - commentCount: pullRequest.comments.length + reviewThreads.commentCount,
561 - commentsTruncated: reviewThreads.truncated,
562 - reviewThreadsTruncated: reviewThreads.reviewThreadsTruncated,
563 - reviewThreads: reviewThreads.reviewThreads.map((thread) => ({
564 - ...thread,
565 - comments: thread.comments.map((comment) => ({
566 - ...comment,
567 - author: withAvatar(
568 - comment.author,
569 - reviewThreads.avatarsByLogin,
570 - input.host,
571 - reviewThreads.botLogins,
572 - ),
558 + ),
559 + reactions: comment.reactions ?? reviewThreads.reactionsById.get(comment.id) ?? [],
560 + editedAt: reviewThreads.editedAtById.get(comment.id) ?? comment.editedAt ?? null,
561 + }))
562 + .toSorted((left, right) => left.createdAt.localeCompare(right.createdAt)),
563 + commentCount: pullRequest.comments.length + reviewThreads.commentCount,
564 + commentsTruncated: reviewThreads.truncated,
565 + reviewThreadsTruncated: reviewThreads.reviewThreadsTruncated,
566 + reviewThreads: reviewThreads.reviewThreads.map((thread) => ({
567 + ...thread,
568 + comments: thread.comments.map((comment) => ({
569 + ...comment,
570 + author: withAvatar(
571 + comment.author,
572 + reviewThreads.avatarsByLogin,
573 + input.host,
574 + reviewThreads.botLogins,
575 + ),
576 + })),
577 })),
574 - })),
575 - })),
578 + };
579 + }),
580 ),
581
582 getReviewThreadComments: (input) =>
packages/source-control-github/src/server/gitHubPullRequestJson.test.ts
+18 -17
@@ -128,9 +128,6 @@ const reviewCommit = ({ commit: { authors, ...commit } }: Json) => ({
128 commit: {
129 messageHeadline: "",
130 committedDate: "",
131 - additions: 0,
132 - deletions: 0,
133 - parents: { totalCount: 1 },
131 ...commit,
132 authors: {
133 nodes: nodesIn(authors).map((author) => ({
@@ -450,6 +447,8 @@ describe("pull request detail decoding", () => {
447 nodes: ((raw["commits"] ?? []) as ReadonlyArray<Record<string, unknown>>).map(
448 ({ authors, ...commit }) => ({
449 commit: {
450 + id: "commit-id",
451 + parents: { totalCount: 1 },
452 ...commit,
453 authors: {
454 nodes: ((authors ?? []) as ReadonlyArray<Record<string, unknown>>).map(
@@ -638,25 +637,27 @@ describe("review thread decoding", () => {
637 },
638 });
639
641 - it("omits misleading line counts from merge commits", () => {
640 + it("selects stats only for non-merge activity commits", () => {
641 const result = expectSuccess(
643 - decodeReviewThreadsJson(
642 + decodePullRequestActivityJson(
643 JSON.stringify({
644 data: {
645 repository: {
646 pullRequest: {
648 - reviewThreads: { totalCount: 0, nodes: [] },
647 + author: null,
648 + comments: { nodes: [], pageInfo: LAST_PAGE },
649 + reviews: { nodes: [], pageInfo: LAST_PAGE },
650 commits: {
650 - nodes: [
651 - {
652 - commit: {
653 - oid: "merge123",
654 - additions: 36_858,
655 - deletions: 12_928,
656 - parents: { totalCount: 2 },
657 - },
651 + nodes: [1, 2].map((parents) => ({
652 + commit: {
653 + id: "commit-" + parents,
654 + oid: "sha-" + parents,
655 + messageHeadline: "Commit",
656 + committedDate: "2026-07-05T00:00:00Z",
657 + parents: { totalCount: parents },
658 + authors: { nodes: [] },
659 },
659 - ],
660 + })),
661 },
662 },
663 },
@@ -664,8 +665,8 @@ describe("review thread decoding", () => {
665 }),
666 ),
667 );
667 -
668 - expect([...result.commitStats]).toEqual([]);
668 + expect(result.nonMergeCommitIds).toEqual(["commit-1"]);
669 + expect(result.commits?.map((commit) => commit.oid)).toEqual(["sha-1", "sha-2"]);
670 });
671
672 it("decodes the newest commits off the same connection, oldest to newest", () => {
packages/source-control-github/src/server/gitHubPullRequestJson.ts
+29 -18
@@ -53,6 +53,7 @@ import type {
53 CheckContext,
54 LabelCandidates,
55 PullRequestActivity,
56 + PullRequestCommitStats,
57 PullRequestCheckContexts,
58 PullRequestCore,
59 PullRequestFilesViewed,
@@ -1124,6 +1125,7 @@ export function toPullRequestHeads(result: PullRequestHeads.Result): {
1125 }
1126
1127 export interface GitHubPullRequestActivityPage {
1128 + readonly nonMergeCommitIds: ReadonlyArray<string>;
1129 readonly author?: PullRequestActor | null;
1130 readonly commits?: ReadonlyArray<PullRequestCommit>;
1131 readonly remarks: ReadonlyArray<PullRequestComment>;
@@ -1137,6 +1139,9 @@ export function toPullRequestActivityPage(
1139 const pr = result.repository?.pullRequest;
1140 if (pr == null) return null;
1141 return {
1142 + nonMergeCommitIds: nodesOf(pr.commits).flatMap(({ commit }) =>
1143 + commit.parents.totalCount > 1 ? [] : [commit.id],
1144 + ),
1145 ...(pr.author === undefined ? {} : { author: toActor(pr.author) }),
1146 ...(pr.commits === undefined
1147 ? {}
@@ -1157,6 +1162,25 @@ export function toPullRequestActivityPage(
1162 };
1163 }
1164
1165 +export function toPullRequestCommitStats(result: PullRequestCommitStats.Result) {
1166 + return new Map(
1167 + (result.nodes ?? []).flatMap((commit) =>
1168 + commit?.__typename === "Commit"
1169 + ? [
1170 + [
1171 + commit.oid,
1172 + {
1173 + additions: Math.max(0, commit.additions),
1174 + deletions: Math.max(0, commit.deletions),
1175 + },
1176 + ] as const,
1177 + ]
1178 + : [],
1179 + ),
1180 + );
1181 +}
1182 +
1183 +/** A check context as the rollup reports it; opaque outside this module. */
1184 export type GitHubCheckContext = CheckFields;
1185
1186 function toCheckContexts(nodes: ReadonlyArray<CheckContext>): ReadonlyArray<GitHubCheckContext> {
@@ -1202,11 +1226,11 @@ export interface GitHubReviewThreadComments {
1226 readonly reviewers: ReadonlyArray<PullRequestActor>;
1227 readonly avatarsByLogin: ReadonlyMap<string, string>;
1228 readonly botLogins: ReadonlySet<string>;
1205 - readonly commitStats: ReadonlyMap<
1206 - string,
1207 - { readonly additions: number; readonly deletions: number }
1208 - >;
1209 - /** Empty means unread; preserve existing commits. */
1229 + /**
1230 + * Empty wherever the read never happened (an install too old for the field, a degraded page),
1231 + * which the caller reads as "keep the `gh pr view` list" rather than as "this pull request has
1232 + * no commits".
1233 + */
1234 readonly commits: ReadonlyArray<PullRequestCommit>;
1235 readonly viewer: { readonly canUpdate: boolean; readonly didAuthor: boolean };
1236 }
@@ -1226,10 +1250,6 @@ export interface GitHubReviewThreadPage {
1250 readonly reviewers: ReadonlyArray<PullRequestActor>;
1251 readonly avatarsByLogin: ReadonlyMap<string, string>;
1252 readonly botLogins: ReadonlySet<string>;
1229 - readonly commitStats: ReadonlyMap<
1230 - string,
1231 - { readonly additions: number; readonly deletions: number }
1232 - >;
1253 readonly commits: ReadonlyArray<PullRequestCommit>;
1254 readonly viewer: { readonly canUpdate: boolean; readonly didAuthor: boolean };
1255 readonly dismissalsByReviewId: ReadonlyMap<string, string>;
@@ -1350,18 +1370,10 @@ export function toReviewThreadPage(result: ReviewThreads.Result): GitHubReviewTh
1370 const actor = toActor(raw) ?? toRequestedTeam(raw);
1371 if (actor !== null && !reviewers.has(actor.login)) reviewers.set(actor.login, actor);
1372 }
1353 - const commitStats = new Map<string, { readonly additions: number; readonly deletions: number }>();
1373 const commits: PullRequestCommit[] = [];
1374 for (const { commit } of nodesOf(pullRequest.commits)) {
1375 const oid = trimmed(commit.oid);
1376 if (oid === null) continue;
1358 - // Merge stats count upstream changes against the first parent as PR work.
1359 - if (commit.parents.totalCount <= 1) {
1360 - commitStats.set(oid, {
1361 - additions: Math.max(0, commit.additions),
1362 - deletions: Math.max(0, commit.deletions),
1363 - });
1364 - }
1377 const committedDate = trimmed(commit.committedDate);
1378 if (committedDate === null) continue;
1379 commits.push({
@@ -1390,7 +1402,6 @@ export function toReviewThreadPage(result: ReviewThreads.Result): GitHubReviewTh
1402 reviewers: [...reviewers.values()],
1403 avatarsByLogin,
1404 botLogins,
1393 - commitStats,
1405 commits,
1406 viewer: toPullRequestViewerFields(pullRequest),
1407 dismissalsByReviewId: toDismissalEntries(pullRequest.reviewDismissals),
packages/source-control-github/src/server/pullRequestReads.graphql
+16
@@ -242,9 +242,13 @@ query PullRequestActivity(
242 commits(last: 100) @include(if: $head) {
243 nodes {
244 commit {
245 + id
246 oid
247 messageHeadline
248 committedDate
249 + parents(first: 1) {
250 + totalCount
251 + }
252 authors(first: 10) {
253 nodes {
254 name
@@ -302,6 +306,18 @@ query PullRequestActivity(
306 }
307 }
308
309 +# Merge commits include upstream changes in their stats, which the timeline does not display.
310 +# Read only the non-merge commits named by the activity connection.
311 +query PullRequestCommitStats($ids: [ID!]!) {
312 + nodes(ids: $ids) {
313 + ... on Commit {
314 + oid
315 + additions
316 + deletions
317 + }
318 + }
319 +}
320 +
321 # Open pull requests whose head branch has one name, from whichever repository it lives in.
322 query PullRequestHeads($owner: String!, $name: String!, $head: String!, $after: String) {
323 repository(owner: $owner, name: $name) {
packages/source-control-github/src/server/pullRequestReads.graphql.ts
+61 -5
@@ -131,10 +131,10 @@ export const NodesBot = Schema.Struct({
131 export interface NodesBot extends Schema.Struct.Type<typeof NodesBot.fields> {}
132
133 /** An object with an ID. */
134 -export const NodesNodeOther = Schema.Struct({
134 +export const ActorAvatarsNodesNodeOther = Schema.Struct({
135 __typename: GraphQL.otherTypename<Shared.Typename.Node>()(["User", "Bot"])
136 })
137 -export interface NodesNodeOther extends Schema.Struct.Type<typeof NodesNodeOther.fields> {}
137 +export interface ActorAvatarsNodesNodeOther extends Schema.Struct.Type<typeof ActorAvatarsNodesNodeOther.fields> {}
138
139 /** `query ActorAvatars` */
140 export const ActorAvatars = GraphQL.query("ActorAvatars", {
@@ -155,7 +155,7 @@ export const ActorAvatars = GraphQL.query("ActorAvatars", {
155 nodes: Schema.Array(Schema.NullOr(Schema.Union([
156 ActorAvatarsNodesUser,
157 NodesBot,
158 - NodesNodeOther
158 + ActorAvatarsNodesNodeOther
159 ])))
160 })
161 })
@@ -646,6 +646,13 @@ export declare namespace PullRequestPreview {
646 export type Result = typeof PullRequestPreview.result.Type
647 }
648
649 +/** The connection type for Commit. */
650 +export const CommitConnection = Schema.Struct({
651 + /** Identifies the total count of items in the connection. */
652 + totalCount: Shared.Int
653 +})
654 +export interface CommitConnection extends Schema.Struct.Type<typeof CommitConnection.fields> {}
655 +
656 /** A user is an individual's account on GitHub that owns repositories and can make new content. */
657 export const UserUser = Schema.Struct({
658 /** The username used to login. */
@@ -673,12 +680,16 @@ export interface GitActorConnection extends Schema.Struct.Type<typeof GitActorCo
680
681 /** Represents a Git commit. */
682 export const PullRequestActivityRepositoryPullRequestCommitsNodesCommitCommit = Schema.Struct({
683 + /** The Node ID of the Commit object */
684 + id: Shared.ID,
685 /** The Git object ID */
686 oid: Shared.GitObjectID,
687 /** The Git commit message headline */
688 messageHeadline: Schema.String,
689 /** The datetime when this commit was committed. */
690 committedDate: Shared.DateTime,
691 + /** The parents of a commit. */
692 + parents: CommitConnection,
693 /**
694 * The list of authors for this commit based on the git author and the Co-authored-by
695 * message trailer. The git author will always be first.
@@ -798,7 +809,7 @@ export const PullRequestActivity = GraphQL.query("PullRequestActivity", {
809 { name: "reviewsAfter", body: "String" }
810 ],
811 selections: [
801 - { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){author@include(if:$", "head", "){__typename login avatarUrl...on User{name}}commits(last:100)@include(if:$", "head", "){nodes{commit{oid messageHeadline committedDate authors(first:10){nodes{name email user{login}}}}}}comments(first:100 after:$", "commentsAfter", ")@include(if:$", "withComments", "){pageInfo{hasNextPage endCursor}nodes{id body createdAt lastEditedAt url author{__typename login avatarUrl...on User{name}}}}reviews(first:100 after:$", "reviewsAfter", ")@include(if:$", "withReviews", "){pageInfo{hasNextPage endCursor}nodes{id body state submittedAt lastEditedAt url author{__typename login avatarUrl...on User{name}}}}}}"] }
812 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){author@include(if:$", "head", "){__typename login avatarUrl...on User{name}}commits(last:100)@include(if:$", "head", "){nodes{commit{id oid messageHeadline committedDate parents(first:1){totalCount}authors(first:10){nodes{name email user{login}}}}}}comments(first:100 after:$", "commentsAfter", ")@include(if:$", "withComments", "){pageInfo{hasNextPage endCursor}nodes{id body createdAt lastEditedAt url author{__typename login avatarUrl...on User{name}}}}reviews(first:100 after:$", "reviewsAfter", ")@include(if:$", "withReviews", "){pageInfo{hasNextPage endCursor}nodes{id body state submittedAt lastEditedAt url author{__typename login avatarUrl...on User{name}}}}}}"] }
813 ],
814 fragments: []
815 },
@@ -822,6 +833,51 @@ export declare namespace PullRequestActivity {
833 export type Result = typeof PullRequestActivity.result.Type
834 }
835
836 +/** Represents a Git commit. */
837 +export const NodesCommit = Schema.Struct({
838 + __typename: Schema.Literal("Commit"),
839 + /** The Git object ID */
840 + oid: Shared.GitObjectID,
841 + /** The number of additions in this commit. */
842 + additions: Shared.Int,
843 + /** The number of deletions in this commit. */
844 + deletions: Shared.Int
845 +})
846 +export interface NodesCommit extends Schema.Struct.Type<typeof NodesCommit.fields> {}
847 +
848 +/** An object with an ID. */
849 +export const PullRequestCommitStatsNodesNodeOther = Schema.Struct({
850 + __typename: GraphQL.otherTypename<Shared.Typename.Node>()(["Commit"])
851 +})
852 +export interface PullRequestCommitStatsNodesNodeOther extends Schema.Struct.Type<typeof PullRequestCommitStatsNodesNodeOther.fields> {}
853 +
854 +/** `query PullRequestCommitStats` */
855 +export const PullRequestCommitStats = GraphQL.query("PullRequestCommitStats", {
856 + document: {
857 + variables: [
858 + { name: "ids", body: "[ID!]!" }
859 + ],
860 + selections: [
861 + { name: "nodes", body: ["(ids:$", "ids", "){__typename...on Commit{oid additions deletions}}"] }
862 + ],
863 + fragments: []
864 + },
865 + variables: {
866 + ids: Schema.Array(Shared.ID)
867 + },
868 + result: Schema.Struct({
869 + /** Lookup nodes by a list of IDs. */
870 + nodes: Schema.Array(Schema.NullOr(Schema.Union([
871 + NodesCommit,
872 + PullRequestCommitStatsNodesNodeOther
873 + ])))
874 + })
875 +})
876 +export declare namespace PullRequestCommitStats {
877 + export type Variables = typeof PullRequestCommitStats.variables.Type
878 + export type Result = typeof PullRequestCommitStats.result.Type
879 +}
880 +
881 /** A repository pull request. */
882 export const NodesPullRequest = Schema.Struct({
883 /** Identifies the pull request number. */
@@ -1666,4 +1722,4 @@ export declare namespace PullRequestSourceBranch {
1722 }
1723
1724 /** Every operation in pullRequestReads.graphql. */
1669 -export const PullRequestReadsGraphQLGroup = GraphQLGroup.make(RoutingIdentityViewer, ActorAvatars, PullRequestCore, PullRequestCheckContexts, PullRequestPreview, PullRequestActivity, PullRequestHeads, PullRequestNodeId, PullRequestSubject, ViewerPermissions, ReviewerCandidates, LabelCandidates, RepositoryLabels, RepositoryAuthors, PullRequestFilesViewed, PullRequestFileStats, PullRequestMergeMessage, PullRequestActionState, PullRequestBranchToDelete, PullRequestSourceBranch)
1725 +export const PullRequestReadsGraphQLGroup = GraphQLGroup.make(RoutingIdentityViewer, ActorAvatars, PullRequestCore, PullRequestCheckContexts, PullRequestPreview, PullRequestActivity, PullRequestCommitStats, PullRequestHeads, PullRequestNodeId, PullRequestSubject, ViewerPermissions, ReviewerCandidates, LabelCandidates, RepositoryLabels, RepositoryAuthors, PullRequestFilesViewed, PullRequestFileStats, PullRequestMergeMessage, PullRequestActionState, PullRequestBranchToDelete, PullRequestSourceBranch)
packages/source-control-github/src/server/pullRequestReviews.graphql
-5
@@ -182,11 +182,6 @@ query ReviewThreads(
182 oid
183 messageHeadline
184 committedDate
185 - additions
186 - deletions
187 - parents(first: 1) {
188 - totalCount
189 - }
185 authors(first: 3) {
186 nodes {
187 name
packages/source-control-github/src/server/pullRequestReviews.graphql.ts
+1 -14
@@ -319,13 +319,6 @@ export const PullRequestTimelineItemsConnection = Schema.Struct({
319 })
320 export interface PullRequestTimelineItemsConnection extends Schema.Struct.Type<typeof PullRequestTimelineItemsConnection.fields> {}
321
322 -/** The connection type for Commit. */
323 -export const CommitConnection = Schema.Struct({
324 - /** Identifies the total count of items in the connection. */
325 - totalCount: Shared.Int
326 -})
327 -export interface CommitConnection extends Schema.Struct.Type<typeof CommitConnection.fields> {}
328 -
322 /** Represents an actor in a Git commit (ie. an author or committer). */
323 export const GitActor = Schema.Struct({
324 /** The name in the Git commit. */
@@ -352,12 +345,6 @@ export const Commit = Schema.Struct({
345 messageHeadline: Schema.String,
346 /** The datetime when this commit was committed. */
347 committedDate: Shared.DateTime,
355 - /** The number of additions in this commit. */
356 - additions: Shared.Int,
357 - /** The number of deletions in this commit. */
358 - deletions: Shared.Int,
359 - /** The parents of a commit. */
360 - parents: CommitConnection,
348 /**
349 * The list of authors for this commit based on the git author and the Co-authored-by
350 * message trailer. The git author will always be first.
@@ -426,7 +413,7 @@ export const ReviewThreads = GraphQL.query("ReviewThreads", {
413 ],
414 selections: [
415 { name: "viewer", body: ["{login}"] },
429 - { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){reviewThreads(first:100 after:$", "after", "){totalCount pageInfo{hasNextPage endCursor}nodes{id isResolved isOutdated path line diffSide comments(first:10){totalCount pageInfo{hasNextPage endCursor}nodes{...ThreadComment}}}}viewerCanUpdate viewerDidAuthor author{__typename login avatarUrl}...Reactions comments(first:100){nodes{id lastEditedAt author{__typename login avatarUrl}...Reactions}}reviews(first:100){nodes{id lastEditedAt author{__typename login avatarUrl}...Reactions}}reviewRequests(first:$", "requestedReviewers", "){nodes{requestedReviewer{__typename...on User{login name avatarUrl}...on Bot{login avatarUrl}...on Team{combinedSlug teamName:name teamAvatarUrl:avatarUrl}}}}latestReviews(first:50){nodes{state author{__typename login avatarUrl}}}reviewDismissals:timelineItems(itemTypes:[REVIEW_DISMISSED_EVENT]first:100){pageInfo{hasNextPage endCursor}nodes{__typename...on ReviewDismissedEvent{dismissalMessage review{id}}}}commits(last:100){nodes{commit{oid messageHeadline committedDate additions deletions parents(first:1){totalCount}authors(first:3){nodes{name avatarUrl user{login}}}}}}}}"] }
416 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){reviewThreads(first:100 after:$", "after", "){totalCount pageInfo{hasNextPage endCursor}nodes{id isResolved isOutdated path line diffSide comments(first:10){totalCount pageInfo{hasNextPage endCursor}nodes{...ThreadComment}}}}viewerCanUpdate viewerDidAuthor author{__typename login avatarUrl}...Reactions comments(first:100){nodes{id lastEditedAt author{__typename login avatarUrl}...Reactions}}reviews(first:100){nodes{id lastEditedAt author{__typename login avatarUrl}...Reactions}}reviewRequests(first:$", "requestedReviewers", "){nodes{requestedReviewer{__typename...on User{login name avatarUrl}...on Bot{login avatarUrl}...on Team{combinedSlug teamName:name teamAvatarUrl:avatarUrl}}}}latestReviews(first:50){nodes{state author{__typename login avatarUrl}}}reviewDismissals:timelineItems(itemTypes:[REVIEW_DISMISSED_EVENT]first:100){pageInfo{hasNextPage endCursor}nodes{__typename...on ReviewDismissedEvent{dismissalMessage review{id}}}}commits(last:100){nodes{commit{oid messageHeadline committedDate authors(first:3){nodes{name avatarUrl user{login}}}}}}}}"] }
417 ],
418 fragments: [
419 { name: "ThreadComment", body: ["on PullRequestReviewComment{id author{__typename login avatarUrl}body createdAt lastEditedAt url...Reactions}"] },