Skip to content

feat(threads): show shared thread titles in channels and on thread tabs - #3772

Closed
jhedlund wants to merge 5 commits into
block:mainfrom
jhedlund:threads/1-titles
Closed

jhedlund wants to merge 5 commits into
block:mainfrom
jhedlund:threads/1-titles

Conversation

@jhedlund

@jhedlund jhedlund commented Nov 17, 2026 •

Copy link
Copy Markdown

Part of #3455.

Shared thread titles in the channel and on thread tabs. This is the first of the four PRs proposed in #3455, and it works on its own.

1-channel-title

Behaviour

  • A thread with a shared title shows that title under its first message in the channel. Choosing the title opens the thread.
  • An open thread's tab shows its title.
  • Renaming a thread tab sets the title for everyone in the channel while the plugin is on. This changes behaviour from main, where a tab rename only affects this device. Renaming a thread tab sets the shared title. If it can't be saved, the tab shows the current title again with an error and Retry; if someone else changed the title first, rename again to replace theirs.
  • Titles are the NIP-AR artifacts (kind 45010, type buzz.thread-title) that Buzz 0.x, its agents and the buzz threads title CLI already read and write, so both apps show the same titles. The relay needs no change.
  • Writes compare against the revision last seen. If someone else changed the title first, the write reports a conflict instead of overwriting.

Scope checkpoint

  • Production budget: about 640 lines. Tests add about 810 lines and docs about 16.
  • Files:
    • src/features/messages/thread-titles.ts: the title convention, mirroring buzz_sdk::thread_title in 0.x.
    • src/features/messages/thread-title-store.ts: one live title set per relay session.
    • src/bundled/channels/useConversationTabs.tsx: tab label and rename.
    • src/bundled/threads/: the plugin, which registers only the timeline accessory.
    • Catalog entries in src/bundled/index.ts and crates/plugin-manager/src/lib.rs.
    • Docs.
  • Relay reads: ceil(joined/100) current reads when the first reader subscribes and whenever the joined set changes, then one read per burst of title changes. Following titles adds no subscriptions, because the existing live routes already carry the joined channels.
  • Non-goals: the Threads page (feat(threads): add a Threads page listing titled threads #3774, draft), pin and done, agent naming, renaming the artifact type, and changes to the relay or to FOUNDATION files.

Two things to flag

  1. The plugin is on by default. buzz.threads joins enabled_by_default (Rust) and enabledByDefault: true (TS). If you'd rather ship it opt-in, that is a two-line change and I'm happy to make it.
  2. How the on/off switch works. Tab titles live in the Channels plugin, but they are on only while Named threads runs. While the plugin is off, nothing reads titles and tab rename is device-local, as on main. No plugin API tells a plugin whether another plugin is enabled, so the switch is a counted flag in thread-title-store.ts. enableThreadTitles() returns a disposer, and the plugin calls it from ctx.effect.
    • I chose this over a plugin-provided cordis service because useConversationTabs has no ctx and three callers in two plugins: Channels' PageTabs and ChannelsPage, and Bestie's BestieConversation. A service would have to be read and passed down by each of them.
    • It is counted, not a boolean, so that when a reloaded plugin's old instance is disposed after the new one starts, titles stay on.
    • If you'd prefer a generic conversation contribution for thread titles, I can do that instead. It means editing features/conversation/*, which are FOUNDATION files, so I didn't do it without asking.

Question carried from #3455

Is buzz.thread-title an acceptable artifact type, or is the buzz.* prefix yours to assign? The same question is open on block/buzz#8563. Renaming it is a one-constant change (THREAD_TITLE_TYPE). Titles already written under the current name would then need either a period of reading both names or a one-off rewrite, and I'd include that.

What follows

Verification

  • Typecheck and Biome are clean.

  • design:check reports nothing in the files this PR adds. It does flag existing upstream CSS on Windows, unrelated to this PR.

  • Targeted suites on this head pass, 83/83: threads, title store and titles, and the conversation-tab tests.

  • Every new test was checked against the bug it targets. Removing each guarded behaviour makes its test fail:

    • the switch's change notification
    • the rename gate
    • the counting
  • Broad vitest comparison against main 949034f, on Windows: threads, channels, Bestie, messages, app, plugins and the bundled catalog. That run was on the previous head, which differs only in one test file. No file fails here that passes on main. A few files failed in the parallel run and pass when re-run alone.

  • cargo buzzodz-plugins: native_catalog_matches_desktop_bundles passes. The three other failures also fail on main on Windows.

  • Live check against a real relay: passed on 2026-11-17, with the revisions checked in the relay database. It was run in a Windows build that also includes the follow-up branches (feat(threads): add a Threads page listing titled threads #3774, pin and done, and the agent tool). As a standalone change, this PR rests on its own typecheck and suites above. The check covers:

    • the title under the root and on the tab
    • a tab rename changing the shared title, confirmed from the relay
    • switching Named threads off with a titled tab open: the label reverts without a reload, and a rename stays local
    • switching it back on: the title returns

    On a folded agents-only message the title appears when the row is expanded, as the reply count does.

🤖 Generated with Claude Code

Read and write the shared thread titles Buzz 0.x, agents and the `buzz`
CLI already set (NIP-AR kind 45010, type `buzz.thread-title`): a titled
thread shows its title under its first message in the channel and on its
thread tab, and renaming a thread tab sets the title for everyone in the
channel. A rename that can't be saved stays on that tab on this device.

One title store per relay session reads joined channels' current titles
and re-reads only channels a live title revision touched. Writes compare
against the revision last seen and report a conflict rather than
overwriting.

Provided by a new optional Named threads plugin (`buzz.threads`), on by
default. While it is off, nothing reads titles and renaming a thread tab
stays device-local, as on main. Channels can't see another plugin's
state, so the plugin turns titles on through a counted switch in the
title store (`enableThreadTitles`, from a `ctx.effect`); counting keeps
titles on when a reloaded plugin's old instance is disposed after the
new one starts.

Part of block#3455.

Co-authored-by: Engineer <f79d52bb0d4ab12c7affaf2235c113a7fc797a9da8f9707757123b67cfafa6c6@buzz.matrixsoftwareinc.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jeff Hedlund <jhedlund@gmail.com>

@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 is a comment, not an approval. A human maintainer (design or core team) must review this PR, since it adds a user-visible, default-on plugin and changes tab rename behavior.

I read the diff against root AGENTS.md, the plugin architecture and defaults docs, and the artifact helpers it reuses. No FOUNDATION file is changed: crates/plugin-manager/src/lib.rs only gets a catalog entry and a default-on entry. There are no path-local AGENTS.md files under src/bundled/ or src/features/messages/ in this checkout.

What looks right

  • Titles are kind 45010 artifacts with a derived d, so a thread has one title. Writes use a strong head read and a prev check, and a lost race is a conflict, not an overwrite.
  • The store never trusts live events as-is. It marks the channel stale and rereads the relay's current heads, so edits, restores and deletes show correctly and created_at ordering is not used.
  • On read it keeps only titles whose d matches the root and whose channel was asked for. Reads are batched at 100 channels.
  • The store has no live subscription of its own, uses a WeakMap per session, and closes when the last reader leaves. The counted on/off switch survives a plugin reload.
  • The accessory is a plugin registration through the existing conversation API, so no core conversation files are edited.
  • Tests cover the plan, conflict, batching, stale marking, the switch and the tab rename paths.

Findings

  • P1: Titles are not checked on read. parseTitle only checks that the tags exist. The 512-byte limit and trimming apply to writes only, so any client that can publish an artifact can set a huge, multi-line or bidi-override title. It then renders in every member's timeline and tab label. Clamp length and strip control and bidi characters in parseTitle, and truncate in the accessory. See the inline comments.
  • P2: Who may set or change a title is not stated. The client never looks at pubkey, so a title is not tied to the thread author or a channel admin, and the row shows no author. If the relay lets any member update the head, any member can retitle someone else's thread and it reads like part of the thread. Please document the relay rule, and maintainers should decide whether that is intended.
  • P2: A tab rename is now a channel-wide write with no confirmation. If the write fails or the name is over 512 bytes, the local name stays and shadows the shared title (tab.name wins). The only signal is a console.warn. See the inline comment.
  • P2: Read volume on a default-on plugin. Each client reads up to 500 current artifacts per 100 joined channels on start and on every change to the joined set. One title change in a channel rereads the whole channel. Titles past 500 per read are dropped, and partial and error are set but nothing in this PR shows them. A failed first read is not retried until the channel list changes. AGENTS.md asks for jitter and capped backoff on fleet-wide read paths. Maintainers should decide whether this ships on or opt-in.
  • P3: Every message row mounts the accessory and subscribes to the whole store snapshot, so a title change rerenders all mounted rows. A selector for one key would avoid it. refresh() has no caller in this PR.
  • P3: The buzz.thread-title type name and the module-level switch between Channels and this plugin need a maintainer decision, as the description says. A plugin fits the architecture here, but a generic conversation contribution would touch FOUNDATION files.
  • P3: The only screenshot is the channel row. Please add the tab label, light and dark, a narrow width, and a long title. The live relay check ran in a build with follow-up branches, not this head. Add tests for hostile titles and for a read that hits the 500 cap.

}>;

/** A live title, or undefined for other types, deletions or malformed events. */
export function parseTitle(event: EventData): ThreadTitle | undefined {

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.

🤖 P1: parseTitle returns the title tag as-is. Other clients are not bound by normalizeTitle, so a member can publish a very long, multi-line or bidi-override title that shows in everyone's timeline and tabs. Clamp the byte length, collapse newlines and strip control and bidi characters here, so every consumer gets a safe string.

Comment thread src/bundled/threads/TitleAccessory.tsx Outdated
onClick={() => openThread()}
>
<MessageReplyIcon size="1rem" aria-hidden="true" />
<span className="text-body-sm">{title.title}</span>

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.

🤖 P1: This span has no truncation, and the same text goes into aria-label. A long title will push the row wider or taller. Truncate to one line here and sanitize in parseTitle. Also consider showing who set the title, since it appears under someone else's message.

},
(cause) => {
console.warn(
"Couldn't save the thread title; kept it on this tab",

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.

🤖 P2: On failure the typed name stays as the local tab name, so it hides the shared title for good, and the user only gets a console.warn. The same happens silently for names over 512 bytes. Please surface the failure and let the user retry or drop the local name. Maintainers should also confirm that a plain tab rename becoming a channel-wide write is intended.

jhedlund and others added 4 commits November 17, 2026 22:21
- parseTitle cleans every title it reads: line breaks and controls become
  a space, bidi formatting characters are removed, and anything over 512
  bytes is cut at a code point boundary. Typed titles get the same cleaning.
- The timeline row keeps a title to one line, with the full title on hover.
- A failed tab rename drops the typed name, so it can't hide the shared
  title, and shows an error toast with Retry. A name over the limit says so
  and changes nothing.
- A failed title read is retried after a jittered delay that doubles up to
  five minutes, instead of waiting for the channel list to change.
- useThreadTitle reads one key, so a title change rerenders only its row.
- Drop the store's unused refresh().

Co-authored-by: Engineer <f79d52bb0d4ab12c7affaf2235c113a7fc797a9da8f9707757123b67cfafa6c6@buzz.matrixsoftwareinc.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jeff Hedlund <jhedlund@gmail.com>
- Retry writes against the revision the rename was typed over, so it
  conflicts instead of replacing a title someone else set meanwhile. A
  conflict offers no Retry: the tab shows the current title, and renaming
  again writes over it. A newer rename of the same tab retires an older
  rename's Retry and outcome.
- A channel whose title read failed waits for its backoff even when live
  changes mark it stale, including changes that arrived during that read.
- The help guide describes the rollback and recovery.

Co-authored-by: Engineer <f79d52bb0d4ab12c7affaf2235c113a7fc797a9da8f9707757123b67cfafa6c6@buzz.matrixsoftwareinc.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jeff Hedlund <jhedlund@gmail.com>
Every thread-tab rename, including a device-local one and a blank one,
retires earlier renames' pending Retry, and Retry does nothing while
shared titles are off. Retry keeps the revision it was typed over.

Co-authored-by: Engineer <f79d52bb0d4ab12c7affaf2235c113a7fc797a9da8f9707757123b67cfafa6c6@buzz.matrixsoftwareinc.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jeff Hedlund <jhedlund@gmail.com>
Only an accepted rename retires an earlier rename's outcome and Retry, so
a name rejected as too long while a save is pending no longer leaves that
save's typed name stranded on the tab when it fails.

Co-authored-by: Engineer <f79d52bb0d4ab12c7affaf2235c113a7fc797a9da8f9707757123b67cfafa6c6@buzz.matrixsoftwareinc.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jeff Hedlund <jhedlund@gmail.com>
@jhedlund

Copy link
Copy Markdown
Author

Thanks for the careful read. Pushed e2c9177..7baa678 with fixes for the P1 and the code-level P2/P3 items; the rest need a maintainer call, noted below.

P1: titles not checked on read — fixed. parseTitle now cleans every title it reads, so every consumer (timeline row, tab label, aria-label) gets a safe string: line breaks, C0/C1 controls and U+2028/2029 become a single space, bidi formatting characters (U+202A–202E, U+2066–2069, U+200E/200F, U+061C) are removed, whitespace runs collapse, and anything over 512 bytes is cut at a code point boundary. A title that cleans to nothing is no title. ZWJ is kept so emoji sequences survive. normalizeTitle applies the same cleaning to typed titles before the byte check. The row's label is one line (truncate, capped at min(60ch, 60vw)), with the full title in the hover hint. Tests cover multi-line, control, bidi-override and over-limit titles and the 500-cap partial flag.

P2: tab rename failure — fixed. A failed write now drops the typed name, so it can't shadow the shared title, and shows an error toast with the reason. Retry writes against the revision the rename was typed over, so it conflicts rather than replacing a title someone else set meanwhile; a conflict offers no Retry (the tab shows the current title, and renaming again writes over it), and a newer rename of the same tab retires an older one's Retry. A name over 512 bytes shows an error toast and changes nothing (before, it stayed local silently). The console.warn is gone, and docs/buzz-help.md describes the new behavior. Whether a thread-tab rename should be a channel-wide write is a product decision for maintainers; the plugin can be turned off, which restores device-local renames.

P2: read volume — partly addressed. A failed read is now retried after a jittered delay (0.5–1.5× of 5 s, doubling to a 5 min cap) instead of waiting for the joined set to change; live title changes in a failed channel wait for that retry rather than bypassing the backoff. Reads otherwise are unchanged: ceil(joined/100) current reads when the first reader mounts and when the joined set changes, then one debounced read per burst of title changes in a channel. partial and error are still not shown in the UI; titles past 500 per 100-channel batch are dropped. Happy to switch the plugin to default-off per docs/plugin-defaults.md if maintainers prefer opt-in.

P2: who may set a title. The client doesn't restrict authorship: anyone the relay lets write a channel artifact can set or change a thread's title, same as the 0.x buzz_sdk::thread_title convention it mirrors. That's the relay's NIP-AR head rule, not a client check. Maintainers should decide whether that's intended or whether titles should be limited to the thread author and channel admins (that would be a relay rule, so a client check alone wouldn't enforce it). Showing who set the title is an option either way.

P3: rerenders — fixed. useThreadTitle now subscribes with a per-key selector, so a title change rerenders only rows in the re-read channel, not every mounted row. The unused refresh() is removed.

P3: type name / module-level switch. Left for the maintainer decision named in the description.

@jhedlund

Copy link
Copy Markdown
Author

Screenshots for the P3 item, from the current head (7baa678). They were rendered in the browser test fixture with mock data, light and dark, at 1440 px and 760 px.

The first thread in the channel has a hostile title, as another client could publish it: several lines, a right-to-left override, and well past 512 bytes. It shows as one clean line in reading order, truncated, on the row and on its tab. The fixture run also checks that the shown title has no line breaks or bidi characters and stays within 512 bytes.

Channel rows: light / dark, 1440 then 760

Thread tabs: light / dark, 1440 then 760 (at 760 the open thread fills the pane)

A live relay check of this head in a desktop build is still to do.

1-channel-rows-dark-760 1-channel-rows-dark-1440 1-channel-rows-light-760 1-channel-rows-light-1440 2-thread-tabs-dark-760 2-thread-tabs-dark-1440 2-thread-tabs-light-760 2-thread-tabs-light-1440

@morgmart

Copy link
Copy Markdown
Contributor

🤖 Thanks for this. We're not going to take this on right now. Letting someone rename a thread for everyone needs extra security around who started the thread, rather than relying on the channel's existing access rules, and that's more than we want to build at the moment.

@jhedlund

Copy link
Copy Markdown
Author

Thanks for taking the time to look, and for the clear reason. That makes sense: tying a shared title to the thread's author would need relay-side enforcement, not just a client check. Closing this and the follow-up #3774. If that author-scoped rule lands in the relay later, I'm happy to revisit on top of it. (or I'd be willing to look into the relay change). I'll keep using this on my local so if it ever comes back up again I'll be ready for it.

@jhedlund jhedlund closed this Nov 18, 2026
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.

3 participants