From 1ec175272bdedda60a2ad6dbfcf285d962e5f942 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:00:38 +0000 Subject: [PATCH] fix(web): default to the chosen founder's inbox, All until one is chosen PR63 made the inbox view default to All so upgraded devices keep their untagged history visible. Both founder keys were still decoding defaults, and client settings are saved as a whole snapshot, so the first unrelated settings write stored founderInboxView "all" and founderInboxOwner "kameron" as if chosen. A new founder client then stayed on All, showing the other founder's routine work and agent-only threads, and choosing an owner under New threads never moved the view. Make both keys optional, so absent means not chosen, and resolve the view in one place: the saved view, else the chosen founder's view, else All. Upgraded devices and fresh clients without a founder stay on All; once a founder is chosen, the default hides the other founder's routine work and agent-only threads, while All and Agents stay one pick away. The owner picker shows "Not set" until chosen. New threads from a client with no chosen owner keep today's Kameron attribution. Task: CLO-866 Model: claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/Sidebar.tsx | 4 +-- .../ThreadNotificationCoordinator.tsx | 6 ++-- .../components/sidebar/SidebarInboxBar.tsx | 11 +++++-- apps/web/src/state/threads.ts | 7 ++++- packages/contracts/src/settings.ts | 6 ++-- packages/contracts/src/threadInbox.test.ts | 30 +++++++++++-------- packages/contracts/src/threadInbox.ts | 6 ++++ 7 files changed, 46 insertions(+), 24 deletions(-) diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index d9610ae185b13..65d66899c080b 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -1,4 +1,4 @@ -import { matchesInboxView } from "@t3tools/contracts"; +import { effectiveInboxView, matchesInboxView } from "@t3tools/contracts"; import { SidebarInboxBar } from "./sidebar/SidebarInboxBar"; import { threadRoutingUpdateFromMenuAction } from "./threadActionMenu.logic"; import { attachSidebarTree } from "../lib/sidebarTree"; @@ -1103,7 +1103,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve ); const threads = useQuietThreadShells(); const promotingDraftThreadKeys = usePromotingDraftThreadKeys(); - const inboxView = useClientSettings((settings) => settings.founderInboxView); + const inboxView = useClientSettings(effectiveInboxView); const inboxThreads = threads.filter( (thread) => threadSearchQuery.trim().length > 0 || diff --git a/apps/web/src/components/ThreadNotificationCoordinator.tsx b/apps/web/src/components/ThreadNotificationCoordinator.tsx index 9fdc3945481a2..6bd4ab973eccf 100644 --- a/apps/web/src/components/ThreadNotificationCoordinator.tsx +++ b/apps/web/src/components/ThreadNotificationCoordinator.tsx @@ -1,4 +1,4 @@ -import { matchesInboxView } from "@t3tools/contracts"; +import { effectiveInboxView, matchesInboxView } from "@t3tools/contracts"; import { type EnvironmentThreadShell, type PendingSubagentRequest, @@ -116,7 +116,7 @@ export function startThreadNotifications( const outsideInbox = new Set(); for (const [environmentId, state] of watched) { for (const [threadId, entry] of state.previous) { - if (!matchesInboxView(entry.thread.source.inbox, getClientSettings().founderInboxView)) + if (!matchesInboxView(entry.thread.source.inbox, effectiveInboxView(getClientSettings()))) outsideInbox.add(threadKey({ environmentId, threadId })); } } @@ -143,7 +143,7 @@ export function startThreadNotifications( kind: ThreadNotificationKind, ) => { const { thread, status } = state; - if (!matchesInboxView(thread.source.inbox, getClientSettings().founderInboxView)) return; + if (!matchesInboxView(thread.source.inbox, effectiveInboxView(getClientSettings()))) return; if ( registry .get(environmentThreadShells.hiddenThreadKeysAtom) diff --git a/apps/web/src/components/sidebar/SidebarInboxBar.tsx b/apps/web/src/components/sidebar/SidebarInboxBar.tsx index 8307abc3069d1..6d49242b29f59 100644 --- a/apps/web/src/components/sidebar/SidebarInboxBar.tsx +++ b/apps/web/src/components/sidebar/SidebarInboxBar.tsx @@ -1,9 +1,9 @@ -import type { InboxView } from "@t3tools/contracts"; +import { effectiveInboxView, type InboxView } from "@t3tools/contracts"; import { updateClientSettings, useClientSettings } from "../../hooks/useSettings"; /** A local view of the shared pool; All and search always include every thread. */ export function SidebarInboxBar() { - const view = useClientSettings((settings) => settings.founderInboxView); + const view = useClientSettings(effectiveInboxView); const owner = useClientSettings((settings) => settings.founderInboxOwner); return (
@@ -33,13 +33,18 @@ export function SidebarInboxBar() { New threads{" "} diff --git a/apps/web/src/state/threads.ts b/apps/web/src/state/threads.ts index bfa59ed5af3f9..ce2f941074e78 100644 --- a/apps/web/src/state/threads.ts +++ b/apps/web/src/state/threads.ts @@ -33,7 +33,12 @@ export const olderSettledThreads = createOlderSettledThreadAtoms( export const threadEnvironment = createThreadEnvironmentAtoms( connectionAtomRuntime, threadFamilies.snapshotAtom, - { getInboxOrigin: () => ({ kind: "human", id: getClientSettings().founderInboxOwner }) }, + { + getInboxOrigin: () => ({ + kind: "human", + id: getClientSettings().founderInboxOwner ?? "kameron", + }), + }, ); const environmentThreads = createEnvironmentThreadStateAtoms(connectionAtomRuntime); export const environmentThreadDetails = createEnvironmentThreadDetailAtoms( diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index 460c30a6d759e..a80361cb12ec5 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -404,9 +404,9 @@ export const VoiceTranscriptionDestination = Schema.Union([ export type VoiceTranscriptionDestination = typeof VoiceTranscriptionDestination.Type; export const ClientSettingsSchema = Schema.Struct({ - founderInboxOwner: Founder.pipe(Schema.withDecodingDefault(Effect.succeed("kameron" as const))), - // Upgraded devices have no saved view; a founder view would hide all unclassified history. - founderInboxView: InboxView.pipe(Schema.withDecodingDefault(Effect.succeed("all" as const))), + // Absent until chosen; whole-snapshot saves must not record a default as a choice. + founderInboxOwner: Schema.optionalKey(Founder), + founderInboxView: Schema.optionalKey(InboxView), notificationMode: NotificationMode.pipe( Schema.withDecodingDefault(Effect.succeed("off" as const)), ), diff --git a/packages/contracts/src/threadInbox.test.ts b/packages/contracts/src/threadInbox.test.ts index 2dd747fa7405f..bb71f853081d0 100644 --- a/packages/contracts/src/threadInbox.test.ts +++ b/packages/contracts/src/threadInbox.test.ts @@ -6,6 +6,7 @@ import { makeThreadInbox, routeThreadInbox, matchesInboxView, + effectiveInboxView, founderInboxLane, compositeThreadKey, } from "./threadInbox.ts"; @@ -27,21 +28,26 @@ describe("shared fleet organizational inbox", () => { expect(matchesInboxView(j, "all")).toBe(true); expect(matchesInboxView(k, "all")).toBe(true); }); - it("shows unclassified history on upgraded devices and persists the picked view", () => { + it("keeps All until a founder is chosen, then defaults to that founder's view", () => { const decode = Schema.decodeUnknownSync(ClientSettingsSchema); const encode = Schema.encodeSync(ClientSettingsSchema); const upgraded = decode({ notificationMode: "off" }); - expect(upgraded.founderInboxView).toBe("all"); - expect(upgraded.founderInboxOwner).toBe("kameron"); - for (const unclassified of [undefined, null]) { - expect(matchesInboxView(unclassified, upgraded.founderInboxView)).toBe(true); - expect(matchesInboxView(unclassified, "jeff")).toBe(false); - } - for (const view of ["jeff", "kameron", "shared", "agents", "all"] as const) { - const saved = decode( - encode({ ...upgraded, founderInboxView: view, founderInboxOwner: "jeff" }), - ); - expect([saved.founderInboxView, saved.founderInboxOwner]).toEqual([view, "jeff"]); + // Any later settings write saves the whole snapshot; it must not record an unmade choice. + const resaved = encode(decode(encode(upgraded))); + expect(["founderInboxView", "founderInboxOwner"].filter((key) => key in resaved)).toEqual([]); + expect(effectiveInboxView(upgraded)).toBe("all"); + expect(matchesInboxView(undefined, effectiveInboxView(upgraded))).toBe(true); + const jeffClient = decode(encode({ ...upgraded, founderInboxOwner: "jeff" })); + const view = effectiveInboxView(jeffClient); + expect(view).toBe("jeff"); + expect(matchesInboxView(makeThreadInbox({ actor: jeff }), view)).toBe(true); + expect(matchesInboxView(makeThreadInbox({ actor: kameron }), view)).toBe(false); + expect(matchesInboxView(makeThreadInbox({ actor: bot }), view)).toBe(false); + expect(matchesInboxView(makeThreadInbox({ actor: bot }), "agents")).toBe(true); + expect(matchesInboxView(undefined, "all")).toBe(true); + for (const picked of ["jeff", "kameron", "shared", "agents", "all"] as const) { + const saved = decode(encode({ ...jeffClient, founderInboxView: picked })); + expect([effectiveInboxView(saved), saved.founderInboxOwner]).toEqual([picked, "jeff"]); } }); it("hides bot-only work by default while All and Agents retain it", () => { diff --git a/packages/contracts/src/threadInbox.ts b/packages/contracts/src/threadInbox.ts index d1095320294f0..a4f11906e604c 100644 --- a/packages/contracts/src/threadInbox.ts +++ b/packages/contracts/src/threadInbox.ts @@ -97,6 +97,12 @@ export function founderInboxLane(inbox: ThreadInbox | null | undefined, founder: return inbox.attentionKind; } +/** The chosen view, else the chosen founder's, else All so unclassified history stays visible. */ +export const effectiveInboxView = (settings: { + readonly founderInboxView?: InboxView | undefined; + readonly founderInboxOwner?: Founder | undefined; +}): InboxView => settings.founderInboxView ?? settings.founderInboxOwner ?? "all"; + /** All deliberately includes every thread, including unclassified history. */ export function matchesInboxView(inbox: ThreadInbox | null | undefined, view: InboxView) { if (view === "all") return true;