From ba5e57133752f15b4676defe9dbe5b2f0576c638 Mon Sep 17 00:00:00 2001 From: Brandon Oxendine Date: Thu, 10 Sep 2026 13:54:56 +0200 Subject: [PATCH] Keep the view steady when reacting or commenting Bind each cached loader to a `{@const}` so the `{#await}` blocks keep the same promise across patch reloads instead of re-running and flashing their pending branch. --- src/components/Changes.svelte | 8 +++++++- src/components/JobCob.svelte | 6 +++++- src/components/ReviewCodeThread.svelte | 11 +++++++++-- src/components/Revision.svelte | 16 ++++++++++++++-- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/components/Changes.svelte b/src/components/Changes.svelte index 08a269932..ad380107b 100644 --- a/src/components/Changes.svelte +++ b/src/components/Changes.svelte @@ -768,7 +768,13 @@ disabled={isTeaserDisabled(commit.id)} {commit}> {#if commit.parents.length > 0} - {#await cachedDiffStats(rid, commit.parents[0], commit.id) then commitStats} + + {@const statsPromise = cachedDiffStats( + rid, + commit.parents[0], + commit.id, + )} + {#await statsPromise then commitStats} {commitStats.filesChanged} diff --git a/src/components/JobCob.svelte b/src/components/JobCob.svelte index b1c6822c8..936641ea4 100644 --- a/src/components/JobCob.svelte +++ b/src/components/JobCob.svelte @@ -176,6 +176,10 @@ return host.split(".").includes(a); } + // Held in a `$derived`; see `ReviewCodeThread`. The TTL here means a re-run + // would refetch and blank the chip. + const jobsPromise = $derived(cachedListJobs(rid, commit)); + function toggleNode(key: string) { if (collapsed.has(key)) { collapsed.delete(key); @@ -289,7 +293,7 @@ } -{#await cachedListJobs(rid, commit) then jobs} +{#await jobsPromise then jobs} {#if jobs.length > 0} {@const groups = groupJobs(jobs)} {@const overallCounts = totalCounts(groups)} diff --git a/src/components/ReviewCodeThread.svelte b/src/components/ReviewCodeThread.svelte index accafc5c9..f5d76679a 100644 --- a/src/components/ReviewCodeThread.svelte +++ b/src/components/ReviewCodeThread.svelte @@ -136,8 +136,15 @@ {#if path} - {#await cachedGetDiffText(rid, base, head, 3, path)} + diff is not fetched here at all. + + Bound to a `{@const}` (a derived) rather than called inside the + `{#await}`: a patch reload replaces the props this reads, and an inline + call would re-run the block, flashing the pending branch and jumping the + scroll position. The derived returns the same cached promise, so it + does not. --> + {@const filePatchPromise = cachedGetDiffText(rid, base, head, 3, path)} + {#await filePatchPromise}
Loading code…
{:then filePatch}
diff --git a/src/components/Revision.svelte b/src/components/Revision.svelte index 2e1c80a9d..1e120b4c4 100644 --- a/src/components/Revision.svelte +++ b/src/components/Revision.svelte @@ -1674,11 +1674,16 @@
{/if} {#if targetRev && targetRev.base !== targetRev.head} + + {@const revisionDiff = cachedGetDiff(rid, { + base: targetRev.base, + head: targetRev.head, + })} {#if hasBody || hasCommits}
{/if}
- {#await cachedGetDiff( rid, { base: targetRev.base, head: targetRev.head } )} + {#await revisionDiff}
Loading diff…
@@ -1737,7 +1742,14 @@ {/if} {/snippet} - {#await cachedGetDiffText(rid, targetRev.base, targetRev.head, 3, path)} + {@const filePatchPromise = cachedGetDiffText( + rid, + targetRev.base, + targetRev.head, + 3, + path, + )} + {#await filePatchPromise}
{:then filePatch}