From c9f46cfb18bff34664fc5f65af70f31daa2d7d8d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 20 Nov 2026 08:11:44 -0700 Subject: A profile's older posts load with no months skipped, and Primal's cache fills what relays have dropped. "I'm searching for his post he made about his Napster app. I feel like he should have more posts. Are we missing some?" (Adam, 2026-11-20, on Ben Arc's profile). The page asked for posts older than the oldest one on it. Relays each hold their own part of an author's history: his own relay's newest 30 ended on September 25, while relay.coinos.io held six stray copies reaching back to April, so the next page asked for posts before April and five months were never shown; the profile ended at 11 posts. Each relay's answer is now measured on its own. A page is taken as complete down to the newest floor among the sources that sent a full page; older strays wait and join the page that reaches them, and the profile ends only when no source has more. The posts around his Napstr launch (August 21 to 27) are on none of the relays the page asks, so Primal's cache is asked as one more source, posts and replies, each signature checked like a relay's. New profile-depth-test scrolls his profile back to the launch post (59 posts; 11 and a fail before). profile-pager, profile-stream, profile-replies, profile-repost, profile-page, profile-open and features-smoke pass; profile-feed-test fails with and without this change (it waits for a textarea on the restore screen). Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01VMan6Upic5L6MMJzkTn8zg --- tools/profile-depth-test.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tools/profile-depth-test.js (limited to 'tools') diff --git a/tools/profile-depth-test.js b/tools/profile-depth-test.js new file mode 100644 index 0000000..5aea719 --- /dev/null +++ b/tools/profile-depth-test.js @@ -0,0 +1,45 @@ +// A profile's older posts, page after page, with no months skipped. Relays +// hold different parts of an author's history: paging "older than the oldest +// post on the page" jumped from late September to April on Ben Arc's profile +// because one relay held six stray copies reaching back that far, and the +// posts around his Napstr launch (2026-08-21) are on none of the relays we +// ask — only in Primal's cache. Reads real relays (relays: 'read'; nothing +// is published). +// Run: bun tools/profile-depth-test.js +import puppeteer from './puppeteer.js'; +import { buildHtml } from '../build.js'; +const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); +let ok = true; +const check = (n, c, d = '') => { console.log(` ${c ? '✓' : '✗'} ${n}${d ? ' — ' + d : ''}`); if (!c) ok = false; }; +const NPUB = process.env.NPUB || 'npub1c878wu04lfqcl5avfy3p5x83ndpvedaxv0dg7pxthakq3jqdyzcs2n8avm'; +const WANT = process.env.WANT || 'For all the seeders out there'; + +const html = await buildHtml({ minify: true, pwa: false }); +const server = Bun.serve({ port: 0, fetch: () => new Response(html, { headers: { 'content-type': 'text/html' } }) }); +const browser = await puppeteer.launch({ relays: 'read', executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox'] }); +const page = await browser.newPage(); +const errs = []; +page.on('pageerror', (e) => errs.push(String(e.stack || e).slice(0, 600))); +try { + await page.setViewport({ width: 390, height: 844 }); + await page.goto(server.url.href + NPUB, { waitUntil: 'domcontentloaded' }); + await page.waitForSelector('.notes-feed:not(.note-ghosts) > [data-key]', { timeout: 20000 }); + const seen = new Map(); // key -> text + let found = false, still = 0, last = 0; + const t0 = Date.now(); + for (let i = 0; i < 400 && !found && still < 40; i++) { + const rows = await page.evaluate(() => [...document.querySelectorAll('.notes-feed > [data-key]')].map((r) => [r.dataset.key, r.textContent.slice(0, 300)])); + for (const [k, t] of rows) seen.set(k, t); + found = [...seen.values()].some((t) => t.includes(WANT)); + still = seen.size === last ? still + 1 : 0; + last = seen.size; + await page.evaluate(() => window.scrollBy(0, 1400)); + await sleep(350); + } + console.log(` ${seen.size} posts read in ${((Date.now() - t0) / 1000).toFixed(1)} s`); + check('scrolling back reaches the Napstr launch post', found, WANT); + check('...past more than a first page', seen.size > 40, seen.size + ' posts'); + check('no page errors', !errs.length, errs.join(' | ')); +} catch (e) { console.error(e); ok = false; } finally { await browser.close(); server.stop(); } +console.log(ok ? '\nPASS' : '\nFAIL'); +process.exit(ok ? 0 : 1); -- cgit v1.2.3