Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eea048e
feat: a project can have a lead chat
badcuban Nov 16, 2026
c5a9917
fix(web): drop the lead chat's keybinding command
badcuban Nov 16, 2026
fd22ec8
feat: the lead chat passes work to threads, and the card starts some …
badcuban Nov 16, 2026
2dd3060
feat(web): a Threads panel groups a project's threads by what needs you
badcuban Nov 16, 2026
cb3fe3a
fix(web): the Threads tab opens on a phone too, and its badge keeps i…
badcuban Nov 16, 2026
447606b
feat(web): a thread's family shows as tabs under the chat header
badcuban Nov 16, 2026
0e896a4
fix(web): family tabs fit their titles and pack to the left
badcuban Nov 17, 2026
1337ea0
fix: passed work keeps the lead's access when handed on, and known pu…
badcuban Nov 17, 2026
fd1a2df
Merge remote-tracking branch 'origin/main' into feat/lead-chat-2-pass
badcuban Nov 17, 2026
009a921
Merge branch 'feat/lead-chat-2-pass' into feat/lead-chat-3-panel-stacked
badcuban Nov 17, 2026
ef9f7f1
Merge branch 'feat/lead-chat-3-panel-stacked' into feat/lead-chat-5-tabs
badcuban Nov 17, 2026
c30e6b8
fix: a lead chat's pass is checked against its ceiling again right be…
badcuban Nov 17, 2026
5fc5d1f
Merge branch 'feat/lead-chat-2-pass' into feat/lead-chat-3-panel-stacked
badcuban Nov 17, 2026
fa6af50
Merge branch 'feat/lead-chat-3-panel-stacked' into feat/lead-chat-5-tabs
badcuban Nov 17, 2026
fdb3039
fix: a lead chat's pass that never ran is marked not sent and stays o…
badcuban Nov 17, 2026
8502866
fix: a pass stopped while prepared, or moved to another computer, sta…
badcuban Nov 17, 2026
4ff5e65
Merge branch 'feat/lead-chat-2-pass' into feat/lead-chat-3-panel-stacked
badcuban Nov 17, 2026
ecd3b3e
Merge branch 'feat/lead-chat-3-panel-stacked' into feat/lead-chat-5-tabs
badcuban Nov 17, 2026
facda57
Merge remote-tracking branch 'origin/main' into feat/lead-chat-2-pass
badcuban Nov 17, 2026
0f5007d
fix: an agent's message still queued when its thread moves arrives as…
badcuban Nov 17, 2026
48194cf
Merge branch 'feat/lead-chat-2-pass' into feat/lead-chat-3-panel-stacked
badcuban Nov 17, 2026
d33e3d5
Merge branch 'feat/lead-chat-3-panel-stacked' into feat/lead-chat-5-tabs
badcuban Nov 17, 2026
f64279e
fix: history handed to an agent never calls another agent's message t…
badcuban Nov 17, 2026
a8da9ad
test(web): the family tabs test waits as long as a slow CI runner needs
badcuban Nov 17, 2026
f526932
Merge remote-tracking branch 'origin/main' into feat/lead-chat-2-pass
badcuban Nov 17, 2026
e12c1a4
Merge branch 'feat/lead-chat-2-pass' into feat/lead-chat-3-panel-stacked
badcuban Nov 17, 2026
1435486
Merge branch 'feat/lead-chat-3-panel-stacked' into feat/lead-chat-5-tabs
badcuban Nov 17, 2026
5fb5471
Merge main into feat/lead-chat-3-panel-stacked
badcuban Nov 17, 2026
0b8f4d9
Merge branch 'feat/lead-chat-3-panel-stacked' into feat/lead-chat-5-tabs
badcuban Nov 17, 2026
1e99230
Merge main into feat/lead-chat-5-tabs
badcuban Nov 17, 2026
df930af
Merge remote-tracking branch 'origin/main' into feat/lead-chat-5-tabs
badcuban Nov 17, 2026
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
6 changes: 3 additions & 3 deletions apps/server/src/guide/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Whether the thread's agent may bring in another model on its own is {place:threa
id: "agent-threads",
title: "Threads agents start",
keywords: ["child thread", "subthread", "thread_start", "spawn", "parallel", "delegate"],
body: `An agent can start threads of its own to work in parallel, and message, read or stop them. Each started thread shows under its parent in the sidebar; its final reply comes back to the parent as a message, which wakes the parent's agent.
body: `An agent can start threads of its own to work in parallel, and message, read or stop them. Each started thread shows under its parent in the sidebar; its final reply comes back to the parent as a message, which wakes the parent's agent. The parent and the threads it started also show as a row of tabs under the chat header, on the parent and on each of its threads: a click opens that thread, with its own message box and draft. The row lists the threads the sidebar shows under the parent; one the user made its own, or whose parent is wrapped, has no row.

{place:threads.agentThreads} decides this: Off, Ask me first (a card in the chat lists the threads and you decide), or Automatic. The same setting covers agents creating or changing scheduled tasks. An agent may start at most 5 threads and send 10 messages to them per message you send.

Expand Down Expand Up @@ -128,9 +128,9 @@ When an agent asks to start several threads, the card has a checkbox per thread,

Only one thread leads a project; making another the lead replaces it. "Stop using as lead chat" turns it back into an ordinary thread, and the threads it started stay with it. Archiving or deleting the lead ends it. A lead can't move to another computer, and each computer keeps its own lead for a project.

The lead's row sits at the top of the sidebar with a flag, says Lead where the project name goes, and never wraps up on its own. The chat shows a Lead chat label beside the title.
The lead's row sits at the top of the sidebar with a flag, says Lead where the project name goes, and never wraps up on its own. The chat shows a Lead chat label beside the title, or, once it has started threads, the family tabs with the lead first.

The Threads tab in the right sidebar shows the project's threads on every computer you can see, grouped as Needs you, Ready for review, Working, Landing, Idle and Done. Open it from the sidebar's list of panels or its + menu, on any thread of the project; it opens by itself the first time a thread becomes the lead on this device. A thread you wrapped up goes under Done (for 7 days, closed until you open it) unless its pull request is still open, which keeps it under Ready for review or Landing. Ready for review says what the pull request waits on, as the Pull requests page does. Click a row to open the thread, or right-click it for the thread's menu. The top line counts what needs you and what's working, with a Lead chat link when you're on another thread.
The Threads tab in the right sidebar shows the project's threads on every computer you can see, grouped as Needs you, Ready for review, Working, Landing, Idle and Done. Open it from the sidebar's list of panels or its + menu, on any thread of the project. A thread you wrapped up goes under Done (for 7 days, closed until you open it) unless its pull request is still open, which keeps it under Ready for review or Landing. Ready for review says what the pull request waits on, as the Pull requests page does. Click a row to open the thread, or right-click it for the thread's menu. The top line counts what needs you and what's working, with a Lead chat link when you're on another thread.

The lead's agent is told its role at the start of every turn. It may start 10 threads and send 20 messages to them per message you send, instead of 5 and 10. It needs {place:threads.agentThreads} to be on, and an agent that can't use the thread tools says so. General chats, a thread another thread still owns, and threads from another computer or an outside agent can't be the lead.`,
},
Expand Down
110 changes: 109 additions & 1 deletion apps/web/src/components/ChatView.agents.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ import {
findVisibleComposerFooter,
mountChatView,
registerChatViewSuiteHooks,
waitForURL,
fixture,
rpcHarness,
} from "./ChatView.browser-harness";
import { readThemePreference } from "../hooks/useTheme";
import { nextFrames, readAfterEachPaint } from "../lib/frameProbe.browser-harness";

vi.mock("../lib/gitStatusState", () => ({
// Read synchronously by the draft seeder to skip a checkout already known
Expand Down Expand Up @@ -1242,6 +1244,104 @@ describe("ChatView (full app): agent browser tabs and rooms", () => {
}
});

it("shows a family as tabs on the parent and its threads, and keeps the row still across a switch", async () => {
const firstChild = "thread-family-first" as ThreadId;
const secondChild = "thread-family-second" as ThreadId;
const loner = "thread-family-loner" as ThreadId;
const withThreads = addThreadToSnapshot(
addThreadToSnapshot(
addThreadToSnapshot(
createSnapshotForTargetUser({
targetMessageId: "msg-user-family-tabs" as MessageId,
targetText: "family tabs target",
}),
firstChild,
),
secondChild,
),
loner,
);
const mounted = await mountChatView({
viewport: DEFAULT_VIEWPORT,
snapshot: {
...withThreads,
threads: withThreads.threads.map((thread) =>
thread.id === firstChild || thread.id === secondChild
? {
...thread,
title: thread.id === firstChild ? "Write the changelog" : "Fix the flaky test",
parentThreadId: THREAD_ID,
attachedToParent: true,
createdAt: thread.id === firstChild ? isoAt(10) : isoAt(20),
}
: thread,
),
},
});
const keyOf = (threadId: ThreadId) =>
scopedThreadKey(scopeThreadRef(LOCAL_ENVIRONMENT_ID, threadId));
const row = () => document.querySelector<HTMLElement>('[data-testid="family-tabs"]');
try {
await waitForElement(row, "The family row should show on the parent.");
const keys = () =>
[...row()!.querySelectorAll<HTMLElement>('[role="tab"]')].map((tab) => tab.dataset.testid);
// A starved CI tab can take seconds to file every thread.
await vi.waitFor(
() =>
expect(keys()).toEqual([
`family-tab-${THREAD_KEY}`,
`family-tab-${keyOf(firstChild)}`,
`family-tab-${keyOf(secondChild)}`,
]),
{ timeout: 10_000 },
);

// Switching to a child: the row stays mounted where it is, every frame.
const rowAtStart = row()!;
const top = rowAtStart.getBoundingClientRect().top;
const samples: { present: boolean; same: boolean; top: number | null }[] = [];
const stop = readAfterEachPaint(() => {
const current = row();
samples.push({
present: current !== null,
same: current === rowAtStart,
top: current?.getBoundingClientRect().top ?? null,
});
});
await page.getByTestId(`family-tab-${keyOf(secondChild)}`).click();
await waitForURL(
mounted.router,
(pathname) => pathname.endsWith(`/${secondChild}`),
"A tab click should open its thread.",
);
await vi.waitFor(
() =>
expect(
row()
?.querySelector(`[data-testid="family-tab-${keyOf(secondChild)}"]`)
?.getAttribute("aria-selected"),
).toBe("true"),
{ timeout: 10_000 },
);
await nextFrames(3);
stop();
expect(samples.length).toBeGreaterThan(0);
expect(samples.every((sample) => sample.present && sample.same)).toBe(true);
expect(samples.every((sample) => sample.top === top)).toBe(true);
// The row says who started this thread: the header's chip gives way.
expect(document.body.textContent).not.toContain("Started by");

// A thread with no family has no row.
await mounted.router.navigate({
to: "/$environmentId/$threadId",
params: { environmentId: LOCAL_ENVIRONMENT_ID, threadId: loner },
});
await vi.waitFor(() => expect(row()).toBeNull(), { timeout: 10_000 });
} finally {
await mounted.cleanup();
}
});

it("names the thread that started this one, in the header and on its request", async () => {
const base = createSnapshotForTargetUser({
targetMessageId: "msg-user-started-by" as MessageId,
Expand Down Expand Up @@ -1282,7 +1382,15 @@ describe("ChatView (full app): agent browser tabs and rooms", () => {
}
: thread,
),
{ ...thisThread, id: parentThreadId, title: "Ship the 0.6 release", messages: [] },
// Its parent is wrapped: no family row stands in for the chip, so the
// header names it (docs/design/lead-chat.md, "Family tabs").
{
...thisThread,
id: parentThreadId,
title: "Ship the 0.6 release",
messages: [],
doneOverride: { state: "done" as const, at: isoAt(400) },
},
],
},
});
Expand Down
49 changes: 0 additions & 49 deletions apps/web/src/components/ChatView.sidebar.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,55 +312,6 @@ describe("ChatView (full app): sidebar", () => {
}
});

it("opens the Threads tab the first time a thread becomes the lead on this device, as the sheet on a narrow window", async () => {
const capabilities = { repositoryIdentity: true, projectLead: true };
const mounted = await mountChatView({
// Below the inline panel's breakpoint, so the panel is the sheet.
viewport: DEFAULT_VIEWPORT,
snapshot: createSnapshotForTargetUser({
targetMessageId: "msg-user-first-lead" as MessageId,
targetText: "first lead",
}),
configureFixture: (nextFixture) => {
nextFixture.serverConfig = {
...nextFixture.serverConfig,
environment: { ...nextFixture.serverConfig.environment, capabilities },
};
nextFixture.welcome = {
...nextFixture.welcome,
environment: { ...nextFixture.welcome.environment, capabilities },
};
},
});

try {
const row = await waitForElement(
() => document.querySelector<HTMLElement>(`[data-testid="thread-row-${THREAD_ID}"]`),
"The thread's sidebar row should be on screen.",
);
const rect = row.getBoundingClientRect();
row.dispatchEvent(
new MouseEvent("contextmenu", {
bubbles: true,
cancelable: true,
clientX: rect.left + 20,
clientY: rect.top + 8,
}),
);
await page.getByRole("button", { name: "Make this the lead chat", exact: true }).click();

await vi.waitFor(
() => {
expect(mounted.router.state.location.search).toMatchObject({ threads: "1" });
expect(document.querySelector("[data-project-board='true']")).not.toBeNull();
},
{ timeout: 8_000, interval: 16 },
);
} finally {
await mounted.cleanup();
}
});

it("narrows the live list to rooms from the View button and marks it while it does", async () => {
const mounted = await mountChatView({
viewport: DEFAULT_VIEWPORT,
Expand Down
11 changes: 9 additions & 2 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ import {
useStore,
} from "../store";
import { readLeadProjectName } from "../leadChat";
import { FamilyTabs, useFamilyTabsShown } from "./chat/FamilyTabs";
import { createProjectSelectorByRef, createThreadSelectorByRef } from "../storeSelectors";
import { useUiStateStore } from "../uiStateStore";
import {
Expand Down Expand Up @@ -2223,6 +2224,7 @@ export default function ChatView(props: ChatViewProps) {
const parentEnvironmentId = remoteOrigin?.environmentId ?? environmentId;
const parentThreadId = remoteOrigin?.threadId ?? activeThread?.parentThreadId ?? null;
const knownParentTitle = useThreadTitle(parentEnvironmentId, parentThreadId);
const familyTabsShown = useFamilyTabsShown(activeThreadKey);
const isLeadChat = useStore(
(state) => activeThreadRef !== null && readLeadProjectName(state, activeThreadRef) !== null,
);
Expand Down Expand Up @@ -8779,8 +8781,9 @@ export default function ChatView(props: ChatViewProps) {
fileBrowserAvailable={!isGeneralChatThread}
taskProgress={taskProgress}
forkContext={forkHeaderContext}
parentContext={parentHeaderContext}
isLeadChat={isLeadChat}
// The family row under the header says both while it shows.
parentContext={familyTabsShown ? null : parentHeaderContext}
isLeadChat={isLeadChat && !familyTabsShown}
outsideOrigin={activeThread.outsideOrigin ?? null}
onOpenParentThread={headerHandlers.onOpenParentThread}
backgroundRuns={headerBackgroundRuns}
Expand Down Expand Up @@ -8896,6 +8899,10 @@ export default function ChatView(props: ChatViewProps) {
>
{chatHeader}
</TitleBarContent>
{/* The open thread's family: its parent and the threads it started. */}
{activeThreadRef !== null && routeKind === "server" ? (
<FamilyTabs threadRef={activeThreadRef} />
) : null}

{threadErrorRateLimitResetCreditDialog}
<ForkThreadDialog
Expand Down
81 changes: 65 additions & 16 deletions apps/web/src/components/Sidebar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,67 @@ export function countThreadAttention(
* and wrapped orders come from the caller's sorts, applied to the rows that
* stand on their own; children keep creation order and are never re-sorted.
*/
/** A parent's children in family order: oldest first, never re-sorted. */
export function sortFamilyChildren<
E extends { readonly thread: { readonly createdAt: string; readonly id: string } },
>(children: readonly E[]): E[] {
return children.toSorted(
(left, right) =>
(toSortableTimestamp(left.thread.createdAt) ?? 0) -
(toSortableTimestamp(right.thread.createdAt) ?? 0) ||
left.thread.id.localeCompare(right.thread.id),
);
}

/**
* Whether a parent heads a live family: it is not wrapped, or a child on a
* computer this app can't see still works or needs the user (that child has
* no row of its own to stand on).
*/
export function headsLiveFamily(
parent: Pick<InboxFamilyEntry, "isDone">,
remoteChildren: readonly InboxRemoteChild[],
): boolean {
return (
!parent.isDone ||
remoteChildren.some((child) => isChildThreadNeedingYou(child) || isChildThreadWorking(child))
);
}

/** Whether a child of a live parent is still in its family (the open thread always is). */
export function isLiveFamilyMember(
child: InboxFamilyExit & { readonly threadKey: string },
parent: { readonly seenAt: string | undefined },
input: { readonly activeThreadKey: string | null; readonly now: string },
): boolean {
return child.threadKey === input.activeThreadKey || !hasLeftLiveFamily(child, parent, input.now);
}

/**
* A parent's open family: the members the sidebar draws under its row and
* the family tabs show (docs/design/lead-chat.md, "Family tabs"). One rule
* for both, so they never disagree. Null when the parent heads no live
* family (wrapped, or no members left).
*/
export function liveFamilyOf<E extends InboxFamilyEntry>(input: {
readonly parent: E;
/** Its attached children, in any order. */
readonly children: readonly E[];
/** Its children on computers this app can't see. */
readonly remoteChildren: readonly InboxRemoteChild[];
readonly activeThreadKey: string | null;
readonly now: string;
}): { readonly children: E[]; readonly remoteChildren: InboxRemoteChild[] } | null {
if (!headsLiveFamily(input.parent, input.remoteChildren)) return null;
const children = sortFamilyChildren(input.children).filter((child) =>
isLiveFamilyMember(child, input.parent, input),
);
const remoteChildren = input.remoteChildren.filter(
(child) => !hasLeftLiveFamily(child, input.parent, input.now),
);
return children.length === 0 && remoteChildren.length === 0 ? null : { children, remoteChildren };
}

export function buildInboxSections<E extends InboxFamilyEntry>(input: {
readonly entries: readonly E[];
readonly parentKeyOf: (entry: E) => string | null;
Expand Down Expand Up @@ -1833,11 +1894,7 @@ export function buildInboxSections<E extends InboxFamilyEntry>(input: {
// A wrapped parent whose children on a computer this app can't see still
// work or need the user stays live: those children have no row of their
// own to stand on, unlike its children here.
const wrapped = (entry: E): boolean =>
entry.isDone &&
!remoteChildrenOf(entry).some(
(child) => isChildThreadNeedingYou(child) || isChildThreadWorking(child),
);
const wrapped = (entry: E): boolean => !headsLiveFamily(entry, remoteChildrenOf(entry));
const childrenByParentKey = new Map<string, E[]>();
for (const entry of input.entries) {
const parent = parentOf(entry);
Expand All @@ -1846,13 +1903,8 @@ export function buildInboxSections<E extends InboxFamilyEntry>(input: {
siblings.push(entry);
childrenByParentKey.set(parent.threadKey, siblings);
}
for (const siblings of childrenByParentKey.values()) {
siblings.sort(
(left, right) =>
(toSortableTimestamp(left.thread.createdAt) ?? 0) -
(toSortableTimestamp(right.thread.createdAt) ?? 0) ||
left.thread.id.localeCompare(right.thread.id),
);
for (const [parentKey, siblings] of childrenByParentKey) {
childrenByParentKey.set(parentKey, sortFamilyChildren(siblings));
}

const liveHeads: E[] = [];
Expand All @@ -1877,10 +1929,7 @@ export function buildInboxSections<E extends InboxFamilyEntry>(input: {
}
if (!wrapped(parent)) {
// Finished with, it moves to Wrapped; otherwise it is in the family.
if (
entry.threadKey !== input.activeThreadKey &&
hasLeftLiveFamily(entry, parent, input.now)
) {
if (!isLiveFamilyMember(entry, parent, input)) {
doneHeads.push(entry);
liveParentByKey.set(entry.threadKey, parent);
}
Expand Down
Loading
Loading