From 0262af2885831f67b7025fff84d4987fed4857c6 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 10 Oct 2026 08:58:02 -0700 Subject: Feed: a mention opens the person, not the post. A tap on @name in a feed post opened their profile and then reached the row, which opened the post's thread on top — Adam had to tap the mention again from inside the thread. The mention stops its tap, and a post's row no longer opens its thread for a tap on any link in it (a mention, a URL, a #tag). tools/feed-mention-tap-test.js (on the old code the tap landed on /nevent1…). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vps2H27rhbG9ZqseGfMrc3 --- src/features/messages.js | 6 +++-- tools/feed-mention-tap-test.js | 58 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 tools/feed-mention-tap-test.js diff --git a/src/features/messages.js b/src/features/messages.js index 35f4712..0a14b9c 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -8225,7 +8225,7 @@ export function messagesFeature(ctx) { } else if (/^(nostr:|@?)(npub|nprofile)1/i.test(part)) { const bare = part.replace(/^(nostr:|@)/i, ''); const ref = parseNostrRef(bare); - if (ref && ref.type === 'pubkey') out.push(h('a', { href: '#', onClick: (e) => { e.preventDefault(); openProfile(ref.pk); } }, '@' + displayName(ref.pk))); + if (ref && ref.type === 'pubkey') out.push(h('a', { href: '#', onClick: (e) => { e.preventDefault(); e.stopPropagation(); openProfile(ref.pk); } }, '@' + displayName(ref.pk))); else out.push(h('span', { class: 'faint' }, bare.slice(0, 12) + '…')); } else if (/^nostr:(note|nevent)1/i.test(part)) { const ref = parseNostrRef(part.slice(6)); @@ -9623,7 +9623,9 @@ export function messagesFeature(ctx) { + (focus ? ';background:var(--accent-soft,rgba(128,128,128,.08));border-radius:' + (joined ? '8px 8px 0 0' : '8px') + ';padding-left:8px;padding-right:8px;margin:0 -8px' : ''), // closest('button') guard: on touch, a ⚡ tap must never double as a // row tap even if propagation quirks let the click reach us - onClick: openable ? (e) => { if (e.target && e.target.closest && e.target.closest('button')) return; openNoteThread(ev); } : undefined, + // nor a link in it: a mention opens the person, a URL its page — the + // thread opening underneath as well buried the profile under the post + onClick: openable ? (e) => { if (e.target && e.target.closest && e.target.closest('button, a')) return; openNoteThread(ev); } : undefined, }, // the avatar is its own tap-target (profile), even inside an openable // row — its handler stops propagation, so the row still opens the thread diff --git a/tools/feed-mention-tap-test.js b/tools/feed-mention-tap-test.js new file mode 100644 index 0000000..e4d3f7a --- /dev/null +++ b/tools/feed-mention-tap-test.js @@ -0,0 +1,58 @@ +// A mention in a feed post opens the person mentioned — not the post's +// thread on top of them (the mention's tap reached the row, which opened +// the thread over the profile it had just shown). Links in a post likewise. +// Run: bun tools/feed-mention-tap-test.js +import puppeteer from './puppeteer.js'; +import { cacheKeyFor } from '../src/wallet.js'; +import { generateSecretKey, getPublicKey, finalizeEvent } from 'nostr-tools/pure'; +import { npubEncode } from 'nostr-tools/nip19'; +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 key = () => { const sk = generateSecretKey(); return { sk, pk: getPublicKey(sk) }; }; +const AUTHOR = key(), FRIEND = key(); +const now = Math.floor(Date.now() / 1000); +const POST = finalizeEvent({ kind: 1, created_at: now - 100, tags: [['p', FRIEND.pk]], content: 'say hello to nostr:' + npubEncode(FRIEND.pk) + ' today' }, AUTHOR.sk); +const html = await buildHtml({ minify: true, pwa: false }); +const server = Bun.serve({ port: 5319, fetch: (req) => { const p = new URL(req.url).pathname; if (p === '/verify-worker.js' || p.startsWith('/punks')) return new Response(Bun.file('dist' + p)); return 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(); +await page.evaluateOnNewDocument(() => { + const Real = window.WebSocket; + window.WebSocket = function (...a) { const ws = new Real(...a); const send = ws.send.bind(ws); ws.send = (d) => { try { const m = JSON.parse(d); if (m[0] === 'REQ') { setTimeout(() => ws.dispatchEvent(new MessageEvent('message', { data: JSON.stringify(['EOSE', m[1]]) })), 0); return; } if (m[0] === 'EVENT') return; } catch {} return send(d); }; return ws; }; + window.WebSocket.prototype = Real.prototype; Object.assign(window.WebSocket, Real); +}); +const errs = []; +page.on('pageerror', (e) => errs.push(String(e))); +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)).includes(x)) return true; await sleep(250); } return false; }; +try { + await page.setViewport({ width: 390, height: 844 }); + await page.goto('http://localhost:5319/', { 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'); + await page.evaluate(([k, a, f, ns]) => { + localStorage.setItem(k + ':follows', JSON.stringify({ tags: [['p', a]], c: '', at: Math.floor(Date.now() / 1000) })); + localStorage.setItem(k + ':feedNotes', JSON.stringify(ns)); + localStorage.setItem(k + ':profiles', JSON.stringify({ [a]: { name: 'Poster', t: Date.now() }, [f]: { name: 'Friendly', t: Date.now() } })); + localStorage.setItem('btc-wallet-feed:' + k, 'following'); + }, [base, AUTHOR.pk, FRIEND.pk, [POST]]); + await page.reload({ waitUntil: 'domcontentloaded' }); + await waitText('Receive', 20000); + await page.evaluate(() => document.querySelector('.app-nav-button[aria-label="Feed"]')?.click()); + check('the post shows the mention by name', await waitText('@Friendly', 15000)); + await page.evaluate(() => [...document.querySelectorAll('[data-zap-post] a')].find((a) => a.textContent === '@Friendly').click()); + await sleep(1200); + const where = await page.evaluate(() => location.pathname); + check('the tap opens Friendly\'s profile, not the post', where.startsWith('/npub1') && !where.includes('nevent'), where); + check('no page errors', errs.length === 0, errs.slice(0, 2).join(' | ')); +} finally { await browser.close(); server.stop(true); } +console.log(ok ? '\n✅ a mention opens the person' : '\n❌ failed'); +process.exit(ok ? 0 : 1); -- cgit v1.2.3