Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/plugin-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ pub fn bundled_manifests() -> Vec<Manifest> {
"../../../src/bundled/changesets/manifest.json"
))
.expect("changesets manifest"),
serde_json::from_str(include_str!("../../../src/bundled/threads/manifest.json"))
.expect("threads manifest"),
]
}
/// New bundles must opt in to the default-on policy.
Expand All @@ -564,6 +566,7 @@ fn enabled_by_default(id: &str) -> bool {
| "buzz.watching"
| "buzz.pairing"
| "buzz.inbox"
| "buzz.threads"
| "buzz.repos"
| "buzz.agents"
| "buzz.claude-code"
Expand Down
14 changes: 14 additions & 0 deletions docs/buzz-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,20 @@ and are asked to sign in again in Buzz.
New reactions from updated clients appear; older unaddressed reactions are not backfilled.
While Buzz is visible, a live reaction briefly replaces the Activity bell with its emoji for three seconds.
Further reactions during that hold do not change the icon; history loading does not trigger it.
- **Threads** (below Activity in the Messages sidebar, or Cmd/Ctrl+Shift+H) lists threads that have a
title in channels you have joined, most recent reply or title change first. Choose one to open the thread,
or narrow the list with the channel menu; the **×** beside it shows all channels again. **Rename** edits a
title in place (Enter saves, Escape cancels); saving it empty removes the title for everyone. If someone
else changed the title first, nothing is overwritten: refresh and try again.
A thread you follow shows its unread reply count (**Mark read** clears it), and a thread with an agent
working in it shows how long it has been working.
The sidebar's Threads entry shows a dot while a named thread is unread, or how many have agents working. Titles are shared,
channel-visible data that agents and the `buzz threads title` CLI also set, and Buzz 0.x shows the same
titles; they are not searchable. A titled thread shows its title under its first message in the channel
(choose it to open the thread) and on its thread tab. Renaming a thread tab sets the shared title; if that
can't be saved, the name stays on that tab on this device only. Title changes and new replies update the
list, which stays loaded while you use other pages; **Refresh** reads it again. Provided by the optional
Named threads plugin, on by default.
- **New messages** marks the first known unread incoming channel message when
you enter. Once established, the divider stays in place for that visit as you
read, reveal another message, or receive new messages. In a channel with more
Expand Down
2 changes: 1 addition & 1 deletion docs/plugin-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ contracts with their own layout and local navigation.
**Channels is the only required bundled plugin.** Todos, Usage, Reminders,
Workflows, Changesets, Shared compute, Charts and File viewer are off by default for fresh installs. Bestie,
Feedback, Diff viewer, Identity Naming, Agent Activity, Terminal, Links, GitHub, Inbox,
Repositories, Agents, Claude, Codex, Builderlab,
Named threads, Repositories, Agents, Claude, Codex, Builderlab,
Membership, and Moderation are on by default, but optional. Both browser and
native catalogs declare that policy.

Expand Down
3 changes: 3 additions & 0 deletions src/app/shell/presentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
NoteIcon,
GearIcon,
LightningIcon,
MessageReplyIcon,
RobotIcon,
SendIcon,
} from "../../shared/design-system/icons/index";
Expand All @@ -23,6 +24,7 @@ export const shellPresentation = {
const bundledOrder = [
"buzz.channels/channels",
"buzz.inbox/inbox",
"buzz.threads/threads",
"buzz.drafts-and-sent/drafts-sent",
"buzz.reminders/reminders",
"buzz.bestie/bestie",
Expand Down Expand Up @@ -54,6 +56,7 @@ export function orderPages(

const bundledIcons = new Map<string, typeof BrowserIcon>([
["buzz.inbox/inbox", BellIcon],
["buzz.threads/threads", MessageReplyIcon],
["buzz.drafts-and-sent/drafts-sent", SendIcon],
["buzz.reminders/reminders", AlarmIcon],
["buzz.agents/agents", RobotIcon],
Expand Down
225 changes: 225 additions & 0 deletions src/bundled/channels/useConversationTabs.titles.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
// @vitest-environment jsdom
import { act, cleanup, renderHook, waitFor } from "@testing-library/react";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { enableThreadTitles } from "../../features/messages/thread-title-store";
import { titleRevision } from "../../features/messages/thread-titles";
import type { Panels } from "../../features/panels/service";
import type { ReadFilter, RelayEvent } from "../../features/relay/events";
import { PublishRejected } from "../../features/relay/outbox";
import type { RelayData } from "../../features/relay/service";
import type { RelaySession } from "../../features/relay/session";
import { channelTabs, useChannelTabState } from "./useChannelTabState";
import { useConversationTabs } from "./useConversationTabs";

// The Named threads plugin turns shared titles on while it runs.
let disable: (() => void) | undefined;
beforeEach(() => {
disable = enableThreadTitles();
});
afterEach(() => {
cleanup();
disable?.();
});

const ALPHA = "11111111-1111-4111-8111-111111111111";
const ROOT = "a".repeat(64);
const TAB = `thread:${ALPHA}:${ROOT}`;

async function harness({
title,
publish = vi.fn(async () => ""),
}: {
title?: string;
publish?: (event: RelayEvent) => Promise<unknown>;
} = {}) {
const heads: RelayEvent[] = [];
if (title) {
const template = await titleRevision(ALPHA, ROOT, { op: "create" }, title);
heads.push({
...template,
id: "e1",
pubkey: "f".repeat(64),
sig: "",
} as unknown as RelayEvent);
}
const snapshotRead = vi.fn(async (filters: readonly ReadFilter[]) => {
const [filter] = filters;
return heads.filter((head) =>
head.tags.some(([k, v]) =>
filter?.["#d"] ? k === "d" && v === filter["#d"][0] : k === "h",
),
);
});
const channels = [{ id: ALPHA, name: "alpha" }];
const writer = {
sign: vi.fn(async (t: { tags: string[][]; content: string }) => ({
...t,
kind: 45010,
created_at: 1,
id: "new",
pubkey: "f".repeat(64),
sig: "",
})),
publish,
};
const writerTaken = vi.fn();
const session = {
viewer: "viewer",
snapshotRead,
// Counted: only a shared title write takes the writer.
get configArtifactWriter() {
writerTaken();
return writer;
},
artifacts: { follow: () => () => {} },
channels: {
list: () => ({ status: "ready", channels }),
ensureList: () => () => {},
subscribeList: () => () => {},
window: () => ({
rows: [{ id: ROOT, content: "Original message" }],
}),
},
} as unknown as RelaySession;
const available: never[] = [];
const panels = {
snapshot: () => available,
subscribe: () => () => {},
} as unknown as Panels;
const relay = {
snapshot: () => ({ status: "ready", session }),
} as unknown as RelayData;
const h = renderHook(() => {
const state = useChannelTabState(session, ALPHA);
const workspace = useConversationTabs({
profiles: new Map(),
state,
relay,
session,
panels,
current: channels[0],
channels,
scope: "scope:viewer",
conversationIcon: () => null,
leadingIds: [],
continuingVisit: true,
isLive: () => true,
openLink: () => false,
});
return { state, workspace };
});
act(() => h.result.current.state.openThreadTab(ALPHA, ROOT, ROOT));
const item = () =>
h.result.current.workspace.items.find((tab) => tab.id === TAB) as
| { label: string; rename?: (name: string) => void }
| undefined;
const localName = () =>
(
h.result.current.state.tabs.find((tab) => tab.id === TAB) as
| { name?: string }
| undefined
)?.name;
return { session, publish, snapshotRead, writerTaken, item, localName };
}

it("labels a thread tab with its local name, then its shared title, then its text", async () => {
const h = await harness({ title: "Launch plan" });
await waitFor(() => expect(h.item()?.label).toBe("Launch plan"));
act(() => {
channelTabs(h.session).rename(ALPHA, ROOT, "Mine");
});
expect(h.item()?.label).toBe("Mine");
act(() => {
channelTabs(h.session).rename(ALPHA, ROOT, "");
});
expect(h.item()?.label).toBe("Launch plan");
expect(h.publish).not.toHaveBeenCalled();
});

it("renaming a thread tab publishes the shared title and drops the local name", async () => {
const h = await harness();
await waitFor(() => expect(h.snapshotRead).toHaveBeenCalled());
expect(h.item()?.label).toBe("Original message");
act(() => h.item()?.rename?.(" Launch plan "));
// The typed name shows while the write is in flight.
expect(h.item()?.label).toBe("Launch plan");
await waitFor(() => expect(h.localName()).toBeFalsy());
expect(h.item()?.label).toBe("Launch plan");
const [signed] = vi.mocked(h.publish).mock.calls[0] ?? [];
expect(signed?.tags).toContainEqual(["op", "create"]);
expect(signed?.tags).toContainEqual(["title", "Launch plan"]);
});

it("renaming against a titled thread updates it from the shown revision", async () => {
const h = await harness({ title: "Launch plan" });
await waitFor(() => expect(h.item()?.label).toBe("Launch plan"));
act(() => h.item()?.rename?.("Ship plan"));
await waitFor(() => expect(h.publish).toHaveBeenCalled());
const [signed] = vi.mocked(h.publish).mock.calls[0] ?? [];
expect(signed?.tags).toContainEqual(["op", "update"]);
expect(signed?.tags).toContainEqual(["prev", "e1"]);
await waitFor(() => expect(h.localName()).toBeFalsy());
expect(h.item()?.label).toBe("Ship plan");
});

it("keeps the typed name on the tab when the shared write fails", async () => {
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
const h = await harness({
publish: vi.fn(async () => {
throw new PublishRejected("Rejected", "restricted: not a member");
}),
});
await waitFor(() => expect(h.snapshotRead).toHaveBeenCalled());
act(() => h.item()?.rename?.("Launch plan"));
await waitFor(() => expect(warn).toHaveBeenCalled());
expect(h.localName()).toBe("Launch plan");
expect(h.item()?.label).toBe("Launch plan");
// Over the byte limit never reaches the relay and stays local too.
const long = "x".repeat(513);
act(() => h.item()?.rename?.(long));
expect(h.localName()).toBe(long);
expect(h.publish).toHaveBeenCalledTimes(1);
warn.mockRestore();
});

it("an empty rename clears only the local name, never the shared title", async () => {
const h = await harness({ title: "Launch plan" });
await waitFor(() => expect(h.item()?.label).toBe("Launch plan"));
act(() => {
channelTabs(h.session).rename(ALPHA, ROOT, "Mine");
});
act(() => h.item()?.rename?.(""));
expect(h.localName()).toBeFalsy();
expect(h.item()?.label).toBe("Launch plan");
expect(h.publish).not.toHaveBeenCalled();
});

it("with shared titles off, a tab shows no shared title and renames stay local", async () => {
disable?.();
const h = await harness({ title: "Launch plan" });
expect(h.item()?.label).toBe("Original message");
act(() => h.item()?.rename?.("Mine"));
expect(h.localName()).toBe("Mine");
expect(h.item()?.label).toBe("Mine");
// A shared write takes the writer as it starts, before any await.
expect(h.writerTaken).not.toHaveBeenCalled();
expect(h.snapshotRead).not.toHaveBeenCalled();
expect(h.publish).not.toHaveBeenCalled();
});

it("follows shared titles being switched off and on while a tab is open", async () => {
const h = await harness({ title: "Launch plan" });
await waitFor(() => expect(h.item()?.label).toBe("Launch plan"));
act(() => disable?.());
expect(h.item()?.label).toBe("Original message");
act(() => h.item()?.rename?.("Mine"));
expect(h.localName()).toBe("Mine");
expect(h.writerTaken).not.toHaveBeenCalled();
act(() => h.item()?.rename?.(""));
act(() => {
disable = enableThreadTitles();
});
await waitFor(() => expect(h.item()?.label).toBe("Launch plan"));
act(() => h.item()?.rename?.("Ship plan"));
await waitFor(() => expect(h.publish).toHaveBeenCalledTimes(1));
});
68 changes: 66 additions & 2 deletions src/bundled/channels/useConversationTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ import {
import { useTabDrag } from "../../features/panels/useTabDrag";
import { PanelCard } from "../../features/panels/PanelCard";
import type { MessageLinkOrigin } from "../../features/messages/MessageRow";
import {
threadTitlesEnabled,
threadTitleStore,
useThreadTitles,
} from "../../features/messages/thread-title-store";
import {
activityKey,
normalizeTitle,
writeTitle,
} from "../../features/messages/thread-titles";
import {
BrowserIcon,
MessageReplyIcon,
Expand Down Expand Up @@ -773,10 +783,14 @@ export function useConversationTabs({
linkedThread.current(channelId, messageId, rootId),
[],
);
// Several open threads stay distinguishable by their original message.
// A device-local name wins, then the thread's shared title. Several open
// threads stay distinguishable by their original message.
const sharedTitles = useThreadTitles(queries).titles;
function threadLabel(tab: Extract<Tab, { kind: "thread" }>, name?: string) {
if (tab.name) return tab.name;
const rootId = rootOfTab(tab);
const shared = sharedTitles?.get(activityKey(tab.channelId, rootId));
if (shared) return shared.title;
const root = queries.channels
.window(tab.channelId)
.rows.find((row) => row.id === rootId);
Expand All @@ -788,6 +802,56 @@ export function useConversationTabs({
.slice(0, 80);
return text || (name ? `Thread · ${name}` : "Thread");
}
// With shared titles on, renaming a thread tab names the thread for
// everyone. The typed name shows on this tab until the write lands, and
// stays there if it fails. A blank name only drops the local one.
function renameThread(tab: Extract<Tab, { kind: "thread" }>, name: string) {
if (!threadTitlesEnabled()) return tabState.renameTab(tab.id, name);
const rootId = rootOfTab(tab);
const read = queries.snapshotRead;
const writer = queries.configArtifactWriter;
let desired: string | undefined;
try {
desired = normalizeTitle(name);
} catch {
return tabState.renameTab(tab.id, name);
}
if (!desired) return tabState.renameTab(tab.id, "");
if (!read || !writer) return tabState.renameTab(tab.id, desired);
const store = threadTitleStore(queries);
const title = desired;
tabState.renameTab(tab.id, title);
writeTitle(
read,
writer,
{
channel: tab.channelId,
root: rootId,
revision: store.get(tab.channelId, rootId)?.revision,
},
title,
AbortSignal.timeout(20_000),
).then(
(revision) => {
if (revision)
store.apply(tab.channelId, rootId, {
title,
channel: tab.channelId,
root: rootId.toLowerCase(),
revision,
updatedAt: Math.floor(Date.now() / 1000),
});
tabState.renameTab(tab.id, "");
},
(cause) => {
console.warn(
"Couldn't save the thread title; kept it on this tab",
cause,
);
tabState.renameTab(tab.id, title);
},
);
}
// The current conversation's own threads are already in its channel.
function openInChannel(tab: Tab, target: ChannelSummary | undefined) {
return target && navigation && viewer && tab.channelId !== currentId
Expand Down Expand Up @@ -848,7 +912,7 @@ export function useConversationTabs({
...(tab.kind === "thread" && {
attentionRequest: tab.attentionRequest,
move: (delta: -1 | 1) => moveBy(tab, delta),
rename: (name: string) => tabState.renameTab(tab.id, name),
rename: (name: string) => renameThread(tab, name),
}),
...(openChannel && {
actions: [{ label: "Open in channel", run: openChannel }],
Expand Down
Loading