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
1 change: 1 addition & 0 deletions apps/server/src/mcp/OrchestratorMcpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ function listItemFromShell(
): OrchestratorMcpThreadListItem {
return {
...(shell.inbox === undefined ? {} : { inbox: shell.inbox }),
...(shell.standing == null ? {} : { standing: shell.standing }),
threadId: shell.id,
projectId: shell.projectId,
title: shell.title,
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/mcp/toolkits/project/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const ThreadLaunchTool = Tool.make("t3_thread_launch", {
standing: Schema.optional(
ThreadStanding.annotate({
description:
"Make it a standing bot thread with this persona ({name, role?, avatarId, accent}). Change later with t3_thread_update set_standing.",
"Make it a standing bot thread with this persona ({name, role?, avatarId, accent}). With inbox omitted, the thread is Shared with FYI attention so both founders see it. Change later with t3_thread_update set_standing.",
}),
),
modelSelection: Schema.optional(ModelSelection),
Expand Down
11 changes: 9 additions & 2 deletions apps/server/src/orchestration-v2/Orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
ProjectId,
} from "@t3tools/contracts";
import {
inboxAfterStandingSet,
makeThreadInbox,
nextFounderSeenMessage,
nextFounderVisits,
Expand Down Expand Up @@ -4891,8 +4892,14 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
};
}
case "thread.standing.set": {
// Standing is identity, not activity: it never bumps updatedAt.
return { ...thread, standing: command.standing };
// Standing is identity, not activity: it never bumps updatedAt. A new persona
// still leaves Agents: background attention is what hid standing bots.
const inbox = inboxAfterStandingSet(thread.inbox, command.standing);
return {
...thread,
standing: command.standing,
...(inbox === undefined ? {} : { inbox }),
};
}
case "thread.tag.set": {
const current = thread.tags ?? [];
Expand Down
7 changes: 7 additions & 0 deletions apps/server/src/peer/linkedSidebar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ it.effect("reads a reachable server-only link and skips catalog and unreachable
threads: [
{
inbox: makeThreadInbox({ actor: { kind: "human", id: "jeff" } }),
standing: { name: "Growth", role: "Pipeline", avatarId: "sprout", accent: "emerald" },
threadId: ThreadId.make("thread-eval"),
projectId: ProjectId.make("project-eval"),
title: "10-model copy eval",
Expand Down Expand Up @@ -105,6 +106,12 @@ it.effect("reads a reachable server-only link and skips catalog and unreachable
"10-model copy eval",
]);
expect(result.environments[0]?.threads[0]?.inbox?.owner).toBe("jeff");
expect(result.environments[0]?.threads[0]?.standing).toEqual({
name: "Growth",
role: "Pipeline",
avatarId: "sprout",
accent: "emerald",
});
expect(result.environments[0]?.threads[0]?.lastVisitedAt).toBe("2026-11-20T03:59:00.000Z");
expect(result.environments[0]?.threads[0]?.latestRunCompletedAt).toBe(
"2026-11-20T03:58:00.000Z",
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/peer/linkedSidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const slimThread = (
thread: (typeof OrchestratorMcpThreadListResult.Type.threads)[number],
): LinkedSidebarThread => ({
...(thread.inbox === undefined ? {} : { inbox: thread.inbox }),
...(thread.standing == null ? {} : { standing: thread.standing }),
threadId: thread.threadId,
projectId: thread.projectId,
title: thread.title,
Expand Down
27 changes: 27 additions & 0 deletions apps/web/src/components/Sidebar.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
groupSidebarThreadsByProject,
resolveSidebarFolderDot,
sidebarFolderExpansionKeys,
filterSidebarV2VisibleThreads,
} from "./Sidebar.logic";
import { scopeThreadRef, scopedThreadKey } from "@t3tools/client-runtime/environment";
import {
Expand Down Expand Up @@ -1730,6 +1731,32 @@ describe("resolveSidebarFolderDot", () => {
});
});

describe("filterSidebarV2VisibleThreads", () => {
it("keeps a standing bot outside the scoped project and hides an ordinary thread there", () => {
const remote = EnvironmentId.make("primary-r720");
const local = EnvironmentId.make("primary-mac-laptop");
const lineage = {
parentThreadId: null,
relationshipToParent: null,
rootThreadId: ThreadId.make("root"),
};
const row = (id: string, standing: { name: string } | null) => ({
archivedAt: null,
environmentId: remote,
id: ThreadId.make(id),
projectId: ProjectId.make("remote-project"),
lineage: { ...lineage, rootThreadId: ThreadId.make(id) },
standing,
});
const visible = filterSidebarV2VisibleThreads(
[row("infra", { name: "Infra" }), row("note", null)],
new Set([`${local}:local-project`]),
new Set(),
);
expect(visible.map((thread) => thread.id)).toEqual([ThreadId.make("infra")]);
});
});

describe("shouldCreateNewThreadInCurrentProject", () => {
it("opens the picker when several projects are open, or only archived ones exist", () => {
expect(shouldCreateNewThreadInCurrentProject(false, 2, 3)).toBe(false);
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/components/Sidebar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ export async function deleteSelectedThreadEntries<
export function filterSidebarV2VisibleThreads<
T extends Pick<SidebarThreadSummary, "archivedAt" | "environmentId" | "id" | "lineage"> & {
projectId: string;
readonly standing?: unknown;
},
>(
threads: readonly T[],
Expand All @@ -622,7 +623,10 @@ export function filterSidebarV2VisibleThreads<
thread.lineage,
delegatedUnderParent,
) &&
(scopedProjectKeys === null ||
// A standing bot on another machine's project still belongs in Bots. Project scope
// continues to hide ordinary threads.
(thread.standing != null ||
scopedProjectKeys === null ||
scopedProjectKeys.has(`${thread.environmentId}:${thread.projectId}`)),
);
}
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ interface SidebarThreadPartitionInput {
readonly optimisticDrop: SidebarOptimisticDrop | null;
readonly workingShelfEnabled: boolean;
readonly inboxFilter: ReadonlyArray<InboxChoice>;
readonly founderInboxOwner: "kameron" | "jeff" | undefined;
/** Boring mode: folders list active threads by the user's latest message. */
readonly sortActiveBySend: boolean;
// Snooze wakes, the queued-turn grace and the Working shelf's exit grace depend
Expand Down Expand Up @@ -483,6 +484,7 @@ function useSidebarThreads(input: {
const workingShelfEnabled =
useClientSettings((s) => s.sidebarWorkingShelfEnabled) && folderGroups === null;
const inboxFilter = useClientSettings(effectiveInboxFilter);
const founderInboxOwner = useClientSettings((settings) => settings.founderInboxOwner);
const inboxReturnsVersion = useSyncExternalStore(
inboxReturns.subscribe,
inboxReturns.getSnapshot,
Expand Down Expand Up @@ -527,6 +529,7 @@ function useSidebarThreads(input: {
optimisticDrop,
workingShelfEnabled,
inboxFilter,
founderInboxOwner,
sortActiveBySend: folderGroups !== null,
clockKey: `${nowMinute}:${snoozeWakeClock}:${inboxReturnsVersion}`,
});
Expand Down Expand Up @@ -681,6 +684,7 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
optimisticDrop,
workingShelfEnabled,
sortActiveBySend,
founderInboxOwner,
} = input;
const preciseNow = new Date().toISOString();
const visible = filterSidebarV2VisibleThreads(threads, scopedProjectKeys, delegatedUnderParent);
Expand Down Expand Up @@ -754,7 +758,7 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
? sortInboxThreadsByReturn(active, inboxObservation.returnedAt)
: sortThreadsForSidebar(active);
const sortedBots = sortBotThreads(bots);
const botGroups = partitionBotGroups(sortedBots);
const botGroups = partitionBotGroups(sortedBots, founderInboxOwner);
return {
botThreads: sortedBots,
myBotThreads: botGroups.mine,
Expand Down
32 changes: 32 additions & 0 deletions apps/web/src/components/bots/botPresence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,36 @@ describe("partitionBotGroups", () => {
mine: [thread("jeff", "jeff"), thread("open")],
});
});

it("shows every standing bot to both founders", () => {
const thread = (id: string, audience?: string) => ({
id,
source: { inbox: audience === undefined ? null : { audience } },
});
const threads = [
thread("shared", "shared"),
thread("mine", "kameron"),
thread("other", "jeff"),
thread("agents", "agent-only"),
thread("open"),
];
expect(partitionBotGroups(threads, "kameron")).toEqual({
mine: [thread("mine", "kameron")],
shared: [
thread("shared", "shared"),
thread("other", "jeff"),
thread("agents", "agent-only"),
thread("open"),
],
});
expect(partitionBotGroups(threads, "jeff")).toEqual({
mine: [thread("other", "jeff")],
shared: [
thread("shared", "shared"),
thread("mine", "kameron"),
thread("agents", "agent-only"),
thread("open"),
],
});
});
});
21 changes: 17 additions & 4 deletions apps/web/src/components/bots/botPresence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,27 @@ export function isSharedBotThread(thread: {
}

/**
* The two bot groups the sidebar shows without an inbox filter: the viewer's own bots, then the
* bots both founders share. A shared bot is never also listed as one's own.
* The two bot groups. Shared audience is Shared Bots. With a viewer, an Agents inbox, a missing
* inbox, or the other founder's bot is Shared Bots too, so both founders see every standing bot.
* The viewer's own founder-audience bots stay in My Bots. A shared bot is never also listed there.
*/
export function partitionBotGroups<
T extends { readonly source: { readonly inbox?: { readonly audience?: string } | null } },
>(threads: readonly T[]): { readonly mine: T[]; readonly shared: T[] } {
>(
threads: readonly T[],
viewer?: "kameron" | "jeff",
): { readonly mine: T[]; readonly shared: T[] } {
const mine: T[] = [];
const shared: T[] = [];
for (const thread of threads) (isSharedBotThread(thread) ? shared : mine).push(thread);
for (const thread of threads) {
const audience = thread.source.inbox?.audience;
const sharedWithBoth =
isSharedBotThread(thread) ||
(viewer !== undefined &&
(audience === "agent-only" ||
audience == null ||
((audience === "kameron" || audience === "jeff") && audience !== viewer)));
(sharedWithBoth ? shared : mine).push(thread);
}
return { mine, shared };
}
6 changes: 4 additions & 2 deletions apps/web/src/components/sidebar/SidebarThreadFilterMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
EMPTY_THREAD_LIST_FILTER_BUCKETS,
inboxMenuOrder,
type olderSettledFilterCounts,
SIDEBAR_FILTER_OPTION_LABEL_CLASS,
SIDEBAR_FILTER_POPUP_CLASS,
threadListFilterCounts,
threadListFilterOf,
toggleFilterOption,
Expand Down Expand Up @@ -93,7 +95,7 @@ export function SidebarThreadFilterMenu<T extends CountedThread>({
<MenuTrigger render={<SidebarHeaderIconButton label={label} />}>
<SlidersHorizontalIcon className={cn("size-4", summary.length > 0 && "text-primary")} />
</MenuTrigger>
<MenuPopup align="end" className="w-[min(19rem,var(--available-width))]">
<MenuPopup align="end" className={SIDEBAR_FILTER_POPUP_CLASS}>
<SidebarThreadFilterOptions
countedThreads={countedThreads}
olderSettled={olderSettled}
Expand Down Expand Up @@ -299,7 +301,7 @@ function FilterOptionRow({
return (
<span className="flex min-w-0 items-center gap-2">
{indicator}
<span className="min-w-0 flex-1 truncate">{label}</span>
<span className={SIDEBAR_FILTER_OPTION_LABEL_CLASS}>{label}</span>
<span className="grid shrink-0 grid-cols-4 gap-x-1.5 text-center">
{STATE_COUNT_COLUMNS.map(([key, name]) => {
const value = count[key];
Expand Down
78 changes: 78 additions & 0 deletions apps/web/src/components/sidebar/threadListFilter.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
inboxMenuOrder,
matchesThreadListFilter,
olderSettledFilterCounts,
SIDEBAR_FILTER_OPTION_LABEL_CLASS,
SIDEBAR_FILTER_POPUP_CLASS,
threadListFilterBucket,
threadListFilterCounts,
threadListFilterOf,
Expand Down Expand Up @@ -355,3 +357,79 @@ describe("thread list filter", () => {
expect(counts.unclassified).toBe(5);
});
});

describe("standing bots stay listed for both founders", () => {
const persona = { name: "Infra" };
const stuck = {
environmentId: crown,
standing: persona,
archivedAt: null,
runtime: { status: "running" },
source: {
inbox: makeThreadInbox({
actor: bot,
routing: {
audience: "kameron",
attentionKind: "background",
owner: "kameron",
assignee: kameron,
reason: "fyi",
},
}),
createdBy: "agent" as const,
},
};

it("lists a background standing bot when Agents is unchecked, for either founder", () => {
for (const owner of ["kameron", "jeff"] as const) {
const filter = {
...threadListFilterOf({ founderInboxOwner: owner }),
inboxes: [owner] as const,
};
expect(matchesThreadListFilter(stuck, filter, "unknown")).toBe(true);
}
expect(
matchesThreadListFilter(
stuck,
{
inboxes: ["kameron", "jeff", "shared", "agents"],
hiddenEnvironmentIds: [crown],
hiddenAttributions: [],
},
"unknown",
),
).toBe(false);
const jeffWithoutAgents = {
...threadListFilterOf({ founderInboxOwner: "jeff" }),
inboxes: ["jeff", "shared"] as const,
};
// Background attention files the lane under Agents, so unchecking Agents hides it.
expect(matchesThreadListFilter({ ...stuck, standing: null }, jeffWithoutAgents)).toBe(false);
expect(matchesThreadListFilter(stuck, jeffWithoutAgents, "unknown")).toBe(true);
});

it("counts a running remote standing bot even when its inbox is unchecked", () => {
const counts = threadListFilterCounts(
[stuck],
{ inboxes: ["jeff"], hiddenEnvironmentIds: [], hiddenAttributions: ["unknown"] },
() => "unknown",
"jeff",
);
expect(counts.environments.get(crown)).toEqual({
working: 1,
done: 0,
needsMe: 0,
settled: 0,
});
});
});

describe("sidebar filter labels", () => {
it("keeps the popover wide enough to show full inbox and environment names", () => {
expect(SIDEBAR_FILTER_POPUP_CLASS).not.toContain("available-width");
expect(SIDEBAR_FILTER_POPUP_CLASS).toContain("40rem");
expect(SIDEBAR_FILTER_OPTION_LABEL_CLASS).not.toContain("truncate");
expect(SIDEBAR_FILTER_OPTION_LABEL_CLASS).toContain("whitespace-nowrap");
expect(SIDEBAR_FILTER_OPTION_LABEL_CLASS).toContain("min-w-[16rem]");
});
});
Loading
Loading