From 1fed3c04a9c195b1f498a3bce343232711f68fa2 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 05:06:31 +0000 Subject: [PATCH 1/3] fix(web): show working, done, and needs-me on filter rows The sidebar filter menu showed one total on each inbox, sender, and environment row. Each row now shows three counts from one classifier: a run that is active or queued, finished work that is not settled, and a thread waiting on a person. Settled threads count in none. The menu reads threads already loaded. Model: grok-4.7 Task: implementation Agent: Codex Lane: magpie Harness: t3/codex Model-family: Grok Model-generation: 4.7 Skills-SHA: installed sha256 linear-company-ops 5dde849d07b26ca18d165a72ade4c6423687110f43d2f1ecf15865ace9fbc7b0, github-repository-ops a1bc3a59cb56aa7db009c844fdda23bd96296e1da3be530b0e4a54fa7f29e958; source commit unknown Co-Authored-By: grok-4.7 --- .../sidebar/SidebarThreadFilterMenu.tsx | 54 +++++- .../sidebar/threadListFilter.logic.test.ts | 155 +++++++++++++++++- .../sidebar/threadListFilter.logic.ts | 108 +++++++++++- 3 files changed, 291 insertions(+), 26 deletions(-) diff --git a/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx b/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx index 18c3a06a4db74..e8a78e34e5571 100644 --- a/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx @@ -28,12 +28,14 @@ import { import { SidebarHeaderIconButton } from "./SidebarThreadHeader"; import { changedThreadListFilters, + EMPTY_THREAD_LIST_FILTER_BUCKETS, inboxMenuOrder, threadListFilterCounts, threadListFilterOf, toggleFilterOption, toggleHiddenEnvironment, type ThreadListFilter, + type ThreadListFilterBucketCounts, } from "./threadListFilter.logic"; const INBOX_LABELS: Record = { @@ -114,7 +116,7 @@ function SidebarThreadFilterOptions({ isChanged: boolean; }) { const connectedEnvironmentIds = useConnectedEnvironmentIds(); - const counts = threadListFilterCounts(countedThreads(), filter, attributionOf); + const counts = threadListFilterCounts(countedThreads(), filter, attributionOf, owner); const shownAttributions = THREAD_ATTRIBUTIONS.filter( (from) => !filter.hiddenAttributions.includes(from), ); @@ -130,13 +132,13 @@ function SidebarThreadFilterOptions({ {inboxOrder.map((inbox) => { const checked = filter.inboxes.includes(inbox); const isLast = checked && filter.inboxes.length === 1; - const count = counts.inboxes.get(inbox) ?? 0; + const count = counts.inboxes.get(inbox) ?? EMPTY_THREAD_LIST_FILTER_BUCKETS; return ( void updateClientSettings({ founderInboxFilter: toggleFilterOption(filter.inboxes, inbox, inboxOrder), @@ -154,13 +156,13 @@ function SidebarThreadFilterOptions({ {THREAD_ATTRIBUTIONS.map((from) => { const checked = shownAttributions.includes(from); const isLast = checked && shownAttributions.length === 1; - const count = counts.from.get(from) ?? 0; + const count = counts.from.get(from) ?? EMPTY_THREAD_LIST_FILTER_BUCKETS; return ( { const shown = toggleFilterOption(shownAttributions, from, THREAD_ATTRIBUTIONS); void updateClientSettings({ @@ -184,13 +186,15 @@ function SidebarThreadFilterOptions({ const checked = shownEnvironmentIds.includes(environment.environmentId); const isLast = checked && shownEnvironmentIds.length === 1; const connected = connectedEnvironmentIds.includes(environment.environmentId); - const count = counts.environments.get(environment.environmentId) ?? 0; + const count = + counts.environments.get(environment.environmentId) ?? + EMPTY_THREAD_LIST_FILTER_BUCKETS; return ( void updateClientSettings({ sidebarHiddenEnvironmentIds: toggleHiddenEnvironment( @@ -240,20 +244,52 @@ function SidebarThreadFilterOptions({ ); } +const STATE_COUNT_COLUMNS = [ + ["working", "working"], + ["done", "done"], + ["needsMe", "needs me"], +] as const satisfies ReadonlyArray; + +function stateCountPhrase(counts: ThreadListFilterBucketCounts) { + return STATE_COUNT_COLUMNS.map(([key, label]) => `${counts[key]} ${label}`).join(", "); +} + function FilterOptionRow({ label, count, indicator, }: { label: string; - count: number; + count: ThreadListFilterBucketCounts; indicator?: ReactNode; }) { return ( {indicator} {label} - {count} + + {STATE_COUNT_COLUMNS.map(([key, name]) => { + const value = count[key]; + return ( + + {value} + {name} + + ); + })} + ); } diff --git a/apps/web/src/components/sidebar/threadListFilter.logic.test.ts b/apps/web/src/components/sidebar/threadListFilter.logic.test.ts index b47e842b49fe0..e1fd0bdd6865e 100644 --- a/apps/web/src/components/sidebar/threadListFilter.logic.test.ts +++ b/apps/web/src/components/sidebar/threadListFilter.logic.test.ts @@ -5,6 +5,7 @@ import { changedThreadListFilters, inboxMenuOrder, matchesThreadListFilter, + threadListFilterBucket, threadListFilterCounts, threadListFilterOf, toggleFilterOption, @@ -42,21 +43,31 @@ describe("thread list filter", () => { }); it("counts each section within the other sections' selection", () => { + const finished = { runtime: { status: "completed" }, latestRun: { status: "completed" } }; const threads = [ - { ...thread(laptop, kameron), from: "kameron" as const }, - { ...thread(laptop, bot), from: "kameron-agents" as const }, - { ...thread(crown, jeff), from: "jeff" as const }, - { ...thread(crown, kameron), from: "kameron" as const }, - { ...thread(laptop, kameron), from: "unknown" as const }, + { ...thread(laptop, kameron), ...finished, from: "kameron" as const }, + { ...thread(laptop, bot), ...finished, from: "kameron-agents" as const }, + { ...thread(crown, jeff), ...finished, from: "jeff" as const }, + { ...thread(crown, kameron), ...finished, from: "kameron" as const }, + { ...thread(laptop, kameron), ...finished, from: "unknown" as const }, ]; const counts = threadListFilterCounts( threads, { inboxes: ["kameron"], hiddenEnvironmentIds: [crown], hiddenAttributions: ["unknown"] }, (candidate) => candidate.from, ); - expect(Object.fromEntries(counts.inboxes)).toEqual({ kameron: 1, agents: 1 }); - expect(Object.fromEntries(counts.environments)).toEqual({ laptop: 1, crown: 1 }); - expect(Object.fromEntries(counts.from)).toEqual({ kameron: 1, unknown: 1 }); + expect(Object.fromEntries(counts.inboxes)).toEqual({ + kameron: { working: 0, done: 1, needsMe: 0 }, + agents: { working: 0, done: 1, needsMe: 0 }, + }); + expect(Object.fromEntries(counts.environments)).toEqual({ + laptop: { working: 0, done: 1, needsMe: 0 }, + crown: { working: 0, done: 1, needsMe: 0 }, + }); + expect(Object.fromEntries(counts.from)).toEqual({ + kameron: { working: 0, done: 1, needsMe: 0 }, + unknown: { working: 0, done: 1, needsMe: 0 }, + }); expect( matchesThreadListFilter( threads[4]!, @@ -107,4 +118,132 @@ describe("thread list filter", () => { expect(toggleHiddenEnvironment([offline, crown], crown, [laptop, crown])).toEqual([offline]); expect(toggleHiddenEnvironment([crown], laptop, [laptop, crown])).toEqual([crown]); }); + + it("buckets working, done and needs-me the same way on every row", () => { + const finished = { runtime: { status: "completed" }, latestRun: { status: "completed" } }; + const quiet = { + ...thread(laptop, kameron), + source: { + inbox: makeThreadInbox({ + actor: kameron, + routing: { attentionKind: "FYI", reason: "fyi" }, + }), + }, + }; + const asked = { + ...quiet, + source: { + inbox: { + ...quiet.source.inbox, + decisionRequest: { + founder: "kameron" as const, + kind: "decision" as const, + question: "Ship it?", + requestedAt: "2026-11-20T00:00:00.000Z", + }, + }, + }, + }; + const attention = { + ...thread(laptop, bot), + ...finished, + source: { + inbox: makeThreadInbox({ + actor: bot, + routing: { + owner: "kameron", + assignee: { kind: "human", id: "kameron" }, + audience: "kameron", + attentionKind: "action", + reason: "review", + }, + }), + }, + }; + const otherAsk = { + ...thread(laptop, jeff), + ...finished, + source: { + inbox: { + ...makeThreadInbox({ + actor: jeff, + routing: { attentionKind: "FYI", reason: "fyi" }, + }), + decisionRequest: { + founder: "jeff" as const, + kind: "decision" as const, + question: "Your call?", + requestedAt: "2026-11-20T00:00:00.000Z", + }, + }, + }, + }; + const fixtures = { + queued: { + ...quiet, + runtime: { status: "queued" }, + latestRun: { status: "queued" }, + }, + running: { + ...quiet, + runtime: { status: "running" }, + latestRun: { status: "running" }, + }, + done: { ...quiet, ...finished }, + failed: { + ...quiet, + runtime: { status: "failed" }, + latestRun: { status: "failed" }, + }, + approval: { + ...quiet, + runtime: { status: "running" }, + latestRun: { status: "running" }, + hasPendingApprovals: true, + }, + question: { + ...quiet, + runtime: { status: "waiting" }, + latestRun: { status: "waiting" }, + hasPendingUserInput: true, + }, + decision: { ...asked, ...finished }, + attention, + settled: { ...quiet, ...finished, settledOverride: "settled" as const }, + otherFounder: otherAsk, + unstarted: quiet, + }; + expect(threadListFilterBucket(fixtures.queued, "kameron")).toBe("working"); + expect(threadListFilterBucket(fixtures.running, "kameron")).toBe("working"); + expect(threadListFilterBucket(fixtures.done, "kameron")).toBe("done"); + expect(threadListFilterBucket(fixtures.failed, "kameron")).toBe("done"); + expect(threadListFilterBucket(fixtures.approval, "kameron")).toBe("needsMe"); + expect(threadListFilterBucket(fixtures.question, "kameron")).toBe("needsMe"); + expect(threadListFilterBucket(fixtures.decision, "kameron")).toBe("needsMe"); + expect(threadListFilterBucket(fixtures.attention, "kameron")).toBe("needsMe"); + expect(threadListFilterBucket(fixtures.settled, "kameron")).toBeNull(); + expect(threadListFilterBucket(fixtures.otherFounder, "kameron")).toBe("done"); + expect(threadListFilterBucket(fixtures.unstarted, "kameron")).toBeNull(); + + const threads = Object.values(fixtures).map((candidate) => ({ + ...candidate, + from: "kameron" as const, + })); + const counts = threadListFilterCounts( + threads, + { + inboxes: ["kameron", "jeff", "agents", "shared"], + hiddenEnvironmentIds: [], + hiddenAttributions: [], + }, + (candidate) => candidate.from, + "kameron", + ); + const kameronRow = { working: 2, done: 2, needsMe: 4 }; + const everyRow = { working: 2, done: 3, needsMe: 4 }; + expect(counts.inboxes.get("kameron")).toEqual(kameronRow); + expect(counts.inboxes.get("jeff")).toEqual({ working: 0, done: 1, needsMe: 0 }); + expect(counts.environments.get(laptop)).toEqual(everyRow); + expect(counts.from.get("kameron")).toEqual(everyRow); + }); }); diff --git a/apps/web/src/components/sidebar/threadListFilter.logic.ts b/apps/web/src/components/sidebar/threadListFilter.logic.ts index 6991999624709..6b6f11402be2e 100644 --- a/apps/web/src/components/sidebar/threadListFilter.logic.ts +++ b/apps/web/src/components/sidebar/threadListFilter.logic.ts @@ -4,6 +4,7 @@ import { } from "@t3tools/client-runtime/state/thread-list-filter"; import { effectiveInboxFilter, + founderInboxLane, Founder, InboxChoice, primaryInbox, @@ -20,12 +21,93 @@ export { interface FilterableThread { readonly environmentId: EnvironmentId; + readonly settledOverride?: "settled" | "active" | null; + readonly hasPendingApprovals?: boolean; + readonly hasPendingUserInput?: boolean; + readonly pendingSubagentRequest?: "approval" | "user_input" | null; + readonly runtime?: { readonly status: string } | null; + readonly latestRun?: { readonly status: string } | null; readonly source: { readonly inbox?: ThreadInbox | null | undefined; readonly createdBy?: string | undefined; }; } +const ACTIVE_RUN_STATUSES: ReadonlySet = new Set([ + "preparing", + "queued", + "starting", + "running", + "waiting", +]); + +const FINISHED_RUN_STATUSES: ReadonlySet = new Set([ + "completed", + "interrupted", + "failed", + "cancelled", + "rolled_back", +]); + +export type ThreadListFilterBucket = "working" | "done" | "needsMe"; + +export interface ThreadListFilterBucketCounts { + readonly working: number; + readonly done: number; + readonly needsMe: number; +} + +export const EMPTY_THREAD_LIST_FILTER_BUCKETS: ThreadListFilterBucketCounts = { + working: 0, + done: 0, + needsMe: 0, +}; + +const activityStatus = (thread: FilterableThread) => + thread.runtime?.status ?? thread.latestRun?.status ?? null; + +const waitsOnHuman = (thread: FilterableThread, viewingFounder: Founder | undefined) => { + if ( + thread.hasPendingApprovals === true || + thread.hasPendingUserInput === true || + thread.pendingSubagentRequest != null + ) { + return true; + } + const inbox = thread.source.inbox; + if (inbox?.pendingHumanRequest === true) { + if (viewingFounder === undefined || inbox.owner === viewingFounder || inbox.owner === null) { + return true; + } + } + const ask = inbox?.decisionRequest; + return ask !== undefined && (viewingFounder === undefined || ask.founder === viewingFounder); +}; + +const attentionForFounder = (thread: FilterableThread, viewingFounder: Founder | undefined) => { + if (viewingFounder === undefined) return false; + const inbox = thread.source.inbox; + return inbox?.attentionKind === "action" && founderInboxLane(inbox, viewingFounder) === "action"; +}; + +export function threadListFilterBucket( + thread: FilterableThread, + viewingFounder?: Founder, +): ThreadListFilterBucket | null { + if (thread.settledOverride === "settled") return null; + const status = activityStatus(thread); + if (waitsOnHuman(thread, viewingFounder)) return "needsMe"; + if (status !== null && ACTIVE_RUN_STATUSES.has(status)) return "working"; + if (attentionForFounder(thread, viewingFounder)) return "needsMe"; + if ( + (status !== null && FINISHED_RUN_STATUSES.has(status)) || + (thread.latestRun != null && FINISHED_RUN_STATUSES.has(thread.latestRun.status)) + ) { + return "done"; + } + return null; +} + const matchesInboxes = (thread: FilterableThread, inboxes: ReadonlyArray) => matchesListedInboxes( primaryInbox(thread.source.inbox), @@ -75,33 +157,41 @@ export function changedThreadListFilters( }; } -const increment = (counts: Map, key: K) => - counts.set(key, (counts.get(key) ?? 0) + 1); - /** * Faceted counts: each section counts threads that pass the other two sections, so a count * is what checking that option would add. */ +const addBucket = ( + counts: Map, + key: K, + bucket: ThreadListFilterBucket | null, +) => { + const current = counts.get(key) ?? EMPTY_THREAD_LIST_FILTER_BUCKETS; + counts.set(key, bucket === null ? current : { ...current, [bucket]: current[bucket] + 1 }); +}; + export function threadListFilterCounts( threads: ReadonlyArray, filter: ThreadListFilter, attributionOf: (thread: T) => ThreadAttribution, + viewingFounder?: Founder, ) { - const inboxes = new Map(); - const environments = new Map(); - const from = new Map(); + const inboxes = new Map(); + const environments = new Map(); + const from = new Map(); for (const thread of threads) { + const bucket = threadListFilterBucket(thread, viewingFounder); const attribution = attributionOf(thread); const environmentShown = !filter.hiddenEnvironmentIds.includes(thread.environmentId); const fromShown = !filter.hiddenAttributions.includes(attribution); const inboxShown = matchesInboxes(thread, filter.inboxes); if (environmentShown && fromShown) { for (const choice of InboxChoice.literals) { - if (matchesInboxes(thread, [choice])) increment(inboxes, choice); + if (matchesInboxes(thread, [choice])) addBucket(inboxes, choice, bucket); } } - if (inboxShown && fromShown) increment(environments, thread.environmentId); - if (inboxShown && environmentShown) increment(from, attribution); + if (inboxShown && fromShown) addBucket(environments, thread.environmentId, bucket); + if (inboxShown && environmentShown) addBucket(from, attribution, bucket); } return { inboxes, environments, from }; } From 2624cb0f43ddb567cdb564b37f11f54a4cf27901 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 05:08:15 +0000 Subject: [PATCH 2/3] fix(web): use the text-3xs token for filter counts Model: grok-4.7 Task: implementation Agent: Codex Lane: magpie Harness: t3/codex Model-family: Grok Model-generation: 4.7 Skills-SHA: installed sha256 linear-company-ops 5dde849d07b26ca18d165a72ade4c6423687110f43d2f1ecf15865ace9fbc7b0, github-repository-ops a1bc3a59cb56aa7db009c844fdda23bd96296e1da3be530b0e4a54fa7f29e958; source commit unknown Co-Authored-By: grok-4.7 --- apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx b/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx index e8a78e34e5571..89bd5c89aab81 100644 --- a/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx @@ -274,7 +274,7 @@ function FilterOptionRow({ Date: Fri, 20 Nov 2026 05:32:09 +0000 Subject: [PATCH 3/3] fix(web): count parked background work as working A thread held by awaited background work has an idle runtime and a finished run. The sidebar Working shelf already treats that as working, so the filter counts do too, even when the inbox also asks for action. Model: grok-4.7 Task: implementation Agent: Codex Lane: magpie Harness: t3/codex Model-family: Grok Model-generation: 4.7 Skills-SHA: installed sha256 linear-company-ops 5dde849d07b26ca18d165a72ade4c6423687110f43d2f1ecf15865ace9fbc7b0, github-repository-ops a1bc3a59cb56aa7db009c844fdda23bd96296e1da3be530b0e4a54fa7f29e958; source commit unknown Co-Authored-By: grok-4.7 --- .../sidebar/threadListFilter.logic.test.ts | 16 ++++++++++++++-- .../components/sidebar/threadListFilter.logic.ts | 9 +++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/sidebar/threadListFilter.logic.test.ts b/apps/web/src/components/sidebar/threadListFilter.logic.test.ts index e1fd0bdd6865e..65d32f9f23ff3 100644 --- a/apps/web/src/components/sidebar/threadListFilter.logic.test.ts +++ b/apps/web/src/components/sidebar/threadListFilter.logic.test.ts @@ -209,6 +209,16 @@ describe("thread list filter", () => { }, decision: { ...asked, ...finished }, attention, + parked: { + ...quiet, + runtime: { status: "idle" }, + latestRun: { status: "completed" }, + }, + parkedAttention: { + ...attention, + runtime: { status: "idle" }, + latestRun: { status: "completed" }, + }, settled: { ...quiet, ...finished, settledOverride: "settled" as const }, otherFounder: otherAsk, unstarted: quiet, @@ -221,6 +231,8 @@ describe("thread list filter", () => { expect(threadListFilterBucket(fixtures.question, "kameron")).toBe("needsMe"); expect(threadListFilterBucket(fixtures.decision, "kameron")).toBe("needsMe"); expect(threadListFilterBucket(fixtures.attention, "kameron")).toBe("needsMe"); + expect(threadListFilterBucket(fixtures.parked, "kameron")).toBe("working"); + expect(threadListFilterBucket(fixtures.parkedAttention, "kameron")).toBe("working"); expect(threadListFilterBucket(fixtures.settled, "kameron")).toBeNull(); expect(threadListFilterBucket(fixtures.otherFounder, "kameron")).toBe("done"); expect(threadListFilterBucket(fixtures.unstarted, "kameron")).toBeNull(); @@ -239,8 +251,8 @@ describe("thread list filter", () => { (candidate) => candidate.from, "kameron", ); - const kameronRow = { working: 2, done: 2, needsMe: 4 }; - const everyRow = { working: 2, done: 3, needsMe: 4 }; + const kameronRow = { working: 4, done: 2, needsMe: 4 }; + const everyRow = { working: 4, done: 3, needsMe: 4 }; expect(counts.inboxes.get("kameron")).toEqual(kameronRow); expect(counts.inboxes.get("jeff")).toEqual({ working: 0, done: 1, needsMe: 0 }); expect(counts.environments.get(laptop)).toEqual(everyRow); diff --git a/apps/web/src/components/sidebar/threadListFilter.logic.ts b/apps/web/src/components/sidebar/threadListFilter.logic.ts index 6b6f11402be2e..2ebaad0a2f2cb 100644 --- a/apps/web/src/components/sidebar/threadListFilter.logic.ts +++ b/apps/web/src/components/sidebar/threadListFilter.logic.ts @@ -97,6 +97,7 @@ export function threadListFilterBucket( if (thread.settledOverride === "settled") return null; const status = activityStatus(thread); if (waitsOnHuman(thread, viewingFounder)) return "needsMe"; + if (thread.runtime?.status === "idle") return "working"; if (status !== null && ACTIVE_RUN_STATUSES.has(status)) return "working"; if (attentionForFounder(thread, viewingFounder)) return "needsMe"; if ( @@ -157,10 +158,6 @@ export function changedThreadListFilters( }; } -/** - * Faceted counts: each section counts threads that pass the other two sections, so a count - * is what checking that option would add. - */ const addBucket = ( counts: Map, key: K, @@ -170,6 +167,10 @@ const addBucket = ( counts.set(key, bucket === null ? current : { ...current, [bucket]: current[bucket] + 1 }); }; +/** + * Faceted counts: each section counts threads that pass the other two sections, so a count + * is what checking that option would add. + */ export function threadListFilterCounts( threads: ReadonlyArray, filter: ThreadListFilter,