Skip to content
Open
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
4 changes: 3 additions & 1 deletion apps/server/src/mcp/OrchestratorMcpService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4967,8 +4967,9 @@ describe("OrchestratorMcpService thread list", () => {
]
: [],
});
const standing = { name: "Ops", role: "Operations", avatarId: "bolt", accent: "sky" } as const;
const shells = [
shell("thread:a-snoozed", "project:a", true),
{ ...shell("thread:a-snoozed", "project:a", true), standing },
shell("thread:a-awake", "project:a", false),
shell("thread:b-snoozed", "project:b", true, true, true),
{
Expand Down Expand Up @@ -5047,6 +5048,7 @@ describe("OrchestratorMcpService thread list", () => {
listed.threads.map((thread) => thread.pinned),
[false, true],
);
assert.deepStrictEqual(listed.threads[0]?.standing, standing);
assert.deepStrictEqual(
listed.threads.map((thread) => [thread.blockedOnThreadWait, thread.pendingBackgroundTasks]),
[
Expand Down
28 changes: 11 additions & 17 deletions apps/server/src/orchestration-v2/Orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4120,23 +4120,17 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
const now = yield* DateTime.now;
const emitEvent = emit(events, command);
const thread: OrchestrationV2AppThread = {
...(command.inboxOrigin === undefined &&
command.inboxRouting === undefined &&
command.createdBy !== "agent"
? {}
: {
inbox: makeThreadInbox({
actor:
command.inboxOrigin ??
(command.createdBy === "agent" ? { kind: "agent", id: "agent" } : null),
...(command.inboxRouting === undefined ? {} : { routing: command.inboxRouting }),
executorEnvironmentId: yield* Effect.serviceOption(ServerEnvironmentIdentity).pipe(
Effect.flatMap((identity) =>
Option.isSome(identity) ? identity.value.getEnvironmentId : Effect.succeed(null),
),
),
}),
}),
inbox: makeThreadInbox({
actor:
command.inboxOrigin ??
(command.createdBy === "agent" ? { kind: "agent", id: "agent" } : null),
...(command.inboxRouting === undefined ? {} : { routing: command.inboxRouting }),
executorEnvironmentId: yield* Effect.serviceOption(ServerEnvironmentIdentity).pipe(
Effect.flatMap((identity) =>
Option.isSome(identity) ? identity.value.getEnvironmentId : Effect.succeed(null),
),
),
}),
createdBy: command.createdBy,
creationSource: command.creationSource,
id: command.threadId,
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/orchestration-v2/ThreadForkService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ContextTransferId,
makeThreadInbox,
OrchestrationV2Actor,
OrchestrationV2AppThread,
OrchestrationV2ContextSourcePoint,
Expand Down Expand Up @@ -103,6 +104,7 @@ export const layer: Layer.Layer<ThreadForkServiceV2> = Layer.succeed(
const { delegatedFrom: _delegatedFrom, ...inherited } = input.sourceProjection.thread;
const targetThread: OrchestrationV2AppThread = {
...inherited,
inbox: inherited.inbox ?? makeThreadInbox({ actor: null }),
// PR context follows the conversation; watching remains the source thread's responsibility.
pullRequests: input.sourceProjection.thread.pullRequests?.map(
({ watch: _watch, ...link }) => link,
Expand Down
21 changes: 21 additions & 0 deletions apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3516,6 +3516,27 @@ it.effect(
...launchInput({ command: "inbox-launch", thread: "inbox-thread" }),
inboxOrigin: { kind: "human" as const, id: "jeff" as const },
};
const unrouted = yield* launches.launch(
launchInput({ command: "no-inbox", thread: "no-inbox" }),
);
const shell = yield* threads.getThreadShell(unrouted.threadId);
assert.equal(shell?.inbox?.audience, "agent-only");
assert.equal(shell?.inbox?.origin, null);
for (const founder of ["jeff", "kameron"] as const) {
const own = yield* launches.launch({
...launchInput({ command: `inbox-${founder}`, thread: `inbox-${founder}` }),
inboxOrigin: { kind: "human", id: founder },
});
const inbox = (yield* threads.getThreadShell(own.threadId))?.inbox;
assert.equal(inbox?.owner, founder);
assert.equal(inbox?.audience, founder);
}
const shared = yield* launches.launch({
...launchInput({ command: "shared-inbox", thread: "shared-inbox" }),
inboxOrigin: { kind: "human", id: "jeff" },
inboxRouting: { audience: "shared" },
});
assert.equal((yield* threads.getThreadShell(shared.threadId))?.inbox?.audience, "shared");
const launched = yield* launches.launch(input);
const original = (yield* threads.getThreadProjection(launched.threadId)).thread.inbox;
assert.equal(original?.owner, "jeff");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,9 @@ describe("ThreadSettlementServiceV2 worker", () => {
});
const idle = makeThread("idle-agent", { inbox: agent, status: "idle" });
const already = done("already", "completed", { settledOverride: "settled" });
const unboundHuman = done("unbound-human", "completed", {
inbox: makeThreadInbox({ actor: null }),
});
const standing = done("standing", "completed", {
standing: { name: "Ops", role: null, avatarId: "bolt", accent: "sky" },
});
Expand All @@ -1077,6 +1080,7 @@ describe("ThreadSettlementServiceV2 worker", () => {
asked,
idle,
already,
unboundHuman,
standing,
human("kameron"),
human("jeff"),
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/orchestration-v2/ThreadSettlementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ export function settlesFinishedAgentWork(
>,
): boolean {
if (thread.standing != null || thread.inbox?.audience !== "agent-only") return false;
// An unattributed conversation uses Agents for routing without becoming autonomous work.
if (thread.inbox.origin === null) return false;
if (!FINISHED_AGENT_RUN_STATUSES.has(thread.status)) return false;
return !agentBackgroundWorkPending(thread);
}
Expand Down
210 changes: 210 additions & 0 deletions apps/web/src/components/Sidebar.founder-inbox.browser.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
import {
DEFAULT_CLIENT_SETTINGS,
EnvironmentId,
ProjectId,
ProviderInstanceId,
ThreadId,
makeThreadInbox,
type Founder,
type LocalApi,
type LinkedSidebarResult,
type LinkedSidebarThread,
} from "@t3tools/contracts";
import { expect, it, vi } from "vite-plus/test";
import { page } from "vite-plus/test/browser";

import { render } from "../../test/render";
import {
__resetClientSettingsPersistenceForTests,
ensureClientSettingsHydrated,
} from "../hooks/useSettings";
import appCss from "../index.css?inline";
import { AppAtomRegistryProvider, appAtomRegistry } from "../rpc/atomRegistry";
import { linkedSidebarByHostAtom } from "../state/linkedSidebar";
import Sidebar from "./Sidebar";
import { SidebarProvider } from "./ui/sidebar";

vi.mock("../localApi", { spy: true });

const environments = ["primary-mac-laptop", "primary-r720", "primary-asus", "omarcy-desktop"].map(
(label) => ({ environmentId: EnvironmentId.make(label), label }),
);

const projectId = ProjectId.make("company");
const fixtureTime = "2026-11-22T00:00:00.000Z";

function standingBot(
name: string,
audience: Founder | "shared" | "agent-only",
): LinkedSidebarThread {
return {
inbox: makeThreadInbox({
actor: { kind: "agent", id: `standing-${name}` },
routing: {
owner: audience === "jeff" || audience === "kameron" ? audience : null,
audience,
attentionKind: "background",
},
}),
standing: { name, accent: "sky", avatarId: "bolt", role: null },
threadId: ThreadId.make(`standing-${name}`),
projectId,
title: name,
createdBy: "agent",
creationSource: "mcp",
status: "idle",
latestRunId: null,
providerInstanceId: ProviderInstanceId.make("codex"),
model: "gpt-5.4",
runtimeMode: "full-access",
interactionMode: "default",
settled: false,
settledAt: null,
snoozed: false,
snoozedUntil: null,
parentThreadId: null,
relationshipToParent: null,
itemCount: 1,
createdAt: fixtureTime,
updatedAt: fixtureTime,
};
}

it.each(["jeff", "kameron"] as const)(
"%s sees their own and Shared Bots, readable filters, and the correct reset",
async (owner) => {
using setup = new DisposableStack();
__resetClientSettingsPersistenceForTests();
setup.defer(__resetClientSettingsPersistenceForTests);
const previousLinks = appAtomRegistry.get(linkedSidebarByHostAtom);
setup.defer(() => appAtomRegistry.set(linkedSidebarByHostAtom, previousLinks));
const style = document.createElement("style");
style.textContent = appCss;
document.head.append(style);
setup.defer(() => style.remove());
await page.viewport(1280, 800);
const shared = ["CEO", "CFO", "CTO", "Product Designer", "Growth"];
const childName = "Delegated CEO research";
const linkedEnvironments = environments.map((environment, index) => ({
...environment,
projects: [
{
id: projectId,
title: "Company",
workspaceRoot: "/projects/company",
defaultModelSelection: null,
createdAt: fixtureTime,
updatedAt: fixtureTime,
deletedAt: null,
scripts: [],
},
],
threads: [
...shared
.filter((_, i) => i % environments.length === index)
.map((name) => standingBot(name, "shared")),
...(index === 0 ? [standingBot("CoS", "kameron")] : []),
...(index === 3
? [standingBot("CoS (Jeff)", "jeff"), standingBot("Personal Finance", "jeff")]
: []),
...(index === 0
? [
{
...standingBot(childName, "agent-only"),
parentThreadId: ThreadId.make("standing-CEO"),
relationshipToParent: "subagent" as const,
},
]
: []),
],
}));
const links: LinkedSidebarResult = { environments: linkedEnvironments };
appAtomRegistry.set(linkedSidebarByHostAtom, new Map([[EnvironmentId.make("local"), links]]));
const persist = vi
.fn<LocalApi["persistence"]["setClientSettings"]>()
.mockResolvedValue(undefined);
using _localApi = vi.spyOn(await import("../localApi"), "ensureLocalApi").mockReturnValue({
persistence: {
getClientSettings: async () => ({
...DEFAULT_CLIENT_SETTINGS,
founderInboxOwner: owner,
founderInboxFilter: [owner],
}),
setClientSettings: persist,
},
} as unknown as LocalApi);
await ensureClientSettingsHydrated();
await using screen = await render(
<AppAtomRegistryProvider>
<SidebarProvider style={{ height: 750 }}>
<Sidebar routeReveal={{ observedKey: null, pendingKey: null }} />
</SidebarProvider>
</AppAtomRegistryProvider>,
);
const mine = screen.getByRole("region", { name: "My Bots" });
const company = screen.getByRole("region", { name: "Shared Bots" });
const jeff = owner === "jeff";
for (const name of jeff ? ["CoS (Jeff)", "Personal Finance"] : ["CoS"]) {
await expect.element(mine.getByText(name, { exact: true })).toBeVisible();
}
for (const name of jeff ? ["CoS"] : ["CoS (Jeff)", "Personal Finance"]) {
await expect.element(screen.getByText(name, { exact: true })).not.toBeInTheDocument();
}
for (const name of shared) {
await expect.element(company.getByText(name, { exact: true })).toBeVisible();
}

const open = () => screen.getByRole("button", { name: /^Filter threads by inbox/ }).click();
await open();
const menu = page.getByRole("menu");
const inboxes = menu.getByRole("group", { name: "Inbox" });
const agents = inboxes.getByRole("menuitemcheckbox", { name: /^Agents,/ });
const personal = inboxes.getByRole("menuitemcheckbox", { name: jeff ? /^Jeff,/ : /^Kameron,/ });
const sharedInbox = inboxes.getByRole("menuitemcheckbox", { name: /^Shared,/ });
await expect.element(personal).toHaveAttribute("aria-checked", "true");
await expect.element(sharedInbox).toHaveAttribute("aria-checked", "true");
await expect.element(agents).toHaveAttribute("aria-checked", "false");
const labels = [
"Kameron",
"Kameron's agents",
"Jeff's agents",
"Unknown",
"Shared",
...environments.map(({ label }) => label),
];
for (const width of [1280, 360]) {
await page.viewport(width, 800);
await expect.element(menu).toBeVisible();

await vi.waitFor(() => {
const popup = menu.element().getBoundingClientRect();
expect(popup.left).toBeGreaterThanOrEqual(0);
expect(popup.right).toBeLessThanOrEqual(width);
for (const label of labels) {
const matches = menu.getByText(label, { exact: true }).elements();
expect(matches.length, label).toBeGreaterThan(0);
for (const element of matches) {
expect(element.scrollWidth, label).toBeLessThanOrEqual(element.clientWidth);
}
}
});
}
await page.viewport(1280, 800);

await agents.click();

await expect.element(agents).toHaveAttribute("aria-checked", "true");

await expect.element(mine.getByText(childName, { exact: true })).not.toBeInTheDocument();
await expect.element(company.getByText(childName, { exact: true })).not.toBeInTheDocument();

await menu.getByRole("menuitem", { name: "Reset to default" }).click();
await vi.waitFor(() =>
expect(persist).toHaveBeenLastCalledWith(expect.objectContaining({ founderInboxFilter: [] })),
);
await open();
await expect.element(personal).toHaveAttribute("aria-checked", "true");
await expect.element(sharedInbox).toHaveAttribute("aria-checked", "true");
await expect.element(agents).toHaveAttribute("aria-checked", "false");
},
);
3 changes: 2 additions & 1 deletion apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
const threads = useSidebarThreadShells();
const promotingDraftThreadKeys = usePromotingDraftThreadKeys();
const threadListFilter = useClientSettings(threadListFilterOf);
const viewingFounder = useClientSettings((settings) => settings.founderInboxOwner);
const founderByEnvironmentId = useClientSettings((settings) => settings.founderByEnvironmentId);
const machineOwners = resolveMachineOwners(serverConfigs, founderByEnvironmentId);
const threadAttributions = resolveThreadAttributions(threads, machineOwners);
Expand All @@ -1236,7 +1237,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
const listFilterApplies = threadSearchQuery.trim().length === 0;
const inboxThreads = listFilterApplies
? threads.filter((thread) =>
matchesThreadListFilter(thread, threadListFilter, attributionOf(thread)),
matchesThreadListFilter(thread, threadListFilter, attributionOf(thread), viewingFounder),
)
: threads;
// The same filter over threads servers counted but did not send, for the Settled total.
Expand Down
26 changes: 19 additions & 7 deletions apps/web/src/components/bots/botPresence.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ThreadId } from "@t3tools/contracts";
import { describe, expect, it } from "vite-plus/test";

import {
Expand Down Expand Up @@ -73,17 +74,28 @@ describe("sortBotThreads", () => {

describe("splitStandingThreads", () => {
it("sends bots to their own group whatever their pin, settle or snooze state", () => {
const persona = { name: "Ops" };
const persona = { name: "Ops", role: null, accent: "sky", avatarId: "bolt" } as const;
const lineage = {
parentThreadId: null,
rootThreadId: ThreadId.make("root"),
relationshipToParent: null,
};
const threads = [
{ id: "a", standing: null, pinnedAt: "2026-11-19T00:00:00Z" },
{ id: "b", standing: persona, pinnedAt: "2026-11-19T00:00:00Z" },
{ id: "c", standing: persona, settledOverride: "settled" },
{ id: "d", standing: persona, snoozedAt: "2026-11-19T00:00:00Z" },
{ id: "e", standing: null },
{ id: "a", standing: null, lineage, pinnedAt: "2026-11-19T00:00:00Z" },
{ id: "b", standing: persona, lineage, pinnedAt: "2026-11-19T00:00:00Z" },
{ id: "c", standing: persona, lineage, settledOverride: "settled" },
{ id: "d", standing: persona, lineage, snoozedAt: "2026-11-19T00:00:00Z" },
{ id: "e", standing: null, lineage },
{ id: "f", standing: persona, lineage: { ...lineage, parentThreadId: ThreadId.make("b") } },
{
id: "g",
standing: persona,
lineage: { ...lineage, relationshipToParent: "subagent" as const },
},
];
const { bots, rest } = splitStandingThreads(threads);
expect(bots.map((thread) => thread.id)).toEqual(["b", "c", "d"]);
expect(rest.map((thread) => thread.id)).toEqual(["a", "e"]);
expect(rest.map((thread) => thread.id)).toEqual(["a", "e", "f", "g"]);
});
});

Expand Down
Loading
Loading