Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions apps/web/src/state/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions packages/contracts/src/threadInbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
routeThreadInbox,
matchesInboxView,
effectiveInboxView,
inboxOriginFor,
founderInboxLane,
compositeThreadKey,
} from "./threadInbox.ts";
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions packages/contracts/src/threadInbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading