Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
feat(composer): a calmer Advanced composer
milind-sonic8ced85bba35
diff --git a/src/components/CallView.tsx b/src/components/CallView.tsxindex 6c8825aba4..c8d79f3c31 100644--- a/src/components/CallView.tsx+++ b/src/components/CallView.tsx@@ -41,7 +41,8 @@ export type CallButtonPlacement = "header" | "composer" | "panel";/** `fill` (Simple composer): a round button in that colour with its glyph in `ink`, and no chevron; the + menu picks the* call mode. *//** `inverse` (phone composer): a round ink-coloured button with an app-coloured glyph: white on Midnight, dark on Meadow. */-export function CallButton({ bot, placement = "header", fill, ink, inverse }: { bot: Bot; placement?: CallButtonPlacement; fill?: string; ink?: string; inverse?: boolean }) {+/** `modeMenu: false` drops the call-mode chevron beside the button, for a composer whose + menu offers the modes. */+export function CallButton({ bot, placement = "header", fill, ink, inverse, modeMenu }: { bot: Bot; placement?: CallButtonPlacement; fill?: string; ink?: string; inverse?: boolean; modeMenu?: boolean }) {const { state } = useStore();return (<CallTargetButton@@ -49,6 +50,7 @@ export function CallButton({ bot, placement = "header", fill, ink, inverse }: {fill={fill}ink={ink}inverse={inverse}+ modeMenu={modeMenu}targetId={bot.id}targetName={bot.name}threadId={bot.threadId}@@ -74,11 +76,13 @@ export function CallTargetButton({fill,ink = "#ffffff",inverse,+ modeMenu = true,}: {placement?: CallButtonPlacement;fill?: string;ink?: string;inverse?: boolean;+ modeMenu?: boolean;targetId: string;targetName: string;threadId?: string;@@ -137,7 +141,7 @@ export function CallTargetButton({const keyId = useId();const elsewhereName = liveElsewhere ? state.bots.find((candidate) => candidate.id === media.botId)?.name : undefined;const composer = placement === "composer";- const round = Boolean(fill) || Boolean(inverse) || placement === "panel";+ const round = Boolean(fill) || Boolean(inverse) || placement === "panel" || !modeMenu;const label = active? t("call.hangUpOn", { name: targetName }): liveElsewherediff --git a/src/components/ChatView.controls.test.ts b/src/components/ChatView.controls.test.tsindex 2a980004ce..3ec44376bf 100644--- a/src/components/ChatView.controls.test.ts+++ b/src/components/ChatView.controls.test.ts@@ -2,7 +2,6 @@ import { createElement, type ComponentProps } from "react";import { renderToStaticMarkup } from "react-dom/server";import { afterAll, describe, expect, it, vi } from "vitest";import type { Bot, InstanceInfo } from "@/state/store";-import type { ApprovalModeSelector } from "./ApprovalModeSelector";import type { ModelPicker } from "./ModelPicker";import { CODEX_USAGE_LIMIT_REACHED, CODEX_USAGE_URL } from "../../shared/codex-usage-limit";import { failedTurnTool } from "../../shared/failed-turn";@@ -12,9 +11,10 @@ import { en } from "@/locales";const fixture = vi.hoisted(() => {vi.stubGlobal("window", {});vi.stubGlobal("localStorage", { getItem: () => null, setItem: () => {} });- return { showThreads: true, advanced: true, menus: [] as { ariaLabel: string; items: { key: string; disabled?: boolean; heading?: string; active?: boolean }[] }[], dispatch: vi.fn(), canWrite: null as boolean | null, showToolCalls: false, platform: "other", localReasonCode: "cua-driver-unavailable", localMessage: "", model: null as ComponentProps<typeof ModelPicker> | null,- approval: null as ComponentProps<typeof ApprovalModeSelector> | null };+ return { showThreads: true, advanced: true, menus: [] as { ariaLabel: string; items: MenuRow[] }[], dispatch: vi.fn(), canWrite: null as boolean | null, showToolCalls: false, platform: "other", localReasonCode: "cua-driver-unavailable", localMessage: "", model: null as ComponentProps<typeof ModelPicker> | null,+ };});+type MenuRow = { key: string; disabled?: boolean; heading?: string; active?: boolean; note?: string; submenu?: MenuRow[]; onSelect?: () => void };vi.mock("@/state/store", async (importOriginal) => {const original = await importOriginal<typeof import("@/state/store")>();return { ...original, useStore: () => ({@@ -51,10 +51,6 @@ vi.mock("./ModelPicker", () => ({ ModelPicker: (props: ComponentProps<typeof Modfixture.model = props;return createElement("span", { "data-test-model-control": true });} }));-vi.mock("./ApprovalModeSelector", () => ({ ApprovalModeSelector: (props: ComponentProps<typeof ApprovalModeSelector>) => {- fixture.approval = props;- return createElement("span", { "data-test-approval-control": true });-} }));const { ChatView, ErrorRow, FailedTurnRow } = await import("./ChatView");const { claudeUpdateTarget } = await import("@/lib/failed-turn");@@ -339,6 +335,10 @@ describe("glass header", () => {});});+/** The approval levels in the composer's + menu, from the newest render. */+const levelRows = () => fixture.menus.findLast((menu) => menu.ariaLabel === "Add")!.items.find((row) => row.key === "approval")!.submenu!;+const pickLevel = (mode: string) => levelRows().find((row) => row.key === `approval:${mode}`)!.onSelect!();+describe("thread control placement", () => {it.each([true, false])("leaves All threads out of the header in both modes (advanced: %s)", (advanced) => {fixture.advanced = advanced;@@ -360,15 +360,13 @@ describe("thread control placement", () => {fixture.advanced = true;});- it("keeps the editor and its controls on one line, wrapping only in a narrow composer", () => {+ it("gives the editor its own line above the composer's footer of controls", () => {const markup = renderToStaticMarkup(createElement(ChatView, { bot }));expect(markup).toContain("@container/composer");const row = /data-composer-row="[^"]*" class="([^"]*)"/.exec(markup)!.at(1)!.split(" ");- expect(row).toContain("@max-[30rem]/composer:flex-wrap");- expect(row).not.toContain("flex-wrap");+ expect(row).toContain("flex-wrap");const editor = /class="mention-editor ([^"]*)"/.exec(markup)!.at(1)!.split(" ");- expect(editor).toEqual(expect.arrayContaining(["min-w-0", "flex-1", "@max-[30rem]/composer:order-first", "@max-[30rem]/composer:basis-full"]));- expect(editor).not.toContain("basis-full");+ expect(editor).toEqual(expect.arrayContaining(["min-w-0", "flex-1", "basis-full"]));const textarea = /<textarea[^>]*class="([^"]*)"/.exec(markup)!.at(1)!.split(" ");expect(textarea).toContain("min-h-6");expect(textarea).not.toContain("min-h-14");@@ -385,8 +383,7 @@ describe("thread control placement", () => {window.ogb = { approvals: { setMode: vi.fn() } } as unknown as NonNullable<Window["ogb"]>;expect(renderToStaticMarkup(createElement(ChatView, { bot: fullBot }))).not.toContain("Use bot’s Full access for this thread");renderToStaticMarkup(createElement(ChatView, { bot }));- expect(fixture.approval?.trustedModesAvailable).toBe(true);- fixture.approval!.onSelect("custom");+ pickLevel("custom");expect(fixture.dispatch).toHaveBeenLastCalledWith({ type: "updateTask", botId: "bot", threadId: "selected", patch: { approvalMode: "custom" } });delete window.ogb;});@@ -396,16 +393,12 @@ describe("thread control placement", () => {if (bridge) window.ogb = { approvals: { setMode: vi.fn() } } as unknown as NonNullable<Window["ogb"]>;fixture.dispatch.mockClear();const markup = renderToStaticMarkup(createElement(ChatView, { bot }));- expect(fixture.approval?.trustedModesAvailable).toBe(bridge);- fixture.approval!.onSelect("full");+ expect(levelRows().some((row) => row.key === "approval:custom")).toBe(bridge);+ pickLevel("full");expect(fixture.dispatch).toHaveBeenCalledExactlyOnceWith({ type: "updateTask", botId: "bot", threadId: "selected", patch: { approvalMode: "full" } });expect(markup).not.toContain('role="alertdialog"');delete window.ogb;}- fixture.dispatch.mockClear();- renderToStaticMarkup(createElement(ChatView, { bot }));- fixture.approval!.onSelect("custom");- expect(fixture.dispatch).not.toHaveBeenCalled();});it("explains provider safety errors without offering an ineffective Retry", () => {@@ -653,24 +646,37 @@ describe("thread control placement", () => {expect(badge[2].split(" ")).toContain("@max-4xl/chathead:sr-only");});- it("keeps the selected thread's model in the header and permissions inside the composer pill", () => {+ it("shows the selected thread's model and its level under the composer's field in Advanced", () => {+ fixture.menus = [];const markup = renderToStaticMarkup(createElement(ChatView, { bot }));expect(markup.match(/data-test-model-control/g)).toHaveLength(1);- expect(markup.indexOf("data-test-model-control")).toBeLessThan(markup.indexOf('role="log"'));- expect(markup.indexOf('data-tour="composer"')).toBeGreaterThan(-1);- expect(markup.indexOf("data-test-approval-control")).toBeGreaterThan(markup.indexOf('data-tour="composer"'));- expect(markup.indexOf("data-test-approval-control")).toBeLessThan(markup.indexOf("<textarea"));+ expect(markup.indexOf("data-test-model-control")).toBeGreaterThan(markup.indexOf("<textarea"));+ expect(markup.slice(markup.indexOf("data-chathead-controls"), markup.indexOf('role="log"'))).not.toContain("data-test-model-control");expect(markup).not.toContain('aria-label="Thread settings"');- expect(fixture.model).toMatchObject({ threadId: "selected", bot: { busy: false, modelSelection: { model: "thread-model" } } });- expect(fixture.approval).toMatchObject({ approvalMode: "ask", busy: false, trustedModesAvailable: false });- fixture.approval!.onSelect("auto");+ expect(fixture.model).toMatchObject({ threadId: "selected", quiet: true, bot: { busy: false, modelSelection: { model: "thread-model" } } });+ expect(levelRows().find((row) => row.key === "approval:ask")?.active).toBe(true);+ pickLevel("auto");expect(fixture.dispatch).toHaveBeenLastCalledWith({ type: "updateTask", botId: "bot", threadId: "selected", patch: { approvalMode: "auto" } });});+ it("keeps the model in Simple mode's header", () => {+ fixture.advanced = false;+ try {+ const markup = renderToStaticMarkup(createElement(ChatView, { bot }));+ expect(markup.match(/data-test-model-control/g)).toHaveLength(1);+ expect(markup.indexOf("data-test-model-control")).toBeLessThan(markup.indexOf('role="log"'));+ expect(fixture.model?.quiet).toBeUndefined();+ } finally {+ fixture.advanced = true;+ }+ });+it("changes a working thread's level from the composer, saying the bot is working", () => {+ fixture.menus = [];renderToStaticMarkup(createElement(ChatView, { bot: { ...bot, busy: true, tasks: (bot.tasks ?? []).map((task) => ({ ...task, busy: true })) } }));- expect(fixture.approval).toMatchObject({ approvalMode: "ask", busy: true });- fixture.approval!.onSelect("full");+ const level = fixture.menus.findLast((menu) => menu.ariaLabel === "Add")!.items.find((row) => row.key === "approval")!;+ expect(level.note).toBe(en["approvalMode.whileWorking"]);+ pickLevel("full");expect(fixture.dispatch).toHaveBeenLastCalledWith({ type: "updateTask", botId: "bot", threadId: "selected", patch: { approvalMode: "full" } });});@@ -678,10 +684,11 @@ describe("thread control placement", () => {window.ogb = { remoteClient: { active: true } } as NonNullable<Window["ogb"]>;try {fixture.model = null;+ fixture.menus = [];const markup = renderToStaticMarkup(createElement(ChatView, { bot }));expect(markup).toContain("data-test-model-control");expect(fixture.model).toMatchObject({ bot: { id: "bot" }, threadId: "selected" });- expect(markup).not.toContain("data-test-approval-control");+ expect(fixture.menus.findLast((menu) => menu.ariaLabel === "Add")!.items.map((row) => row.key)).not.toContain("approval");} finally {delete window.ogb;}@@ -689,10 +696,13 @@ describe("thread control placement", () => {it.each([true, false])("pins a place per conversation from the composer only in Advanced (advanced: %s)", (advanced) => {fixture.advanced = advanced;+ fixture.menus = [];const markup = renderToStaticMarkup(createElement(ChatView, { bot }));- const pill = markup.slice(markup.indexOf('data-tour="composer"'), markup.indexOf("<textarea"));- expect(pill.match(/data-testid="place-chip"/g) ?? []).toHaveLength(advanced ? 1 : 0);- expect(markup.includes("Where this conversation works")).toBe(advanced);+ const plus = fixture.menus.findLast((menu) => menu.ariaLabel === "Add");+ expect(plus?.items.some((row) => row.key === "place") ?? false).toBe(advanced);+ expect(markup).not.toContain('data-testid="place-chip"');+ const pinned = renderToStaticMarkup(createElement(ChatView, { bot: { ...bot, tasks: (bot.tasks ?? []).map((task) => ({ ...task, surface: "browser" as const })) } }));+ expect(pinned.match(/data-testid="place-chip"/g) ?? []).toHaveLength(advanced ? 1 : 0);fixture.advanced = true;});});diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsxindex 7fd368ddff..fb1bd9b466 100644--- a/src/components/ChatView.tsx+++ b/src/components/ChatView.tsx@@ -1072,8 +1072,8 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal)}<ThreadContextWarning bot={bot} messages={messages} />{phone && <UsageAlert engine={bot.modelSelection?.instanceId} />}- {/* The model and the bot's computer stay in view in both modes; Simple mode moves only ⋯ into the bot panel. */}- {!phone && <ModelPicker key={bot.threadId} bot={bot} threadId={bot.threadId} />}+ {/* Simple mode keeps the model here and moves only ⋯ into the bot panel; Advanced shows it under the composer's field. */}+ {!phone && (!advanced || canWrite === false) && <ModelPicker key={bot.threadId} bot={bot} threadId={bot.threadId} />}<LiveCallChip currentBotId={bot.id} onOpen={(botId, threadId) => openThread(dispatch, { botId, threadId }, store.state(), showThreads)} />{!phoneMenu && <WatchScreenButton botId={bot.id} messages={messages} liveTools={liveTools} place={place} />}<PinnedMessagesMenupins={pinnedPreview(messages, bot.pinnedMessageId, bot.name)}diff --git a/src/components/Composer.advanced.test.ts b/src/components/Composer.advanced.test.tsnew file mode 100644index 0000000000..151a083316--- /dev/null+++ b/src/components/Composer.advanced.test.ts@@ -0,0 +1,247 @@+// @vitest-environment happy-dom+// Advanced mode's composer on a wider screen: the field on its own line, then one quiet footer row with a + that holds+// every tool, the model, chips only for what this conversation changes, and on the right Context, the mic and one round+// button that calls, or sends while there is something to send.+import { createElement } from "react";+import { flushSync } from "react-dom";+import { createRoot, type Root } from "react-dom/client";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import type { Bot, Group } from "@/state/store";+import { restoreComposerDraft } from "@/lib/drafts";+import { setCallMode } from "@/lib/call-mode";+import { BOT_BUTTON, botButtonTone } from "@/lib/bot-button";++const fixture = vi.hoisted(() => ({+ agentsMcp: true,+ dispatch: vi.fn(),+ call: null as Record<string, unknown> | null,+ groupCall: null as Record<string, unknown> | null,+ model: null as Record<string, unknown> | null,+ config: undefined as unknown,+}));+const ENGINE = "claude-3f0c2b1e-9d1a-4c55-8a51-0a3a6f1e2b7c";+vi.mock("@/state/store", async (importOriginal) => {+ const original = await importOriginal<typeof import("@/state/store")>();+ return { ...original, useStore: () => ({+ state: { ...original.initialState, config: fixture.config ?? original.initialState.config, bots: [bot, peer], instances: [{+ instanceId: ENGINE, driverKind: "claudeAgent", displayName: "Claude", capabilities: { agentsMcp: fixture.agentsMcp },+ }] },+ dispatch: fixture.dispatch,+ }) };+});+vi.mock("@/lib/analytics", () => ({ track: vi.fn() }));+vi.mock("@/lib/cloud-guest", async (importOriginal) => ({ ...await importOriginal<typeof import("@/lib/cloud-guest")>(), useReactor: () => "user" }));+vi.mock("@/lib/use-owner-or-admin", () => ({ useOwnerOrAdmin: () => true }));+vi.mock("@/lib/interface-mode", () => ({ useAdvancedMode: () => true, setAdvancedMode: vi.fn() }));+vi.mock("./CallView", () => ({ CallButton: (props: Record<string, unknown>) => {+ fixture.call = props;+ return null;+} }));+vi.mock("./GroupCallView", () => ({ GroupCallButton: (props: Record<string, unknown>) => {+ fixture.groupCall = props;+ return null;+} }));+vi.mock("./ModelPicker", () => ({ ModelPicker: (props: Record<string, unknown>) => {+ fixture.model = props;+ return createElement("span", { "data-test-model": true });+} }));++import { Composer } from "./Composer";++const bot: Bot = {+ id: "atlas", threadId: "atlas-thread", name: "Atlas", title: "", description: "",+ color: "purple", notifications: false, unread: false, busy: false, messages: [], approvalMode: "ask",+ modelSelection: { instanceId: ENGINE, model: "fake" },+};+const peer: Bot = { ...bot, id: "juniper", threadId: "juniper-thread", name: "Juniper", color: "teal" };+const room: Group = {+ id: "room", threadId: "room-thread", name: "Launch planning", memberIds: [bot.id, peer.id],+ defaultResponder: { kind: "member", botId: bot.id }, bulletin: "", unread: false,+ createdAt: 1, setupCompletedAt: 1, messages: [],+};+const task = { threadId: bot.threadId, title: "New thread", createdAt: 1 };++let root: Root;+let container: HTMLDivElement;+const render = (props: Parameters<typeof Composer>[0]) => flushSync(() => root.render(createElement(Composer, props)));+const plus = () => container.querySelector<HTMLElement>("[data-composer-plus]")?.closest("button") ?? null;+const popover = () => document.body.querySelector<HTMLElement>('[data-sidebar-popover-menu="anchored"]');+const item = (key: string) => document.body.querySelector<HTMLButtonElement>(`[data-menu-key="${key}"]`);+const keys = () => [...popover()!.querySelectorAll("[data-menu-key]")].map((row) => row.getAttribute("data-menu-key"));+const classes = (selector: string) => container.querySelector(selector)!.className.split(" ");+const click = (element: Element | null) => {+ if (!element) throw new Error("nothing to click");+ flushSync(() => (element as HTMLElement).click());+};+const type = (value: string) => {+ const field = container.querySelector("textarea")!;+ flushSync(() => {+ Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value")!.set!.call(field, value);+ field.dispatchEvent(new Event("input", { bubbles: true }));+ });+};+const sendButton = () => container.querySelector<HTMLButtonElement>('button[aria-label="Send message"]');+function openPlus() {+ click(plus());+ expect(popover()).not.toBeNull();+}++beforeEach(() => {+ fixture.agentsMcp = true;+ fixture.config = undefined;+ fixture.call = null;+ fixture.groupCall = null;+ fixture.model = null;+ setCallMode("turns");+ vi.stubGlobal("ResizeObserver", class { observe() {} disconnect() {} });+ vi.spyOn(HTMLElement.prototype, "scrollIntoView").mockImplementation(() => {});+ for (const id of [`bot:${bot.id}:${bot.threadId}`, `group:${room.id}:${room.threadId}`]) restoreComposerDraft(id, { text: "", attachments: [] });+ container = document.createElement("div");+ document.body.append(container);+ root = createRoot(container);+});+afterEach(() => {+ flushSync(() => root.unmount());+ container.remove();+ document.body.innerHTML = "";+ vi.clearAllMocks();+ vi.restoreAllMocks();+ vi.unstubAllGlobals();+});++describe("the Advanced composer in a bot chat", () => {+ it("puts the field on its own line above one footer row, on the floating surface", () => {+ render({ bot });+ expect(classes('[data-tour="composer"]')).toEqual(expect.arrayContaining(["rounded-[20px]", "bg-composer", "ring-[0.5px]", "shadow-(--shadow-float)"]));+ expect(classes(".mention-editor")).toContain("basis-full");+ expect(container.querySelector("[data-composer-row] > .mention-editor + [data-composer-tools]")).not.toBeNull();+ expect(classes("[data-composer-row]")).toContain("flex-wrap");+ expect(classes("[data-composer-actions]")).toContain("ml-auto");+ expect(classes("[data-composer-backdrop]")).toContain("top-1/2");+ type("a short one");+ expect(classes(".mention-editor")).toContain("basis-full");+ });++ it("keeps the footer calm: a quiet +, the model, Context, and one call button with no chevron of its own", () => {+ render({ bot });+ const tools = container.querySelector("[data-composer-tools]")!;+ expect(tools.querySelector("[data-composer-plus]")).not.toBeNull();+ expect(plus()?.getAttribute("aria-label")).toBe("Add");+ expect(classes("[data-composer-plus]")).toEqual(expect.arrayContaining(["size-8", "text-ink-secondary"]));+ for (const gone of ["Attach a file", "Teach a task", "Work until done"]) expect(container.querySelector(`button[aria-label="${gone}"]`)).toBeNull();+ expect(container.querySelector('[aria-label$="for Claude"]')).toBeNull();+ expect(container.querySelector('[data-testid="place-chip"]')).toBeNull();+ expect(container.querySelector("[data-goal-chip]")).toBeNull();+ expect(container.querySelector("[data-approval-chip]")).toBeNull();+ expect(tools.querySelector("[data-test-model]")).not.toBeNull();+ expect(fixture.model).toMatchObject({ bot: { id: "atlas" }, threadId: "atlas-thread", quiet: true });+ expect(container.querySelector("[data-composer-context]")).not.toBeNull();+ expect(fixture.call).toMatchObject({ bot: { id: "atlas" }, placement: "composer", modeMenu: false });+ expect(fixture.call?.fill).toBeUndefined();+ });++ it("holds attach, Work until done, Teach a task, where it works, the approval level and the call mode in the +", () => {+ render({ bot });+ openPlus();+ expect(keys()).toEqual(["attach", "goal", "teach", "place", "approval", "call:turns", "call:live"]);+ expect(item("approval")!.textContent).toContain("Before Atlas acts");+ expect(item("place")!.textContent).toContain("Works on");+ });++ it("attaches through the file picker", () => {+ const picker = vi.spyOn(HTMLInputElement.prototype, "click").mockImplementation(() => {});+ render({ bot });+ openPlus();+ click(item("attach"));+ expect(picker).toHaveBeenCalledOnce();+ });++ it("starts a /learn draft from Teach a task, ahead of anything typed", () => {+ restoreComposerDraft(`bot:${bot.id}:${bot.threadId}`, { text: "how I file expenses", attachments: [] });+ render({ bot });+ openPlus();+ click(item("teach"));+ expect(container.querySelector("textarea")!.value).toBe("/learn how I file expenses");+ });++ it.each([+ ["skill authoring is off", () => { fixture.config = { features: { skillAuthoring: false } }; }],+ ["the engine can't run agents", () => { fixture.agentsMcp = false; }],+ ])("leaves Teach a task out when %s", (_, setup) => {+ setup();+ render({ bot });+ openPlus();+ expect(keys()).not.toContain("teach");+ });++ it("shows Work until done as a chip only while it is on", () => {+ render({ bot });+ openPlus();+ click(item("goal"));+ const chip = container.querySelector<HTMLButtonElement>("[data-goal-chip]")!;+ expect(chip.getAttribute("aria-label")).toBe("Turn off Work until done");+ click(chip);+ expect(container.querySelector("[data-goal-chip]")).toBeNull();+ });++ it("changes the conversation's approval level from the +, then shows it as a chip while it differs from the bot's", () => {+ render({ bot });+ openPlus();+ click(item("approval"));+ click(item("approval:full"));+ expect(fixture.dispatch).toHaveBeenCalledWith({ type: "updateTask", botId: "atlas", threadId: "atlas-thread", patch: { approvalMode: "full" } });+ render({ bot: { ...bot, tasks: [{ ...task, approvalMode: "full" }] } });+ const chip = container.querySelector("[data-approval-chip]")!;+ expect(chip.getAttribute("data-approval-chip")).toBe("full");+ expect(chip.textContent).toBe("Full access");+ });++ it("shows the place chip only while this conversation is pinned to a place", () => {+ render({ bot: { ...bot, tasks: [{ ...task, surface: "browser", surfaceAuto: true }] } });+ expect(container.querySelector('[data-testid="place-chip"]')).toBeNull();+ render({ bot: { ...bot, tasks: [{ ...task, surface: "browser" }] } });+ expect(container.querySelector('[data-testid="place-chip"]')?.getAttribute("aria-label")).toContain("Browser");+ });++ it("swaps the call button for Send while there is something to send, in the bot's colour, and drops the call modes", () => {+ render({ bot });+ expect(sendButton()).toBeNull();+ fixture.call = null;+ type("hello");+ expect(fixture.call).toBeNull();+ const send = sendButton()!;+ expect(send.className.split(" ")).toContain("size-8");+ const tone = botButtonTone("purple");+ expect(send.style.getPropertyValue("--bot-button")).toBe(tone.fill);+ openPlus();+ expect(keys().some((key) => key?.startsWith("call:"))).toBe(false);+ });++ it("keeps Stop and the call button while the bot works, with a queued message waiting to send", () => {+ restoreComposerDraft(`bot:${bot.id}:${bot.threadId}`, { text: "and also this", attachments: [] });+ render({ bot: { ...bot, busy: true } });+ expect(container.querySelector('button[aria-label="Stop this turn"]')).not.toBeNull();+ expect(fixture.call).toMatchObject({ placement: "composer", modeMenu: false });+ });++ it("keeps the model in the footer while setup holds the field, with the tools put away", () => {+ render({ bot, locked: true });+ expect(plus()).toBeNull();+ expect(container.querySelector("[data-test-model]")).not.toBeNull();+ });+});++describe("the Advanced composer in a room", () => {+ it("offers Finish together in the +, shows no model, and keeps the room's accent Send", () => {+ render({ group: room, members: [bot, peer] });+ expect(container.querySelector("[data-test-model]")).toBeNull();+ expect(fixture.groupCall).toBeNull();+ openPlus();+ expect(keys()).toEqual(["attach", "goal", "teach"]);+ expect(item("goal")!.textContent).toBe("Finish together");+ restoreComposerDraft(`group:${room.id}:${room.threadId}`, { text: "hello room", attachments: [] });+ render({ group: room, members: [bot, peer] });+ expect(sendButton()!.className.split(" ")).not.toContain(BOT_BUTTON);+ expect(sendButton()!.style.backgroundColor).toBe("var(--color-accent)");+ });+});diff --git a/src/components/Composer.phone.test.ts b/src/components/Composer.phone.test.tsindex ec8a761441..db2b1e958a 100644--- a/src/components/Composer.phone.test.ts+++ b/src/components/Composer.phone.test.ts@@ -33,6 +33,7 @@ vi.mock("./CallView", () => ({ CallButton: (props: Record<string, unknown>) => {fixture.call = props;return null;} }));+vi.mock("./ModelPicker", () => ({ ModelPicker: () => null }));vi.mock("./GroupCallView", () => ({ GroupCallButton: (props: Record<string, unknown>) => {fixture.groupCall = props;return null;@@ -111,12 +112,13 @@ describe("the phone composer", () => {expect(item("place")?.textContent).toContain("Works on");});- it("keeps Advanced mode's buttons in a row on a wider screen", () => {+ it("gives Advanced mode on a wider screen its quiet footer + instead of the round one", () => {vi.stubGlobal("matchMedia", (query: string) => ({ matches: !query.includes("max-width"), addEventListener() {}, removeEventListener() {} }));fixture.advanced = true;render({ bot });- expect(container.querySelector('button[aria-label="Attach a file"]')).not.toBeNull();- expect(container.querySelector('[data-testid="place-chip"]')).not.toBeNull();+ expect(container.querySelector("[data-composer-tools] [data-composer-plus]")).not.toBeNull();+ expect(container.querySelector("[data-composer-plus]")!.className.split(" ")).toContain("size-8");expect(fixture.call?.inverse).toBe(false);+ expect(fixture.call?.modeMenu).toBe(false);});});diff --git a/src/components/Composer.simple.test.ts b/src/components/Composer.simple.test.tsindex e129c3033d..8824a72546 100644--- a/src/components/Composer.simple.test.ts+++ b/src/components/Composer.simple.test.ts@@ -1,7 +1,6 @@// @vitest-environment happy-dom// Simple mode's composer: one pill with a round + (attach, Work until done or Finish together, Teach a task), a chip for a// mode only while this conversation turns it on, and one round button in the bot's tone that calls, sends or stops.-// Advanced keeps its row of buttons.import { createElement } from "react";import { flushSync } from "react-dom";import { createRoot, type Root } from "react-dom/client";@@ -291,133 +290,23 @@ describe("the Simple composer in a group chat", () => {});});-describe("the Advanced composer", () => {- it("keeps the paperclip, the approval shield and the split call button, with no +, on Simple's floating surface", () => {- fixture.advanced = true;+describe("the Simple composer beside Advanced", () => {+ it("keeps Advanced's footer and its quiet + out of the pill, and the call button's own mode menu", () => {render({ bot });- expect(plus()).toBeNull();- expect(container.querySelector('[data-tour="composer"]')!.className.split(" ")).toEqual(expect.arrayContaining(["rounded-2xl", "bg-composer", "ring-[0.5px]", "shadow-(--shadow-float)"]));- expect(container.querySelector('button[aria-label="Attach a file"]')).not.toBeNull();- expect(container.querySelector('[aria-haspopup="menu"][aria-label$="for Claude"]')).not.toBeNull();- expect(fixture.call).toMatchObject({ placement: "composer" });- expect(fixture.call?.fill).toBeUndefined();- expect(container.querySelector("[data-composer-backdrop]")!.className.split(" ")).toContain("top-1/2");+ expect(container.querySelector("[data-composer-tools]")).toBeNull();+ expect(container.querySelector(".mention-editor")!.className.split(" ")).not.toContain("basis-full");+ expect(fixture.call?.modeMenu).toBe(true);});- it("offers Teach a task as its own button, which starts a /learn draft ahead of anything typed", () => {- fixture.advanced = true;- restoreComposerDraft(`bot:${bot.id}:${bot.threadId}`, { text: "how I file expenses", attachments: [] });- render({ bot });- const teach = container.querySelector<HTMLButtonElement>('button[aria-label="Teach a task"]');- expect(teach).not.toBeNull();- click(teach);- expect(container.querySelector("textarea")!.value).toBe("/learn how I file expenses");- });-- it("leaves Teach a task out when skill authoring is off", () => {- fixture.advanced = true;- fixture.config = { features: { skillAuthoring: false } };+ it("never stacks the field over its buttons, however long the message", () => {render({ bot });- expect(container.querySelector('button[aria-label="Teach a task"]')).toBeNull();- });-- it("leaves Teach a task out when the bot's engine can't run agents", () => {- fixture.advanced = true;- fixture.agentsMcp = false;- render({ bot });- expect(container.querySelector('button[aria-label="Teach a task"]')).toBeNull();- });-- it("sends with the bot's own button too, and keeps the accent in a room", () => {- fixture.advanced = true;- restoreComposerDraft(`bot:${bot.id}:${bot.threadId}`, { text: "hello", attachments: [] });- render({ bot: { ...bot, color: "teal" } });- const send = sendButton()!;- expect(send.className.split(" ")).toContain("size-8");- expectBotButton(send, "teal");- expect(send.className).not.toMatch(/\bbg-accent\b|text-white/);- restoreComposerDraft(`group:${room.id}:${room.threadId}`, { text: "hello room", attachments: [] });- render({ group: room, members: [bot, peer] });- expect(sendButton()!.className.split(" ")).not.toContain(BOT_BUTTON);- expect(sendButton()!.style.backgroundColor).toBe("var(--color-accent)");- });-- it("keeps the room's Goal chip and its header call button", () => {- fixture.advanced = true;- render({ group: room, members: [bot, peer] });- expect(container.querySelector('[aria-label="Finish together"]')?.getAttribute("aria-pressed")).toBe("false");- expect(fixture.groupCall).toBeNull();- });-- describe("with a message longer than one line", () => {- const type = (value: string) => {- const field = container.querySelector("textarea")!;- flushSync(() => {- Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value")!.set!.call(field, value);- field.dispatchEvent(new Event("input", { bubbles: true }));- });- };- const classes = (selector: string) => container.querySelector(selector)!.className.split(" ");- const stacked = () => classes(".mention-editor").includes("basis-full");- /** A field 20 characters wide: longer text wraps onto a second 24px line. */- const wrapPast20 = () => vi.spyOn(HTMLTextAreaElement.prototype, "scrollHeight", "get")- .mockImplementation(function (this: HTMLTextAreaElement) { return this.value.length > 20 ? 48 : 24; });-- it("gives the text the full width above the buttons, and puts it back beside them on one line", () => {- fixture.advanced = true;- render({ bot });- expect(stacked()).toBe(false);- type("Okay I have done my outreach.\nAnother line of text.");- expect(classes(".mention-editor")).toEqual(expect.arrayContaining(["order-first", "basis-full"]));- expect(classes("[data-composer-row]")).toContain("flex-wrap");- expect(classes("[data-composer-actions]")).toContain("ml-auto");- type("Okay I have done my outreach.");- expect(stacked()).toBe(false);- expect(classes("[data-composer-row]")).not.toContain("flex-wrap");- });-- it("stacks once the text wraps beside the buttons, and stays stacked until it is shorter than where it wrapped", () => {- wrapPast20();- fixture.advanced = true;- render({ bot });- type("a".repeat(25));- expect(stacked()).toBe(true);- // Wider on its own line, it would fit on one row there; it still must not flip back and forth.- type("a".repeat(30));- expect(stacked()).toBe(true);- type("a".repeat(24));- expect(stacked()).toBe(true);- type("a".repeat(10));- expect(stacked()).toBe(false);- });-- it("measures each new message afresh, so a wrap from a narrower composer does not stick", () => {- const wrap = wrapPast20();- fixture.advanced = true;- render({ bot });- type("a".repeat(25));- expect(stacked()).toBe(true);- type("");- // Wider now: 30 characters fit on the one row.- wrap.mockImplementation(function (this: HTMLTextAreaElement) { return this.value.length > 40 ? 48 : 24; });- type("a".repeat(30));- expect(stacked()).toBe(false);- });-- it("never stacks an empty field, even when its placeholder wraps", () => {- vi.spyOn(HTMLTextAreaElement.prototype, "scrollHeight", "get").mockReturnValue(48);- fixture.advanced = true;- render({ bot });- expect(stacked()).toBe(false);- });-- it("leaves Simple's pill alone", () => {- wrapPast20();- render({ bot });- type("a".repeat(25) + "\nb");- expect(stacked()).toBe(false);- expect(classes("[data-composer-row]")).not.toContain("flex-wrap");+ const field = container.querySelector("textarea")!;+ flushSync(() => {+ Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value")!.set!.call(field, "a".repeat(25) + "\nb");+ field.dispatchEvent(new Event("input", { bubbles: true }));});+ expect(container.querySelector(".mention-editor")!.className.split(" ")).not.toContain("basis-full");+ expect(container.querySelector("[data-composer-row]")!.className).not.toContain("flex-wrap");});});diff --git a/src/components/Composer.tsx b/src/components/Composer.tsxindex 8c177450b7..940cde208c 100644--- a/src/components/Composer.tsx+++ b/src/components/Composer.tsx@@ -2,7 +2,7 @@ import { directMessageSent, roomMessageSent } from "@/lib/product-events";import { TeamAudienceLabel } from "./TeamSideSwitch";import { useComposerDictation } from "@/lib/use-composer-dictation";import { useCallback, useEffect, useMemo, useRef, useState, type SetStateAction } from "react";-import { Mic, Paperclip, Square, X } from "lucide-react";+import { Mic, Square, X } from "lucide-react";import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select"; import { useStoreRef } from "@/state/store-ref"; import { sameDrawnBots } from "@/lib/drawn-bots";import { visibleMessages, currentTaskBot, type Bot, type Group, type InstanceInfo, type Message } from "@/state/store";import { cn } from "@/lib/cn";@@ -41,8 +41,7 @@ import { PointedChips } from "./app/PointedChips"; import { SetupRequestChip, seimport { takePointedChips } from "@/lib/pointed-chips";import { openPageFor } from "@/lib/open-page";import { splitTranscriptCitations, type CitationAttachment } from "@/lib/citations";-import { PlaceChip } from "./PlaceChip";-import { ApprovalModeSelector } from "./ApprovalModeSelector";+import { ComposerAdvancedTools } from "./ComposerAdvancedTools";import { approvalModeFor } from "../../shared/approval-mode";import { useOnCall } from "@/lib/call";import { isLiveCallRunning, useLiveMedia } from "@/lib/live-call-media";@@ -71,10 +70,10 @@ import { composerPlaceholder, sendLabels, SIMPLE_COMPOSER, SIMPLE_CONTROL, slotCimport { PendingApprovalActions, PendingApprovalPanel, pendingApprovals } from "./PendingApproval";import { CallButton } from "./CallView";import { GroupCallButton } from "./GroupCallView";-import { ApprovalChip, ComposerPlusMenu, GoalToggle, TeachTaskButton } from "./ComposerPlusMenu";+import { ApprovalChip, ComposerPlusMenu, GoalToggle } from "./ComposerPlusMenu";import { PhonePlus } from "./PhonePlus";import { useThreadApproval } from "./thread-approval";-import { useStackedField, useTallPill } from "./composer-wrap";+import { useTallPill } from "./composer-wrap";import { ComposerReplyStrip } from "./ReplyQuote";import { escapeCancelsReply } from "@/lib/replies";import { useThreadRefs } from "./ThreadRefs";@@ -137,6 +136,8 @@ export function Composer({const singleRow = useMediaQuery(PHONE_LAYOUT);// Simple mode on a wider screen: one pill holding a round +, the field, the mic and one round button in the bot's colour.const simpleDock = !advanced && !singleRow;+ // Advanced mode on a wider screen: the field on its own line, with one quiet footer row of tools under it.+ const stacked = advanced && !singleRow;const sendKey = useSendKey(); const followUpDefault = useFollowUpDefault();const sendLabel = sendKeyLabel(sendKey);const remoteClient = window.ogb?.remoteClient?.active === true;@@ -234,7 +235,6 @@ export function Composer({const [dismissedAt, setDismissedAt] = useState<number | null>(null);const [dismissedSlashAt, setDismissedSlashAt] = useState<number | null>(null);const inputRef = useRef<HTMLTextAreaElement>(null);- const stacked = useStackedField(inputRef, advanced && !singleRow, text);const draftIdRef = useRef(draftId);draftIdRef.current = draftId;const caretRef = useRef(0);@@ -511,7 +511,7 @@ export function Composer({const mayAct = useMayAct(), mayStop = !sharedChat || mayAct(profile?.tasks?.find((task) => task.threadId === threadId)?.askedBy);const stoppable = (busy || Boolean(!group && bot?.waitingForTeammates)) && mayStop;const stopInSlot = simpleDock && stoppable && !locked && !hasContent && !calling;- const callShown = !simpleDock || !hasContent || busy || Boolean(!group && bot?.waitingForTeammates) || calling;+ const callShown = singleRow || !hasContent || busy || Boolean(!group && bot?.waitingForTeammates) || calling;const slot = slotColors(bot?.color, Boolean(group));// A one-to-one bot at work: Enter does the chosen follow-up and Ctrl/⌘ with it the other one. Rooms keep their own queue.const followUpFor = (alternate: boolean) => resolveFollowUp({ running: busy && !group && Boolean(bot), alternate, preferred: followUpDefault, canSteer }) ?? undefined;@@ -778,7 +778,7 @@ export function Composer({data-composer-backdropclassName={cn("pointer-events-none absolute -left-5 -right-5 bg-app", advanced ? "-bottom-3 top-1/2" : cn("top-0", simpleDock ? "-bottom-4" : "-bottom-3"))}/>- <div ref={shellRef} data-tour="composer" data-look="composer" data-multiline={multiline ? "" : undefined} className={cn("@container/composer relative z-[1]", singleRow ? "flex items-end gap-2" : simpleDock ? cn(SIMPLE_COMPOSER, multiline ? "rounded-[18px]" : "rounded-[22px]") : cn("rounded-2xl px-2 py-1.5", ELEVATED_FLOAT))}>+ <div ref={shellRef} data-tour="composer" data-look="composer" data-multiline={multiline ? "" : undefined} className={cn("@container/composer relative z-[1]", singleRow ? "flex items-end gap-2" : simpleDock ? cn(SIMPLE_COMPOSER, multiline ? "rounded-[18px]" : "rounded-[22px]") : cn("rounded-[20px] px-2 pb-2 pt-2.5", ELEVATED_FLOAT))}>{singleRow && !locked && (<div className="flex shrink-0 items-center"><PhonePlus@@ -798,7 +798,7 @@ export function Composer({)}<div className={singleRow ? cn("min-w-0 flex-1 rounded-[26px] px-3 py-1.5", ELEVATED_FLOAT) : "contents"}>{replyTo && <ComposerReplyStrip message={replyTo} fallbackName={bot?.name} onClear={onClearReply} />}- <div data-composer-row className={cn("flex items-end", simpleDock ? "gap-1.5" : "gap-1", !singleRow && !simpleDock && "@max-[30rem]/composer:flex-wrap", stacked && "flex-wrap")}>+ <div data-composer-row className={cn("flex items-end", simpleDock ? "gap-1.5" : stacked ? "flex-wrap gap-x-1 gap-y-1.5" : "gap-1")}><inputref={fileInput}type="file"@@ -810,36 +810,16 @@ export function Composer({e.target.value = "";}}/>- {!locked && !singleRow && (- <div className={cn("flex items-center gap-1", simpleDock ? "shrink-0" : "flex-wrap")}>- {simpleDock && <ComposerPlusMenu onAttach={() => fileInput.current?.click()} goal={goal} teach={canLearn ? teachTask : undefined} />}- {advanced && <button- type="button"- onClick={() => fileInput.current?.click()}- aria-label={t("composer.attach")}- title={t("composer.attach")}- className="flex size-8 shrink-0 items-center justify-center rounded-full text-ink-secondary hover:bg-control hover:text-ink"- >- <Paperclip size={16} strokeWidth={1.75} absoluteStrokeWidth />- </button>}- {advanced && canLearn && <TeachTaskButton onClick={teachTask} />}+ {!locked && simpleDock && (+ <div className="flex items-center gap-1 shrink-0">+ <ComposerPlusMenu onAttach={() => fileInput.current?.click()} goal={goal} teach={canLearn ? teachTask : undefined} />{/* Simple mode shows a mode's chip only while it is on, so a choice made in the + menu or the bot panel stays in view. */}- {goal && (advanced || goal.on) && <GoalToggle {...goal} compact={simpleDock} />}- {advanced && approvalChoice && <ApprovalModeSelector {...approvalChoice} />}- {simpleDock && approvalChoice && profile && bot && approvalModeFor(bot) !== approvalModeFor(profile) && <ApprovalChip choice={approvalChoice} />}- {modeBot && !remoteClient && advanced && (- <PlaceChip- bot={modeBot}- task={composerTask}- live={Boolean(modeBot.busy)}- disabled={Boolean(modeBot.busy)}- onPin={(surface) => dispatch({ type: "updateTask", botId: modeBot.id, threadId: modeBot.threadId, patch: { surface } })}- />- )}+ {goal?.on && <GoalToggle {...goal} compact />}+ {approvalChoice && profile && bot && approvalModeFor(bot) !== approvalModeFor(profile) && <ApprovalChip choice={approvalChoice} />}</div>)}<MentionTextarea- wrapperClassName={singleRow || simpleDock ? undefined : cn("@max-[30rem]/composer:order-first @max-[30rem]/composer:basis-full", stacked && "order-first basis-full")}+ wrapperClassName={stacked ? "basis-full" : undefined}inputRef={inputRef}peers={[...(group ? members ?? [] : bots.filter((member) => member.id !== bot?.id)), ...teammates.peers]}everyone={Boolean(group && !group.dm)}@@ -934,11 +914,17 @@ export function Composer({aria-label={t("composer.placeholder.bot", { name: group ? group.name : (bot?.name ?? "") })}className={cn("block max-h-[9rem] w-full resize-none overflow-y-auto bg-transparent placeholder:text-ink-tertiary focus:outline-none",- !simpleDock && "px-1 text-[15px]",+ !simpleDock && cn(stacked ? "px-2" : "px-1", "text-[15px]"),simpleDock ? "min-h-7 px-0.5 py-1 text-[14px] leading-5" : "min-h-6 py-1 leading-6",)}/>- <div data-composer-actions className={cn("flex items-center", simpleDock ? "gap-2" : "gap-1", !singleRow && !simpleDock && "@max-[30rem]/composer:ml-auto", stacked && "ml-auto")}>+ {stacked && (+ <ComposerAdvancedTools profile={profile} bot={modeBot} task={composerTask} locked={locked} remoteClient={remoteClient}+ onAttach={() => fileInput.current?.click()} goal={goal} teach={canLearn ? teachTask : undefined} approval={approvalChoice}+ callBotId={callShown && bot && !group ? bot.id : undefined}+ onPin={(surface) => modeBot && dispatch({ type: "updateTask", botId: modeBot.id, threadId: modeBot.threadId, patch: { surface } })} />+ )}+ <div data-composer-actions className={cn("flex items-center", simpleDock ? "gap-2" : "gap-1", stacked && "ml-auto")}>{(simpleDock ? stoppable : busy && mayStop) && !locked && (<buttononClick={interruptTurn}@@ -973,7 +959,7 @@ export function Composer({<Mic size={16} strokeWidth={1.75} absoluteStrokeWidth className="[&_rect]:fill-current" /></button>)}- {callShown && bot && !group && <CallButton bot={bot} placement="composer" fill={advanced || singleRow ? undefined : slot.fill} ink={slot.ink} inverse={singleRow} />}+ {callShown && bot && !group && <CallButton bot={bot} placement="composer" fill={advanced || singleRow ? undefined : slot.fill} ink={slot.ink} inverse={singleRow} modeMenu={!stacked} />}{callShown && group && !advanced && <GroupCallButton group={group} members={members ?? []} placement="composer" fill={slot.fill} ink={slot.ink} />}{hasContent && !locked && (<ComposerSendButton compact={simpleDock} waits={busy && !steersNow} label={sendNames.label} title={sendNames.title} look={slot.button}diff --git a/src/components/ComposerAdvancedTools.tsx b/src/components/ComposerAdvancedTools.tsxnew file mode 100644index 0000000000..db64156896--- /dev/null+++ b/src/components/ComposerAdvancedTools.tsx@@ -0,0 +1,42 @@+import { approvalModeFor } from "../../shared/approval-mode";+import { personPin, type Place } from "@/lib/place";+import type { Bot, Task } from "@/state/store";+import { ApprovalChip, GoalToggle } from "./ComposerPlusMenu";+import { ModelPicker } from "./ModelPicker";+import { PhonePlus } from "./PhonePlus";+import { PlaceChip } from "./PlaceChip";+import type { ApprovalChoice } from "./thread-approval";++/**+ * The start of Advanced mode's footer under the field: one + holding every tool, the model, and a chip only for what+ * this conversation changes: Work until done while it is on, an approval level other than the bot's own, a pinned place.+ */+export function ComposerAdvancedTools({ profile, bot, task, locked, remoteClient, onAttach, goal, teach, approval, callBotId, onPin }: {+ profile?: Bot;+ /** The bot as this conversation runs it; undefined in a room. */+ bot?: Bot;+ task?: Pick<Task, "surface" | "surfaceAuto"> | null;+ locked: boolean;+ remoteClient: boolean;+ onAttach: () => void;+ goal?: { on: boolean; onToggle: () => void; solo?: boolean };+ teach?: () => void;+ approval?: ApprovalChoice;+ callBotId?: string;+ onPin: (surface: Place | null) => void;+}) {+ const place = bot && !remoteClient ? { bot, task, disabled: Boolean(bot.busy), onPin } : undefined;+ const ownLevel = approval && profile && bot && approvalModeFor(bot) !== approvalModeFor(profile);+ return (+ <div data-composer-tools className="flex min-w-0 items-center gap-1">+ {!locked && (+ <PhonePlus quiet onAttach={onAttach} goal={goal} teach={teach} callBotId={callBotId}+ approval={approval && bot && { name: bot.name, choice: approval }} place={place} />+ )}+ {bot && <ModelPicker key={bot.threadId} bot={bot} threadId={bot.threadId} quiet />}+ {!locked && goal?.on && <GoalToggle {...goal} compact />}+ {!locked && ownLevel && <ApprovalChip choice={approval} quiet />}+ {!locked && place && personPin(task) && <PlaceChip bot={place.bot} task={task} live={place.disabled} disabled={place.disabled} onPin={onPin} />}+ </div>+ );+}diff --git a/src/components/ComposerPlusMenu.tsx b/src/components/ComposerPlusMenu.tsxindex f5037219cd..50f8ef5ded 100644--- a/src/components/ComposerPlusMenu.tsx+++ b/src/components/ComposerPlusMenu.tsx@@ -122,22 +122,8 @@ function approvalItem(name: string, choice: ApprovalChoice, simple: boolean): Si};}-/** The thread's approval level as a small pill that opens its choices: in the Simple composer while it is not the- * default, and on the bot panel's Details. */-export function TeachTaskButton({ onClick }: { onClick: () => void }) {- return (- <button- type="button"- onClick={onClick}- aria-label={t("composer.teachTask")}- title={t("composer.teachTask")}- className="flex size-8 shrink-0 items-center justify-center rounded-full text-ink-secondary hover:bg-control hover:text-ink"- >- <GraduationCap size={16} strokeWidth={1.75} absoluteStrokeWidth />- </button>- );-}-+/** The thread's approval level as a small pill that opens its choices: in the composer while it is not the bot's own+ * level, and on the bot panel's Details. */export function ApprovalChip({ choice, quiet = false }: { choice: ApprovalChoice; quiet?: boolean }) {const { current, note, items } = approvalMenu(choice, !useAdvancedMode());const CurrentIcon = current.Icon;@@ -164,11 +150,11 @@ export function ApprovalChip({ choice, quiet = false }: { choice: ApprovalChoice}/**- * The composer's round +: attach files, Work until done (Finish together in a group) and Teach a task. A phone's + also- * holds what its narrow composer has no room for: the thread's approval level, the call mode and where the bot works,- * each running the handler its Advanced button runs. With attaching the only choice, the + opens the file picker.+ * The composer's round +: attach files, Work until done (Finish together in a group) and Teach a task. A phone's + and+ * Advanced mode's also hold the thread's approval level, the call mode and where the bot works.+ * With attaching the only choice, the + opens the file picker.*/-export function ComposerPlusMenu({ onAttach, goal, teach, approval, callBotId, extraItems = [], circle = false }: {+export function ComposerPlusMenu({ onAttach, goal, teach, approval, callBotId, extraItems = [], circle = false, quiet = false }: {onAttach: () => void;/** Starts a /learn draft in the field, where the composer offers /learn. */teach?: () => void;@@ -176,6 +162,8 @@ export function ComposerPlusMenu({ onAttach, goal, teach, approval, callBotId, eextraItems?: SidebarMenuItem[];/** The phone dock: a round button of its own beside the field, not a small chip inside it. */circle?: boolean;+ /** Advanced mode's footer: a bare + that opens the full menu, submenus included. */+ quiet?: boolean;goal?: { on: boolean; onToggle: () => void; solo?: boolean };approval?: { name: string; choice: ApprovalChoice };/** The bot whose call button the call mode starts, as that button's own mode menu did. */@@ -222,7 +210,17 @@ export function ComposerPlusMenu({ onAttach, goal, teach, approval, callBotId, e};})),];- const trigger = (open: boolean) => circle ? (+ const trigger = (open: boolean) => quiet ? (+ <span+ data-composer-plus+ className={cn(+ "flex size-8 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-control hover:text-ink",+ open && "bg-control text-ink",+ )}+ >+ <Plus size={18} strokeWidth={1.75} absoluteStrokeWidth aria-hidden="true" />+ </span>+ ) : circle ? (<spandata-composer-plusclassName={cn(@@ -245,7 +243,7 @@ export function ComposerPlusMenu({ onAttach, goal, teach, approval, callBotId, e</button>);}- if (!circle) return <ComposerMenu items={items} renderTrigger={trigger} />;+ if (!circle && !quiet) return <ComposerMenu items={items} renderTrigger={trigger} />;return (<SidebarPopoverMenuitems={items}diff --git a/src/components/ModelPicker.tsx b/src/components/ModelPicker.tsxindex adf00468c1..6675a6dda2 100644--- a/src/components/ModelPicker.tsx+++ b/src/components/ModelPicker.tsx@@ -206,14 +206,14 @@ export function ModelPicker({className,contained = false,label,- size = "md",+ size = "md", quiet = false,}: {bot: Bot;threadId?: string;className?: string;contained?: boolean;label?: ReactNode;- size?: "sm" | "md";+ size?: "sm" | "md"; quiet?: boolean;}) {const { dispatch: storeDispatch, refreshInstances, refreshModels: refreshInstanceModels } = useStoreActions(), state = useStoreSelector((s) => ({ instances: s.instances, modelVariantSessions: s.modelVariantSessions, profile: s.bots.find((candidate) => candidate.id === shown.id) }), sameFields);const [open, setOpen] = useState(false);@@ -607,7 +607,7 @@ export function ModelPicker({{...triggerProps}className={cn("group flex items-center gap-1.5 rounded-full py-1 pl-2 pr-2.5 text-[13px] text-ink disabled:cursor-not-allowed",- contained+ contained || quiet? "hover:bg-ink/[0.06] aria-expanded:bg-ink/[0.08] disabled:opacity-50 disabled:hover:bg-transparent": cn(ELEVATED_FLOAT, ELEVATED_HOVER, "disabled:text-ink-tertiary disabled:hover:bg-composer"),!contained && active && !showActiveAccount && cn(COMPACT_SQUARE, USAGE_WARN_WIDENS),diff --git a/src/components/PhonePlus.tsx b/src/components/PhonePlus.tsxindex e83b1682b6..03f170d3a5 100644--- a/src/components/PhonePlus.tsx+++ b/src/components/PhonePlus.tsx@@ -1,17 +1,17 @@-// The phone composer's round + (Composer.tsx): the + menu, with where the bot works when there is a choice.+// The phone composer's round + and Advanced mode's quiet + (Composer.tsx): the + menu, with where the bot works when there is a choice.import type { ComponentProps } from "react";import { ComposerPlusMenu } from "./ComposerPlusMenu";import { usePlaceMenuItem } from "./PlaceChip";-type PhonePlusProps = Pick<ComponentProps<typeof ComposerPlusMenu>, "onAttach" | "goal" | "teach" | "approval" | "callBotId">;+type PhonePlusProps = Pick<ComponentProps<typeof ComposerPlusMenu>, "onAttach" | "goal" | "teach" | "approval" | "callBotId" | "quiet">;-function PhonePlusWithPlace({ place, ...rest }: PhonePlusProps & { place: Parameters<typeof usePlaceMenuItem>[0] }) {+function PhonePlusWithPlace({ place, quiet, ...rest }: PhonePlusProps & { place: Parameters<typeof usePlaceMenuItem>[0] }) {const item = usePlaceMenuItem(place);- return <ComposerPlusMenu {...rest} extraItems={[item]} circle />;+ return <ComposerPlusMenu {...rest} extraItems={[item]} circle={!quiet} quiet={quiet} />;}-/** The phone composer's round +: attach, Finish together, where the bot works, approval level and call mode. */-export function PhonePlus({ place, ...rest }: PhonePlusProps & { place?: Parameters<typeof usePlaceMenuItem>[0] }) {- return place ? <PhonePlusWithPlace place={place} {...rest} /> : <ComposerPlusMenu {...rest} circle />;+/** The + with everything the composer keeps out of sight: attach, Finish together, where the bot works, approval level and call mode. */+export function PhonePlus({ place, quiet, ...rest }: PhonePlusProps & { place?: Parameters<typeof usePlaceMenuItem>[0] }) {+ return place ? <PhonePlusWithPlace place={place} quiet={quiet} {...rest} /> : <ComposerPlusMenu {...rest} circle={!quiet} quiet={quiet} />;}diff --git a/src/components/composer-wrap.ts b/src/components/composer-wrap.tsindex 63f8c24e3e..52328e71e8 100644--- a/src/components/composer-wrap.ts+++ b/src/components/composer-wrap.ts@@ -14,31 +14,3 @@ export function useTallPill(shellRef: RefObject<HTMLDivElement | null>, on: bool}, [shellRef, on]);return tall;}--/**- * Advanced: a message past one line takes the composer's full width above the buttons instead of wrapping in the gap- * between them. `wrapAt` is the length at which the one-row field wrapped; the field goes back beside the buttons- * only below it, so wider text on its own line cannot flip back and forth.- */-export function useStackedField(inputRef: RefObject<HTMLTextAreaElement | null>, on: boolean, text: string): boolean {- const [wrapAt, setWrapAt] = useState<number | null>(null);- const stacked = on && (text.includes("\n") || (wrapAt !== null && text.length >= wrapAt));- // Width changes (a resized window, a panel opening) can wrap the one-row field too, so watch its size, not just the text.- useLayoutEffect(() => {- const input = inputRef.current;- if (!on || stacked || !input || typeof ResizeObserver === "undefined") return;- const measure = () => {- // An empty field's height is its placeholder's, which may wrap; that is not a message. The next message measures afresh.- if (!input.value) return setWrapAt(null);- const style = getComputedStyle(input);- const line = parseFloat(style.lineHeight) || 24;- const content = input.scrollHeight - (parseFloat(style.paddingTop) || 0) - (parseFloat(style.paddingBottom) || 0);- if (content > line * 1.5) setWrapAt(input.value.length);- };- measure();- const observer = new ResizeObserver(measure);- observer.observe(input);- return () => observer.disconnect();- }, [inputRef, on, stacked, text]);- return stacked;-}