diff --git a/changes/wizbar-0-7-1.md b/changes/wizbar-0-7-1.md index 18ab351..85bef02 100644 --- a/changes/wizbar-0-7-1.md +++ b/changes/wizbar-0-7-1.md @@ -1,3 +1,5 @@ kind: changed WizBar 0.7.1 look and polish (#231): the running card leads with one large live count, shows each harness's name beside its logo and count, and sets its right-aligned model column in 11 px muted text; sidebar section rules use calmer neutral borders with tighter header spacing and sort/filter pickers shown on hover or focus; Cloud agents parse `Gemini Neon, Medium` and `GPT-6.2 medium effort` into plain model words and fold older done, stopped and lapsed agents into an expandable `N earlier` line while keeping live and recently finished (last 30 minutes) agents visible; and Yours excludes `launch-fleet` loop runs regardless of repository (search still finds them). The running card's harness bar is replaced by named counts, the cloud and local split moves to the card's last line, and the waiting line shows only when something waits on you. `wizbar agents --json` lists recent agents in `rows` and folded older ones in a new `earlier` field. + +The look update also puts each thread card on two lines (title, status and age; then the quiet details), and the footer line adds what is waiting on you and how many live agents are on GitHub. diff --git a/docs/evidence/wizbar-0-7/look/r2-d/card.png b/docs/evidence/wizbar-0-7/look/r2-d/card.png new file mode 100644 index 0000000..b76cf88 Binary files /dev/null and b/docs/evidence/wizbar-0-7/look/r2-d/card.png differ diff --git a/docs/evidence/wizbar-0-7/look/r2-d/sidebar.png b/docs/evidence/wizbar-0-7/look/r2-d/sidebar.png new file mode 100644 index 0000000..b85f682 Binary files /dev/null and b/docs/evidence/wizbar-0-7/look/r2-d/sidebar.png differ diff --git a/docs/evidence/wizbar-0-7/look/r2-f/card.png b/docs/evidence/wizbar-0-7/look/r2-f/card.png new file mode 100644 index 0000000..d904610 Binary files /dev/null and b/docs/evidence/wizbar-0-7/look/r2-f/card.png differ diff --git a/docs/evidence/wizbar-0-7/look/r2-f/sidebar.png b/docs/evidence/wizbar-0-7/look/r2-f/sidebar.png new file mode 100644 index 0000000..e81f750 Binary files /dev/null and b/docs/evidence/wizbar-0-7/look/r2-f/sidebar.png differ diff --git a/docs/evidence/wizbar-0-7/look/r2-merged/card.png b/docs/evidence/wizbar-0-7/look/r2-merged/card.png new file mode 100644 index 0000000..493a9a3 Binary files /dev/null and b/docs/evidence/wizbar-0-7/look/r2-merged/card.png differ diff --git a/docs/evidence/wizbar-0-7/look/r2-merged/sidebar.png b/docs/evidence/wizbar-0-7/look/r2-merged/sidebar.png new file mode 100644 index 0000000..6a0d67f Binary files /dev/null and b/docs/evidence/wizbar-0-7/look/r2-merged/sidebar.png differ diff --git a/wizbar/README.md b/wizbar/README.md index fe16f18..2dfbf67 100644 --- a/wizbar/README.md +++ b/wizbar/README.md @@ -48,7 +48,7 @@ are in the [v0.3 sidebar contract](contracts/sidebar-v3.v1.md) and the and `status:`. Quote values with spaces, as in `harness:"Claude Code"`. Active, unpinned matches appear in Yours. Pinned, snoozed, muted and settled matches stay on their shelves. -- **The running card shows every running thread.** The card opens with one live running count, awake, starting and asleep totals, and each harness's name beside its logo and count, then scrolls through every running thread with a quiet right-aligned model column. Specs follow the sidebar's sort, with `Other` last. Click a group heading to fold or open it for the session. Untitled rows show a role and ticket when the fallback names one, or the harness name otherwise. The current heading stays visible as you scroll, and a fade shows when more rows are available. The card lists live GitHub status notes for agents the sidebar cannot match. These rows show the note's harness and model and open its issue or pull request. The card reports their count separately as `N more on GitHub`. `wizbar stats --json` reports the same rows in `unseen`. +- **The running card shows every running thread.** The card opens with one live running count, awake, starting and asleep totals, and each harness's name beside its logo and count, then scrolls through every running thread with a quiet right-aligned model column. Specs follow the sidebar's sort, with `Other` last. Click a group heading to fold or open it for the session. Untitled rows show a role and ticket when the fallback names one, or the harness name otherwise. The current heading stays visible as you scroll, and a fade shows when more rows are available. The card lists live GitHub status notes for agents the sidebar cannot match. These rows show the note's harness and model and open its issue or pull request. The card reports their count separately as `N on GitHub`. `wizbar stats --json` reports the same rows in `unseen`. - **Cloud agents.** The sidebar lists GitHub agents with no matching desktop thread. It starts after Pinned and can be moved or collapsed. Working and asking agents with live notes appear first and count in the header. Agents that finished in the last 30 minutes follow by most recent update; older done, stopped and lapsed agents fold into one quiet `N earlier` line that opens in place. Names link to GitHub. `wizbar agents [--json]` lists the same rows; its JSON puts recent agents in `rows` and the folded older ones in `earlier`. The host's desktop thread list leaves out agents that run in their own cloud sandbox (such as Antigravity), so WizBar reads them from GitHub: live `openwiz:status v1` notes, and optionally a fleet's run map (`--run-map`), whose thread ids tell which agents the desktop cannot see. Rows show the role, the repository and ticket, the model in plain words (for example `Neon · Medium` or `Sol 6.2 · Medium`), the state and the last activity, and open the pull request, or the ticket when the note names none. The card ends with a plain line that agents in their own cloud sandbox may be missing. - **The producer** writes `.openwiz/agents.v1.json` beside the specs files, with its own 20-request budget after the specs scan. To fill Cloud agents, add a `--repo` for each product repository and, optionally, `--run-map 'owner/name#'`. - **A calmer thread view.** A new setting, Composer footer, hides the bar under diff --git a/wizbar/browser/running-card.test.ts b/wizbar/browser/running-card.test.ts index a1d2ab0..2524237 100644 --- a/wizbar/browser/running-card.test.ts +++ b/wizbar/browser/running-card.test.ts @@ -208,7 +208,7 @@ it.skipIf(!browserPath)("shows all large machine totals without clipping or elli const page = await browser.newPage({ viewport: { width: 350, height: 600 } }); try { await page.goto(`${url}?large-summary=1`); - await page.getByRole("button", { name: "360 running" }).hover(); + await page.getByRole("button", { name: "360 running, 120 waiting on you" }).hover(); const card = page.getByRole("region", { name: "Running threads" }); const waiting = card.getByText("120 waiting on you"); const machines = card.getByText("120 cloud, 120 local, 120 unknown"); @@ -226,3 +226,79 @@ it.skipIf(!browserPath)("shows all large machine totals without clipping or elli await page.close(); } }); + +it.skipIf(!browserPath)("R6 keeps three-digit footer counts on one line at 300 px and shortens as designed", async () => { + const page = await browser.newPage({ viewport: { width: 300, height: 600 } }); + try { + await page.goto(`${url}?narrow-footer=1`); + const status = page.getByRole("status", { name: "125 running, 120 waiting on you, 105 on GitHub" }); + await status.waitFor({ state: "visible" }); + await expect.poll(async () => status.evaluate((node) => { + const text = node.querySelector('[aria-hidden="true"]') as HTMLElement; + return { + text: text.textContent, + oneLine: node.getBoundingClientRect().height <= 22, + fits: text.scrollWidth <= text.clientWidth, + hasGitHub: node.querySelector("[data-on-github]") !== null, + }; + })).toEqual({ + text: "125 running · 120 waiting on you", + oneLine: true, + fits: true, + hasGitHub: false, + }); + + await page.setViewportSize({ width: 210, height: 600 }); + await expect.poll(async () => status.evaluate((node) => { + const text = node.querySelector('[aria-hidden="true"]') as HTMLElement; + return { + text: text.textContent, + oneLine: node.getBoundingClientRect().height <= 22, + fits: text.scrollWidth <= text.clientWidth, + hasGitHub: node.querySelector("[data-on-github]") !== null, + }; + })).toEqual({ + text: "125 running · 120 waiting", + oneLine: true, + fits: true, + hasGitHub: false, + }); + } finally { + await page.close(); + } +}); + +it.skipIf(!browserPath)("R2 keeps all thread card detail icons inside the card at 300 px", async () => { + const page = await browser.newPage({ viewport: { width: 300, height: 400 } }); + try { + await page.goto(`${url}?dense-card=1`); + const details = page.getByRole("group", { name: "Thread details" }); + await details.waitFor({ state: "visible" }); + await page.getByText("Opus 5.5 · Medium").waitFor({ state: "visible" }); + const bounds = await details.evaluate((group) => { + const card = group.closest("li")!.firstElementChild!.getBoundingClientRect(); + const groupRect = group.getBoundingClientRect(); + const icons = [...group.querySelectorAll('[role="img"]')].map((el) => ({ + label: el.getAttribute("aria-label"), + right: el.getBoundingClientRect().right, + })); + return { + overflow: getComputedStyle(group).overflow, + groupWithinCard: groupRect.right <= card.right + 0.5, + iconsWithinCard: icons.every((icon) => icon.right <= card.right + 0.5), + iconCount: icons.length, + // Line 2 stays one line: no chip wraps (about 18 px tall at this size). + oneLine: groupRect.height <= 22, + }; + }); + expect(bounds).toEqual({ + overflow: "hidden", + groupWithinCard: true, + iconsWithinCard: true, + iconCount: 2, + oneLine: true, + }); + } finally { + await page.close(); + } +}); diff --git a/wizbar/browser/running-card.tsx b/wizbar/browser/running-card.tsx index bae10d6..1d51da0 100644 --- a/wizbar/browser/running-card.tsx +++ b/wizbar/browser/running-card.tsx @@ -1,5 +1,6 @@ import { renderSlot } from "@get-bb/plugin-sdk/testing/app"; import { FooterCounter } from "../src/FooterCounter"; +import { ThreadCard } from "../src/ThreadCard"; import { v4SpecsFile, v4Threads } from "../src/fixtures/v4"; const [hostStyles] = Object.values(import.meta.glob( @@ -25,33 +26,150 @@ const binding = JSON.stringify([{ orchestratorThreadId: "sample-orchestrator", statusWriterLogin: "sample-user", }]); -const largeSummary = new URLSearchParams(location.search).has("large-summary"); -const total = largeSummary ? 480 : 100; -const threads = Array.from({ length: total }, (_, index) => { - const n = index + 1; - const title = `Sample thread ${n}`; - const local = !largeSummary || n <= 120; - return { - ...v4Threads[local ? 0 : 1]!, id: `sample-${n}`, title, displayTitle: title, - runtimeStatus: largeSummary && n > 240 && n <= 360 ? "starting" as const : "active" as const, - hasPendingInteraction: largeSummary && n > 360, - providerId: n % 2 ? "codex" : "claude-code", - parentThreadId: n <= 60 ? "sample-fleet-0" : n <= 90 ? "sample-fleet-1" : null, - createdAt: now - total + index, updatedAt: now, +const params = new URLSearchParams(location.search); +const largeSummary = params.has("large-summary"); +const narrowFooter = params.has("narrow-footer"); +const denseCard = params.has("dense-card"); + +if (denseCard) { + const parent = { + ...v4Threads[0]!, + id: "dense-parent", + title: "Dense card with every detail chip at 300 px", + displayTitle: "Dense card with every detail chip at 300 px", + providerId: "claude-code", + activity: { workflows: 2, backgroundAgents: 1, backgroundCommands: 0, planMode: 0, goals: 0 }, + environment: { + id: "env_dense", + name: "Synthetic workspace", + branchName: "room/1042-refine-command-palette-a1b2", + path: null, + isWorktree: true, + providerId: "git-worktree", + workspaceDisplayKind: "other" as const, + }, + updatedAt: now - 7 * 60 * 1000, }; -}); + const children = Array.from({ length: 12 }, (_, index) => ({ + ...v4Threads[0]!, + id: `dense-child-${index + 1}`, + title: `Child ${index + 1}`, + displayTitle: `Child ${index + 1}`, + parentThreadId: parent.id, + })); + renderSlot({ component: () => ( + + ) }, {}, { + pluginId: "dense-card-browser", + sidebarThreads: { status: "ready", threads: [parent, ...children] }, + sidebarPullRequests: { + [parent.id]: { + experimental_autoMerge: false, + experimental_inMergeQueue: null, + experimental_checks: { state: "passing" }, + experimental_review: { state: "none" }, + experimental_mergeability: { state: "mergeable" }, + number: 1088, + title: "Refine command palette", + url: "https://github.com/example/sample-repo/pull/1088", + state: "open", + attention: "none", + }, + }, + rpc: { + cardModels: () => ({ source: "host", items: [{ threadId: parent.id, model: "Opus 5.5", effort: "medium" }] }), + } as never, + }); +} else if (narrowFooter) { + const stamp = new Date(now - 60_000).toISOString().replace(/\.\d{3}Z$/, "Z"); + const repo = "example/sample-plans"; + const running = Array.from({ length: 125 }, (_, index) => ({ + ...v4Threads[0]!, + id: `narrow-run-${index + 1}`, + title: `Running ${index + 1}`, + displayTitle: `Running ${index + 1}`, + runtimeStatus: "active" as const, + hasPendingInteraction: false, + updatedAt: now, + })); + const waiting = Array.from({ length: 120 }, (_, index) => ({ + ...v4Threads[0]!, + id: `narrow-wait-${index + 1}`, + title: `Waiting ${index + 1}`, + displayTitle: `Waiting ${index + 1}`, + runtimeStatus: "idle" as const, + hasPendingInteraction: true, + updatedAt: now, + })); + const agents = Array.from({ length: 105 }, (_, index) => ({ + repository: repo, + ticket: `${repo}#${200 + index}`, + commentId: index + 1, + agent: "builder", + harness: "Synthetic", + model: "Sample", + state: "working", + live: true, + step: "Building", + updatedAt: stamp, + time: stamp, + })); + renderSlot({ component: () => ( + + ) }, {}, { + pluginId: "narrow-footer-browser", + sidebarThreads: { status: "ready", threads: [...running, ...waiting] }, + settings: { wizdeckFactories: binding, specsSort: "newest" }, + rpc: { + specsFile: () => ({ kind: "content", text: JSON.stringify(specs) }), + agentsFile: () => ({ kind: "content", text: JSON.stringify({ version: 1, generatedAt: stamp, agents }) }), + cardModels: () => ({ source: "none", items: [] }), + } as never, + }); +} else { + const total = largeSummary ? 480 : 100; + const threads = Array.from({ length: total }, (_, index) => { + const n = index + 1; + const title = `Sample thread ${n}`; + const local = !largeSummary || n <= 120; + return { + ...v4Threads[local ? 0 : 1]!, id: `sample-${n}`, title, displayTitle: title, + runtimeStatus: largeSummary && n > 240 && n <= 360 ? "starting" as const : "active" as const, + hasPendingInteraction: largeSummary && n > 360, + providerId: n % 2 ? "codex" : "claude-code", + parentThreadId: n <= 60 ? "sample-fleet-0" : n <= 90 ? "sample-fleet-1" : null, + createdAt: now - total + index, updatedAt: now, + }; + }); -renderSlot({ component: () => ( - -) }, {}, { - pluginId: "running-card-browser", - sidebarThreads: { status: "ready", threads }, - settings: { wizdeckFactories: binding, specsSort: "newest" }, - rpc: { - specsFile: () => ({ kind: "content", text: JSON.stringify(specs) }), - cardModels: () => ({ source: "none", items: [] }), - } as never, -}); + renderSlot({ component: () => ( + + ) }, {}, { + pluginId: "running-card-browser", + sidebarThreads: { status: "ready", threads }, + settings: { wizdeckFactories: binding, specsSort: "newest" }, + rpc: { + specsFile: () => ({ kind: "content", text: JSON.stringify(specs) }), + cardModels: () => ({ source: "none", items: [] }), + } as never, + }); +} diff --git a/wizbar/src/ChildrenPopover.tsx b/wizbar/src/ChildrenPopover.tsx index 058b3cd..064c45b 100644 --- a/wizbar/src/ChildrenPopover.tsx +++ b/wizbar/src/ChildrenPopover.tsx @@ -110,7 +110,7 @@ export function ChildrenPopover({ return ( {label} diff --git a/wizbar/src/FooterCounter.test.tsx b/wizbar/src/FooterCounter.test.tsx index d76b676..ca7173f 100644 --- a/wizbar/src/FooterCounter.test.tsx +++ b/wizbar/src/FooterCounter.test.tsx @@ -190,16 +190,16 @@ describe("V3: the list-bottom line counts the one running rule", () => { const base = v3Threads.find(({ id }) => id === "thr_v3_pinned_idle")!; it("shows the stats panel's running total for the fixture rows", () => { renderSlot(line, {}, { sidebarThreads: { status: "ready", threads: v3Threads } }); - expect(screen.getByRole("status", { name: "4 running" }).textContent).toBe("4 running"); + expect(screen.getByRole("status", { name: "4 running, 3 waiting on you" }).textContent).toBe("4 running · 3 waiting on you"); }); it.each([ ["busy but waiting on you", { hasPendingInteraction: true, indicator: "waiting-for-input" as const, - activity: { ...base.activity, backgroundCommands: 1 } }, "0"], - ["an attention indicator over an idle runtime", { indicator: "runtime" as const }, "0"], - ["runtime work behind no indicator", { status: "active" as const, runtimeStatus: "active" as const }, "1"], - ])("counts %s by runtime work, not the indicator", (_, overrides, expected) => { + activity: { ...base.activity, backgroundCommands: 1 } }, "0 running, 1 waiting on you", "0 running · 1 waiting on you"], + ["an attention indicator over an idle runtime", { indicator: "runtime" as const }, "0 running", "0 running"], + ["runtime work behind no indicator", { status: "active" as const, runtimeStatus: "active" as const }, "1 running", "1 running"], + ])("counts %s by runtime work, not the indicator", (_, overrides, expectedLabel, expectedText) => { renderSlot(line, {}, { sidebarThreads: { status: "ready", threads: [{ ...base, ...overrides }] } }); - expect(screen.getByRole("status", { name: `${expected} running` }).textContent).toBe(`${expected} running`); + expect(screen.getByRole("status", { name: expectedLabel }).textContent).toBe(expectedText); }); it("hides the number when a row's runtime status is unrecognised", () => { const rendered = renderSlot(line, {}, { sidebarThreads: { status: "ready", @@ -207,3 +207,94 @@ describe("V3: the list-bottom line counts the one running rule", () => { expect(rendered.container.innerHTML).toBe(""); }); }); + +describe("footer summary: waiting on you and live GitHub agents", () => { + it("shows waiting on you in warning colour and live GitHub agents in muted text when non-zero", async () => { + const now = Date.now(); + const stamp = new Date(now - 60_000).toISOString().replace(/\.\d{3}Z$/, "Z"); + const repo = "example/sample-factory"; + const binding = JSON.stringify([{ + projectKey: "sample-factory", cloudroomProjectId: "prj_sample", repositories: [repo], + home: { hostId: "hst_sample", rootPath: "/synthetic/sample" }, + orchestratorThreadId: "thr_orch", statusWriterLogin: "sample-writer", + }]); + const agents = [ + { repository: repo, ticket: `${repo}#101`, commentId: 1, agent: "builder", harness: "Synthetic", + model: "Sample", state: "working", live: true, step: "Building", updatedAt: stamp, time: stamp }, + { repository: repo, ticket: `${repo}#102`, commentId: 2, agent: "reviewer", harness: "Synthetic", + model: "Sample", state: "working", live: true, step: "Reviewing", updatedAt: stamp, time: stamp }, + { repository: repo, ticket: `${repo}#103`, commentId: 3, agent: "builder", harness: "Synthetic", + model: "Sample", state: "done", live: false, step: "Done", updatedAt: stamp, time: stamp }, + ]; + renderSlot(line, {}, { + pluginId: "synthetic-footer-github", + settings: { wizdeckFactories: binding }, + sidebarThreads: { status: "ready", threads: v3Threads }, + rpc: { + agentsFile: () => ({ kind: "content", text: JSON.stringify({ version: 1, generatedAt: stamp, agents }) }), + } as never, + }); + const status = await screen.findByRole("status", { name: "4 running, 3 waiting on you, 2 on GitHub" }); + expect(status.textContent).toBe("4 running · 3 waiting on you · 2 on GitHub"); + const waiting = status.querySelector("[data-waiting-on-you]") as HTMLElement; + const github = status.querySelector("[data-on-github]") as HTMLElement; + expect(waiting.style.color).toContain("--warning"); + expect(github.style.color).toContain("--muted-foreground"); + }); + + it("drops the GitHub part first, then shortens waiting on you to waiting when narrow", () => { + const scrollWidth = vi.spyOn(HTMLElement.prototype, "scrollWidth", "get").mockImplementation(function (this: HTMLElement) { + const text = this.textContent ?? ""; + return text.includes("on GitHub") ? 290 : text.includes("waiting on you") ? 240 : 180; + }); + const clientWidth = vi.spyOn(HTMLElement.prototype, "clientWidth", "get").mockReturnValue(250); + try { + const rendered = renderSlot(candidate, { source: positiveSource, waitingOnYou: 1, onGitHub: 3 }); + const status = screen.getByRole("status", { name: "5 running, 1 waiting on you, 3 on GitHub" }); + expect(status.textContent).toBe("5 running · 1 waiting on you"); + expect(status.querySelector("[data-on-github]")).toBeNull(); + expect(status.querySelector("[data-waiting-on-you]")?.textContent).toBe("1 waiting on you"); + + clientWidth.mockReturnValue(200); + rendered.rerender(); + const narrowed = screen.getByRole("status", { name: "5 running, 2 waiting on you, 3 on GitHub" }); + expect(narrowed.textContent).toBe("5 running · 2 waiting"); + expect(narrowed.querySelector("[data-on-github]")).toBeNull(); + expect(narrowed.querySelector("[data-waiting-on-you]")?.textContent).toBe("2 waiting"); + } finally { + scrollWidth.mockRestore(); + clientWidth.mockRestore(); + } + }); + + it("R4 reports no GitHub count while disconnected, matching the Cloud agents section", async () => { + const now = Date.now(); + const stamp = new Date(now - 60_000).toISOString().replace(/\.\d{3}Z$/, "Z"); + const repo = "example/sample-factory"; + const binding = JSON.stringify([{ + projectKey: "sample-factory", cloudroomProjectId: "prj_sample", repositories: [repo], + home: { hostId: "hst_sample", rootPath: "/synthetic/sample" }, + orchestratorThreadId: "thr_orch", statusWriterLogin: "sample-writer", + }]); + const agents = [ + { repository: repo, ticket: `${repo}#101`, commentId: 1, agent: "builder", harness: "Synthetic", + model: "Sample", state: "working", live: true, step: "Building", updatedAt: stamp, time: stamp }, + ]; + fakeTimers(); + const rendered = renderSlot(line, {}, { + pluginId: "synthetic-footer-github-disconnect", + settings: { wizdeckFactories: binding }, + sidebarThreads: { status: "ready", threads: v3Threads }, + rpc: { + agentsFile: () => ({ kind: "content", text: JSON.stringify({ version: 1, generatedAt: stamp, agents }) }), + } as never, + }); + await act(async () => { await Promise.resolve(); }); + expect(screen.getByRole("status", { name: "4 running, 3 waiting on you, 1 on GitHub" })).toBeDefined(); + + await rendered.setRealtimeConnectionState("reconnecting"); + outlastHold(); + expect(screen.queryByRole("status")).toBeNull(); + expect(rendered.container.textContent).not.toContain("on GitHub"); + }); +}); diff --git a/wizbar/src/FooterCounter.tsx b/wizbar/src/FooterCounter.tsx index 828b2ff..09ae25b 100644 --- a/wizbar/src/FooterCounter.tsx +++ b/wizbar/src/FooterCounter.tsx @@ -1,11 +1,15 @@ import { useEffect, useLayoutEffect, useReducer, useRef, useState, type ReactNode } from "react"; import type { PluginSidebarThread } from "@get-bb/plugin-sdk"; +import { cloudAgents } from "./agents/cloud"; +import { useAgentsRead } from "./agents/use-agents"; import { countRunning, type ObservableRunningSource, type RunningCount, type RunningCountSource } from "./running-count"; -import { cardPinNext, isRunning, readSidebarRows, type SidebarRowsStatus } from "./stats"; +import { cardPinNext, computeStats, isRunning, readSidebarRows, type SidebarRowsStatus } from "./stats"; import type { CardEventV4, CardStateV4 } from "./fixtures/v4"; import { MatrixMark } from "./MatrixMark"; import { StatsPanel } from "./StatsPanel"; +import { readSpecsFile } from "./specs/read"; import { SpecsReadContext, useSpecsRead } from "./specs/SpecsSection"; +import { tokens } from "./specs/theme"; import { experimental_usePluginId, experimental_useSidebarThreads, useRealtimeConnectionState } from "@get-bb/plugin-sdk/app"; import { useFeatureSourceStatus, useWizBarSettings } from "./SettingsPage"; @@ -55,7 +59,10 @@ export function useObservableRows(): { status: SidebarRowsStatus; rows: readonly * card is `StatsPanel`, the `wizbar stats` data for the same rows. */ export function FooterCounter({ className }: { className?: string }) { const { status, rows } = useObservableRows(); + const connection = useRealtimeConnectionState(); const specsRead = useSpecsRead(); + const now = Date.now(); + const agents = useAgentsRead(now); const base = { version: 1, scope: "observable-sidebar", subagents: { status: "unproven", count: null } } as const; const source: ObservableRunningSource = rows && status === "ready" ? { ...base, status, threads: rows.filter((t) => !t.isArchived).map((t) => ({ id: t.id, projectId: t.projectId, parentThreadId: t.parentThreadId, isWorking: isRunning(t) })) } @@ -65,7 +72,14 @@ export function FooterCounter({ className }: { className?: string }) { const held = useRef(null); if (rows && status === "ready") held.current = rows; const cardRows = rows ?? held.current; - return ( + const activeRows = cardRows?.filter((t) => !t.isArchived) ?? null; + const stats = computeStats(activeRows, now, "UTC"); + const waitingOnYou = stats.status === "ready" ? stats.waitingOnYou : 0; + const specs = specsRead ? readSpecsFile(specsRead, now) : null; + const file = specs?.status === "ready" ? specs.file : null; + const cloud = cloudAgents(agents, file, status === "ready" && connection === "connected" ? rows : null, now); + const onGitHub = cloud.status === "ready" ? cloud.active : 0; + return ( @@ -80,25 +94,33 @@ const CARD_MARGIN = 8; /** * "N running" (specs-section.v1.md section 7): threads only, with a matrix - * mark and the visible word. The card fills the sidebar, inset 8 px. Hover or focus opens the card; a click (Enter or Space) pins it and - * another unpins it; Escape closes it. Synthetic inputs are not host proof. + * mark and the visible word, plus waiting-on-you and live GitHub agent counts + * when non-zero (dropping GitHub first, then shortening to "N waiting" to fit + * one line). The card fills the sidebar, inset 8 px. Hover or focus opens the + * card; a click (Enter or Space) pins it and another unpins it; Escape closes + * it. Synthetic inputs are not host proof. * R1 (#172): a gap in the source keeps the last known count, and an open card, in place: unmarked for * `FOOTER_HOLD_MS`, then marked last known while the card stays open, and hidden once it is closed. */ -export function FooterCounterArtwork({ source, className, card }: { +export function FooterCounterArtwork({ source, className, card, waitingOnYou = 0, onGitHub = 0 }: { source: RunningCountSource | null; className?: string; card?: (stale: boolean) => ReactNode; + waitingOnYou?: number; + onGitHub?: number; }) { const { footerCountEnabled } = useWizBarSettings(); const live = countRunning(source); - const last = useRef(null); + const last = useRef<{ count: RunningCount; waitingOnYou: number; onGitHub: number } | null>(null); const gapSince = useRef(null); if (live) { - last.current = live; + last.current = { count: live, waitingOnYou, onGitHub }; gapSince.current = null; } else if (gapSince.current === null && last.current) gapSince.current = Date.now(); - const count = live ?? (gapSince.current === null ? null : last.current); + const current = live ? { count: live, waitingOnYou, onGitHub } : (gapSince.current === null ? null : last.current); + const count = current?.count ?? null; + const waiting = current?.waitingOnYou ?? 0; + const github = current?.onGitHub ?? 0; const stale = live === null && gapSince.current !== null && Date.now() - gapSince.current >= FOOTER_HOLD_MS; const [, wake] = useReducer((n: number) => n + 1, 0); const staleAt = live === null && !stale ? gapSince.current : null; @@ -108,14 +130,19 @@ export function FooterCounterArtwork({ source, className, card }: { return () => clearTimeout(timer); }, [staleAt]); const [state, setState] = useState("closed"); - const send = (event: CardEventV4) => setState((current) => cardPinNext(current, event)); + const send = (event: CardEventV4) => setState((currentState) => cardPinNext(currentState, event)); const cardOpen = state !== "closed" && card !== undefined; const shown = footerCountEnabled && count !== null && (!stale || cardOpen); useEffect(() => { if (!shown) setState("closed"); }, [shown]); const wrapper = useRef(null); + const textRef = useRef(null); const [room, setRoom] = useState(null); + const [width, setWidth] = useState(0); + const [fit, setFit] = useState<{ key: string; tier: 0 | 1 | 2 }>({ key: "", tier: 0 }); + const fitKey = `${count?.total ?? ""}:${waiting}:${github}:${width}`; + const tier: 0 | 1 | 2 = fit.key === fitKey ? fit.tier : 0; const open = cardOpen && shown; // The card may use the space above the trigger, less a margin, and its list scrolls. useLayoutEffect(() => { @@ -125,19 +152,42 @@ export function FooterCounterArtwork({ source, className, card }: { window.addEventListener("resize", measure); return () => window.removeEventListener("resize", measure); }, [open]); + useLayoutEffect(() => { + const node = wrapper.current; + if (!shown || !node || typeof ResizeObserver === "undefined") return; + const measure = () => setWidth(Math.round(node.clientWidth)); + measure(); + const observer = new ResizeObserver(measure); + observer.observe(node); + return () => observer.disconnect(); + }, [shown]); + useLayoutEffect(() => { + const el = textRef.current; + if (!shown || !el || el.clientWidth <= 0 || el.scrollWidth <= el.clientWidth) return; + const next: 0 | 1 | 2 | null = + tier === 0 ? (github > 0 ? 1 : waiting > 0 ? 2 : null) + : tier === 1 && waiting > 0 ? 2 + : null; + if (next !== null) setFit({ key: fitKey, tier: next }); + }, [shown, fitKey, tier, github, waiting]); if (!shown || count === null) return null; - const label = `${count.total} running${stale ? ", last known" : ""}`; + const label = [ + `${count.total} running`, + ...(waiting > 0 ? [`${waiting} waiting on you`] : []), + ...(github > 0 ? [`${github} on GitHub`] : []), + ...(stale ? ["last known"] : []), + ].join(", "); return (
send("enter")} onPointerLeave={() => send("leave")} onFocus={() => send("focus")} onBlur={(event) => { if (!event.currentTarget.contains(event.relatedTarget as Node | null)) send("blur"); }} onKeyDown={(event) => { if (event.key === "Escape") send("escape"); }}> send("click")} onKeyDown={(event) => { if (event.key !== "Enter" && event.key !== " ") return; @@ -145,7 +195,22 @@ export function FooterCounterArtwork({ source, className, card }: { send("click"); }}> 0 ? "working" : "idle"} /> - + {/* After the trigger, so Tab moves into the card. The padding bridges the gap to the diff --git a/wizbar/src/StatsPanel.test.tsx b/wizbar/src/StatsPanel.test.tsx index 6c112b6..e704025 100644 --- a/wizbar/src/StatsPanel.test.tsx +++ b/wizbar/src/StatsPanel.test.tsx @@ -103,21 +103,21 @@ describe("V3: footer stats panel", () => { const View = ({ open }: { open: boolean }) => createElement("div", null, createElement(FooterCounter), open ? createElement(Panel, props) : null); const rendered = renderSlot({ component: View }, { open: false }, { pluginId: "synthetic-wz20-gap" }); - expect(screen.getByRole("status", { name: "4 running" })).toBeDefined(); + expect(screen.getByRole("status", { name: "4 running, 3 waiting on you" })).toBeDefined(); await rendered.setRealtimeConnectionState("reconnecting"); await rendered.setRealtimeConnectionState("connected"); // R1 (#172): the line holds its last count through a brief gap, then drops it. - expect(screen.getByRole("status", { name: "4 running" })).toBeDefined(); + expect(screen.getByRole("status", { name: "4 running, 3 waiting on you" })).toBeDefined(); act(() => { vi.advanceTimersByTime(FOOTER_HOLD_MS); }); rendered.rerender(createElement(View, { open: true })); - expect(screen.queryByRole("status", { name: /running$/ })).toBeNull(); + expect(screen.queryByRole("status", { name: /running\b/ })).toBeNull(); expect(lines()[0]).toBe("Stats unavailable"); // The same retained data in new arrays and new row objects (any consumer's // own projection) still does not clear the gap. fixtureFeed.current = { status: "ready", threads: fresh() }; rendered.rerender(createElement(View, { open: true })); expect(lines()[0]).toBe("Stats unavailable"); - expect(screen.queryByRole("status", { name: /running$/ })).toBeNull(); + expect(screen.queryByRole("status", { name: /running\b/ })).toBeNull(); // Closed and reopened: a newly mounted panel's projection cannot clear it. rendered.rerender(createElement(View, { open: false })); rendered.rerender(createElement(View, { open: true })); @@ -126,7 +126,7 @@ describe("V3: footer stats panel", () => { rendered.rerender(createElement(View, { open: true })); expect(lines()[0]).toBe(fixtureCount); expect(lines()[1]).toBe(fixtureLine); - expect(screen.getByRole("status", { name: "4 running" })).toBeDefined(); + expect(screen.getByRole("status", { name: "4 running, 3 waiting on you" })).toBeDefined(); }); // R2: the waiting flag decides running versus waiting, so a malformed one diff --git a/wizbar/src/ThreadCard.test.tsx b/wizbar/src/ThreadCard.test.tsx index a649a28..86b9fec 100644 --- a/wizbar/src/ThreadCard.test.tsx +++ b/wizbar/src/ThreadCard.test.tsx @@ -250,7 +250,7 @@ describe("Muted machine markers at the registered app boundary", () => { } }); -// WZ18 (#40): the card's third line. Synthetic rows; expected text from the +// WZ18 (#40): the card's second line. Synthetic rows; expected text from the // sidebar v3 contract's chip table, not from the code under test. describe("WZ18 card metadata at the registered app boundary", () => { const PR_URL = "https://github.com/example/sample-repo/pull/1088"; @@ -396,4 +396,75 @@ describe("WZ18 card metadata at the registered app boundary", () => { const branch = screen.getByText("room/1042-refine-command-palette-a1b2"); expect(branch.className.split(/\s+/)).toEqual(expect.arrayContaining(["hidden", "group-hover/card:block"])); }); + + it("renders as two lines: title and status/age on line 1; children, model and machine icon on line 2", async () => { + const parent = thread({ environment: environment("git-worktree", "room/1042-refine-command-palette-a1b2") }); + renderMeta([parent, child(1), child(2)], { cardModels: hostModels }); + const row = card(); + const container = row.firstElementChild!; + const lines = [...container.children].filter((el) => el.tagName === "DIV"); + expect(lines).toHaveLength(2); + expect(within(lines[0] as HTMLElement).getByText("Review parser")).toBeDefined(); + expect(within(lines[0] as HTMLElement).getByText("7m")).toBeDefined(); + const details = within(row).getByRole("group", { name: "Thread details" }); + expect(details).toBe(lines[1]); + const childrenChip = await within(details).findByText("2 children"); + const model = await within(details).findByText("Opus 5.5 · Medium"); + const machine = within(details).getByRole("img", { name: "Local" }); + expect(childrenChip.compareDocumentPosition(model) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + expect(model.compareDocumentPosition(machine) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + }); + + it("R1 shows the muted project name first on line 2 under All projects and hides it when scoped to one project", async () => { + const first = thread({ + id: "thr_synfirst", + projectId: projects[0]!.id, + title: "Review parser", + displayTitle: "Review parser", + environment: environment("git-worktree", "room/1042-refine-command-palette-a1b2"), + }); + const second = thread({ + id: "thr_synsecond", + projectId: projects[1]!.id, + title: "Write guide", + displayTitle: "Write guide", + environment: environment("git-worktree", "room/1043-write-guide-c3d4"), + }); + renderMeta([first, second], { + cardModels: hostModels, + pullRequests: { thr_synfirst: pull(1088) }, + }); + const firstDetails = within(card("Review parser")).getByRole("group", { name: "Thread details" }); + const secondDetails = within(card("Write guide")).getByRole("group", { name: "Thread details" }); + const firstProject = within(firstDetails).getByText("Orchard"); + const secondProject = within(secondDetails).getByText("Harbor"); + const linkChip = within(firstDetails).getByRole("link", { name: "#1042 → PR #1088" }); + expect(firstProject.className.split(/\s+/)).toEqual(expect.arrayContaining(["min-w-[4ch]", "truncate", "text-muted-foreground"])); + // The full name stays readable on hover when it truncates. + expect(firstProject.getAttribute("title")).toBe(firstProject.textContent); + expect(firstProject.compareDocumentPosition(linkChip) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + expect(Number(firstProject.style.flexShrink)).toBeGreaterThan(Number(linkChip.style.flexShrink || 1)); + expect(secondProject).toBeDefined(); + + fireEvent.keyDown(screen.getByLabelText(/Project scope/), { key: "Enter" }); + fireEvent.click(screen.getByRole("option", { name: "Harbor" })); + const scopedDetails = within(card("Write guide")).getByRole("group", { name: "Thread details" }); + expect(within(scopedDetails).queryByText("Harbor")).toBeNull(); + }); + + it("R2 clips overflow on line 2 and allows the link chip to shrink", () => { + const sample = thread({ + environment: environment("git-worktree", "room/1042-refine-command-palette-a1b2"), + activity: { workflows: 2, backgroundAgents: 1, backgroundCommands: 0, planMode: 0, goals: 0 }, + }); + renderMeta([sample, child(1)], { + cardModels: hostModels, + pullRequests: { thr_synsample: pull(1088) }, + }); + const details = within(card()).getByRole("group", { name: "Thread details" }); + expect(details.className.split(/\s+/)).toContain("overflow-hidden"); + const linkChip = within(details).getByRole("link", { name: "#1042 → PR #1088" }); + expect(linkChip.className.split(/\s+/)).toEqual(expect.arrayContaining(["min-w-0", "truncate"])); + expect(linkChip.className.split(/\s+/)).not.toContain("shrink-0"); + }); }); diff --git a/wizbar/src/ThreadCard.tsx b/wizbar/src/ThreadCard.tsx index 1889681..55a233d 100644 --- a/wizbar/src/ThreadCard.tsx +++ b/wizbar/src/ThreadCard.tsx @@ -21,9 +21,11 @@ import type { t3sidebarRpcContract } from "./server"; import type { CardModelV3 } from "./v3-types"; /** - * One thread as a three-line card: project and status, title, then model, - * issue/PR link, child count and activity; the branch shows on hover only. The card is the whole point of this sidebar — status lives in the - * row instead of in its position, which is what lets the list stay still. + * One thread as a two-line card: title with status/age at the right, then + * quiet details (project name in All projects, PR/issue link, child count, + * activity, model/effort, harness logo, machine icon); the branch shows on + * hover only. The card is the whole point of this sidebar — status lives in + * the row instead of in its position, which is what lets the list stay still. * * The row is a positioned container with a full-bleed anchor UNDER the * controls, the way bb's own thread row does it: a `