From 9b85b4e7483c2d77204b1925719696d1b1559e9a Mon Sep 17 00:00:00 2001 From: Vignan Posham Date: Mon, 7 Sep 2026 01:38:19 -0400 Subject: [PATCH] Guard sticky-tile registration against stale image loads If a tile is virtualised out before its in-flight thumbnail finishes, the load event still fires on the detached . Without a guard that callback would add the index to state.stickyTiles, potentially pinning a later replacement tile whose own has not painted yet. Only register the index while this is still the live tile for it (state.renderedTiles.get(index) === a). Co-Authored-By: Claude Sonnet 5 --- app/src/client/tiles.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/client/tiles.ts b/app/src/client/tiles.ts index aecc4f9..19360fb 100644 --- a/app/src/client/tiles.ts +++ b/app/src/client/tiles.ts @@ -78,7 +78,11 @@ export function createTile (index: number): HTMLAnchorElement { // Pin this tile: once loaded it is never virtualised out again, so a // scroll back up reuses this exact instead of rebuilding it in a // blank/placeholder state. See state.stickyTiles / virtualize(). - state.stickyTiles.add(index) + // Guard: if this tile was virtualised out before its (in-flight) image + // finished, the load still fires on the now-detached . Only pin the + // index while this is still the live tile for it, so a stale request + // can't mark a not-yet-loaded replacement tile as sticky. + if (state.renderedTiles.get(index) === a) state.stickyTiles.add(index) } a.appendChild(img)