From ac5c37b661568067747abb18dfa2b45ec45ea58a Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Fri, 23 Oct 2026 09:50:05 +0100 Subject: [PATCH] web/repo: let the diff queue refetch a file whole whole() fetches a file's sides once Signed-off-by: oppiliappan --- web/src/lib/components/repo/diffQueue.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/web/src/lib/components/repo/diffQueue.ts b/web/src/lib/components/repo/diffQueue.ts index 7829088b2..46533990a 100644 --- a/web/src/lib/components/repo/diffQueue.ts +++ b/web/src/lib/components/repo/diffQueue.ts @@ -27,6 +27,7 @@ export interface DiffQueue { applyPatch: (url: string, signal: AbortSignal) => Promise; /** hands the queue files someone else already parsed, so it stops chasing them */ adopt: (parsed: Record) => void; + whole: (key: string) => boolean; destroy: () => void; } @@ -36,6 +37,8 @@ export const createDiffQueue = (host: DiffQueueHost): DiffQueue => { let running = 0; const pending = new Set(); const inFlight = new Set(); + const replacing = new Set(); + const tried = new Set(); // file order is monotonic down the page, so index distance stands in for // pixels let focusIndex = 0; @@ -103,7 +106,7 @@ export const createDiffQueue = (host: DiffQueueHost): DiffQueue => { running++; inFlight.add(file.key); try { - if (host.entry(file.key)) return; + if (host.entry(file.key) && !replacing.has(file.key)) return; const contents = await fetchWithRetry(file); if (!("oldFile" in contents)) { host.put({ [file.key]: { note: contents.note } }); @@ -130,6 +133,7 @@ export const createDiffQueue = (host: DiffQueueHost): DiffQueue => { } } finally { inFlight.delete(file.key); + replacing.delete(file.key); running--; pump(); } @@ -149,6 +153,15 @@ export const createDiffQueue = (host: DiffQueueHost): DiffQueue => { pump(); }, drain: () => pump(), + whole: (key) => { + if (tried.has(key)) return pending.has(key) || inFlight.has(key); + if (!byKey().get(key)?.file.sides) return false; + tried.add(key); + replacing.add(key); + pending.add(key); + pump(); + return true; + }, adopt: (parsed) => { const landing: Record = {}; for (const [key, value] of Object.entries(parsed)) { -- 2.54.0