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
2 changes: 1 addition & 1 deletion apps/server/src/guide/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Some agents lack a level; they run at the next safer one they have, and the comp
keywords: ["room", "multiple agents", "reviewer", "second opinion", "hand off", "teammate"],
body: `A room is a thread with more than one agent: for example one agent doing the work and another reviewing it. Rooms are turned on with {place:threads.enableRooms}; {place:threads.room} sets which agents new threads start with.

You add and remove agents at the top of the model button's panel in the composer: one pill per agent, the picked one being who your next message goes to (typing @ and picking an agent does the same). The model and effort under the pills are that agent's.
You add and remove agents at the top of the model button's panel in the composer: one pill per agent, the picked one being who your next message goes to (typing @ and picking an agent does the same). The model and effort under the pills are that agent's. Pointing at a pill turns its icon into ⋯, a menu to rename the agent or remove it; a right-click, or a long press on a touch screen, opens the same menu, and a double-click renames.

Only one agent works at a time, in the same checkout. Agents in a room can ask each other a question on the side, ask for an independent review of the changes, or hand the next turn to another agent. Up to three agents can answer on the side at once, one answer each, so you can ask a second agent while the first is still answering, and an agent can ask two or three for a review of the same changes in one go.

Expand Down
57 changes: 57 additions & 0 deletions apps/web/src/components/ChatView.agents.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,41 @@ describe("ChatView (full app): agent browser tabs and rooms", () => {
picker.click();
await waitForElement(() => pill(astraId), "Unable to find astra's pill.");

// Pointing at a pill swaps its icon for ⋯ without resizing it: a pill
// that grew could wrap onto the next line, out from under the pointer,
// and flicker between the two. (offsetWidth: the picker's opening
// animation scales bounding boxes.)
const options = () =>
pill(astraId)!.querySelector<HTMLButtonElement>('button[aria-label$=" options"]')!;
const widthBefore = pill(astraId)!.offsetWidth;
// At rest no pill shows its ⋯, the picked one included.
for (const button of document.querySelectorAll(
'[data-room-agents-bar] button[aria-label$=" options"]',
)) {
expect(getComputedStyle(button).visibility).toBe("hidden");
}
await userEvent.hover(pill(astraId)!);
await vi.waitFor(() => expect(getComputedStyle(options()).visibility).toBe("visible"));
expect(pill(astraId)!.offsetWidth).toBe(widthBefore);

// Its menu renames without closing the picker or changing who is picked.
options().click();
const menuItem = (text: string) =>
[...document.querySelectorAll<HTMLElement>('[role="menuitem"]')].find(
(item) => item.textContent === text,
) ?? null;
(await waitForElement(() => menuItem("Rename…"), "The pill's menu should open.")).click();
const nameBox = await waitForElement(
() => pill(astraId)!.querySelector<HTMLInputElement>("input"),
"Rename should open the pill's name box.",
);
await vi.waitFor(() => expect(document.activeElement).toBe(nameBox));
expect(document.querySelector("[data-model-picker-variant]")).not.toBeNull();
expect(pill("primary")?.getAttribute("aria-checked")).toBe("true");
expect(pill(astraId)?.getAttribute("aria-checked")).toBe("false");
await userEvent.keyboard("{Escape}");
await vi.waitFor(() => expect(pill(astraId)!.querySelector("input")).toBeNull());

// "+" starts adding; picking an agent instead means not a new one after
// all, and the list below is that agent's again.
document
Expand Down Expand Up @@ -597,6 +632,28 @@ describe("ChatView (full app): agent browser tabs and rooms", () => {
});
// Still open: picking an agent doesn't close the picker.
expect(document.querySelector("[data-model-picker-variant]")).not.toBeNull();

// A right-click opens the same menu, which removes the agent.
pill(astraId)!.dispatchEvent(
new MouseEvent("contextmenu", { bubbles: true, cancelable: true, button: 2 }),
);
(
await waitForElement(
() => menuItem("Remove from thread"),
"Right-click should open the menu.",
)
).click();
await vi.waitFor(() =>
expect(
wsRequests.find(
(request) =>
request._tag === ORCHESTRATION_WS_METHODS.dispatchCommand &&
(request as { type?: string }).type === "thread.participant.remove",
),
).toMatchObject({ participantId: astraId }),
);
expect(document.querySelector("[data-model-picker-variant]")).not.toBeNull();
expect(pill("primary")?.getAttribute("aria-checked")).toBe("true");
} finally {
useRoomRecipientStore.getState().choose(THREAD_REF, null);
await mounted.cleanup();
Expand Down
9 changes: 6 additions & 3 deletions apps/web/src/components/chat/ModelPickerContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,14 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
return;
}

// A dropdown open over the settings rows, or an agent's name being
// typed, owns the keys: a jump would change the model underneath it.
// A dropdown open over the settings rows, an agent pill's menu, or an
// agent's name being typed, owns the keys: a jump would change the model
// underneath it.
if (
event.target instanceof Element &&
event.target.closest("[data-slot='select-popup'], [data-room-agents-bar] input")
event.target.closest(
"[data-slot='select-popup'], [data-slot='menu-popup'], [data-room-agents-bar] input",
)
) {
return;
}
Expand Down
Loading
Loading