From 6864b1045f2dc778d85fa3084e7e80e6fee26914 Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Wed, 7 Oct 2026 13:53:35 +0000 Subject: [PATCH] thread-briefs: count only sidebar threads on the Briefs badge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The badge on the Briefs sidebar row counted every stored brief whose status was waiting-on-me, but archiving a thread keeps its brief, so an archived thread kept counting while the board — driven by the sidebar's threads — never drew it. The result was a "2" over a board showing nothing but Done. Count only signals whose thread is in the sidebar list, the same rule the board uses, so the badge and the page it opens agree. Co-Authored-By: Claude Fable 5.1 --- plugins/thread-briefs/README.md | 4 +++- plugins/thread-briefs/app.test.tsx | 17 +++++++++++++++++ plugins/thread-briefs/app.tsx | 17 +++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/plugins/thread-briefs/README.md b/plugins/thread-briefs/README.md index f843d7ec..7b90c568 100644 --- a/plugins/thread-briefs/README.md +++ b/plugins/thread-briefs/README.md @@ -412,7 +412,9 @@ the built-in sidebar does. The two are folded together by pure functions in without mounting anything. The **count on the sidebar row** — bb calls it a panel accessory — is threads -waiting on you, and it costs nothing: the overlay that draws the row glyphs has +waiting on you, among the threads the sidebar is showing: the badge and the +board it opens are read off the same list, so an archived thread whose last +brief said "waiting on you" counts on neither. It costs nothing: the overlay that draws the row glyphs has already folded the briefs against the live thread list, so the badge reads that same store rather than making a second request per window. Nothing is drawn at zero; the accessory shares the row's trailing column with bb's own options diff --git a/plugins/thread-briefs/app.test.tsx b/plugins/thread-briefs/app.test.tsx index 55ef2dec..50f00459 100644 --- a/plugins/thread-briefs/app.test.tsx +++ b/plugins/thread-briefs/app.test.tsx @@ -796,6 +796,23 @@ describe("the board's sidebar badge", () => { overlay.lifecycle.unmount(); }); + it("does not count a thread the sidebar is not showing", async () => { + // Archiving a thread keeps its brief, so the kv scan still returns the + // signal. The board draws only the sidebar's threads, and the badge on the + // way to it must agree with what it opens onto. + const { overlay, badge } = await mountBoth({ + signals: [waiting("thr_1"), waiting("thr_archived")], + threads: [sidebarThread({ id: "thr_1" })], + }); + await waitFor(() => + expect( + badge.getByRole("status", { name: "1 thread waiting on you" }), + ).toBeTruthy(), + ); + badge.lifecycle.unmount(); + overlay.lifecycle.unmount(); + }); + it("does not count a thread whose agent is running", async () => { // The same live fold the row glyph makes: the agent has it, so it is not // waiting on you. diff --git a/plugins/thread-briefs/app.tsx b/plugins/thread-briefs/app.tsx index 0640122e..55c13530 100644 --- a/plugins/thread-briefs/app.tsx +++ b/plugins/thread-briefs/app.tsx @@ -170,6 +170,12 @@ function BriefSync() { return ids; }, [threads]); + /** Every thread this window's sidebar is showing, by id. */ + const sidebarIds = useMemo( + () => new Set(threads.map((thread) => thread.id)), + [threads], + ); + /** * The project each row belongs to. * @@ -223,17 +229,23 @@ function BriefSync() { const next = new Map(); let waitingOnMe = 0; for (const signal of signals) { + // A brief with no row beside it belongs to a thread this window is not + // showing — archived, most often, since archiving keeps the brief. The + // board is driven by the sidebar's threads and never draws such a card, + // so the badge must not count it either: a "2" over a board of nothing + // but Done is a badge that cannot be trusted. + const inSidebar = sidebarIds.has(signal.threadId); // The same live fold the decoration below makes, counted before it: a // thread whose agent is running is `working`, and is not waiting on you. if ( + inSidebar && !workingIds.has(signal.threadId) && signal.status === "waiting-on-me" ) { waitingOnMe += 1; } // A thread with no row in the sidebar has no cursor to age, so it simply - // never greys: the one place this can happen is a thread the current - // window is not showing, which has no glyph to draw either. + // never greys, and has no glyph to draw either. const latestAttentionAt = attentionByThreadId.get(signal.threadId); const stale = latestAttentionAt !== undefined && @@ -261,6 +273,7 @@ function BriefSync() { attentionByThreadId, now, projectByThreadId, + sidebarIds, signals, thresholds, workingIds,