Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
51554cd
perf(web): keep pull request answers in IndexedDB so reloads paint at…
Bil0000 Oct 30, 2026
4fe7cf1
perf(web): pull request hover cards paint from the summary already held
Bil0000 Oct 30, 2026
70ed789
perf(mobile): pull requests opened from threads paint from the summar…
Bil0000 Oct 30, 2026
666c0d9
perf(server): listed pull requests answer hover previews without the …
Bil0000 Oct 30, 2026
6fc1c8c
perf(github): skip a refused reviewer read and fetch commit stats alo…
Bil0000 Oct 30, 2026
7cf4785
fix(pr): list seeds keep newer previews, and equal updates pick the l…
Bil0000 Oct 30, 2026
7b53746
perf(web): pull requests page paints its first rows at once and loads…
Bil0000 Oct 31, 2026
3ee075c
fix(web): a pull request prefetch stops when its row leaves the list
Bil0000 Oct 31, 2026
6a2739c
fix(web): a pull request prefetch ends when its row leaves the list
Bil0000 Oct 31, 2026
4c8e3e8
fix(web): a removed row's prefetch reads nothing and its pending time…
Bil0000 Oct 31, 2026
91ec7a8
fix(web): a focused pull request row keeps its prefetch when the poin…
Bil0000 Oct 31, 2026
d4e8ed9
Merge remote-tracking branch 'origin/main' into pr-27798
juliusmarminge Nov 2, 2026
0931f0d
test: takeover tests for faster pull request views
juliusmarminge Nov 2, 2026
9f505ca
refactor: trim the faster pull request views to their smallest shape
juliusmarminge Nov 2, 2026
90aca1d
fix(pr): answers don't wait on saves, row prefetch fills the panel's …
juliusmarminge Nov 2, 2026
334d8d9
fix(web): an oversized answer drops its older saved copy, and saved s…
juliusmarminge Nov 2, 2026
813b1fe
perf(web): prune the saved query cache once per burst of saves, not o…
juliusmarminge Nov 2, 2026
e7a6ebe
fix(pr): the hover card keeps the known summary's state over a restor…
juliusmarminge Nov 2, 2026
4577853
Merge remote-tracking branch 'origin/main' into pr-27798-fix
juliusmarminge Nov 2, 2026
5a0995c
fix(pr): the hover card keeps a merged preview merged over an older s…
juliusmarminge Nov 2, 2026
8b4effa
Merge remote-tracking branch 'origin/main' into pr-27798
juliusmarminge Nov 2, 2026
dc9eff3
fix(pr): hover cards trust the preview over a summary, saved answers …
juliusmarminge Nov 3, 2026
31be123
test(server): a pinned account's list does not seed the shared previe…
juliusmarminge Nov 3, 2026
1282f18
fix(web): saved query answers end with their query and tabs share one…
juliusmarminge Nov 3, 2026
cffa192
Merge remote-tracking branch 'origin/main' into pr-27798
juliusmarminge Nov 3, 2026
f64c0c2
Merge remote-tracking branch 'origin/main' into land/27798
juliusmarminge Nov 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import type { ThreadListFilters } from "../../persistence/mobile-preferences";
import { appAtomRegistry } from "../../state/atom-registry";
import { useProjects } from "../../state/entities";
import { environmentThreadShells } from "../../state/threads";
import { withKnownPullRequestSummary } from "../../state/use-thread-pr";
import { mobilePreferencesAtom } from "../../state/preferences";
import {
DEFAULT_MOBILE_PROJECT_GROUPING_SETTINGS,
Expand Down Expand Up @@ -589,6 +590,7 @@ function AdaptiveWorkspaceLayoutContent(
columns: workspaceTabColumns(Platform.OS, tab, options?.columns ?? layout.usesSplitView),
check: workspaceSelectionCheck,
overlays,
seedPullRequest: withKnownPullRequestSummary,
},
);
if (layout.variant === "medium") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chip } from "../../components/ui/Chip";
import { PullRequestSectionHeading } from "./PullRequestSectionHeading";
import type { PullRequestListEntry } from "@t3tools/contracts";
import type { PullRequestListEntry, PullRequestSummary } from "@t3tools/contracts";
import { View } from "react-native";
import { PullRequestCardGroup, PullRequestCardRow } from "./PullRequestControls";
import { PullRequestStackCard } from "./PullRequestStackCard";
Expand All @@ -14,11 +14,14 @@ export function PullRequestOverviewLoading({
params,
stack,
}: {
readonly summary: PullRequestListEntry;
readonly summary: PullRequestListEntry | PullRequestSummary;
readonly params: PullRequestParams;
readonly stack: PullRequestStackState;
}) {
const review = pullRequestListReviewStatus(summary);
const review = pullRequestListReviewStatus({
reviewDecision: summary.reviewDecision ?? undefined,
viewerReviewRequested: "viewerReviewRequested" in summary && summary.viewerReviewRequested,
});
const conflicting = summary.mergeability === "conflicting";
const clean = summary.mergeability === "mergeable";
return (
Expand Down Expand Up @@ -89,7 +92,7 @@ export function PullRequestOverviewLoading({
<View className="h-11 rounded-xl bg-subtle-strong" />
</View>
</PullRequestCardGroup>
{summary.labels.length ? (
{"labels" in summary && summary.labels.length ? (
<View className="flex-row flex-wrap gap-2">
{summary.labels.map((label) => (
<Chip key={label.name} label={label.name} size="small" />
Expand Down
16 changes: 10 additions & 6 deletions apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-na
import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { RegistryContext, useAtomRefresh, useAtomValue } from "@effect/atom-react";
import { pullRequestReviewKey } from "./pullRequestReviewDrafts";
import { type PullRequestDetail, type PullRequestListEntry } from "@t3tools/contracts";
import {
type PullRequestDetail,
type PullRequestListEntry,
type PullRequestSummary,
} from "@t3tools/contracts";
import { PullRequestOverviewLoading } from "./PullRequestOverviewLoading";
import { copyPullRequestLink, sharePullRequestLink } from "./pullRequestLink";
import { pullRequestStatus } from "./pullRequestStatus";
Expand Down Expand Up @@ -180,11 +184,11 @@ function usePullRequestActivityRows(params: PullRequestParams, filter: ActivityF
}

function PullRequestIdentity(props: {
readonly pr: PullRequestDetail | PullRequestListEntry;
readonly pr: PullRequestDetail | PullRequestListEntry | PullRequestSummary;
readonly params: PullRequestParams;
}) {
const { pr } = props;
const status = pullRequestStatus(pr);
const status = pullRequestStatus({ state: pr.state, isDraft: pr.isDraft === true });
return (
<View className="gap-3">
<View className="flex-row flex-wrap items-center gap-2">
Expand All @@ -196,8 +200,8 @@ function PullRequestIdentity(props: {
<Text className={`text-xs font-t3-medium ${status.text}`}>{status.label}</Text>
</View>
)}
<PullRequestDiffStats additions={pr.additions} deletions={pr.deletions} compact />
{"changedFiles" in pr ? (
<PullRequestDiffStats additions={pr.additions ?? 0} deletions={pr.deletions ?? 0} compact />
{"changedFiles" in pr && pr.changedFiles !== undefined ? (
<Text className="text-2xs text-foreground-muted">
{pr.changedFiles} {pr.changedFiles === 1 ? "file" : "files"}
</Text>
Expand All @@ -209,7 +213,7 @@ function PullRequestIdentity(props: {
{pr.title}
</Text>
<View className="flex-row items-center gap-2">
<PullRequestAvatar actor={pr.author} size={20} />
<PullRequestAvatar actor={pr.author ?? null} size={20} />
<Text className="min-w-0 flex-1 text-xs font-t3-medium" numberOfLines={1}>
{pr.author?.login ?? "Unknown author"}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { pullRequestStatus } from "./pullRequestStatus";
import type { PullRequestParams } from "./usePullRequestDiff";
import type { PullRequestStackState } from "./usePullRequestStack";
import { PullRequestGlyph } from "./pullRequestGlyphs";
import { withKnownPullRequestSummary } from "../../state/use-thread-pr";

export function PullRequestStackCard(props: {
readonly params: PullRequestParams;
Expand Down Expand Up @@ -67,7 +68,9 @@ export function PullRequestStackCard(props: {
selected
? undefined
: () => {
const params = pullRequestLayerParams(props.params, layer.number);
const params = withKnownPullRequestSummary(
pullRequestLayerParams(props.params, layer.number),
);
if (Platform.OS === "android")
selectDetail({ name: "PullRequest", params });
else navigation.dispatch(StackActions.push("PullRequest", params));
Expand Down
9 changes: 7 additions & 2 deletions apps/mobile/src/features/pull-requests/usePullRequestDiff.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import type { ChangeRequestTerminology } from "@t3tools/client-runtime/source-control-clients";
import { EnvironmentId, ProjectId, type PullRequestListEntry } from "@t3tools/contracts";
import {
EnvironmentId,
ProjectId,
type PullRequestListEntry,
type PullRequestSummary,
} from "@t3tools/contracts";
import { useAtomRefresh } from "@effect/atom-react";
import { useLayoutEffect, useMemo, useState } from "react";

Expand All @@ -18,7 +23,7 @@ export type PullRequestParams = {
readonly repository: string;
readonly number: number;
readonly host?: string;
readonly initialSummary?: PullRequestListEntry;
readonly initialSummary?: PullRequestListEntry | PullRequestSummary;
};

export type PullRequestDiffParams = PullRequestParams & { readonly commit?: string };
Expand Down
10 changes: 8 additions & 2 deletions apps/mobile/src/features/workspace/workspace-tab-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ function detailRoute(
tab: "threads" | "pullRequests",
selections: WorkspaceSelections,
check: WorkspaceSelectionCheck,
seedPullRequest?: (identity: Omit<PullRequestSelection, "key">) => object,
): RouteLike | undefined {
if (tab === "threads") {
const draft = selections.threadsDraft;
Expand Down Expand Up @@ -184,7 +185,11 @@ function detailRoute(
(route) =>
route.name === "PullRequest" &&
samePullRequest(pullRequestSelection(route.params), pullRequest),
) ?? { key: pullRequest.key, name: "PullRequest", params: identityOf(pullRequest) }
) ?? {
key: pullRequest.key,
name: "PullRequest",
params: seedPullRequest?.(identityOf(pullRequest)) ?? identityOf(pullRequest),
}
);
}

Expand All @@ -204,6 +209,7 @@ export function workspaceTabNavigationState<
readonly columns: boolean;
readonly check: WorkspaceSelectionCheck;
readonly overlays?: readonly RouteLike[];
readonly seedPullRequest?: (identity: Omit<PullRequestSelection, "key">) => object;
},
) {
const overlays = options.overlays ?? [];
Expand All @@ -221,7 +227,7 @@ export function workspaceTabNavigationState<
const home = state.routes.find((route) => route.name === "Home") ?? { name: "Home" };
const detail =
options.columns && tab !== "usage"
? detailRoute(state, tab, selections, options.check)
? detailRoute(state, tab, selections, options.check, options.seedPullRequest)
: undefined;
const routes = [...[home, ...(detail ? [detail] : [])].map(keyed), ...overlays];
return { ...state, index: routes.length - 1, routes };
Expand Down
6 changes: 4 additions & 2 deletions apps/mobile/src/native/useOpenPullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useProjects, useThreadShell } from "../state/entities";
import { tryOpenExternalUrl } from "../lib/openExternalUrl";
import { appAtomRegistry } from "../state/atom-registry";
import { environmentServerConfigsAtom } from "../state/server";
import { withKnownPullRequestSummary } from "../state/use-thread-pr";

type PullRequestContext = { readonly environmentId: string; readonly projectId: string };

Expand All @@ -19,10 +20,11 @@ export function useNavigateToPullRequest(options?: { readonly replace?: boolean
return async (url: string, context: PullRequestContext | null) => {
// Read at press time so a config push does not hand every link a new handler.
const serverConfigs = appAtomRegistry.get(environmentServerConfigsAtom);
const params = nativePullRequestDestination(url, context, projects, (environmentId) =>
const destination = nativePullRequestDestination(url, context, projects, (environmentId) =>
serverConfigs.has(environmentId),
);
if (!params) return tryOpenExternalUrl(url, "pull-request");
if (!destination) return tryOpenExternalUrl(url, "pull-request");
const params = withKnownPullRequestSummary(destination);
// Android shows one page at a time; iOS opens it over the current page, so Back returns.
if (Platform.OS === "android") selectDetail({ name: "PullRequest", params });
else if (replace) navigation.dispatch(StackActions.replace("PullRequest", params));
Expand Down
59 changes: 58 additions & 1 deletion apps/mobile/src/state/thread-pr-presentation.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
import type { ThreadPullRequestLink, VcsStatusResult } from "@t3tools/contracts";
import type {
PullRequestSummary,
ThreadPullRequestKey,
ThreadPullRequestLink,
VcsStatusResult,
} from "@t3tools/contracts";
import {
sourceControlClients,
type ChangeRequestTerminology,
} from "@t3tools/client-runtime/source-control-clients";

import {
legacyThreadPullRequestKey,
resolveThreadCurrentPullRequestLink,
resolveThreadPullRequestBadge,
threadPullRequestKeyOf,
} from "@t3tools/client-runtime/thread-pull-requests";

export type ThreadPr = NonNullable<VcsStatusResult["pr"]>;
Expand Down Expand Up @@ -142,3 +149,53 @@ export function rememberBounded<V>(
}
return next;
}

/** The newest summary held for `pullRequest`, matched strictly by host, repository and number. */
export function knownPullRequestSummary(
pullRequest: ThreadPullRequestKey,
threads: Iterable<Pick<EnvironmentThreadShell, "projectId" | "pullRequests">>,
summaries: Iterable<PullRequestSummary>,
): PullRequestSummary | undefined {
const key = threadPullRequestKeyOf(pullRequest);
let newest:
| { readonly summary: PullRequestSummary; readonly updatedAt: number; readonly readAt: number }
| undefined;
// Checks and reviews change without moving `updatedAt`, so equal versions prefer the later read.
const consider = (summary: PullRequestSummary, readAt = Number.NEGATIVE_INFINITY) => {
const updatedAt = Date.parse(summary.updatedAt);
if (
newest === undefined ||
updatedAt > newest.updatedAt ||
(updatedAt === newest.updatedAt && readAt > newest.readAt)
) {
newest = { summary, updatedAt, readAt };
}
};
for (const summary of summaries) {
if (threadPullRequestKeyOf(legacyThreadPullRequestKey(summary)) === key) {
consider(summary, summary.observedAt);
}
}
for (const thread of threads) {
for (const link of thread.pullRequests) {
const snapshot = link.snapshot;
if (snapshot?.updatedAt == null || threadPullRequestKeyOf(link) !== key) continue;
consider(
{
...snapshot,
updatedAt: snapshot.updatedAt,
provider: (
sourceControlClients.findByChangeRequestUrl(link.url) ??
sourceControlClients.get(undefined)
).kind,
projectId: thread.projectId,
repository: link.repository,
number: link.number,
url: link.url,
},
Date.parse(snapshot.syncedAt),
);
}
}
return newest?.summary;
}
51 changes: 50 additions & 1 deletion apps/mobile/src/state/use-thread-pr.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { ProjectId, type ThreadPullRequestLink } from "@t3tools/contracts";
import {
ProjectId,
type PullRequestSummary,
SourceControlProviderKind,
type ThreadPullRequestLink,
} from "@t3tools/contracts";
import { describe, expect, it } from "vite-plus/test";

import {
knownPullRequestSummary,
presentThreadLinkedPullRequests,
rememberBounded,
resolveThreadPrSource,
Expand Down Expand Up @@ -113,6 +119,49 @@ describe("resolveThreadPrSource compatibility", () => {
});
});

describe("knownPullRequestSummary", () => {
it("seeds from the newest summary of the same pull request, never another's", () => {
const projectId = ProjectId.make("project");
const link = linkedPr(7);
const threads = [
{
projectId,
pullRequests: [
{ ...link, snapshot: { ...link.snapshot!, updatedAt: "2026-09-08T00:00:00.000Z" } },
],
},
];
const listed: PullRequestSummary = {
provider: SourceControlProviderKind.make("github"),
projectId,
repository: "t3tools/t3code",
number: 7,
title: "Listed title",
url: "https://github.com/t3tools/t3code/pull/7",
state: "open",
headBranch: "change-7",
baseBranch: "main",
updatedAt: "2026-09-09T00:00:00.000Z",
};
const lookup = (host: string, number: number, summaries = [listed]) =>
knownPullRequestSummary({ host, repository: "t3tools/t3code", number }, threads, summaries);

expect(lookup("github.com", 7, [])?.title).toBe("Change 7");
expect(lookup("github.com", 7)?.title).toBe("Listed title");
expect(lookup("github.com", 8)).toBeUndefined();
expect(lookup("gitlab.com", 7)).toBeUndefined();

const sameVersion = { ...listed, updatedAt: "2026-09-08T00:00:00.000Z" };
const syncedAt = Date.parse(link.snapshot!.syncedAt);
expect(lookup("github.com", 7, [{ ...sameVersion, observedAt: syncedAt - 1 }])?.title).toBe(
"Change 7",
);
expect(lookup("github.com", 7, [{ ...sameVersion, observedAt: syncedAt + 1 }])?.title).toBe(
"Listed title",
);
});
});

describe("rememberBounded", () => {
it("moves a re-answered entry to the newest slot and evicts the oldest past the limit", () => {
let snapshots: ReadonlyMap<string, number> = new Map();
Expand Down
18 changes: 18 additions & 0 deletions apps/mobile/src/state/use-thread-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import { Atom } from "effect/reactivity";
import { use, useMemo } from "react";

import { connectionAtomRuntime } from "../connection/runtime";
import { appAtomRegistry } from "./atom-registry";
import { serverEnvironment } from "./server";
import { environmentThreadShells } from "./threads";
import { useEnvironmentQuery } from "./query";
import { ThreadPrDemandContext } from "./thread-pr-demand";
import {
knownPullRequestSummary,
rememberBounded,
resolveThreadPrSource,
presentThreadPr,
Expand Down Expand Up @@ -59,6 +62,21 @@ const pullRequestSummaryAtom = createLinkedPullRequestSummaryAtomFamily(

export { type ThreadPr, type ThreadPrPresentation } from "./thread-pr-presentation";

/** Seeds a pull request page with a summary already in memory, never another pull request's. */
export function withKnownPullRequestSummary<
Params extends { readonly host?: string; readonly repository: string; readonly number: number },
>(params: Params) {
const initialSummary =
params.host === undefined
? undefined
: knownPullRequestSummary(
{ host: params.host, repository: params.repository, number: params.number },
appAtomRegistry.get(environmentThreadShells.threadShellsAtom),
appAtomRegistry.get(pullRequestSnapshotsAtom).values(),
);
return initialSummary === undefined ? params : { ...params, initialSummary };
}

export function useThreadPr(thread: EnvironmentThreadShell): ThreadPrPresentation | null {
const demand = use(ThreadPrDemandContext);
const supportsLinks = useAtomValue(
Expand Down
Loading
Loading