Skip to content

feat(messages): let a plugin sort, filter and page a reader's rows - #3818

Open
LordMelkor wants to merge 34 commits into
mainfrom
lordmelkor/conversation-arrangement
Open

LordMelkor wants to merge 34 commits into
mainfrom
lordmelkor/conversation-arrangement

Conversation

@LordMelkor

@LordMelkor LordMelkor commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Someone reading a 2,000-reply thread today can only scroll replies in arrival order; this PR adds general reader-presentation hooks so a plugin can sort, filter, and page a thread or channel timeline in place while core draws only the chosen rows.

What changes

  • Reader presentation (placement: "reader", arrangement.ts, ThreadPanel.tsx, ChannelTimeline.tsx): lets one mounted reader-bar accessory supply presentation.events and limits, drawing rows with normal controls while retaining other supplied events within bounded headroom for delayed live multi-target deletions, recovering focus cleanly without stealing reader-bar focus, and putting use-reading.ts / unread.ts into partial mode.
  • Stateless relay & tree helpers (relay/session.ts, replyTree): adds foldRows, retain() (1 hold per handle in the 64-slot / 8 MiB pool), snapshotRead(..., { priority }), windowNewer, direction: "newer" thread verification, and replyTree optional parent lookup.
  • Reference caller (tests/fixtures/conversation-arranger/plugin.ts): test fixture sorting Oldest/Newest/Top, filtering by person, and verifying NIP-CW channel page bounds; the production Thread Sort plugin ships outside this repo.
  • Companion & size: works with or without feat(relay): read NIP-CW windows oldest first buzz#9641 (buzz-window-newer; falls back to older pages without it). +8,598 / −192 across 40 files over 078aaaa (prod +1,740 / −166, tests/fixtures +6,858 / −26; FOUNDATION edits in session.ts, contracts.ts, service.tsx, author.ts).

What to decide or check

  • Known limits:
    • Holds share the 64-slot / 8 MiB observe limit (live exact "Top" across ~50,000 replies needs summary/top-candidate tracking or a relay-ranked query); reconnects re-read at background priority after up to 10 s random delay when visible.
    • readPage scan limits (>2,400 channel / >2,000 thread) and 503 busy-thread budgets predate this PR (snapshotRead is the supported scan path); plugin background scans take turns with host missing-parent pages (#3908).
    • Own sends during a presentation may not auto-scroll into view; subthreadId task branch views (#3730) show host rows with no reader bar; Huddle end times (kind: 48103) aren't retained on start-row presentations; rows dated >300 s back arriving after the repair read wait for the next read.
    • unread counts only host-fetched rows (forced-unread state and complete DM read cutoffs now cover held-only rows).
  • buzz-review-completed is not added.

Testing

At b8a3fad (main 078aaaa) on a separate Linux machine:

  • Suites: pnpm typecheck, 785 focused tests across 17 files (broker capabilities, pin management, ThreadPanel, ChannelTimeline, arrangement, reading, and author.test.mjs), and unfiltered vitest (25,941 passed, 0 failed, 39 skipped) pass. At 34d57a4 + 47fa0d6 / e944bdf (PR code unchanged since): tests/browser/message-navigation.spec.mjs (44/44 across Chromium & WebKit) and browser focus probe (12/12 each in Chromium 153 & WebKit 26.6) pass.
  • End-user test: real browser app (34d57a4) against local feat(relay): read NIP-CW windows oldest first buzz#9641 (bf4bd04f2) with a 2,500-reply thread and 3,000-message channel passed 35/35 with zero console or page errors; in packaged Linux Buzz, Thread Sort showed each sort and a 2-person filter within 1.5 s in 27/27 runs on an 800-reply thread.
  • Fix isolation: 39 review fixes verified by isolated revert tests at 674efc4c1; reference plugin enforces NIP-CW bound verification per channel lane.

Core changes

Each core change keeps feature logic in plugins and adds only the smallest general hook:

Change Necessity Minimality
session.foldRows(channelId, events, rootId?) Access/visibility (canAccess, eventVisibility), proof checks, and the 650-line fold (relay/fold.ts) are private to core. Stateless function returning ChannelMessage rows; no cache, reads, or view.
session.retain() → { set, dispose } Live reactions/edits/deletions fail visibility without known targets, and edit/react/read/copy checks miss unshown snapshotRead rows. One evidence hold per handle in the existing 64-slot / 8 MiB pool; grants no access.
snapshotRead(filters, { priority }) Background scans contend with foreground user reads; readRemote feeds all open views. Exposes existing ReadOptions.priority (relay/reader.ts:13-16; 1 line + type).
session.windowNewer Only host transports read NIP-11 (buzz-window-newer). Boolean beside searchSort, set by both hosts.
direction: "newer" thread verification Reader rejects newer thread pages today. Binds direction and forward cursor into existing verification.
placement: "reader" accessory (present, presentation, limits) Existing accessories mount only in composer/message/response slots. Reuses accessory boundary and revocation; first presenter wins, others get held.
Presentation host (arrangement.ts, ThreadPanel.tsx, ChannelTimeline.tsx) Plugins lack scroller, read-state, row-component, and multi-target deletion evidence access. Pure functional core + thin shell; draws presented rows, retains heldEvidence within headroom, recovers focus safely, disables conflicting host chrome, restores omitted link targets.
replyTree(rows, rootId?, displayParent?) Display nesting goes through the reader's tree builder. Optional parent lookup keeping cycle/unknown/earlier-row guards.
Partial reading (use-reading.ts, unread.ts) Non-complete presentations must mark only viewed rows read; held-only rows need manual unread state and DM cutoff updates. Adds partial lease input (collapsed branches force partial), surfaces held-only forced unread, and updates DM cutoffs.
Prior review answers, largest files, reference fixture details, test doubles, timings, and related PRs

Answers to prior reviews

  • e944bdf5a (review 6009665684): added heldEvidence within bounded headroom for delayed live multi-target deletions, plus focusRecoveryTarget, usePresentedFocusRecovery, and collapsed-branch summary recovery (scoping :scope > [data-layout] in ReplyBranch.tsx to collapsed summaries so existing reply/thread-line handoffs keep main's outer row target).
  • ed88f57a6: extracted pure functional core (selectEvidence, applyLiveEvents, allEvidence, readerMode), excluded root aux from limits, preserved multi-target deletion targets, admitted verified pending-send echoes, downgraded display.complete without bumping revision, kept ThreadPanel editMessages chronological, settled reading on paused legacy traversal, included held events in copiesOf and DM cutoffs, surfaced forced-unread for held-only rows.
  • 11f4a8cc3 (fixed at 6de6e4688): removed host window admission and channel-bound checks so main reads are unchanged when no plugin is installed; restored omitted message-link targets; treated collapsed-branch presentations as partial; added 960 s repair read; rebased onto block/buzz-app#3552.
  • Replaces block/buzz-app#3660: dropped registerArranger / loadAll in favor of mounted reader accessories.
  • 674efc4c1: added per-lane signed bound verification (h + d tags, forward cursor, has_more agreement) in the reference fixture.

Largest production files & architecture notes

  • arrangement.ts +837, ThreadPanel.tsx +237 / −46, ChannelTimeline.tsx +176 / −32, session.ts +120 / −9, unread.ts +75 / −30.
  • readerMode(display) drives presented, chronologicalChrome, hostNavigation, and partialReading from one source of truth.
  • snapshotRead returns raw relay bounds so plugins verify author/tags themselves.

Reference fixture (tests/fixtures/conversation-arranger/plugin.ts)

  • Top (distinct reactors) & Oldest sorts, text filter preserving position on change/clear, Next/Previous past 460/2,400 limits, More, Buzz order, ended recovery, 960 s repair read, 503 by-id fallback, staged live updates, reconnect re-read while visible, and oracle comparison on a 2,000-reply thread and 5,000-row channel.

End-user timings & test doubles

  • At 620c02aaf (relay 80036cc8c): Oldest loads 1–200 in ~1.0 s and pages to 2,401–2,500 in 0.4–1.0 s/page; Top ranks 2,500 replies in 3.1 s; reaction re-ranks in ~0.3 s; reconnect recovers in 9.3 s; busy-thread 503 fallback matches oracle rows 1–134 of 2,529. Bundled with a test-only browser-catalog shim.
  • 49 test doubles on added lines copy existing patterns in ThreadPanel.test.tsx, ChannelTimeline.viewport.test.tsx, and use-reading.test.ts.
  • Earlier per-head checks are in the top comment.

Related PRs

Made with human guidance from the maintainer driving this work.

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This needs a human maintainer's review: it comes from outside the core maintainer group, and it changes what readers see. A design or core-team reviewer should look at it.

I looked at the relay and session core and at the reader and plugin contract. I found no P0 or P1 issues. retain().set checks access on set and again on every access purge. Holds need admission proof. Newer-direction pages and 39006/39007 window bounds are verified. foldRows matches the reader's fold. The snapshotRead priority passes through. With no reader accessory, the default reader path is unchanged as far as I traced it.

Inline: two P2s (hold evidence reaching unread's structural lookups, and the hold memory/slot bound) and one P3 (Back/Forward saving a presented row as the anchor).

Two more P3s:

  • unread.ts (~2500): requireMessage accepts held-only evidence, but prepareThreadRead and markCapturedMessagesRead still validate with events.get(...). Those mark-read actions never apply to held-only rows.
  • ChannelTimeline.tsx (~382): presented rows skip withoutStartingAgents before membershipRows. In a Solo chat, the owner's starting-agent join and remove notices come back if a plugin includes them.

Not covered: I ran no tests or visual checks. I only skimmed the test bodies and the reference plugin fixture. I didn't measure the per-frame refold cost.

Comment thread src/features/relay/unread.ts Resolved
Comment thread src/features/relay/session.ts Resolved
@LordMelkor

LordMelkor commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Head b8a3fad merges main 078aaaa (#3993, #4270, #4253) into 34d57a4 and changes no PR code: resolved the single conflict in browser-host/relay-broker.mjs (relayAuthority) by keeping both windowNewer and main's pins capabilities; the net PR diff over main is unchanged (+8,598 / −192 across 40 files).

Checked on a separate Linux machine at b8a3fad (on main 078aaaa): pnpm typecheck, 785 focused tests across 17 files (including browser-host/relay-authority.test.mjs, browser-host/relay-broker.test.mjs, MessageManagement.test.tsx, ThreadPanel.*, ChannelTimeline.*, arranger-plugin.test.tsx, and author.test.mjs), all four broker /api/relay/session combinations of relay signing identity and buzz-window-newer, and unfiltered vitest run (25,941 passed, 0 failed, 39 skipped) pass. CI is running on b8a3fad.

Earlier, head 34d57a4 merges main e5a9b4f (#4211, #2953, #2920, #4222, #4213) into e944bdf and changes no PR code: outside docs/, the diff is the same as at e944bdf. #4213 removed docs/plugin-architecture.md and shortened docs/buzz-help.md, so this PR's two doc additions are dropped, and the reader contract is documented on the exported types in contracts.ts.

Checked on a separate Linux machine at 34d57a4 (on main e5a9b4f): pnpm typecheck, the pre-push type/test lane (11,498 passed, 29 skipped), design-system and rust-clippy checks pass; full vitest run: 25,573 tests in 1,196 files pass, 39 skipped (including ChannelTimeline.restore.test.tsx 197/197 and author.test.mjs 1/1); end-user test against a local relay from block/buzz#9641 at bf4bd04f2: 35/35 pass, with no console or page errors. At e944bdf (PR code unchanged since): tests/browser/message-navigation.spec.mjs: 44/44 pass (22/22 each in Chromium and WebKit); browser focus probe: 12/12 pass each in Chromium 153 and WebKit 26.6. CI: 77 checks pass, 1 skipped.

Earlier, head e944bdf adds one commit ("fix(messages): keep ReplyBranch messageRef focus target for existing navigation") on e1527f2. It restores main's focus target for the existing reply and thread-line handoffs in ReplyBranch.tsx. e1527f2 had moved them to the inner message box, and message-navigation.spec.mjs failed in Chromium and WebKit. Only the new collapsed-summary handoff targets the message box, so arrow-key selection works after it.

Checked on a separate Linux machine at e944bdf (on main 352f46e): pnpm typecheck and the type, design-system and rust-clippy checks pass; full vitest run: 25,556 tests in 1,194 files pass, 39 skipped; tests/browser/message-navigation.spec.mjs: 44/44 pass (22/22 each in Chromium and WebKit); browser focus probe: 12/12 pass each in Chromium 153 and WebKit 26.6. Automated review: 0 findings on the range from ed88f57 to e944bdf. CI: 77 checks pass, 1 skipped, after one rerun of Browser journeys (webkit, 12/18) (attempt 1 failed on tests/browser/solo-rename.spec.mjs:838, which timed out waiting for aria-current="page" after clicking a plugin-owned Solo sidebar row; this PR does not change Solo regions or sidebar navigation, and it passed on rerun).

Earlier, head e1527f2 adds one commit ("fix(messages): preserve deletion candidates and recover focus in presentations") on ed88f57, addressing both blocking findings from review 6009665684 and clarifying ConversationPresentation.events TSDoc.

  • Live multi-target deletion (arrangement.ts, contracts.ts): retains other supplied presentation.events within bounded headroom as deletion evidence via heldEvidence, preserves prior held targets across same-owner re-presents, and ends cleanly rather than silently evicting held candidates when live growth exceeds limits.
  • Focus recovery (arrangement.ts, ReplyBranch.tsx, ChannelTimeline.tsx, ThreadPanel.tsx): added focusRecoveryTarget, usePresentedFocusRecovery, and collapsed branch summary removal recovery so removing a focused row or branch summary moves focus to the nearest surviving selectable row's [data-layout] box (or history scroller) without stealing reader-bar focus or intentional blurs.

Checked on a separate Linux machine at e1527f2 (on main 352f46e): pnpm typecheck and the type, design-system and rust-clippy checks pass; full vitest run: 25,556 tests in 1,194 files pass, 39 skipped; browser focus probe: 12/12 pass each in Chromium 153 and WebKit 26.6; end-user test against a local relay from block/buzz#9641 at bf4bd04f2: 35/35 pass, with no console or page errors. Automated review: 0 findings on the new commit. CI: two browser shards failed in message-navigation.spec.mjs; fixed in e944bdf.

Earlier, head ed88f57 rebased onto main 352f46e and separated the presentation functional core (EvidenceState, allEvidence, selectEvidence, applyLiveEvents, readerMode in arrangement.ts) from its shell, while fixing ThreadPanel chronological editMessages, suppressed arrival counting and settled reading boundaries while presented, held-only copy/forced-unread/DM-cutoff handling in session.ts and unread.ts, and reference-fixture scan bounds. Checked on a separate Linux machine at ed88f57: pnpm typecheck and the type, design-system and rust-clippy checks pass; full vitest run: 25,547 tests in 1,194 files pass, 39 skipped; end-user test against block/buzz#9641 at bf4bd04f2: 35/35 pass, with no console or page errors; automated review found 0 issues in arrangement.ts, ThreadPanel.tsx, session.ts, or security/contracts. CI: 77 checks pass, 1 skipped.

Earlier, head 3edff25 adds one commit on 91aa4d2, "test(arranger): discard a channel page with a surplus bound or extra tags", which answers the second review of the reference fixture. It changes only the reference fixture and its tests (2 files, +35 / −9), with no production lines. A channel page is now taken only when the answer holds exactly one bound per requested lane and no others, and each channel bound carries exactly its d and h tags (NIP-CW §Channel-mode Client Behavior, step 5). Two new rows in "fails the scan on …, and leaves the host's rows" cover a surplus bound for a cursor nobody asked for and a bound with an extra tag; both fail with 91aa4d2's plugin.ts and pass here.

Checked on a separate Linux machine at 3edff25: pnpm typecheck and the type, design-system and rust-clippy checks pass; full vitest run: 25,443 tests in 1,194 files pass, 38 skipped; the end-user test against a local relay from block/buzz#9641 at cec39df69 passes 35/35, with no console or page errors. An automated review of the new commit found nothing. CI: 77 checks pass, 1 skipped.

Current main: 22 commits on main since this PR's base e901df9 change 15 of its files, among them src/features/conversation/contracts.ts, src/features/conversation/service.tsx, src/features/messages/ThreadPanel.tsx and src/features/relay/session.ts. The merge with main 352f46e is clean. On a separate Linux machine, the merged tree passes pnpm typecheck and full vitest run: 25,539 tests in 1,194 files pass, 39 skipped.

Earlier, head 91aa4d2 adds one commit on 674efc4, "test(arranger): check each channel page's bounds before taking the page", which answers the review of 674efc4. It changes only the reference fixture and its tests (3 files, +157 / −26), with no production lines. The reference plugin now takes a channel page only when exactly one relay-signed bound answers each requested lane, with h and d tags that name the channel and the exact request, and a well-formed cursor that agrees with has_more and moves forward. These are the rules parseWindow applies in src/features/relay/window.ts. The host reader already checks thread bounds (verifyThreadWindows, src/features/relay/reader.ts:216) before a plugin sees them. The new table test "fails the scan on …, and leaves the host's rows" (arranger-plugin.test.tsx) covers five cases. With 674efc4's plugin.ts, the four channel cases fail: three never reach the failed-scan status and time out, and the stalled cursor keeps the scan running until the run is stopped at 120 s.

Checked on a separate Linux machine at 91aa4d2: pnpm typecheck and the type, design-system and rust-clippy checks pass; full vitest run: 25,441 tests in 1,194 files pass, 38 skipped; the end-user test against a local relay from block/buzz#9641 at cec39df69 passes 35/35, with no console or page errors. An automated review of the new commit found nothing. CI: 77 checks pass, 1 skipped.

Earlier, head 674efc4 was this change rebased onto main e901df9, plus one fix. GitHub showed conflicts with two PRs that merged today. #3730 (task branch views, subthreadId) conflicted in two places in src/features/messages/ThreadPanel.tsx. Both keep main's rule that a branch view marks only the rows on screen, and this PR still reads the rows it shows. #3876 (signed invocation intent) replaced a helper in src/features/relay/threads.ts next to this PR's inChannel export. Main's change is kept, and no code here changed.

The new commit, "fix(reader): leave an invocation branch's rows to the host", starts no arrangement in a branch view. That view's root is the invocation message, and the reader bar can't tell a plugin it is in a branch, so a presentation there could show rows from outside it. A branch view now has no reader bar and shows main's rows. The new test "leaves an invocation branch to the host's rows, with no bar" (ThreadPanel.arranger.test.tsx) passes, and fails when the fix is reverted. The GitHub diff is now 41 files, +7,426 / −177.

Verified on a separate Linux machine at 674efc4: pnpm typecheck and the type, design-system and rust-clippy checks pass; full vitest run: 25,436 tests in 1,194 files pass, 38 skipped; fix isolation: each of the 39 fixes checked here, the new one included, fails its test when reverted on its own; end-user test by the maintainer's agent against a local relay from block/buzz#9641 at cec39df69: 35/35 checks pass, with no console or page errors. Automated review: 7 P2s, none on a line the rebase or the new fix touched. CI: 77 checks pass, 1 skipped, after one rerun. One WebKit browser test, tests/browser/right-pane-dismissal.spec.mjs:85 (GitHub visits through history and reload), failed on the first run when its Close click after a reload didn't take effect, and passed on the rerun. This PR doesn't change the panel workspace or the GitHub view. On a separate Linux machine, that test then passed 60 of 60 WebKit runs at this head and 60 of 60 at main e901df9.

Earlier, head b635ad6 was the same change on main 6ba83fa, before #3876 merged. It passed the same checks on a separate Linux machine. CI: 76 checks pass, 1 skipped; the one failure was a repeat of a plugin settings browser test in the flake check (1 of 10 WebKit runs), which this PR does not change. Both required checks passed.

Earlier, head c44c517 was the same change rebased onto main d9c4672, for a conflict with #4116 in src/features/relay/session.ts (it rewrote the comment above isProfileFilter, next to this PR's RETAIN_MAX_BYTES; both are kept). Checked there on a separate Linux machine: the same lanes, 25,332 tests in 1,191 files (38 skipped), the 38 fix reverts, and the end-user test (35/35). CI: 77 checks pass, 1 skipped.

Earlier, head 2339eb8 was one test-only commit on cf121aa (src/features/messages/arranger-plugin.test.tsx, +4 / −1).

  • Hidden-tab reconnect test: "reads the whole thread again after a reconnect once it is visible, and is not exact until it has" previously waited 20 ms of real time to check that no read starts while the tab is hidden. It now turns on fake timers (setTimeout, clearTimeout) around the reconnect and advances them 10 s (the reference plugin's full reconnect jitter window), so the check no longer depends on real time. The file's afterEach now also restores real timers, so a failing check can't leave fake timers on for later tests.

Verified at 2339eb8: arranger-plugin.test.tsx passes 29/29, the updated test passes 5/5 runs, and removing the reference plugin's hidden-tab check fails it ("expected 13 to be 11"). Automated review: the first pass found one P2 (a failing check could leave fake timers on), fixed by the afterEach reset; the second pass found nothing. CI: 77 checks passed, 1 skipped. Everything else (full vitest run and end-user checks) is unchanged from cf121aa.

Earlier, head cf121aa rebased onto main 418d0c0 (GitHub showed conflicts with main), plus two small changes and two test cleanups.

Verified on a separate Linux machine at cf121aa (on main 418d0c0): pnpm typecheck, type/design-system/rust-clippy checks pass; full vitest run: 24,917 tests in 1,194 files pass, 36 skipped; fix isolation: reverting any of the 41 review fixes alone fails its test; end-user test by the maintainer's agent against a local relay from block/buzz#9641 at cec39df69: 35/35 database-oracle checks pass, with no console or page errors.

Earlier, head 620c02a rebased onto main 23e1dee with #3908 and #3987.

Earlier, head 6de6e46 answered the review of 11f4a8c (5 inline findings fixed, each replied to on its thread; core-fit answer in its own comment).

  • Unchanged host reads without a plugin: removed window admission, the reader's channel-bound check, and the reader target prop. Production code is +1,169 / −152.
  • Message links: links to rows omitted by a presentation restore the reader's rows and reveal the target.
  • Collapsed replies: a presentation with a collapsed branch is treated as partial.
  • Reference plugin: stages live updates and keeps them only when the hold accepts; re-reads late rows before marking an oldest-first scan exact; re-presents as non-complete on disconnect.
  • Rebased onto feat(read-state): sync read state and thread follows per NIP-RS #3552: a presentation passes its last drawn row as latestMessageId and newest row as catchUpMessageId (removing endMessageId). A list that turns partial keeps its reading visit so a manual unread stays until the reader leaves.
  • Known limits: added five items — read marks on held-only rows, live rows >300 seconds before live subscriptions opened, held-only sent-to-channel copies, stale presentations until re-presented, and Huddle rows.

Earlier, on the two P3s in the ea81886 review body:

  • Mark-read paths: fixed. markCapturedMessagesRead and prepareThreadRead now use the same lookup as requireMessage, covering held-only rows (tested for a captured read, a thread mark, and a thread read of a held reply under a held root).
  • withoutStartingAgents: kept as-is intentionally. A presentation displays the exact rows a plugin chose; the start-of-chat rule relies on Buzz order and chat start, neither of which applies here. Plugins can omit membership notices (the reference plugin reads kind 9 only at tests/fixtures/conversation-arranger/plugin.ts:169).

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Follow-up on ea81886: no findings.

  • Holds and unread: structural is back to counted and fetched events only. The new placing lookup reaches held events only on the paths that place a named read or unread mark: requireMessage, viewed rows, captured reads and thread reads. markCapturedMessagesRead and prepareThreadRead now validate with knownEvent, so held-only rows can be marked.
  • Back/Forward: both readers skip the saved place while a presentation shows, and each has a test for it.
  • Hold bound: agreed. It has the same contract as observe on main: the same 64 slots, the same per-view 8 MiB bound, and no owner scoping. A shared budget belongs in a separate change that covers both. Listing it as a known limit in the description is enough here.
  • Starting-agent notices: the reasoning holds. A presentation shows exactly the rows the plugin picked.
  • 3858e11 (one reader accessory at a time, nothing kept while held): the docs and PresentResult now say a held accessory has to present again once presentation is none. That matches free().

This still needs a human maintainer's review: it comes from outside the core maintainer group, and it changes what readers see.

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Follow-up on e43abec, which only changes tests. Both changes hold up. hostRows now waits on the panel's aria-busy={positioning} on "Thread messages", replacing the 300 ms quiet-read loop. The withdraw test now states the fixture's case outright, that the host doesn't show the reading row, instead of recomputing nearestShown. If no row below is shown, near is undefined and the assertion fails rather than passing vacuously. I have no new findings.

This is a comment, not an approval. The PR comes from outside the core maintainer group and changes what users see, so a human maintainer from the core or design team needs to review it.

@LordMelkor
LordMelkor requested a review from a team November 18, 2026 16:47
@LordMelkor
LordMelkor force-pushed the lordmelkor/conversation-arrangement branch 2 times, most recently from 0a38477 to a088b93 Compare November 18, 2026 21:29

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Follow-up on e43abec. My last review left nothing open. The feature commit was rebased onto main with no content change, and three test and cleanup commits were added:

  • 8192149 drops comments and redundant return types. Its retain() docs note matches the JSDoc it removed.
  • 31ba35d drops the raised test timeouts.
  • a088b93 finds thread rows by tag name.

None of them change behavior. In a clean worktree the touched suites pass without the raised timeouts: 11 files, 559 tests. The touched directories have no tsc errors, and biome reports only infos.

This needs approval from a human maintainer.

@LordMelkor
LordMelkor requested a review from a team November 19, 2026 03:59

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Follow-up on a088b93. My last review left nothing open. Five new commits since then, with no rebase. They touch only:

  • the reference arranger plugin fixture and the fixture relay;
  • the plugin guide and tests;
  • the root_aux removal in relay types and thread binding.

No new problems. The new 503 fallback, the paged #e aux reads and the 9005 handling match fold.ts and threads.ts. A new test fails if the fallback is skipped. The messages, relay and tests suites pass locally (281 files, 7,414 tests), the touched directories have no tsc errors, and biome reports only infos.

This needs approval from a human maintainer.

@LordMelkor
LordMelkor requested a review from a team November 19, 2026 07:44

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Star Lord reviewed 11f4a8c from source. Please fix the live-reply and unread regressions inline. The arranger is a test fixture, and the core team should decide whether in-place arrangement warrants the proposed reader and relay-session APIs.

Comment thread src/features/relay/threads.ts Resolved
Comment thread src/features/messages/ThreadPanel.tsx Resolved
Comment thread src/features/messages/ThreadPanel.tsx Resolved
@LordMelkor
LordMelkor requested a review from a team November 19, 2026 16:45
@wesbillman

Copy link
Copy Markdown
Collaborator

🤖 Carl, an automated reviewer, commenting via Wes's GitHub account. Reviewed at 11f4a8c.

On the core-fit question: I don't think the reader presentation belongs in core in this shape.

  • placement: "reader" with present() adds a second mode to ThreadPanel and ChannelTimeline. Partial reads, saved place, paging, day dividers and row merging all branch on whether a plugin is presenting, plus the new arrangement.ts. Any future change to those behaviors has to cover both paths. The collapsed-reply unread finding in the review above is an example of that cost.
  • The only consumer in this PR is a test fixture. The 8 MiB hold limits an exact live Top to roughly a few thousand replies, depending on event volume. Exact ranking at scan time still works past that bound, but live updates then reach only the held rows.
  • The admission changes run with no plugin installed. The late-clock live-reply finding comes from the thread-window gate in threads.ts. store.ts changes channel admission separately.

The general pieces (snapshotRead priority, windowNewer, maybe foldRows) are small and could land separately once a plugin or host caller needs them. Whether threads should get sort and filter at all is a product call. If they should, a host sort of loaded rows is smaller, as long as results limited to the loaded window are acceptable. For an exact whole-thread Top at scale, I'd start with a relay-ranked query and keep rendering in the host.

@LordMelkor
LordMelkor force-pushed the lordmelkor/conversation-arrangement branch from 11f4a8c to 6de6e46 Compare November 19, 2026 20:50
@LordMelkor

LordMelkor commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 @wesbillman — following up on your core-fit comment for a yes/no from the core maintainers:

Someone reading a 2,000-reply thread sorts the replies by reactions or filters to one author, reads the result in the thread itself, and stays at the same reply when they clear the filter. Will core take in-place reader placement (placement: "reader" with present(), drawing a plugin's rows in ThreadPanel and ChannelTimeline)?

  • After review cuts: production code is +1,169/−152 lines (removed window admission, the reader's channel-bound check, and the reader target prop). With no plugin installed, host reads work as on main. The only caller stays the test fixture tests/fixtures/conversation-arranger/plugin.ts.
  • If no: without reader placement (leaving roughly 330 lines of read hooks, alongside block/buzz#9641), a plugin shows its rows only in its own panel beside the thread — losing reading in place, keeping place after clearing a filter, read marking of viewed rows, and the thread composer.

On your three points, at 6de6e46:

  1. The second mode. The reader disables paging, the unread line, the saved place, day dividers, and row merging while a presentation shows, because each assumes a contiguous time-ordered window (e.g., host paging on a three-row filter would page the host window for rows not shown). A follow-up could fold roughly half these branches into a shared window object filled by either mode; this PR leaves that out. The collapsed-reply issue is fixed by treating a presentation with any collapsed branch as partial.
  2. Test-fixture caller and 8 MiB hold. The 8 MiB bound is per hold, and scan-time ranking does not depend on it: foldRows is stateless, so a plugin can keep compact summaries of all rows and hold only top candidates. Live updates then reach only held rows, which the PR body lists under Known limits. A relay-ranked query would help a live Top at that scale, and a plugin would still need reader placement to show its pages inside the thread.
  3. Admission with no plugin installed. Removed. threads.ts (thread-window gate), store.ts (channel admission), and the reader's channel-bound check now match main. The reference plugin uses snapshotRead, which touches none of those paths, and checks session.relayAuthor itself. The new session methods are no-ops until called, and reader branches run only while a presentation shows.

A host sort of loaded rows or a host-rendered relay-ranked query puts the sorting feature in core. Keeping policy in the plugin (which sorts exist, what filters match, paging, and wording) lets core render only the rows the plugin chose. The PR body lists each hook and why a plugin cannot replace it today.

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This follows up my last review. Of the three earlier threads, two are fixed in code: hold evidence moved into structural, and ChannelTimeline and ThreadPanel now guard against saving a Back/Forward place while a presentation is open. The third, the per-handle hold budget, was agreed to be shared with observe and left for a separate change.

The ten new commits remove the window-admission gate. threads.ts now only extracts growAux, and the aux-closure result matches the old loop. The commits also:

  • withdraw a presentation so a link target it omits can be shown
  • treat collapsed branches as partial for reading
  • catch up through catchUpMessageId
  • keep the reading visit when a list becomes partial

I found no new issues. The messages, relay, conversation, tests and plugins suites pass (7,923 tests). One failure, in src/plugins/author.test.mjs, came from my local environment: its inner pnpm install aborts without a TTY. The touched directories have no tsc errors.

Notes for maintainers:

  • This adds a plugin API for reader rows and touches FOUNDATION files (conversation/contracts.ts, conversation/service.tsx, relay/session.ts, plugins/author.ts), so it needs core-team review. Your question about whether this fits core is still waiting for an answer from them.
  • It conflicts with main in src/features/messages/ThreadPanel.tsx, so it needs a rebase.
  • It comes from outside the core maintainer group, so a human maintainer still needs to review it.

@LordMelkor
LordMelkor force-pushed the lordmelkor/conversation-arrangement branch from 6de6e46 to 620c02a Compare November 19, 2026 22:59
@LordMelkor
LordMelkor requested a review from a team November 19, 2026 23:00

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This head is a rebase onto main. The only changes to the PR's own diff are one line in ThreadPanel.tsx, where main's lineRow replaces unreadBoundary in the !presented && !parent guard, and the withdraw test, which now holds the reads after withdraw to allow for main's background paging. That test passed 5 of 5 runs, and the ThreadPanel tests pass (182). My earlier review still applies. This needs core-team review for the FOUNDATION files and an answer on whether it fits core. It comes from outside the core maintainer group, so a human maintainer still needs to review it.

@LordMelkor
LordMelkor requested a review from a team November 19, 2026 23:51
@LordMelkor

LordMelkor commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 A real plugin now uses the reader hooks raised in comment 7016004596: Thread Sort, an internal plugin that uses placement: "reader" with present() from this PR and the oldest-first windows from block/buzz#9641. The fixture stays as the test caller in this PR.

  • What it does: In a thread, it sorts replies Oldest first, Newest first, or Top (one vote per person who reacted, older first on ties), filters to any number of people with optional nearby replies, and offers Show in context. Clearing the filter keeps the reader's place, and results cover the whole thread rather than only loaded replies.
  • Speed in packaged Buzz (on a separate Linux machine): On an 800-reply thread, each sort and a two-person filter showed within 1.5 s in 27 of 27 runs. On a 2,000-event thread, runs finished within 3 s in 14 of 14 runs.
  • The hold limit raised in the review: When Buzz refuses part of a large thread, the plugin's bar says "Replies may be out of date" with Refresh. A packaged check with Buzz's live views filled showed that line; ranking at scan time still covers the whole thread.

@LordMelkor
LordMelkor force-pushed the lordmelkor/conversation-arrangement branch 4 times, most recently from b635ad6 to 674efc4 Compare November 20, 2026 23:37

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 :bot: Jude’s code review agent

⚠️ Needs a desktop and mobile check before merge
Client relay contract: NIP-11 buzz-window-newer enables direction:"newer"/after window reads; check the desktop reader and mobile compatibility against a capable relay and a pre-capability relay (block/buzz#9641).

Verdict: COMMENT — recommend request changes for the concrete finding below. This repository reserves the Request Changes review action for human reviewers.
Reviewed: 94a4f42e89ec7dca6bf1f18495796a4136ecb604..674efc4c13af3e1566e56b8f6a50150f323f3e01 (exact head 674efc4c13af3e1566e56b8f6a50150f323f3e01).
Risk: high — signed window bounds drive whole-thread/channel completeness and the presented read state.

Blocking finding — validate each channel-window bound before accepting its page. In tests/fixtures/conversation-arranger/plugin.ts:245–276, pages() filters signed kind-39006 events by author and then chooses the first body matching the requested direction. It does not bind that event to the channel and the exact requested head/cursor (h and d), enforce one bound per requested lane, validate cursor shape and forward progress, or check that has_more agrees with next_cursor. A stale or mixed signed bound can end a scan early (pages() returns null and scanAll() marks it complete) or repeatedly request a page. The existing host channel reader rejects these cases in src/features/relay/window.ts:54–101; the reference plugin should uphold the same window contract. Author action: check each bound's tags and response cardinality against the corresponding request, reject malformed/contradictory/non-advancing cursors before keep() or advancing, and add regression tests for swapped/duplicate bounds, contradictory has_more, and a stalled cursor.

Product/UI evidence: Source tests at this head cover 2,000-reply Top ranking, pagination beyond 460 rows, edited-text filtering, older-only fallback, and reader-place restoration (src/features/messages/arranger-plugin.test.tsx:328,612,640,800,818; ThreadPanel.presentation.test.tsx:721; ChannelTimeline.presentation.test.tsx:623). No separate source-proven UI blocker. These are inspected tests, not an independently witnessed native journey.

Validation: Hosted checks for this head reported success for JavaScript/Rust, Chromium/WebKit browser journeys, and required CI; Windows native validation was skipped. The PR author reports a Linux/browser local-relay oracle at this head; that is author evidence, not independent validation. An independent full package run was not completed in this review. No native desktop/mobile behavior was independently exercised.

Verification owner: author for the bound-validation fix and adversarial tests; reviewer/tooling for re-review and independent full package validation at the next head; desktop/mobile release verification for the relay compatibility gate. For desktop, exercise the actual installed Thread Sort plugin in Tauri against #9641's capable and pre-capability relay with a 2,000-reply thread: Oldest/Top, filtering/clearing, paging, Show in context, focus/anchor, keyboard/screen reader, and error/Retry; capture NIP-11 and emitted window requests. For Flutter iOS/Android, smoke channel/thread paging and read/unread state against both relays and confirm no newer-direction request from the legacy client.

Residual risk: Native UX and relay-skew behavior remain unproven. The reference test fixture has no Show-in-context journey and no asserted failed-scan/Retry state in the inspected tests; those are confidence gaps, not additional author-actionable findings here. Re-review after the author's change; no clearance carries to a new head.

LordMelkor and others added 21 commits November 21, 2026 19:49
Read replies' aux in the channel by #h, plus kind 5 and 9005 deletions
that carry no h tag, hold each page as it arrives so a live deletion of
an event already read is kept, and remember a root's refusal only after
its fallback page completes. Follow kind 9005 live.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
…avy root's

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
…an h-less one in the fallback

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
A thread view dropped live and replayed replies older than its oldest
page, so a reply from a skewed clock, or one sent while the client was
away, never showed. Mark every subscription delivery as streamed and
pass that to session observers; only finite reads (readPage and
snapshotRead scans) stay limited to the view's window.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
…s row by row

When a presentation leaves out the message a link or inline reveal
opened, the reader now withdraws it once per request, so the host
reveals the target. A presentation made after the target was revealed,
or a second one that leaves it out, stays, and the visit completes.
Background and returning visits never withdraw.

A presentation with collapsed branches leaves rows out, so reading
stays row by row until every branch is open.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
The reference plugin added live rows to its cache before the session
accepted the hold, so a refused hold left the cache over its bound and
every later hold failed. Stage them until the hold accepts. Stop and
release the scan when the reader takes its rows back.

Before a scan counts as exact, read the conversation's messages again
from the first page's time less NIP-CW's 960 s allowance, so a row that
commits behind the walk's cursor is found. The fixture relay now serves
plain message reads with since, and stamps bounds with its clock.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
…s it

The arranger reads through snapshotRead, which never reaches the views'
accept paths, so the admission changes served no caller in this change.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
A plugin that wants a row shown asks for it with place { id }; the reader
already reveals the row a link opens. The fixture now keeps the reader's
place when the filter changes and starts at the top for a new sort.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
The reader checked every channel window's bound, including the host's
own reads, which the channel store already parses. A plugin reading
through snapshotRead gets the bound as the relay sent it and can check
its author against session.relayAuthor itself, as the reference plugin
now does. The docs say so, and say what a readPage scan does to the
host's open views now that their admission is main's.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
The heavy-root test deletes two top replies, then picks the reply with
the most reactions on the paused page and deletes those reactions too.
When it picked one of the two already deleted, the second deletion
changed nothing and the test's own precondition failed, about one run in
five. It now picks among the replies it keeps.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
#3552 added `catchUpMessageId` to `useReading`: the bottom
row earns the dwell and catch-up reads through another row. That is what
`endMessageId` did for a presentation, inverted. A presentation now passes
its last drawn row as `latestMessageId` and its newest row as
`catchUpMessageId`, so `useReading` has no prop of its own for it. The
channel's catch-up row under a presentation is its newest top-level post,
as main's rule is for the host's rows.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
A presentation turns partial when a branch collapses, when it starts or
ends, and when it stops being whole. Restarting the reading effect then
ended the visit, which drops a manual unread's protection from #3552.
The effect now reads partial when it takes a lease, and a flip replaces
only the leases.

The reference plugin also presents again when its connection drops, so
a thread it showed whole is no longer complete while it may be missing
rows.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
…pages

Main's #3908 pages back toward a missing parent in the background, and
every read in the channel feeds the open thread view. So the host's rows
at a withdraw vary from run to run (175 to 256 in 20 runs), and its
older pages keep landing after it.

The test now takes the reader's row from the rows shown at the withdraw.
It holds every read that starts after the withdraw, so the host's pages
stop at a fixed point. A refresh would still be recorded, because a
requested read aborts a held parent page. The test checks that no
foreground read and no first-window re-read came after the withdraw.
The reader stayed on the same row at the same offset in all 20 runs.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
Withdrawing a lane that was neither shown nor held changed nothing, but
still notified every subscriber, so each unmount of an accessory that
never presented woke them all.

The row bound is now tested against a limit of two rather than a copy of
the thread reader's 460, which the plugin test already pins. Two test
names now say only what their tests check.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
A presented channel or thread lists every row it shows, so it folds no
agent activity. Relayed runs fold through the same disclosures, but they
were grouped from the host's own rows: a channel folded presented rows
under groups from its chronological window, and a thread folded the
plugin's rows in the plugin's order. Both now take the same rows as
activity, which are none while a presentation shows.

The subscriber test also pins the notification when a held lane withdraws.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
… ms wait

The reconnect test proved that no read starts while the tab is hidden by
waiting 20 ms of real time. Advance fake timers through the reference
plugin's whole 10 s jitter window instead, so the check does not depend
on real time.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
#3730 lets a plugin workspace open one invocation branch of a
thread (`subthreadId`). That view's root is the invocation message, not the
thread root, and its rows are only that branch. The reader bar gives an
arranging plugin no way to tell, so a presentation there would show rows
from outside the branch. A branch view now starts no arrangement: no reader
bar, and the host's rows as main shows them.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
The reference plugin took the first relay-signed 39006 bound in a channel
answer and trusted its body. A bound for another channel or cursor, a
second bound for the same page, a has_more that disagrees with its
cursor, or a cursor that does not move could end a scan early and call a
partial list complete, or read the same page forever.

Each lane now needs exactly one bound whose h and d tags name the channel
and the request's cursor, with a well-formed cursor that moves the scan
forward and agrees with has_more, as the host's own channel reader checks
(parseWindow). Anything else fails the scan before the page is kept. The
host already checks a thread page's bounds before a read returns.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
…tags

NIP-CW step 5: a window answer carries exactly one kind-39006 bound for
each window it serves, and a channel bound has exactly one d tag and one
h tag. pages() now fails the scan when the answer carries more bounds
than the lanes it asked for, or a channel bound carries any other tag,
before it keeps the page or moves a cursor. Two new rows in the bounds
table cover a surplus bound for a cursor nobody asked for and a bound
with an extra tag.

Co-authored-by: Clod <c7b21872e9ddb79ca62967d0e21e6a4518a669eb04648e963cdfb2426e62fafb@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: LordMelkor <kray@squareup.com>
… edge cases

Separate pure presentation evidence selection and live admission
(selectEvidence, applyLiveEvents, allEvidence) and derived reader mode
switches (readerMode) from the stateful shell in arrangement.ts, and fix
the edge cases that lived in the imperative paths:

- Exclude thread-root auxiliaries from live presentation budgets by
  keeping the header root separate from tracked reply rows.
- Preserve non-displayed target evidence for selected multi-target
  auxiliaries so visibility checks keep multi-target deletions intact.
- Admit verified live echoes of named pending own sends into tracked
  evidence so subsequent edits/reactions attach after outbox eviction.
- Downgrade display.complete when a new non-replay in-scope row arrives
  outside the presented ids, without bumping revision.
- Consolidate reader chrome/navigation guards through readerMode(display),
  keep ThreadPanel editMessages chronological, suppress arrival counting
  while presented, and settle reading when host legacy traversal pauses.
- Include held events in linked-copy discovery (copiesOf), surface manual
  forced-unread state for held-only messages in attention/snapshot, and
  include held-only witnesses in complete DM read cutoffs.
- Fix reference arranger fixture edge cases (abort scanning on fail,
  stop live ingestion after retention failure, retry overlap after
  forward exhaustion, avoid stalling on an oversized leading row).

Co-authored-by: Neon <f68e5587c8df616f518c6e19ea842a595208c2f610357a8438457d26c2eb3c60@buzz.block.builderlab.xyz>
Signed-off-by: LordMelkor <kray@squareup.com>
@LordMelkor
LordMelkor force-pushed the lordmelkor/conversation-arrangement branch from 3edff25 to ed88f57 Compare November 22, 2026 01:36

@jedwards27 jedwards27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 :bot: Jude’s code review agent

⚠️ Needs a desktop and mobile check before merge
Client↔relay contract: NIP-11 buzz-window-newer and direction:"newer"/after paging depend on still-open block/buzz#9641. Exercise the actual Desktop Thread Sort reader and iOS/Android channel/thread pagination against capable and older relays.

Verdict: COMMENT — recommend request changes for the two author-actionable defects below. In this repository, a human reviewer decides whether to use the Request Changes action.
Reviewed: base 352f46e77e4eb0682fe2c29b7139f823f2effc74 → exact head ed88f57a631eb37c75ca0851a7efcfdaca339e67 (41-file three-dot PR delta).
Risk: high — presentation substitutes reader rows, live deletion evidence affects visible messages, and partial reading depends on relay window completeness.

Blocking — live multi-target deletion can leave a deleted presented reply visible. In src/features/messages/arrangement.ts:141–164,216–223, initial evidence drops omitted reply B when only A is presented, and delayed live aux admission looks for missing dependencies only in the arriving batch. A valid kind-5 deletion targeting A and B cannot then pass target visibility through the retained evidence and fold (src/features/relay/session.ts:500–518,3597–3607), leaving A on screen. An independent throwaway production-seam Vitest probe at this clean head failed: expected no rows, got A. The existing snapshot-only multi-target test at src/features/messages/arrangement.test.ts:619–631 does not cover delayed live arrival. Author action: preserve bounded target evidence for live aux admission (without depending on an optional plugin hold), and add a regression with A+B present in the initial snapshot, only A displayed, then a live deletion of both.

Blocking — focus drops to the page body when a presented selected row disappears. src/features/messages/ChannelTimeline.tsx:398–401 swaps the row set; :945–958 pins focused IDs only if they remain in that set, with no transfer when the focused row unmounts. A throwaway RTL probe at this head focused a host row, presented rows omitting it, and observed document.activeElement === body. A live Top re-ranking beyond the presented page, or an edit that stops matching a text filter, can remove the selected row while a keyboard or screen-reader user is reading it. Author action: transfer focus to a sensible surviving row or the history region on focused-row removal, without stealing it from reader-bar controls; assert the live-update case in a component regression.

Other contracts traced: Channel page responses now reject surplus kind-39006 bounds before retention (tests/fixtures/conversation-arranger/plugin.ts:278–317; regression at arranger-plugin.test.tsx:1237–1249), addressing the previous review blocker. Thread bounds are host-verified before admission (src/features/relay/thread-window.ts:113–175). Reader presentation tests exercise ordering, paging suppression, partial-read boundaries, anchors and Back/Forward target reveal; these do not establish native behavior.

Validation: At this exact head, independent focused Vitest in five files passed 128/128 and git diff --check passed. Another reviewer’s pnpm check passed on isolated Blox; its full pnpm exec vitest run and pnpm build were still in progress when this review was filed, not claimed as passes. Two temporary reproduction probes were removed and the checked trees restored clean. Hosted checks currently show 77 pass and one skipped (Windows native validation); hosted results are not native app/mobile evidence. No manual/native journey was independently exercised.

Verification owner: author for both fixes and regression tests; reviewer/tooling for changed-head suite and native Desktop checks; mobile/release verification for iOS/Android and capable/older-relay compatibility before merge. Residual risk: actual Tauri plugin UI, Show in context, failed scan → Retry, keyboard/screen-reader restoration, and mobile relay-skew behavior remain unwitnessed. Re-review the new head; this verdict does not transfer across commits.

…entations

Retain bounded snapshot deletion-evidence candidates with live-growth
headroom (unifying same-owner prior held evidence across replacements so
omitted or previously displayed co-targets stay resolvable, ending cleanly
instead of silently evicting held candidates when live growth exceeds
limits, and short-circuiting candidate sizing at the cap), and recover
keyboard focus when a presentation change or live deletion removes a
focused row or collapsed reply branch summary across native browser
focusout-on-removal semantics.

Co-authored-by: Neon <f68e5587c8df616f518c6e19ea842a595208c2f610357a8438457d26c2eb3c60@buzz.block.builderlab.xyz>
Signed-off-by: LordMelkor <kray@squareup.com>
@LordMelkor

LordMelkor commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 jedwards27, both blocking findings from review 6009665684 are fixed at e944bdf:

  • Live multi-target deletion: the reader now also holds the other events in presentation.events as deletion evidence, within its limits and with room left for live updates. A live deletion of A and B now hides A when B came in presentation.events, and A stays hidden when the plugin presents again. If live updates outgrow that room, the presentation ends rather than dropping evidence. Regressions in arrangement.test.ts.
  • Focus on row removal: when a presentation change or live update removes the focused row or a collapsed reply-branch summary, focus moves to the nearest surviving selectable row, then the first mounted row, then the history region, and arrow-key selection keeps working from there. Focus in the reader bar or after an intentional blur stays where it is. Regressions in ChannelTimeline.presentation.test.tsx and ThreadPanel.presentation.test.tsx.

Checked on a separate Linux machine at e944bdf: pnpm typecheck and the type, design-system, and rust-clippy checks pass; full vitest run: 25,556 tests in 1,194 files pass, 39 skipped; tests/browser/message-navigation.spec.mjs: 44/44 pass (22/22 each in Chromium and WebKit); browser focus probe: 12/12 pass each in Chromium 153 and WebKit 26.6 (focused row, inner control, and collapsed branch summary removal, plus arrow-key and Escape selection, reader-bar focus, and intentional blur); end-user test against block/buzz#9641 at bf4bd04f2 (checked at e1527f2, unchanged in e944bdf): 35/35 pass, with no console or page errors. Automated review: 0 findings on the range. CI: 77 checks pass, 1 skipped.

LordMelkor and others added 2 commits November 22, 2026 00:01
…navigation

Scope the :scope > [data-layout] focus target lookup in ReplyBranch to the new collapsed-branch summaryRef recovery path so pre-existing messageRef and collapseRef paths keep focusing [data-message-id] directly, preserving tests/browser/message-navigation.spec.mjs in Chromium and WebKit.

Co-authored-by: Neon <f68e5587c8df616f518c6e19ea842a595208c2f610357a8438457d26c2eb3c60@buzz.block.builderlab.xyz>
Signed-off-by: LordMelkor <kray@squareup.com>
Merge origin/main (e5a9b4f: #4211, #2953, #2920, #4222 url 2.5.9, #4213 short docs).

Resolved the two documentation conflicts from #4213 by keeping origin/main's
removal of docs/plugin-architecture.md and shortened docs/buzz-help.md.

Co-authored-by: Neon <f68e5587c8df616f518c6e19ea842a595208c2f610357a8438457d26c2eb3c60@buzz.block.builderlab.xyz>
Signed-off-by: LordMelkor <kray@squareup.com>
@LordMelkor
LordMelkor requested review from a team and jedwards27 November 23, 2026 15:02
Merge origin/main (078aaaa: #3993 pin/unpin channel messages, #4270 plugin menu, #4253 cookie 0.18.3).

Resolved the single capability conflict in browser-host/relay-broker.mjs by keeping
both windowNewer and origin/main's pins properties.

Co-authored-by: Neon <f68e5587c8df616f518c6e19ea842a595208c2f610357a8438457d26c2eb3c60@buzz.block.builderlab.xyz>
Signed-off-by: LordMelkor <kray@squareup.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants