From c7056fbbdbbdf9c5107320c11c168d30ce5d303a Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Wed, 18 Nov 2026 03:01:58 +0000 Subject: [PATCH] fix(web): don't attribute new threads to Kameron before an owner is chosen With no owner chosen (any upgraded or fresh client), new threads were sent with a Kameron origin, so a Jeff client filled Kameron's inbox and its own work was missing from Jeff's view. Send no origin until an owner is chosen: the server then creates no inbox record, so the thread is unclassified and visible in All, which is the view an unchosen client resolves to, exactly like legacy history. Once an owner is picked in the Inbox or New threads picker, new work is attributed to that founder. Task: CLO-866 Model: claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 --- apps/web/src/state/threads.ts | 14 +++++++------- packages/contracts/src/threadInbox.test.ts | 16 ++++++++++++++++ packages/contracts/src/threadInbox.ts | 8 ++++++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/apps/web/src/state/threads.ts b/apps/web/src/state/threads.ts index ce2f941074e78..9e164f425736e 100644 --- a/apps/web/src/state/threads.ts +++ b/apps/web/src/state/threads.ts @@ -12,7 +12,12 @@ import { createThreadEnvironmentAtoms, createThreadFamilyAtoms, } from "@t3tools/client-runtime/state/threads"; -import type { EnvironmentId, OrchestrationV2ThreadShell, ThreadId } from "@t3tools/contracts"; +import { + inboxOriginFor, + type EnvironmentId, + type OrchestrationV2ThreadShell, + type ThreadId, +} from "@t3tools/contracts"; import * as Option from "effect/Option"; import { AsyncResult, Atom } from "effect/reactivity"; @@ -33,12 +38,7 @@ export const olderSettledThreads = createOlderSettledThreadAtoms( export const threadEnvironment = createThreadEnvironmentAtoms( connectionAtomRuntime, threadFamilies.snapshotAtom, - { - getInboxOrigin: () => ({ - kind: "human", - id: getClientSettings().founderInboxOwner ?? "kameron", - }), - }, + { getInboxOrigin: () => inboxOriginFor(getClientSettings()) }, ); const environmentThreads = createEnvironmentThreadStateAtoms(connectionAtomRuntime); export const environmentThreadDetails = createEnvironmentThreadDetailAtoms( diff --git a/packages/contracts/src/threadInbox.test.ts b/packages/contracts/src/threadInbox.test.ts index bb71f853081d0..bde1cf4ca7dd8 100644 --- a/packages/contracts/src/threadInbox.test.ts +++ b/packages/contracts/src/threadInbox.test.ts @@ -7,6 +7,7 @@ import { routeThreadInbox, matchesInboxView, effectiveInboxView, + inboxOriginFor, founderInboxLane, compositeThreadKey, } from "./threadInbox.ts"; @@ -50,6 +51,21 @@ describe("shared fleet organizational inbox", () => { expect([effectiveInboxView(saved), saved.founderInboxOwner]).toEqual([picked, "jeff"]); } }); + it("attributes new work only to a chosen founder and leaves unchosen work in All", () => { + expect(inboxOriginFor({})).toBeUndefined(); + // The server creates no inbox for a human thread without an origin, like legacy history. + for (const view of ["kameron", "jeff", "agents", "shared"] as const) { + expect(matchesInboxView(undefined, view)).toBe(false); + } + expect(matchesInboxView(undefined, effectiveInboxView({}))).toBe(true); + const origin = inboxOriginFor({ founderInboxOwner: "jeff" }); + expect(origin).toEqual(jeff); + const inbox = makeThreadInbox({ actor: origin ?? null }); + expect([matchesInboxView(inbox, "jeff"), matchesInboxView(inbox, "kameron")]).toEqual([ + true, + false, + ]); + }); it("hides bot-only work by default while All and Agents retain it", () => { const inbox = makeThreadInbox({ actor: bot }); expect(matchesInboxView(inbox, "kameron")).toBe(false); diff --git a/packages/contracts/src/threadInbox.ts b/packages/contracts/src/threadInbox.ts index a4f11906e604c..d9bc3b9b7eb87 100644 --- a/packages/contracts/src/threadInbox.ts +++ b/packages/contracts/src/threadInbox.ts @@ -103,6 +103,14 @@ export const effectiveInboxView = (settings: { readonly founderInboxOwner?: Founder | undefined; }): InboxView => settings.founderInboxView ?? settings.founderInboxOwner ?? "all"; +/** New work is attributed only to a chosen founder; otherwise it stays unclassified (All). */ +export const inboxOriginFor = (settings: { + readonly founderInboxOwner?: Founder | undefined; +}): InboxActor | undefined => + settings.founderInboxOwner === undefined + ? undefined + : { kind: "human", id: settings.founderInboxOwner }; + /** All deliberately includes every thread, including unclassified history. */ export function matchesInboxView(inbox: ThreadInbox | null | undefined, view: InboxView) { if (view === "all") return true;