Skip to content
Merged
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
4 changes: 3 additions & 1 deletion plugins/thread-briefs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions plugins/thread-briefs/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 15 additions & 2 deletions plugins/thread-briefs/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -223,17 +229,23 @@ function BriefSync() {
const next = new Map<string, Decoration>();
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 &&
Expand Down Expand Up @@ -261,6 +273,7 @@ function BriefSync() {
attentionByThreadId,
now,
projectByThreadId,
sidebarIds,
signals,
thresholds,
workingIds,
Expand Down
Loading