Files
paseo/packages/app/src/git/commit-file-diff-query.ts
T
Mohamed Boudra d311797653 Reduce stalls when opening large diffs (#4574)
* perf(app): reduce avoidable work when opening large diffs

Large snapshots were recursively reconstructed for reference stability, while native scroll worklets captured complete file models. Preserve identity at the data producers and prepare text for the visible window without rebuilding unchanged files.

* test(app): await commit diff query completion without polling

* chore(app): remove profiling artifacts from the source tree
2026-09-09 16:05:44 +02:00

29 lines
1.1 KiB
TypeScript

import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
import { checkoutCommitFileDiffQueryKey, COMMIT_FILE_DIFF_STALE_TIME } from "./query-keys";
import { shareCommitFileDiff } from "./diff-sharing";
export function commitFileDiffQueryOptions(input: {
serverId: string;
cwd: string;
sha: string;
path: string;
client: Pick<DaemonClient, "getCommitFileDiff"> | null;
enabled: boolean;
}) {
return {
queryKey: checkoutCommitFileDiffQueryKey(input.serverId, input.cwd, input.sha, input.path),
queryFn: () => {
if (!input.client) throw new Error("Host disconnected");
return input.client.getCommitFileDiff(input.cwd, input.sha, input.path);
},
enabled: input.enabled,
gcTime: COMMIT_FILE_DIFF_STALE_TIME,
// Only successful file bodies are immutable. Null/error results can recover.
immutableWhen: (data: Awaited<ReturnType<DaemonClient["getCommitFileDiff"]>>) =>
data.file !== null,
dataShape: "value" as const,
refetchOnWindowFocus: false,
structuralSharing: shareCommitFileDiff,
};
}