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
This commit is contained in:
Mohamed Boudra
2026-09-09 16:05:44 +02:00
committed by GitHub
parent 0b3d82a469
commit d311797653
21 changed files with 816 additions and 163 deletions
@@ -0,0 +1,28 @@
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,
};
}