From bc2f2298ae1d07ace54ba9e8931a3ce2fe5b7d47 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Tue, 24 Nov 2026 12:47:39 +0000 Subject: [PATCH 1/2] feat(web): bot groups and org chart, quieter activity timeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sidebar bots now list in three groups: My bots (filed to the viewer's inbox), Closura bots (the old Shared Bots: Shared, Agents or unfiled) and Teammate bots (the other founder's inbox). A founder's CoS lists only when that founder's inbox is shown, so Jeff's CoS stays out of Kameron's view. CEO heads the org tree with CoS under it, Product Designer sits under Product / Site and Daemon under CTO. Platform / CTO and Infra / ARC Ops display as Platform and ARC Ops; stored names are unchanged. A bot or thread out of provider quota reads "Blocked · quota", and a bot keeps it after the failure is seen, like thread rows already did. In the timeline, a lone collapsed update renders in place instead of behind a "1 update" toggle, the live "Working for" status shares one row with the collapsed activity beside it, an expanded activity run keeps a collapse control pinned to the top while its pill is scrolled away, and the "Human conversation" toggle is a muted label. Co-Authored-By: Claude Opus 5.5 --- .../test-t3-app/references/feature-map.md | 2 +- .../features/threads/thread-list-v2-items.tsx | 2 +- apps/web/src/components/ChatView.tsx | 4 +- apps/web/src/components/Sidebar.logic.test.ts | 2 +- apps/web/src/components/Sidebar.tsx | 39 ++++-- .../src/components/bots/botOrgTree.test.ts | 29 ++++- apps/web/src/components/bots/botOrgTree.ts | 29 ++++- .../src/components/bots/botPresence.test.ts | 72 +++++++---- apps/web/src/components/bots/botPresence.ts | 85 +++++++++---- apps/web/src/components/chat/ChatHeader.tsx | 12 +- .../chat/MessagesTimeline.browser.test.tsx | 8 +- .../chat/MessagesTimeline.logic.test.ts | 52 ++++++-- .../components/chat/MessagesTimeline.logic.ts | 72 ++++++++--- .../src/components/chat/MessagesTimeline.tsx | 118 ++++++++++++++---- .../components/chat/TimelineWorkGroupRows.tsx | 10 +- .../components/sidebar/SidebarBotsGroup.tsx | 16 ++- .../components/sidebar/SidebarThreadRow.tsx | 2 +- 17 files changed, 405 insertions(+), 149 deletions(-) diff --git a/.agents/skills/test-t3-app/references/feature-map.md b/.agents/skills/test-t3-app/references/feature-map.md index 8cccd22cad682..8b8760043eb7e 100644 --- a/.agents/skills/test-t3-app/references/feature-map.md +++ b/.agents/skills/test-t3-app/references/feature-map.md @@ -37,7 +37,7 @@ Code: apps/web/src/components/sidebar/ - **sidebar.working-section** — collapsed "Working" section for threads busy with background work. Turn off in **Settings → General → Working section**. - **sidebar.snoozed-shelf** — "Snoozed" threads, hidden until their wake time. - **sidebar.settled-shelf** — "Settled" finished threads. Drag a thread onto the header to settle it. -- **sidebar.bots-group** — "My Bots" and "Shared Bots" groups for standing bot threads. Shared bots are the ones filed to the Shared inbox. +- **sidebar.bots-group** — "My bots", "Closura bots" and "Teammate bots" groups for standing bot threads. My and Teammate bots are filed to the viewer's or the other founder's inbox; Closura bots are Shared, Agents or unfiled. A founder's CoS lists only when that founder's inbox is shown. - **sidebar.project-folder** — per-project folders when **Settings → Labs → Boring sidebar (group by project)** is on; "Pin project" / "Unpin project", "Project settings". - **sidebar.thread-row** — one thread: title, status, PR badge, hover actions. Click opens `/$environmentId/$threadId`. Drop files on it to attach them. - **sidebar.thread-status** — row status labels: "Working", "Waiting", "Needs you", "Needs action", "Usage limit reached", "Failed", "Woke", "Unsent draft". diff --git a/apps/mobile/src/features/threads/thread-list-v2-items.tsx b/apps/mobile/src/features/threads/thread-list-v2-items.tsx index 14acc06c01083..78f7544681f7e 100644 --- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx +++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx @@ -139,7 +139,7 @@ const STATUS_LABEL_BY_STATUS: Partial> = iconTintClassName: "accent-danger-foreground", }, limited: { - label: "Limited", + label: "Blocked · quota", icon: "exclamationmark.circle", className: "text-warning-foreground", iconTintClassName: "accent-warning-foreground", diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index a83f96fbae2d6..425bfed052d6d 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -1,4 +1,4 @@ -import { resolveBotPresence } from "./bots/botPresence"; +import { botPresenceInput, resolveBotPresence } from "./bots/botPresence"; import { resolveThreadLastVisitedAt, resolveThreadStatusPill } from "./Sidebar.logic"; import { useUiStateStore } from "../uiStateStore"; import { ChildThreadApprovals } from "./chat/ChildThreadApprovals"; @@ -1862,7 +1862,7 @@ export default function ChatView(props: ChatViewProps) { }, }); return resolveBotPresence( - pill === null ? null : { ...pill, errorClass: activeThreadShell.runtime?.lastErrorClass }, + botPresenceInput(pill, activeThreadShell.runtime), activeStanding.role, ).avatarState; })(); diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.ts index 3004948057bd4..ff2135572d7de 100644 --- a/apps/web/src/components/Sidebar.logic.test.ts +++ b/apps/web/src/components/Sidebar.logic.test.ts @@ -1873,7 +1873,7 @@ describe("standing bots bound by a scheduled task", () => { it("keeps every standing bot listed when a scheduled task binds its thread after the snapshot", () => { const snapshot = listedBots(new Set()); expect(snapshot.mine.map((thread) => thread.id)).toEqual([cosId]); - expect(snapshot.shared.map((thread) => thread.id)).toEqual([ctoId]); + expect(snapshot.closura.map((thread) => thread.id)).toEqual([ctoId]); // A running scheduled task now reports these threads as its fresh-session threads. const updated = listedBots( diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 0a19c2698ad78..0e997bf9edc58 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -5,6 +5,7 @@ import { threadListFilterOf, } from "./sidebar/threadListFilter.logic"; import { + type FounderByEnvironmentId, launchingThreadIdOf, resolveMachineOwners, resolveThreadAttributions, @@ -424,6 +425,7 @@ interface SidebarThreadPartitionInput { readonly workingShelfEnabled: boolean; readonly inboxFilter: ReadonlyArray; readonly founderInboxOwner: "kameron" | "jeff" | undefined; + readonly machineOwners: FounderByEnvironmentId; /** Boring mode: folders list active threads by the user's latest message. */ readonly sortActiveBySend: boolean; // Snooze wakes, the queued-turn grace and the Working shelf's exit grace depend @@ -516,6 +518,7 @@ function useSidebarThreads(input: { useClientSettings((s) => s.sidebarWorkingShelfEnabled) && folderGroups === null; const inboxFilter = useClientSettings(effectiveInboxFilter); const founderInboxOwner = useClientSettings((settings) => settings.founderInboxOwner); + const founderByEnvironmentId = useClientSettings((settings) => settings.founderByEnvironmentId); const inboxReturnsVersion = useSyncExternalStore( inboxReturns.subscribe, inboxReturns.getSnapshot, @@ -561,6 +564,7 @@ function useSidebarThreads(input: { workingShelfEnabled, inboxFilter, founderInboxOwner, + machineOwners: resolveMachineOwners(serverConfigs, founderByEnvironmentId), sortActiveBySend: folderGroups !== null, clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`, }); @@ -655,7 +659,8 @@ function useSidebarThreads(input: { threads, workingShelfEnabled, searchableThreads: [ - ...botThreads, + // Search looks across every inbox, so it includes a CoS the bot groups leave out. + ...partition.allBotThreads, ...pinnedThreads, ...activeThreads, ...workingThreads, @@ -716,6 +721,7 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) { workingShelfEnabled, sortActiveBySend, founderInboxOwner, + machineOwners, } = input; const preciseNow = new Date().toISOString(); const visible = filterSidebarV2VisibleThreads(threads, scopedProjectKeys, delegatedUnderParent); @@ -789,11 +795,16 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) { ? sortInboxThreadsByReturn(active, inboxObservation.returnedAt) : sortThreadsForSidebar(active); const sortedBots = sortBotThreads(bots); - const botGroups = partitionBotGroups(sortedBots, founderInboxOwner); + const botGroups = partitionBotGroups(sortedBots, founderInboxOwner, { + shownInboxes: input.inboxFilter, + machineOwnerOf: (thread) => machineOwners[thread.environmentId], + }); return { - botThreads: sortedBots, + botThreads: [...botGroups.mine, ...botGroups.closura, ...botGroups.teammates], + allBotThreads: sortedBots, myBotThreads: botGroups.mine, - sharedBotThreads: botGroups.shared, + closuraBotThreads: botGroups.closura, + teammateBotThreads: botGroups.teammates, pinnedThreads: optimisticDrop?.section !== "pinned" || optimisticDrop.order === null ? sortedPinned @@ -1470,7 +1481,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve workingShelfEnabled, botThreads, myBotThreads, - sharedBotThreads, + closuraBotThreads, + teammateBotThreads, pinnedThreads, draggableThreadKeys, activeReorderableThreadKeys, @@ -3561,7 +3573,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve {!isSearchingThreads ? ( <> + ({ id: name, standing: { name } }); @@ -23,8 +23,8 @@ describe("orderBotTree", () => { "CoS", ]), ).toEqual([ - "0:CoS", "0:CEO", + "1:CoS", "1:CTO", "2:Platform", "2:Infra / ARC Ops", @@ -36,6 +36,16 @@ describe("orderBotTree", () => { ]); }); + it("puts Product Designer under Product and Daemon under CTO", () => { + expect(shape(["Daemon", "Product Designer", "Product / Site", "CTO", "CEO"])).toEqual([ + "0:CEO", + "1:CTO", + "2:Daemon", + "1:Product / Site", + "2:Product Designer", + ]); + }); + it("shows a bot as a root when its manager is not in the list", () => { expect(shape(["CTO", "Platform"])).toEqual(["0:CTO", "1:Platform"]); expect(shape(["Platform", "CFO"])).toEqual(["0:CFO", "0:Platform"]); @@ -57,6 +67,15 @@ describe("orderBotTree", () => { }); }); +describe("botDisplayName", () => { + it("shows Platform and ARC Ops under their short names and leaves other names alone", () => { + expect(botDisplayName("Platform / CTO")).toBe("Platform"); + expect(botDisplayName("Infra / ARC Ops")).toBe("ARC Ops"); + expect(botDisplayName("infra/arc ops")).toBe("ARC Ops"); + expect(botDisplayName("CTO")).toBe("CTO"); + }); +}); + describe("founders are not bots", () => { it("recognizes founder names", () => { expect(isFounderName(" Kameron ")).toBe(true); @@ -83,12 +102,12 @@ describe("visibleBotRows", () => { ); it("marks bots with reports and lists everything when nothing is collapsed", () => { - expect(shown([])).toEqual(["0:CoS", "0:CEO-", "1:CTO-", "2:Platform", "1:CFO"]); + expect(shown([])).toEqual(["0:CEO-", "1:CoS", "1:CTO-", "2:Platform", "1:CFO"]); }); it("hides a collapsed bot's whole subtree but not its siblings", () => { - expect(shown(["CTO"])).toEqual(["0:CoS", "0:CEO-", "1:CTO+", "1:CFO"]); - expect(shown(["CEO"])).toEqual(["0:CoS", "0:CEO+"]); + expect(shown(["CTO"])).toEqual(["0:CEO-", "1:CoS", "1:CTO+", "1:CFO"]); + expect(shown(["CEO"])).toEqual(["0:CEO+"]); }); it("ignores a collapse flag on a bot with no reports", () => { diff --git a/apps/web/src/components/bots/botOrgTree.ts b/apps/web/src/components/bots/botOrgTree.ts index d2d9c80c48c94..fda8dd0bfdb45 100644 --- a/apps/web/src/components/bots/botOrgTree.ts +++ b/apps/web/src/components/bots/botOrgTree.ts @@ -1,32 +1,42 @@ /** - * The Bots shelf as an org tree. The chain of command mirrors closura-agent-config - * `config/standing-threads.json` (`reportsTo`): CoS and CEO at the root, the executive team under - * CEO, and the engineering team under CTO. Founders are humans, never bots, so they have no - * place here and never list in the Bots shelf. + * The Bots shelf as an org tree. The chain of command lives here; closura-agent-config + * `config/standing-threads.json` names the seats but carries no reporting lines. CEO is the root, + * with CoS and the executive team under it and the engineering team under CTO. Founders are + * humans, never bots, so they have no place here and never list in the Bots shelf. */ /** Normalized bot name -> the normalized name it reports to; `null` is a root. */ const REPORTS_TO: Readonly> = { - cos: null, ceo: null, + cos: "ceo", cto: "ceo", cfo: "ceo", product: "ceo", growth: "ceo", + "product designer": "product", platform: "cto", "infra / arc ops": "cto", "release engineer": "cto", "pr reviewer": "cto", + daemon: "cto", }; /** Existing persona names that are the same seat under a longer title. */ const ALIASES: Readonly> = { + "chief of staff": "cos", "product / site": "product", + designer: "product designer", "platform / cto": "platform", "infra/arc ops": "infra / arc ops", "arc ops": "infra / arc ops", }; +/** Seats shown under a shorter name than the persona's; the stored name is unchanged. */ +const DISPLAY_NAMES: Readonly> = { + platform: "Platform", + "infra / arc ops": "ARC Ops", +}; + /** Root order and sibling order follow the chart, not the alphabet. */ const SEAT_ORDER = Object.keys(REPORTS_TO); @@ -38,6 +48,15 @@ function botSeat(name: string | null | undefined): string { return ALIASES[key] ?? key; } +/** The name a bot is shown under. */ +export function botDisplayName(name: string): string { + return DISPLAY_NAMES[botSeat(name)] ?? name; +} + +export function isChiefOfStaff(name: string | null | undefined): boolean { + return botSeat(name) === "cos"; +} + export function isFounderName(name: string | null | undefined): boolean { return FOUNDER_NAMES.has((name ?? "").trim().toLowerCase().replace(/\s+/g, " ")); } diff --git a/apps/web/src/components/bots/botPresence.test.ts b/apps/web/src/components/bots/botPresence.test.ts index 179d3a039665f..3ebf3f1e059ce 100644 --- a/apps/web/src/components/bots/botPresence.test.ts +++ b/apps/web/src/components/bots/botPresence.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vite-plus/test"; import { + botPresenceInput, partitionBotGroups, resolveBotPresence, sortBotThreads, @@ -37,7 +38,7 @@ describe("resolveBotPresence", () => { }); expect(resolveBotPresence({ label: "Failed", errorClass: "usage_limit" }, "Ops")).toEqual({ avatarState: "waiting", - line: "Limited", + line: "Blocked · quota", badge: null, }); expect( @@ -87,25 +88,36 @@ describe("splitStandingThreads", () => { }); }); +describe("botPresenceInput", () => { + it("keeps a quota block on the bot after its failure is seen", () => { + const blocked = { status: "failed", lastErrorClass: "usage_limit" } as const; + expect(resolveBotPresence(botPresenceInput(null, blocked), "Ops").line).toBe("Blocked · quota"); + expect( + botPresenceInput(null, { status: "failed", lastErrorClass: "provider_error" }), + ).toBeNull(); + expect(botPresenceInput({ label: "Working" }, blocked)?.label).toBe("Working"); + }); +}); + describe("partitionBotGroups", () => { + const thread = (id: string, audience?: string, name = "Ops", machine?: "kameron" | "jeff") => ({ + id, + machine, + standing: { name }, + source: { inbox: audience === undefined ? null : { audience } }, + }); + it("puts shared-inbox bots in their own group and leaves the rest as mine", () => { - const thread = (id: string, audience?: string) => ({ - id, - source: { inbox: audience === undefined ? null : { audience } }, - }); expect( partitionBotGroups([thread("shared", "shared"), thread("jeff", "jeff"), thread("open")]), ).toEqual({ - shared: [thread("shared", "shared")], + closura: [thread("shared", "shared")], mine: [thread("jeff", "jeff"), thread("open")], + teammates: [], }); }); - it("shows every standing bot to both founders", () => { - const thread = (id: string, audience?: string) => ({ - id, - source: { inbox: audience === undefined ? null : { audience } }, - }); + it("splits Closura bots from the other founder's bots", () => { const threads = [ thread("shared", "shared"), thread("mine", "kameron"), @@ -115,21 +127,35 @@ describe("partitionBotGroups", () => { ]; expect(partitionBotGroups(threads, "kameron")).toEqual({ mine: [thread("mine", "kameron")], - shared: [ - thread("shared", "shared"), - thread("other", "jeff"), - thread("agents", "agent-only"), - thread("open"), - ], + closura: [thread("shared", "shared"), thread("agents", "agent-only"), thread("open")], + teammates: [thread("other", "jeff")], }); expect(partitionBotGroups(threads, "jeff")).toEqual({ mine: [thread("other", "jeff")], - shared: [ - thread("shared", "shared"), - thread("mine", "kameron"), - thread("agents", "agent-only"), - thread("open"), - ], + closura: [thread("shared", "shared"), thread("agents", "agent-only"), thread("open")], + teammates: [thread("mine", "kameron")], }); }); + + it("lists a founder's CoS only when that founder's inbox is shown", () => { + const jeffsCos = thread("jeff-cos", "shared", "CoS", "jeff"); + const filedCos = thread("filed-cos", "jeff", "Chief of Staff"); + const kameronsCos = thread("kameron-cos", "shared", "CoS", "kameron"); + const threads = [jeffsCos, filedCos, kameronsCos, thread("cto", "shared", "CTO", "jeff")]; + const ids = (viewer: "kameron" | "jeff", shownInboxes: string[]) => { + const groups = partitionBotGroups(threads, viewer, { + shownInboxes, + machineOwnerOf: (bot) => bot.machine, + }); + return [...groups.mine, ...groups.closura, ...groups.teammates].map((bot) => bot.id); + }; + expect(ids("kameron", ["kameron", "agents", "shared"])).toEqual(["kameron-cos", "cto"]); + expect(ids("kameron", ["kameron", "jeff", "agents", "shared"])).toEqual([ + "jeff-cos", + "kameron-cos", + "cto", + "filed-cos", + ]); + expect(ids("jeff", ["jeff", "agents", "shared"])).toEqual(["filed-cos", "jeff-cos", "cto"]); + }); }); diff --git a/apps/web/src/components/bots/botPresence.ts b/apps/web/src/components/bots/botPresence.ts index d120f9abf5aa4..cba7bfa02b922 100644 --- a/apps/web/src/components/bots/botPresence.ts +++ b/apps/web/src/components/bots/botPresence.ts @@ -2,7 +2,7 @@ import type { OrchestrationV2ProviderFailureClass } from "@t3tools/contracts"; import type { ThreadStatusPill } from "../Sidebar.logic"; import type { BotAvatarState } from "./BotAvatar"; -import { isFounderName } from "./botOrgTree"; +import { isChiefOfStaff, isFounderName } from "./botOrgTree"; function isFounderStanding(standing: unknown): boolean { const name = (standing as { name?: unknown } | null)?.name; @@ -24,6 +24,25 @@ export type BotPresenceInput = Pick & { readonly errorClass?: OrchestrationV2ProviderFailureClass | null | undefined; }; +/** + * The bot's pill, or a quota block when its runtime is out of provider quota. Like a thread row's + * Limited status, a quota block stays after the failure is seen: the bot cannot work until it ends. + */ +export function botPresenceInput( + pill: Pick | null, + runtime: + | { + readonly status: string; + readonly lastErrorClass?: OrchestrationV2ProviderFailureClass | null | undefined; + } + | null + | undefined, +): BotPresenceInput | null { + if (runtime?.status === "failed" && runtime.lastErrorClass === "usage_limit" && pill === null) + return { label: "Failed", errorClass: "usage_limit" }; + return pill === null ? null : { ...pill, errorClass: runtime?.lastErrorClass }; +} + /** Maps the thread's status pill onto a bot's quieter vocabulary. */ export function resolveBotPresence( pill: BotPresenceInput | null, @@ -36,7 +55,7 @@ export function resolveBotPresence( return { avatarState: "running", line: label, badge: null }; // A usage limit is the bot waiting, not a failure: a calm glow, no failure ring. if (label === "Failed" && pill?.errorClass === "usage_limit") - return { avatarState: "waiting", line: "Limited", badge: null }; + return { avatarState: "waiting", line: "Blocked · quota", badge: null }; if (label === "Failed") return { avatarState: "failed", line: "Failed", badge: null }; if (label === "Completed") return { avatarState: "idle", line: role ?? "New reply", badge: "unread" }; @@ -73,35 +92,51 @@ export function splitStandingThreads( return { bots, rest }; } -/** A shared bot belongs to both founders; every other standing bot is one's own. */ -function isSharedBotThread(thread: { - readonly source: { readonly inbox?: { readonly audience?: string } | null | undefined }; -}): boolean { - return thread.source.inbox?.audience === "shared"; +type Founder = "kameron" | "jeff"; + +interface GroupableBot { + readonly standing: { readonly name: string } | null; + readonly source: { + readonly inbox?: { + readonly audience?: string; + readonly owner?: string | null; + } | null; + }; } +const asFounder = (value: string | null | undefined): Founder | undefined => + value === "kameron" || value === "jeff" ? value : undefined; + /** - * The two bot groups. Shared audience is Shared Bots. With a viewer, an Agents inbox, a missing - * inbox, or the other founder's bot is Shared Bots too, so both founders see every standing bot. - * The viewer's own founder-audience bots stay in My Bots. A shared bot is never also listed there. + * The three bot groups. My bots are filed to the viewer's own inbox, Teammate bots to the other + * founder's, and Closura bots are everything else (Shared, Agents or no inbox). Without a viewer + * every non-shared bot is My bots. A founder's CoS is personal: it lists only for that founder or + * when their inbox is among `shownInboxes`. Its founder is its inbox, else the machine it runs on. */ -export function partitionBotGroups< - T extends { readonly source: { readonly inbox?: { readonly audience?: string } | null } }, ->( +export function partitionBotGroups( threads: readonly T[], - viewer?: "kameron" | "jeff", -): { readonly mine: T[]; readonly shared: T[] } { + viewer?: Founder, + scope?: { + readonly shownInboxes: ReadonlyArray; + readonly machineOwnerOf: (thread: T) => Founder | undefined; + }, +): { readonly mine: T[]; readonly closura: T[]; readonly teammates: T[] } { const mine: T[] = []; - const shared: T[] = []; + const closura: T[] = []; + const teammates: T[] = []; for (const thread of threads) { - const audience = thread.source.inbox?.audience; - const sharedWithBoth = - isSharedBotThread(thread) || - (viewer !== undefined && - (audience === "agent-only" || - audience == null || - ((audience === "kameron" || audience === "jeff") && audience !== viewer))); - (sharedWithBoth ? shared : mine).push(thread); + const inbox = thread.source.inbox; + const audience = inbox?.audience; + if (scope !== undefined && isChiefOfStaff(thread.standing?.name)) { + const founder = + asFounder(audience) ?? asFounder(inbox?.owner) ?? scope.machineOwnerOf(thread); + if (founder !== undefined && founder !== viewer && !scope.shownInboxes.includes(founder)) + continue; + } + if (audience === "shared") closura.push(thread); + else if (viewer === undefined || audience === viewer) mine.push(thread); + else if (asFounder(audience) !== undefined) teammates.push(thread); + else closura.push(thread); } - return { mine, shared }; + return { mine, closura, teammates }; } diff --git a/apps/web/src/components/chat/ChatHeader.tsx b/apps/web/src/components/chat/ChatHeader.tsx index 0cad8953de62f..ca1ae4bf342e4 100644 --- a/apps/web/src/components/chat/ChatHeader.tsx +++ b/apps/web/src/components/chat/ChatHeader.tsx @@ -45,6 +45,7 @@ import { textDirection } from "~/textDirection"; import { useClientSettings } from "../../hooks/useSettings"; import { GuestShareIndicator } from "./GuestShareControls"; import { BotAvatar, type BotAvatarState } from "../bots/BotAvatar"; +import { botDisplayName } from "../bots/botOrgTree"; interface ChatHeaderProps { activeThreadEnvironmentId: EnvironmentId; @@ -277,13 +278,13 @@ export const ChatHeader = memo(function ChatHeader({ /> + ); +} + +/** An expanded run's collapse control, pinned to the top while the run's own pill is scrolled away. */ +function StickyActivityCollapse({ + row, + belowTitlebarFade, + onCollapse, +}: { + row: Extract; + belowTitlebarFade: boolean; + onCollapse: () => void; +}) { + return ( +
+
+ - {row.summary} - +
); } +function ActivityTimelineRow({ row }: { row: Extract }) { + const ctx = use(TimelineRowCtx); + const pill = ctx.onToggleActivity(row)} />; + if (row.working) return ; + return ( +
{pill}
+ ); +} + function TurnFoldTimelineRow({ row }: { row: Extract }) { const ctx = use(TimelineRowCtx); const { loading, error, toggle } = useDeferredWorkLoading(row, () => diff --git a/apps/web/src/components/chat/TimelineWorkGroupRows.tsx b/apps/web/src/components/chat/TimelineWorkGroupRows.tsx index 1784f38da4557..f01a7235eb4a0 100644 --- a/apps/web/src/components/chat/TimelineWorkGroupRows.tsx +++ b/apps/web/src/components/chat/TimelineWorkGroupRows.tsx @@ -344,7 +344,14 @@ function ExpandedWorkGroupEntries({ const workEntryKey = (entry: TimelineWorkEntry) => entry.id; -export function WorkingTimelineRow({ row }: { row: Extract }) { +export function WorkingTimelineRow({ + row, + trailing, +}: { + row: Extract; + /** The collapsed activity this status shares its row with. */ + trailing?: ReactNode; +}) { const { isCompacting, isPreparingWorktree, backgroundWorktreeSetup } = use(TimelineRowActivityCtx); const compacting = row.compacting === true || isCompacting; @@ -370,6 +377,7 @@ export function WorkingTimelineRow({ row }: { row: Extract{label} : null} + {trailing} {backgroundWorktreeSetup ? ( ) : null} diff --git a/apps/web/src/components/sidebar/SidebarBotsGroup.tsx b/apps/web/src/components/sidebar/SidebarBotsGroup.tsx index 68fd9b229bc76..75d0266ae5dde 100644 --- a/apps/web/src/components/sidebar/SidebarBotsGroup.tsx +++ b/apps/web/src/components/sidebar/SidebarBotsGroup.tsx @@ -25,8 +25,8 @@ import { contextMenuSourceOf } from "../../contextMenuSource"; import { useThreadSelectionStore } from "../../threadSelectionStore"; import { useUiStateStore } from "../../uiStateStore"; import { BotAvatar, BOT_ACCENT_CLASSES } from "../bots/BotAvatar"; -import { orderBotTree, visibleBotRows } from "../bots/botOrgTree"; -import { resolveBotPresence } from "../bots/botPresence"; +import { botDisplayName, orderBotTree, visibleBotRows } from "../bots/botOrgTree"; +import { botPresenceInput, resolveBotPresence } from "../bots/botPresence"; import { resolveThreadLastVisitedAt, resolveThreadStatusPill } from "../Sidebar.logic"; import { useClientSettings } from "../../hooks/useSettings"; @@ -163,6 +163,7 @@ const SidebarBotRow = memo(function SidebarBotRow( ) { const { thread, threadKey } = props; const standing = thread.standing!; + const name = botDisplayName(standing.name); const threadRef = scopeThreadRef(thread.environmentId, thread.id); const localLastVisitedAt = useUiStateStore((state) => state.threadLastVisitedAtById[threadKey]); const lastVisitedAt = resolveThreadLastVisitedAt(thread.lastVisitedAt, localLastVisitedAt); @@ -179,10 +180,7 @@ const SidebarBotRow = memo(function SidebarBotRow( : typingLabel( (props.typing?.[thread.id] ?? []).filter((founder) => founder !== viewingFounder), ); - const presence = resolveBotPresence( - pill === null ? null : { ...pill, errorClass: thread.runtime?.lastErrorClass }, - standing.role, - ); + const presence = resolveBotPresence(botPresenceInput(pill, thread.runtime), standing.role); const accent = BOT_ACCENT_CLASSES[standing.accent]; const handleKeyDown = (event: KeyboardEvent) => { if (event.target !== event.currentTarget) return; @@ -204,7 +202,7 @@ const SidebarBotRow = memo(function SidebarBotRow( data-testid="sidebar-bot-row" data-bot-state={presence.avatarState} aria-current={props.isActive ? "page" : undefined} - aria-label={`${standing.name}${typingText ? `, ${typingText}` : presence.line ? `, ${presence.line}` : ""}${attentionLabel( + aria-label={`${name}${typingText ? `, ${typingText}` : presence.line ? `, ${presence.line}` : ""}${attentionLabel( attention, )}${ presence.badge === "needs-you" @@ -245,7 +243,7 @@ const SidebarBotRow = memo(function SidebarBotRow( state={presence.avatarState} /> - {standing.name} + {name} {typingText ? ( { diff --git a/apps/web/src/components/sidebar/SidebarThreadRow.tsx b/apps/web/src/components/sidebar/SidebarThreadRow.tsx index 991db4b02bb74..97bfc7a29edd5 100644 --- a/apps/web/src/components/sidebar/SidebarThreadRow.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadRow.tsx @@ -835,7 +835,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP } : status === "limited" ? { - label: "Limited", + label: "Blocked · quota", icon: "failed" as const, className: "text-warning-foreground", } From 9569ab3114a58c2e9a04c6e3b3cc10a98fa8cc1e Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Tue, 24 Nov 2026 13:12:26 +0000 Subject: [PATCH 2/2] fix(web): stable bot group keys, CoS fallback test, feature map wording MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Repairs from the independent review of the sidebar and timeline change. Bot group collapse state is keyed by a stable group id, and saved "My Bots"/"Shared Bots" entries are renamed on load. An unowned CoS stays listed for every viewer, now pinned by a test and a comment. The feature map names the "Blocked · quota" status and the real CoS rule. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/test-t3-app/references/feature-map.md | 4 ++-- apps/web/src/components/Sidebar.tsx | 3 +++ apps/web/src/components/bots/botPresence.test.ts | 10 ++++++++++ apps/web/src/components/bots/botPresence.ts | 1 + apps/web/src/components/sidebar/SidebarBotsGroup.tsx | 4 +++- apps/web/src/uiStateStore.test.ts | 5 +++++ apps/web/src/uiStateStore.ts | 10 +++++++++- 7 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.agents/skills/test-t3-app/references/feature-map.md b/.agents/skills/test-t3-app/references/feature-map.md index 8b8760043eb7e..19ccd20611a1d 100644 --- a/.agents/skills/test-t3-app/references/feature-map.md +++ b/.agents/skills/test-t3-app/references/feature-map.md @@ -37,10 +37,10 @@ Code: apps/web/src/components/sidebar/ - **sidebar.working-section** — collapsed "Working" section for threads busy with background work. Turn off in **Settings → General → Working section**. - **sidebar.snoozed-shelf** — "Snoozed" threads, hidden until their wake time. - **sidebar.settled-shelf** — "Settled" finished threads. Drag a thread onto the header to settle it. -- **sidebar.bots-group** — "My bots", "Closura bots" and "Teammate bots" groups for standing bot threads. My and Teammate bots are filed to the viewer's or the other founder's inbox; Closura bots are Shared, Agents or unfiled. A founder's CoS lists only when that founder's inbox is shown. +- **sidebar.bots-group** — "My bots", "Closura bots" and "Teammate bots" groups for standing bot threads. My and Teammate bots are filed to the viewer's or the other founder's inbox; Closura bots are Shared, Agents or unfiled. A founder's CoS lists for that founder, and for the other founder only when its owner's inbox is shown. - **sidebar.project-folder** — per-project folders when **Settings → Labs → Boring sidebar (group by project)** is on; "Pin project" / "Unpin project", "Project settings". - **sidebar.thread-row** — one thread: title, status, PR badge, hover actions. Click opens `/$environmentId/$threadId`. Drop files on it to attach them. -- **sidebar.thread-status** — row status labels: "Working", "Waiting", "Needs you", "Needs action", "Usage limit reached", "Failed", "Woke", "Unsent draft". +- **sidebar.thread-status** — row status labels: "Working", "Waiting", "Needs you", "Needs action", "Blocked · quota", "Failed", "Woke", "Unsent draft". - **sidebar.thread-hover-actions** — "Settle", "Un-settle", "Wake" buttons; press and drag to apply to a range. - **sidebar.draft-row** — unsent draft; "Discard draft" (with Undo). - **sidebar.thread-menu** — right-click a thread row: diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 0e997bf9edc58..7f78fd1ae4ee0 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -3574,6 +3574,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve <> { "filed-cos", ]); expect(ids("jeff", ["jeff", "agents", "shared"])).toEqual(["filed-cos", "jeff-cos", "cto"]); + // A CoS nobody owns stays listed for every viewer. + const unowned = thread("unowned-cos", undefined, "CoS"); + for (const viewer of ["kameron", "jeff"] as const) { + expect( + partitionBotGroups([unowned], viewer, { + shownInboxes: [viewer], + machineOwnerOf: () => undefined, + }).closura, + ).toEqual([unowned]); + } }); }); diff --git a/apps/web/src/components/bots/botPresence.ts b/apps/web/src/components/bots/botPresence.ts index cba7bfa02b922..f22f458b94b74 100644 --- a/apps/web/src/components/bots/botPresence.ts +++ b/apps/web/src/components/bots/botPresence.ts @@ -130,6 +130,7 @@ export function partitionBotGroups( if (scope !== undefined && isChiefOfStaff(thread.standing?.name)) { const founder = asFounder(audience) ?? asFounder(inbox?.owner) ?? scope.machineOwnerOf(thread); + // A CoS with no known founder stays listed for everyone rather than vanish. if (founder !== undefined && founder !== viewer && !scope.shownInboxes.includes(founder)) continue; } diff --git a/apps/web/src/components/sidebar/SidebarBotsGroup.tsx b/apps/web/src/components/sidebar/SidebarBotsGroup.tsx index 75d0266ae5dde..1f4c752209ac9 100644 --- a/apps/web/src/components/sidebar/SidebarBotsGroup.tsx +++ b/apps/web/src/components/sidebar/SidebarBotsGroup.tsx @@ -54,6 +54,8 @@ export function SidebarBotsGroup( readonly activeThreadKey: string | null; /** The group's heading; "Bots" keeps the single group for a search or an older list. */ readonly label?: string; + /** Keys the saved collapsed state, so renaming the label keeps it. */ + readonly groupId?: string; readonly testId?: string; }, ) { @@ -68,7 +70,7 @@ export function SidebarBotsGroup( const botCollapsedById = useUiStateStore((state) => state.botCollapsedById); const setBotCollapsed = useUiStateStore((state) => state.setBotCollapsed); const label = props.label ?? "Bots"; - const groupKey = `group:${label}`; + const groupKey = `group:${props.groupId ?? "bots"}`; const groupCollapsed = botCollapsedById[groupKey] === true; const rows = visibleBotRows( orderBotTree(props.threads), diff --git a/apps/web/src/uiStateStore.test.ts b/apps/web/src/uiStateStore.test.ts index e763e88a14e32..7e38b3e4174e7 100644 --- a/apps/web/src/uiStateStore.test.ts +++ b/apps/web/src/uiStateStore.test.ts @@ -110,6 +110,11 @@ describe("bot collapse state", () => { .botCollapsedById, ).toEqual({ a: true }); expect(parsePersistedState({}).botCollapsedById).toEqual({}); + expect( + parsePersistedState({ + botCollapsedById: { "group:My Bots": true, "group:Shared Bots": true }, + }).botCollapsedById, + ).toEqual({ "group:mine": true, "group:closura": true }); }); }); diff --git a/apps/web/src/uiStateStore.ts b/apps/web/src/uiStateStore.ts index 855aeb13545ba..ee30ebf072fe2 100644 --- a/apps/web/src/uiStateStore.ts +++ b/apps/web/src/uiStateStore.ts @@ -124,6 +124,12 @@ function sanitizeTimestampRecord(value: unknown): Record { ); } +/** Bot groups were keyed by their labels before they had stable ids. */ +const LEGACY_BOT_GROUP_KEYS: Readonly> = { + "group:My Bots": "group:mine", + "group:Shared Bots": "group:closura", +}; + export function parsePersistedState(parsed: PersistedUiState): UiState { const projectExpandedById = parsed.projectExpandedById === undefined @@ -150,7 +156,9 @@ export function parsePersistedState(parsed: PersistedUiState): UiState { return { botCollapsedById: Object.fromEntries( - Object.entries(sanitizeBooleanRecord(parsed.botCollapsedById)).filter(([, value]) => value), + Object.entries(sanitizeBooleanRecord(parsed.botCollapsedById)) + .filter(([, value]) => value) + .map(([key, value]) => [LEGACY_BOT_GROUP_KEYS[key] ?? key, value]), ), projectExpandedById, projectOrder,