From 06df23884d69bb2f46a6deeb9b05722d5ba45b53 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 28 Sep 2026 22:48:26 -0700 Subject: A face tapped in the feed opens that person's profile at its top; Back returns to the same place in the feed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The profile kept the feed's scroll offset, so the reader landed deep in the person's posts — which read as a thread opening. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Du1qT1wbkYwYK6zkGH79Rp --- tools/avatar-profile-test.js | 73 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tools/avatar-profile-test.js (limited to 'tools/avatar-profile-test.js') diff --git a/tools/avatar-profile-test.js b/tools/avatar-profile-test.js new file mode 100644 index 0000000..c91ad26 --- /dev/null +++ b/tools/avatar-profile-test.js @@ -0,0 +1,73 @@ +// Tapping a face in the feed opens that person's profile AT ITS TOP — not +// the thread the row would open, and not the profile scrolled down to +// wherever the reader was in the feed. Back returns to the same place. +// +// Run: bun tools/avatar-profile-test.js +import puppeteer from 'puppeteer-core'; +import { generateMnemonic } from '@scure/bip39'; +import { wordlist } from '@scure/bip39/wordlists/english'; +import { cacheKeyFor } from '../src/wallet.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 html = await buildHtml({ minify: true, pwa: false }); +const server = Bun.serve({ port: 5271, fetch: () => new Response(html, { headers: { 'content-type': 'text/html' } }) }); +const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox'] }); +const page = await browser.newPage(); +const click = (t) => page.evaluate((x) => { const e = [...document.querySelectorAll('button')].find((n) => n.textContent.trim().toLowerCase().includes(x)); if (e) { e.click(); return true; } return false; }, t); +const waitText = async (x, ms = 25000) => { for (let i = 0; i < ms / 250; i++) { if ((await page.evaluate(() => document.body.innerText)).toLowerCase().includes(x)) return true; await sleep(250); } return false; }; +try { + await page.setViewport({ width: 390, height: 844 }); + await page.goto('http://localhost:5271/', { waitUntil: 'domcontentloaded' }); + await page.evaluate(() => localStorage.setItem('btc-wallet-network', 'regtest')); + await page.reload({ waitUntil: 'domcontentloaded' }); + await sleep(400); + await click('create a new wallet'); await sleep(600); + await page.waitForSelector('.words .w .t'); + const mn = (await page.$$eval('.words .w .t', (l) => l.map((e) => e.textContent.trim()))).join(' '); + await click('skip verification'); + await waitText('receive', 20000); + const base = cacheKeyFor(mn + '\n'); + const A = 'a'.repeat(63) + '9', B = 'b'.repeat(63) + '7'; + await page.evaluate(([k, a, b]) => { + const now = Math.floor(Date.now() / 1000); + const ns = Array.from({ length: 30 }, (_, i) => ({ + id: (i + 16).toString(16).padStart(64, 'c'), pubkey: i % 2 ? b : a, kind: 1, created_at: now - i * 60, + content: 'post number ' + i + '\n\n' + 'a few lines so rows have height. '.repeat(4), tags: [], + })); + localStorage.setItem(k + ':follows', JSON.stringify({ tags: [['p', a], ['p', b]], c: '', at: now })); + localStorage.setItem(k + ':feedNotes', JSON.stringify(ns)); + localStorage.setItem(k + ':profiles', JSON.stringify({ [a]: { name: 'Alice Poster', t: Date.now() }, [b]: { name: 'Bob Poster', about: 'bob bio here', t: Date.now() } })); + }, [base, A, B]); + await page.reload({ waitUntil: 'domcontentloaded' }); + await waitText('receive', 20000); + await page.evaluate(() => document.querySelector('.app-bottom-nav .app-nav-button').click()); + await waitText('post number 15', 15000); + await sleep(1500); + + // scroll down to a row well into the feed, then tap its face + await page.evaluate(() => { const r = [...document.querySelectorAll('.notes-feed .note-avatar')].find((n) => n.closest('[data-key]')?.innerText.includes('post number 13')); r.scrollIntoView({ block: 'center' }); }); + await sleep(700); + const feedY = await page.evaluate(() => window.scrollY); + const pt = await page.evaluate(() => { const r = [...document.querySelectorAll('.notes-feed .note-avatar')].find((n) => n.closest('[data-key]')?.innerText.includes('post number 13')).getBoundingClientRect(); return { x: r.x + r.width / 2, y: r.y + r.height / 2 }; }); + await page.touchscreen.tap(pt.x, pt.y); + await sleep(1200); + const after = await page.evaluate(() => ({ y: window.scrollY, text: document.body.innerText.slice(0, 400), thread: !!document.querySelector('.note-thread, .thread-page') })); + if (process.env.DBG) console.log(feedY, JSON.stringify(after)); + check('the tap opens the profile', /Bob Poster/.test(after.text) && /bob bio here/.test(after.text), after.text.replace(/\s+/g, ' ').slice(0, 80)); + check('...at its top', after.y < 5, 'scrollY ' + after.y + ' (feed was at ' + feedY + ')'); + + await page.goBack().catch(() => {}); + await sleep(1200); + let back = await page.evaluate(() => ({ y: window.scrollY, feed: !!document.querySelector('.notes-feed') && document.body.innerText.includes('post number 13') })); + if (!back.feed) { + await page.evaluate(() => { const b = document.querySelector('.back, [aria-label="Back"]'); if (b) b.click(); }); + await sleep(1200); + back = await page.evaluate(() => ({ y: window.scrollY, feed: !!document.querySelector('.notes-feed') })); + } + check('back returns to the feed where the reader was', back.feed && Math.abs(back.y - feedY) < 60, 'scrollY ' + back.y + ' vs ' + feedY); +} finally { await browser.close(); server.stop(true); } +console.log(ok ? '\n✅ a face opens its profile at the top' : '\n❌ failed'); +process.exit(ok ? 0 : 1); -- cgit v1.2.3 From 73ab54a004113b32a9a12661e7e7eb9151999ee3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 28 Sep 2026 23:25:10 -0700 Subject: Someone's timeline gets a labelled feed chip instead of a blank black pill. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Du1qT1wbkYwYK6zkGH79Rp --- src/features/messages.js | 4 +++- tools/avatar-profile-test.js | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'tools/avatar-profile-test.js') diff --git a/src/features/messages.js b/src/features/messages.js index c6a99b5..452377e 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -7680,7 +7680,9 @@ export function messagesFeature(ctx) { ...items.map((f) => h('button', { class: 'feed-chip' + (f.id === curFeedId ? ' on' : ''), type: 'button', 'data-key': 'chip:' + f.id, onClick: () => switchFeed(f.id), - }, f.name)), + // someone's timeline carries the person, not a name — an empty + // label left a blank black pill + }, f.of ? t('feedOfTitle', { name: displayName(f.of) }) : f.name || feedSummary(f))), h('button', { class: 'feed-chip add', type: 'button', title: t('feedNew'), 'aria-label': t('feedNew'), onClick: () => openFeedEditor(null) }, '+')); } // The sheets a post (or a person) can open: the ⋯ menu, the reaction diff --git a/tools/avatar-profile-test.js b/tools/avatar-profile-test.js index c91ad26..0f59e10 100644 --- a/tools/avatar-profile-test.js +++ b/tools/avatar-profile-test.js @@ -68,6 +68,14 @@ try { back = await page.evaluate(() => ({ y: window.scrollY, feed: !!document.querySelector('.notes-feed') })); } check('back returns to the feed where the reader was', back.feed && Math.abs(back.y - feedY) < 60, 'scrollY ' + back.y + ' vs ' + feedY); + + // "Their timeline" from the profile: its chip names it (it was a blank pill) + await page.evaluate(() => { const r = [...document.querySelectorAll('.notes-feed .note-avatar')].find((n) => n.closest('[data-key]')?.innerText.includes('Bob Poster')); r.click(); }); + await sleep(1000); + await click('their timeline'); + await sleep(1500); + const chip = await page.evaluate(() => document.querySelector('.feed-chip.on')?.textContent || null); + check('someone’s timeline has a labelled chip', !!chip && /Bob Poster/.test(chip), JSON.stringify(chip)); } finally { await browser.close(); server.stop(true); } console.log(ok ? '\n✅ a face opens its profile at the top' : '\n❌ failed'); process.exit(ok ? 0 : 1); -- cgit v1.2.3 From d5598a131a9d160b929ff7ccbd650a4ef57b21c0 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 28 Sep 2026 23:29:55 -0700 Subject: "Save feed" on someone's timeline adds it to your feeds at once, instead of an editor listing every person they follow. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The editor copied their whole follow list into the form, one row each — long enough to freeze the browser. A saved timeline now keeps only the person (of: pk); their follow list is read from the relays when it is opened, so it stays small in sync and follows who they follow. Its ⋯ offers Delete rather than Edit, and list pickers leave it out. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Du1qT1wbkYwYK6zkGH79Rp --- src/features/messages.js | 72 +++++++++++++++++++++++++++++++++----------- src/i18n.js | 1 + tools/avatar-profile-test.js | 14 +++++++++ 3 files changed, 70 insertions(+), 17 deletions(-) (limited to 'tools/avatar-profile-test.js') diff --git a/src/features/messages.js b/src/features/messages.js index 452377e..2cf799b 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -4173,7 +4173,7 @@ export function messagesFeature(ctx) { if (!ui.listPick) return null; const pk = ui.listPick; const close = () => { ui.listPick = null; render(); }; - const feeds = st().feeds; + const feeds = st().feeds.filter((f) => !f.of); // a timeline is someone, not a list const toggle = (f) => { const s = st(); const def = s.feeds.find((x) => x.id === f.id); @@ -4245,8 +4245,37 @@ export function messagesFeature(ctx) { for (const pk of def.authors || []) if (pk) set.add(pk); for (const pk of def.priv || []) if (pk) set.add(pk); // a list's private members for (const pk of packAuthors(def)) set.add(pk); + if (def.of) for (const pk of ofFollows.get(def.of)?.authors || []) set.add(pk); return [...set].slice(0, FEED_AUTHORS_MAX); }; + // Someone's timeline is their follow list, read from the relays when the + // feed is opened (and again after ten minutes) — never copied into the + // feed itself, so a saved one stays small in sync and follows them. + const ofFollows = new Map(); // pk -> { authors, at, loading } + const ofLoaded = (def) => !!ofFollows.get(def.of)?.at; + function loadOfFollows(def) { + const pk = def.of; + let f = ofFollows.get(pk); + if (!f) { f = { authors: [], at: 0, loading: false }; ofFollows.set(pk, f); } + if (f.loading || (f.at && Date.now() - f.at < 600_000)) return; + f.loading = true; + liveProfileOf(pk); // their name and face for the title + queryOn([...new Set([...(def.relays || []), ...PROFILE_RELAYS, ...NOTE_RELAYS])], { kinds: [3], authors: [pk] }, 6000) + .catch(() => []) + .then((evs) => { + const newest = (evs || []).sort((a, b) => b.created_at - a.created_at)[0]; + const had = f.at; + if (newest || !had) f.authors = newest ? hexList(newest.tags.filter((x) => x[0] === 'p').map((x) => x[1])) : []; + f.at = Date.now(); f.loading = false; + // whatever was built before the list was known + for (const id of [...feedStates.keys()]) { + if (feedDef(id)?.of !== pk || id === curFeedId) continue; + dropFeedState(id); + } + if (feedDef(curFeedId)?.of === pk) { dropFeedState(curFeedId); selectFeed(curFeedId); } + scheduleRepaint(); + }); + } function feedNow() { if (!feedDef(curFeedId)) curFeedId = FOLLOWING; // a feed deleted on another device @@ -4308,6 +4337,7 @@ export function messagesFeature(ctx) { // history restores ui.feedId and the view catches up from here. function selectFeed(id) { if (!feedDef(id)) return; + if (feedDef(id).of) loadOfFollows(feedDef(id)); if (id !== curFeedId) { curFeedId = id; if (!adhocFeeds.has(id)) { try { localStorage.setItem(FEED_LS, id); } catch {} } @@ -4344,19 +4374,9 @@ export function messagesFeature(ctx) { const id = 'of:' + pk + (readFrom.length ? '@' + readFrom.join(',') : ''); let def = adhocFeeds.get(id); if (!def) { - def = { id, name: '', follows: false, authors: [], packs: [], topics: [], of: pk, ofAt: 0, relays: readFrom }; + def = { id, name: '', follows: false, authors: [], packs: [], topics: [], of: pk, relays: readFrom }; adhocFeeds.set(id, def); - liveProfileOf(pk); // their name and face for the title - queryOn([...new Set([...relays, ...PROFILE_RELAYS, ...NOTE_RELAYS])], { kinds: [3], authors: [pk] }, 6000) - .catch(() => []) - .then((evs) => { - const newest = (evs || []).sort((a, b) => b.created_at - a.created_at)[0]; - def.authors = newest ? hexList(newest.tags.filter((x) => x[0] === 'p').map((x) => x[1])) : []; - def.ofAt = Date.now(); - dropFeedState(id); // whatever was built before the list was known - if (curFeedId === id) selectFeed(id); - scheduleRepaint(); - }); + loadOfFollows({ ...def, relays: [...relays, ...readFrom] }); } showFeed(id); } @@ -7682,7 +7702,7 @@ export function messagesFeature(ctx) { onClick: () => switchFeed(f.id), // someone's timeline carries the person, not a name — an empty // label left a blank black pill - }, f.of ? t('feedOfTitle', { name: displayName(f.of) }) : f.name || feedSummary(f))), + }, f.name || (f.of ? t('feedOfTitle', { name: displayName(f.of) }) : feedSummary(f)))), h('button', { class: 'feed-chip add', type: 'button', title: t('feedNew'), 'aria-label': t('feedNew'), onClick: () => openFeedEditor(null) }, '+')); } // The sheets a post (or a person) can open: the ⋯ menu, the reaction @@ -7703,7 +7723,9 @@ export function messagesFeature(ctx) { item('\u{1F4E1}', t('feedRelays') + (feedRelays(def) ? ' \u00b7 ' + feedRelays(def).length : ''), () => { ui.feedRelayEdit = { id: def.id, input: '' }; }), def.builtin || visitor ? null : adhocFeeds.has(def.id) - ? item('\u{1F4BE}', t('feedSaveAdhoc'), () => openFeedEditor(def)) + ? item('\u{1F4BE}', t('feedSaveAdhoc'), () => (def.of ? saveTimelineFeed(def) : openFeedEditor(def))) + // a saved timeline is the person, nothing to edit — only to drop + : def.of ? item('\u{1F5D1}', t('feedDelete'), () => deleteFeed(def.id)) : item('\u270e', t('feedEdit'), () => openFeedEditor(def)), h('button', { class: 'btn-ghost btn-block', onClick: close }, t('back')))); } @@ -7853,7 +7875,7 @@ export function messagesFeature(ctx) { }), def.of ? avatar(def.of, 'chat-avatar mini', true) : null, h('h3', { style: 'margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap' }, - def.builtin && !def.all ? t('feedTitle') : def.of ? t('feedOfTitle', { name: displayName(def.of) }) : def.name), + def.builtin && !def.all ? t('feedTitle') : def.of && !def.name ? t('feedOfTitle', { name: displayName(def.of) }) : def.name), // one ⋯ for the feed itself (share, relays, save or edit) and one // pencil for a new post: the title keeps the room a phone has h('button', { @@ -7867,7 +7889,7 @@ export function messagesFeature(ctx) { ui.feedRelayEdit && ui.feedRelayEdit.id === def.id ? relayPanel(def) : null, visitor ? null : feedChips(), visitor ? null : postComposer(), - def.of && !def.ofAt + def.of && !ofLoaded(def) ? h('div', { class: 'row gap6', style: 'justify-content:center;align-items:center;padding:12px 0' }, h('span', { class: 'spinner sm' }), h('span', { class: 'small muted' }, t('feedOfLoading'))) : def.of && !hasQuery @@ -7953,6 +7975,22 @@ export function messagesFeature(ctx) { deleteFollowSet(prev).catch(() => {}); } } + // "Save feed" on someone's timeline: into the chips at once. The editor + // would have copied their whole follow list in, one row per person. + function saveTimelineFeed(adhoc) { + const s = st(); + const have = s.feeds.find((f) => f.of === adhoc.of && JSON.stringify(f.relays || []) === JSON.stringify(adhoc.relays || [])); + const id = have ? have.id : 'f' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6); + if (!have) { + s.feeds.push({ id, name: '', follows: false, authors: [], packs: [], topics: [], of: adhoc.of, + ...(adhoc.relays && adhoc.relays.length ? { relays: adhoc.relays } : {}), at: Date.now() }); + save(s); + } + adhocFeeds.delete(adhoc.id); + feedStates.delete(adhoc.id); + switchFeed(id); + toast(t('feedSaved')); + } function deleteFeed(id) { const s = st(); const def = s.feeds.find((f) => f.id === id); diff --git a/src/i18n.js b/src/i18n.js index 02c60aa..afc76ef 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -242,6 +242,7 @@ const STR = { feedTopicsHelp: 'Posts tagged with any of these. With people set as well, only their posts on these topics.', feedDelete: 'Delete feed', feedSaveAdhoc: 'Save feed', + feedSaved: 'Feed saved', feedNoQuery: 'Add people or topics to this feed.', feedOfTitle: '{name}’s timeline', feedOfLoading: 'Reading who they follow…', diff --git a/tools/avatar-profile-test.js b/tools/avatar-profile-test.js index 0f59e10..6e84429 100644 --- a/tools/avatar-profile-test.js +++ b/tools/avatar-profile-test.js @@ -76,6 +76,20 @@ try { await sleep(1500); const chip = await page.evaluate(() => document.querySelector('.feed-chip.on')?.textContent || null); check('someone’s timeline has a labelled chip', !!chip && /Bob Poster/.test(chip), JSON.stringify(chip)); + + // ⋯ → Save feed: straight into the chips, no editor listing their follows + await page.evaluate((l) => document.querySelector('button[aria-label="' + l + '"]').click(), 'Feed options'); + await sleep(500); + const saved = await click('save feed'); + await sleep(1000); + const savedState = await page.evaluate(() => ({ editor: /New feed/.test(document.body.innerText), chips: [...document.querySelectorAll('.feed-chip')].map((c) => c.textContent), on: document.querySelector('.feed-chip.on')?.textContent })); + check('“Save feed” on a timeline saves it without the editor', saved && !savedState.editor && /Bob Poster/.test(savedState.on || ''), JSON.stringify(savedState)); + await page.reload({ waitUntil: 'domcontentloaded' }); + await waitText('receive', 20000); + await page.evaluate(() => document.querySelector('.app-bottom-nav .app-nav-button').click()); + await sleep(2000); + const kept = await page.evaluate(() => [...document.querySelectorAll('.feed-chip')].map((c) => c.textContent)); + check('...and it is still among the feeds after a reload', kept.some((c) => /(Bob Poster|npub1hwam).*’s timeline/.test(c)), JSON.stringify(kept)); } finally { await browser.close(); server.stop(true); } console.log(ok ? '\n✅ a face opens its profile at the top' : '\n❌ failed'); process.exit(ok ? 0 : 1); -- cgit v1.2.3 From 3948ad95beb6e5e40dd275b7c4909ec8c4dee8a9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 29 Sep 2026 11:01:43 -0700 Subject: Quoted notes are found on more relays and never show as a bare "view note"; Back from a post keeps the feed's place. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - findNote: the reference's hints, its author's NIP-65 relays and ours, plus a wide net of big public relays, all at once, first answer wins. A real quote (SuiGenerisJohn → 0c5e0f08…) sat only on nostr.mom, named by neither the nevent nor its author's relay list. - A feed row whose quote isn't in yet shows the quote card with "Fetching note…" / "Couldn't find that note" instead of a link; the card replaces it once found. - Opening a post remembers the scroll position like opening a profile does; Back restores it instead of landing at the top of the feed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Du1qT1wbkYwYK6zkGH79Rp --- src/features/messages.js | 65 ++++++++++++++++++++++++++++++++------------ tools/avatar-profile-test.js | 11 ++++++++ tools/quote-card-test.js | 19 +++++++++---- 3 files changed, 73 insertions(+), 22 deletions(-) (limited to 'tools/avatar-profile-test.js') diff --git a/src/features/messages.js b/src/features/messages.js index 00f66b9..b5b4c01 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -3079,17 +3079,28 @@ export function messagesFeature(ctx) { // A profile opens at its top: keeping the feed's scroll offset landed the // reader deep in that person's posts, which read as a thread. Back (a // popstate) puts them where they were on the page they left. - const profReturn = []; // [{ pk, y }] per profile opened, newest last + // The same for a post opened into its thread: Back lands on the row the + // reader tapped, not the top of the feed. + const pageReturn = []; // [{ key, y }] per profile/thread opened, newest last + const pageKey = () => ui.noteThread && !(ui.profilePk && ui.profOverThread) ? 'thread' + : ui.profilePk ? 'p:' + ui.profilePk : ''; + function rememberPlace(key) { + if (pageKey() === key) return; + let y = 0; try { y = window.scrollY || 0; } catch {} + pageReturn.push({ key, y }); + if (pageReturn.length > 20) pageReturn.shift(); + } if (typeof window !== 'undefined') window.addEventListener('popstate', () => { - const top = profReturn[profReturn.length - 1]; - if (!top || ui.profilePk === top.pk) return; - profReturn.pop(); - requestAnimationFrame(() => { try { window.scrollTo(0, top.y); } catch {} }); + const top = pageReturn[pageReturn.length - 1]; + if (!top || pageKey() === top.key) return; + pageReturn.pop(); + const y = top.y; + // twice: the page under it may paint its rows a frame late + requestAnimationFrame(() => { try { window.scrollTo(0, y); } catch {} + requestAnimationFrame(() => { try { if (Math.abs(window.scrollY - y) > 2) window.scrollTo(0, y); } catch {} }); }); }); function openProfile(pk) { - let y = 0; try { y = window.scrollY || 0; } catch {} - if (ui.profilePk !== pk) profReturn.push({ pk, y }); - if (profReturn.length > 20) profReturn.shift(); + rememberPlace('p:' + pk); ui.profilePk = pk; // Opened from inside a thread (an author's avatar/name), the profile // stacks ON TOP of it — back returns to the conversation. The screen @@ -5389,15 +5400,35 @@ export function messagesFeature(ctx) { // wanted, half a minute on, with any relay hints the reference carried. const QUOTE_RETRY_MS = 30_000; const quoted = new Map(); // id -> { status, ev, at } + // Where a referenced note may be: the reference's hints, its author's own + // relays, ours — and when none of those has it, a wider net of big public + // relays (a quoted note in the wild sat only on nostr.mom, which neither + // the reference nor its author's relay list named). + const WIDE_RELAYS = ['wss://nostr.mom', 'wss://relay.nostr.band', 'wss://nostr.wine', 'wss://relay.snort.social', + 'wss://offchain.pub', 'wss://relay.nostr.bg', 'wss://nostr.oxtr.dev', 'wss://relay.damus.io', 'wss://nos.lol', 'wss://relay.primal.net']; + // All at once, first answer wins: asked in turn, a note on a far relay + // took longer than the feed waits for a row. + function findNote(ref) { + const pick = (evs) => (evs || []).find((e) => e.id === ref.id) || null; + const ask = (relays) => (relays.length ? queryOn(relays, { ids: [ref.id] }, 4500).then(pick).catch(() => null) : Promise.resolve(null)); + const near = [...new Set([...(ref.relays || []), ...zapRelays()])]; + const asks = [ + ask(near), + ref.author ? relaysOf(ref.author).catch(() => []).then((rs) => ask(rs.filter((r) => !near.includes(r)))) : Promise.resolve(null), + ask(WIDE_RELAYS.filter((r) => !near.includes(r))), + ]; + return new Promise((resolve) => { + let left = asks.length; + for (const a of asks) a.then((ev) => { if (ev) resolve(ev); else if (--left === 0) resolve(null); }); + }); + } function quotedNote(ref) { let c = quoted.get(ref.id); if (c && (c.status !== 'missing' || Date.now() - (c.at || 0) < QUOTE_RETRY_MS)) return c; if (!c) { c = { status: 'loading', ev: null, at: 0 }; quoted.set(ref.id, c); } c.at = Date.now(); c.promise = (async () => { - const relays = [...new Set([...(ref.relays || []), ...zapRelays()])]; - const evs = await queryOn(relays, { ids: [ref.id] }, 4500).catch(() => []); - c.ev = (evs || [])[0] || c.ev || null; + c.ev = (await findNote(ref).catch(() => null)) || c.ev || null; c.status = c.ev ? 'ready' : 'missing'; if (c.ev) cacheNotifNotes([c.ev]); // the open thread quotes it: keep it with the thread for the next reload @@ -5428,9 +5459,10 @@ export function messagesFeature(ctx) { let c = feedPaint ? feedPaint.quotes.get(ref.id) : quotedNote(ref); if (feedPaint && !c?.ev) { const live = quoteWarm(ref); - if (!(live.ev && live.warm)) return h('a', { - href: '#', onClick: (e) => { e.preventDefault(); e.stopPropagation(); openNoteRef(ref); }, - }, t('noteRefLink')); + // not (yet) found: the card says so where the quote will be — never a + // bare "view note" link that only leads to the same answer + if (!(live.ev && live.warm)) return h('div', { class: 'quote-card' }, + h('span', { class: 'small faint' }, t(live.status === 'missing' ? 'noteRefNotFound' : 'noteRefLoading'))); c = { ...live }; feedPaint.quotes.set(ref.id, c); } @@ -6900,6 +6932,7 @@ export function messagesFeature(ctx) { return c; } function openNoteThread(ev) { + rememberPlace('thread'); ui.noteThread = { rootId: rootIdOf(ev), focusId: ev.id, seed: ev, scrollPending: true }; ui.profOverThread = false; // a freshly opened thread goes on top render(); @@ -6912,9 +6945,7 @@ export function messagesFeature(ctx) { const cached = saved && (saved.root.id === ref.id ? saved.root : saved.replies.find((e) => e.id === ref.id)); if (cached) { openNoteThread(cached); return; } toast(t('noteRefLoading')); - const relays = [...new Set([...(ref.relays || []), ...NOTE_RELAYS])]; - const evs = await queryOn(relays, { ids: [ref.id] }, 4000).catch(() => []); - const ev = (evs || [])[0]; + const ev = quoted.get(ref.id)?.ev || await findNote(ref).catch(() => null); if (ev) openNoteThread(ev); else toast(t('noteRefNotFound')); } diff --git a/tools/avatar-profile-test.js b/tools/avatar-profile-test.js index 6e84429..54c40dc 100644 --- a/tools/avatar-profile-test.js +++ b/tools/avatar-profile-test.js @@ -69,6 +69,17 @@ try { } check('back returns to the feed where the reader was', back.feed && Math.abs(back.y - feedY) < 60, 'scrollY ' + back.y + ' vs ' + feedY); + // a post opened into its thread: Back lands where the reader was + await page.evaluate(() => { const r = [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.innerText.includes('post number 13')); r.scrollIntoView({ block: 'center' }); }); + await sleep(700); + const y0 = await page.evaluate(() => window.scrollY); + await page.evaluate(() => [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.innerText.includes('post number 13')).querySelector('.note-text').click()); + await sleep(1500); + const inThread = await page.evaluate(() => !!document.querySelector('.thread-page')); + await page.goBack(); await sleep(1500); + const y1 = await page.evaluate(() => window.scrollY); + check('back from a post returns to the same place in the feed', inThread && y0 > 500 && Math.abs(y1 - y0) < 60, 'scrollY ' + y1 + ' vs ' + y0); + // "Their timeline" from the profile: its chip names it (it was a blank pill) await page.evaluate(() => { const r = [...document.querySelectorAll('.notes-feed .note-avatar')].find((n) => n.closest('[data-key]')?.innerText.includes('Bob Poster')); r.click(); }); await sleep(1000); diff --git a/tools/quote-card-test.js b/tools/quote-card-test.js index 91edf3b..d2d7d7e 100644 --- a/tools/quote-card-test.js +++ b/tools/quote-card-test.js @@ -25,6 +25,7 @@ const found = await pool.querySync(['wss://relay.primal.net', 'wss://nos.lol'], const target = (found || []).filter((e) => e.content && e.content.length > 20)[0]; if (!target) { console.log(' ✗ no note to quote (relays quiet)'); process.exit(1); } const nevent = neventOf(target.id, target.pubkey); +const FAR = 'nevent1qvzqqqqqqypzqntcggz30qhq60ltqdx32zku9d46unhrkjtcv7fml7jx3dh4h94nqqsqchs0pz4hnqm6jurakjwcd6wcrph7wyy80j0ljup68p4hynvsz3q3nhre2'; const html = await buildHtml({ minify: true, pwa: false }); const server = Bun.serve({ port: 5269, fetch: () => new Response(html, { headers: { 'content-type': 'text/html' } }) }); @@ -59,21 +60,24 @@ try { await waitText('receive', 20000); const base = cacheKeyFor(mn + '\n'); const A = 'a'.repeat(63) + '9'; - await page.evaluate(([k, pk, ref]) => { + await page.evaluate(([k, pk, ref, FAR]) => { localStorage.setItem(k + ':follows', JSON.stringify({ tags: [['p', pk]], c: '', at: Math.floor(Date.now()/1000) })); localStorage.setItem(k + ':feedNotes', JSON.stringify([ { id: 'd'.repeat(64), pubkey: pk, kind: 1, created_at: Math.floor(Date.now()/1000), content: 'what he said nostr:' + ref, tags: [] }, + // quotes a note that sits only on nostr.mom — not in the reference, not in its author's relay list + { id: 'e'.repeat(64), pubkey: pk, kind: 1, created_at: Math.floor(Date.now()/1000) - 60, content: 'I remember this.\n\nnostr:' + FAR, tags: [] }, ])); localStorage.setItem(k + ':profiles', JSON.stringify({ [pk]: { name: 'Quoter', t: Date.now() } })); - }, [base, A, nevent]); + }, [base, A, nevent, FAR]); if (process.argv.includes('--slow')) await page.evaluate(() => localStorage.setItem('__slowQuote', '1')); await page.reload({ waitUntil: 'domcontentloaded' }); await waitText('receive', 20000); await page.evaluate(() => document.querySelector('.app-bottom-nav .app-nav-button').click()); await sleep(7000); if (process.argv.includes('--slow')) { - for (let i = 0; i < 40 && !(await page.evaluate(() => document.body.innerText.includes('view note'))); i++) await sleep(250); - check('a late quote first paints as a link', await page.evaluate(() => document.body.innerText.includes('view note'))); + for (let i = 0; i < 40 && !(await page.evaluate(() => !!document.querySelector('.quote-card'))); i++) await sleep(250); + check('a late quote first paints as a placeholder card, not a link', await page.evaluate(() => !document.body.innerText.includes('view note') + && [...document.querySelectorAll('.quote-card')].some((q) => /Couldn.t find|Fetching note/.test(q.innerText)))); await sleep(SLOW_MS + 4000); } @@ -87,7 +91,12 @@ try { check('...with whose note it is', !!(card && card.hasAvatar), card ? card.text.slice(0, 50) : ''); const body = target.content.replace(/\s+/g, ' ').slice(0, 24); check('...and what it actually said', !!(card && card.text.replace(/\s+/g, ' ').includes(body.slice(0, 18))), body); - check('no "view note" link left in the post', !(await page.evaluate(() => document.body.innerText)).includes('view note')); + if (!process.argv.includes('--slow')) { + const far = await page.evaluate(() => { const r = [...document.querySelectorAll('.notes-feed [data-key]')].find((n) => n.innerText.includes('Quoter') && n.innerText.includes('I remember this')); return r && r.querySelector('.quote-card')?.innerText; }); + check('a quote found only on a far relay still shows as its card', !!far && !/Couldn.t find|Fetching/.test(far), JSON.stringify((far || '').slice(0, 60))); + } + // (a quote inside a quote stays a link on purpose: one level of cards) + check('no "view note" link left in the post', !(await page.evaluate(() => [...document.querySelectorAll('.notes-feed a')].some((a) => a.textContent === 'view note' && !a.closest('.quote-card'))))); // the outer post keeps its actions; the quote has none of its own const acts = await page.evaluate(() => ({ outer: document.querySelectorAll('.notes-feed > .row .note-acts').length, -- cgit v1.2.3 From e96c445e73d26e946cf2a3d515b5f0ab697ef5f0 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 30 Sep 2026 09:05:19 -0700 Subject: From someone's timeline, ‹ goes back to their profile and the Feed tab is your own feed again. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Feed tab reopened whichever feed was last on — the session timeline — and ‹ on it went to the chat list, so there was no way back to your own feed. The tab now opens the last of your own feeds; ‹ on a feed opened from somewhere (a timeline, a #tag, a pack link) steps back in history. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Du1qT1wbkYwYK6zkGH79Rp --- src/features/messages.js | 12 ++++++++++-- tools/avatar-profile-test.js | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'tools/avatar-profile-test.js') diff --git a/src/features/messages.js b/src/features/messages.js index 3d9b1e9..b14cb75 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -3899,6 +3899,8 @@ export function messagesFeature(ctx) { const FEED_LS = 'btc-wallet-feed'; // the feed last on screen, remembered per device const feedStates = new Map(); // id -> state const adhocFeeds = new Map(); // id -> definition, this session only + // the feed of your own you last had on (never a session one) + const homeFeedId = () => { let id = FOLLOWING; try { id = localStorage.getItem(FEED_LS) || FOLLOWING; } catch {} return feedDef(id) && !adhocFeeds.has(id) ? id : FOLLOWING; }; let curFeedId = (() => { try { return localStorage.getItem(FEED_LS) || FOLLOWING; } catch { return FOLLOWING; } })(); // Two feeds everyone has: the people you follow, and everything the coinos // relay carries. Each remembers its own relay choice in the state. @@ -7993,9 +7995,12 @@ export function messagesFeature(ctx) { // A destination tab is a destination: tapping Feed while already // there always returns to its top. Only the explicit "x new posts" // pill jumps to the first unread arrival. - if (active === 'feed' && ui.msgView === 'feed' && !ui.profilePk && !ui.noteThread && !ui.feedEdit) { glideToTop(); return; } + // (someone's timeline or a #tag opened from a post isn't the Feed + // tab — the tab is your own feeds, the one you last had on) + const own = adhocFeeds.has(curFeedId) ? homeFeedId() : curFeedId; + if (active === 'feed' && ui.msgView === 'feed' && !ui.profilePk && !ui.noteThread && !ui.feedEdit && own === curFeedId) { glideToTop(); return; } leavePage(); - if (visitor) { ui.pubProf = true; openFirehose(); } else showFeed(curFeedId); + if (visitor) { ui.pubProf = true; openFirehose(); } else showFeed(own); window.scrollTo({ top: 0 }); }), button('messages', t('msgDmsTitle'), '', () => { @@ -8060,6 +8065,9 @@ export function messagesFeature(ctx) { h('div', { class: 'row gap6', style: 'align-items:center' }, backBtn(() => { stopFeedWatch(); + // a feed opened from somewhere (a profile's timeline, a #tag, a + // pack link) goes back there — or, reached directly, to yours + if (!visitor && adhocFeeds.has(def.id)) { ctx.goBack(() => { ui.chatOpen = true; ui.msgView = 'feed'; selectFeed(homeFeedId()); }); return; } if (visitor) { ui.chatOpen = false; ui.msgView = null; ui.pubProf = null; } else ui.msgView = 'home'; render(); }), diff --git a/tools/avatar-profile-test.js b/tools/avatar-profile-test.js index 54c40dc..293d7c1 100644 --- a/tools/avatar-profile-test.js +++ b/tools/avatar-profile-test.js @@ -88,6 +88,24 @@ try { const chip = await page.evaluate(() => document.querySelector('.feed-chip.on')?.textContent || null); check('someone’s timeline has a labelled chip', !!chip && /Bob Poster/.test(chip), JSON.stringify(chip)); + // ‹ on their timeline goes back to their profile, not the chat list + await page.evaluate(() => document.querySelector('.feed-page .chat-back').click()); + await sleep(1200); + const backTo = await page.evaluate(() => ({ profile: /bob bio here/.test(document.body.innerText), chats: /Communities/.test(document.body.innerText) && !document.querySelector('.feed-page') })); + check('‹ on someone’s timeline goes back to their profile', backTo.profile && !backTo.chats, JSON.stringify(backTo)); + // ...and from their timeline, the Feed tab is your own feed again + await click('their timeline'); + await sleep(1500); + await page.evaluate(() => document.querySelector('.app-bottom-nav .app-nav-button').click()); + await sleep(1200); + const mine = await page.evaluate(() => document.querySelector('.feed-chip.on')?.textContent || null); + check('the Feed tab brings back your own feed', mine === 'Following', JSON.stringify(mine)); + // back onto their timeline for the save below + await page.evaluate(() => { const r = [...document.querySelectorAll('.notes-feed .note-avatar')].find((n) => n.closest('[data-key]')?.innerText.includes('Bob Poster')); r.click(); }); + await sleep(1000); + await click('their timeline'); + await sleep(1500); + // ⋯ → Save feed: straight into the chips, no editor listing their follows await page.evaluate((l) => document.querySelector('button[aria-label="' + l + '"]').click(), 'Feed options'); await sleep(500); -- cgit v1.2.3