From e76d643835c45f6624856850137e71e986315eb0 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 8 Oct 2026 13:50:44 -0700 Subject: Prefetch visible post threads after a bounded reading dwell --- tools/thread-cache-test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tools/thread-cache-test.js') diff --git a/tools/thread-cache-test.js b/tools/thread-cache-test.js index 6bac353..67b191b 100644 --- a/tools/thread-cache-test.js +++ b/tools/thread-cache-test.js @@ -139,6 +139,24 @@ try { assert.equal(restored.root.id, r.id); assert.equal(restored.replies.length, 2); }); + for (const clickWhileLoading of [false, true]) { + const warm = makeFeature(), seed = note(clickWhileLoading ? 501 : 500); + const answer = note(clickWhileLoading ? 511 : 510, [['e', seed.id, '', 'root']]); + requests = []; + const prefetched = warm.feature.testThread(seed, true); + await wait(() => waiting.length === 1); + if (clickWhileLoading) assert.equal(warm.feature.testThread(seed), prefetched); + for (const q of waiting.splice(0)) q.resolve([answer]); + await prefetched.loading; + if (!clickWhileLoading) assert.equal(store.find(seed.id), null, 'speculation does not evict persisted visits'); + const opened = warm.feature.testThread(seed); + assert.equal(opened, prefetched); + assert.equal(opened.status, 'ready'); + assert.equal(opened.replies[0].id, answer.id); + assert.equal(requests.length, 1, 'click shares the existing relay query'); + assert.equal(store.find(seed.id).replies[0].id, answer.id); + } + console.log('✓ clicks reuse completed and in-flight prefetches and persist visited threads'); const deepLink = makeFeature(); requests = []; await deepLink.feature.testOpen({ id: e.id }); -- cgit v1.2.3