Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(ui): long model names fit their rows, and the sidebar pill says Apps once an app is connected (#3689)
Fraserd6ae3c566427
diff --git a/src/components/ModelPicker.simple.test.ts b/src/components/ModelPicker.simple.test.tsindex 83944d5cd5..b4d37eaf65 100644--- a/src/components/ModelPicker.simple.test.ts+++ b/src/components/ModelPicker.simple.test.ts@@ -363,7 +363,7 @@ describe("the model picker in Simple mode", () => {expect(atDefault).toContain('title="The model decides how hard to think." class="text-[12px] leading-4 text-ink-tertiary">Default</span>');});- it("names the model on the Simple chip at every header width, quiet until hovered; thinking and route stay in its tooltip and the menu", () => {+ it("names the model on the Simple chip, quiet until hovered; thinking and route stay in its tooltip and the menu", () => {const chip = render(bot("high")).nodes.find((node) => node.props["data-tour"] === "model")!;const markup = renderToStaticMarkup(chip);expect(markup).not.toContain("data-model-effort");@@ -374,7 +374,7 @@ describe("the model picker in Simple mode", () => {expect(String(chip.props.className)).toContain("rounded-full");expect(String(chip.props.className)).not.toMatch(/\bborder\b|bg-control/);expect(markup).not.toContain("@max-4xl/chathead");- expect(markup).toContain('<span class="max-w-[160px] truncate">Opus 5.5</span>');+ expect(markup).toContain('<span class="min-w-0 max-w-[160px] truncate">Opus 5.5</span>');expect(markup).toContain("opacity-60");fixture.advanced = true;const advanced = render(bot("high")).nodes.find((node) => node.props["data-tour"] === "model")!;@@ -401,6 +401,15 @@ describe("the model picker in Simple mode", () => {expect(String(chip.props.className)).not.toContain("shadow-(--shadow-float)");});+ it("lets the contained trigger shrink inside the bot panel's Model row, and the loose one keep its size", () => {+ const contained = render(bot(), { contained: true }).nodes.find((node) => node.props["data-tour"] === "model")!;+ expect(String(contained.props.className)).toContain("min-w-0 max-w-[58%]");+ expect(String(contained.props.className)).not.toMatch(/\bshrink-0\b/);+ const loose = render(bot()).nodes.find((node) => node.props["data-tour"] === "model")!;+ expect(String(loose.props.className)).toContain("shrink-0");+ expect(String(loose.props.className)).not.toContain("max-w-[58%]");+ });+it("puts the provider before a model the catalog names in one bare word, on the chip and the current row", () => {fixture.instances = [claude(), cursor];const forBot = bot(undefined, "cursor", "auto");@@ -741,6 +750,23 @@ describe("the model picker in Simple mode", () => {expect(html).not.toMatch(/data-simple-route="true"[^>]*>openai</);});+ it("renders a model's route on its own line in a row that may grow", () => {+ fixture.instances = [engine("pi", "piAgent", "pi", "custom", [+ { id: "amazon-bedrock/claude-sonnet-4-5", label: "Claude Sonnet 4.5", custom: true, provider: "amazon-bedrock" },+ { id: "anthropic/claude-sonnet-4-5", label: "Claude Sonnet 4.5", custom: true, provider: "anthropic" },+ ])];+ const html = menu(open(bot(undefined, "pi", "amazon-bedrock/claude-sonnet-4-5")).html);+ const row = html.split("<button").find((part) => part.includes("data-simple-route") && part.includes("anthropic"));+ expect(row).toBeDefined();+ const lines = row!.slice(row!.indexOf("data-simple-model-text"));+ expect(lines).toMatch(/data-simple-model-text="true" class="[^"]*\bflex-col\b/);+ expect(lines).toMatch(/<span class="truncate">Claude Sonnet 4\.5<\/span>/);+ expect(lines).toMatch(/data-simple-route="true" class="[^"]*\btruncate\b[^"]*">anthropic</);+ expect(row).toContain("min-h-[30px]");+ expect(row).not.toMatch(/\sh-\[30px\]/);+ expect(row).not.toContain("max-w-[45%]");+ });+it("looks for local models only when asked, on Show all where a provider offers them, never just for opening", () => {const codexMany = engine("codex", "codex", "Codex", "subscription", many(8));fixture.instances = [claude(true, many(8)), codexMany, grok, local];diff --git a/src/components/ModelPicker.tsx b/src/components/ModelPicker.tsxindex 445bd4f939..335ec17590 100644--- a/src/components/ModelPicker.tsx+++ b/src/components/ModelPicker.tsx@@ -744,10 +744,10 @@ export function ModelPicker({<button{...triggerProps}className={cn(- "group flex shrink-0 items-center rounded-full text-[13px] leading-[18px] text-ink-secondary disabled:cursor-not-allowed disabled:text-ink-tertiary",+ "group flex items-center rounded-full text-[13px] leading-[18px] text-ink-secondary disabled:cursor-not-allowed disabled:text-ink-tertiary",contained- ? "transition-colors duration-150 hover:bg-ink/[0.06] hover:text-ink aria-expanded:bg-ink/[0.08] aria-expanded:text-ink disabled:hover:bg-transparent"- : cn(ELEVATED_FLOAT, ELEVATED_HOVER, "hover:text-ink aria-expanded:text-ink disabled:hover:bg-composer"),+ ? "min-w-0 max-w-[58%] transition-colors duration-150 hover:bg-ink/[0.06] hover:text-ink aria-expanded:bg-ink/[0.08] aria-expanded:text-ink disabled:hover:bg-transparent"+ : cn("shrink-0", ELEVATED_FLOAT, ELEVATED_HOVER, "hover:text-ink aria-expanded:text-ink disabled:hover:bg-composer"),size === "sm" ? "h-7 pl-2 pr-1.5" : "h-8 pl-2.5 pr-2",)}>@@ -757,7 +757,7 @@ export function ModelPicker({: <span className="size-3.5 rounded-full bg-ink/[0.08]" aria-hidden="true" />}{attention && <span data-model-attention className="absolute -bottom-0.5 -right-0.5 size-1.5 rounded-full bg-warning ring-[1.5px] ring-app" />}</span>- <span className="max-w-[160px] truncate">{modelName(active, selection.model)}</span>+ <span className="min-w-0 max-w-[160px] truncate">{modelName(active, selection.model)}</span><ChevronDown size={12} strokeWidth={2} aria-hidden="true" className="ml-1 shrink-0 text-ink-tertiary group-hover:text-ink-secondary" /></button>);diff --git a/src/components/SidebarConnectApps.dom.test.ts b/src/components/SidebarConnectApps.dom.test.tsnew file mode 100644index 0000000000..dcad327ea9--- /dev/null+++ b/src/components/SidebarConnectApps.dom.test.ts@@ -0,0 +1,35 @@+// @vitest-environment happy-dom+import { act, createElement } from "react";+import { createRoot } from "react-dom/client";+import { expect, it, vi } from "vitest";++import { initialState } from "@/state/store";++const inventory = vi.hoisted(() => ({ services: {} as Record<string, { connected: boolean }> }));++vi.mock("@/state/store", async (original) => ({ ...await original<typeof import("@/state/store")>(), useStore: () => ({ state: initialState, dispatch: vi.fn() }) }));+vi.mock("./PluginsPanel", () => ({ preloadConnectedApps: async () => ({ services: inventory.services, authoritative: true }) }));+vi.mock("./bot-settings/useBotApps", () => ({ loadAppCards: async () => new Map([["github", { slug: "github", label: "GitHub", logo: null, domain: "github.com" }]]) }));++import { SidebarConnectApps } from "./SidebarConnectApps";++(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++async function pill(services: Record<string, { connected: boolean }>, circle = false) {+ inventory.services = services;+ const root = createRoot(document.body.appendChild(document.createElement("div")));+ await act(async () => { root.render(createElement(SidebarConnectApps, { circle })); });+ await act(() => new Promise((resolve) => setTimeout(resolve, 0)));+ const button = document.querySelector<HTMLButtonElement>('[data-sidebar-nav="apps"]')!;+ const seen = { label: circle ? button.getAttribute("aria-label") : button.firstElementChild!.textContent, faces: [...button.querySelectorAll("[data-app-face]")].map((face) => face.getAttribute("data-app-face")) };+ act(() => root.unmount());+ document.body.innerHTML = "";+ return seen;+}++it("asks to connect apps until one is connected, then is simply the way into Apps", async () => {+ expect(await pill({})).toEqual({ label: "Connect apps", faces: ["gmail", "slack", "notion"] });+ expect(await pill({ github: { connected: false } }), "an app that is only listed is not connected").toEqual({ label: "Connect apps", faces: ["gmail", "slack", "notion"] });+ expect(await pill({ github: { connected: true } })).toEqual({ label: "Apps", faces: ["github", "gmail", "slack"] });+ expect((await pill({ github: { connected: true } }, true)).label, "and on the collapsed rail").toBe("Apps");+});diff --git a/src/components/SidebarConnectApps.tsx b/src/components/SidebarConnectApps.tsxindex 261f450f9f..fb67c130e3 100644--- a/src/components/SidebarConnectApps.tsx+++ b/src/components/SidebarConnectApps.tsx@@ -25,9 +25,14 @@ export function appFaces(connected: readonly string[], cards: ReadonlyMap<stringreturn [...own, ...POPULAR_APPS.filter((app) => !own.some((card) => card.slug === app.slug))].slice(0, APP_FACES);}-function useAppFaces(): AppFace[] {+interface SidebarApps {+ faces: AppFace[];+ connected: boolean;+}++function useSidebarApps(): SidebarApps {const { state } = useStore();- const [faces, setFaces] = useState<AppFace[]>(() => appFaces([], new Map()));+ const [apps, setApps] = useState<SidebarApps>(() => ({ faces: appFaces([], new Map()), connected: false }));useEffect(() => {if (state.pluginsOpen) return;let alive = true;@@ -35,12 +40,12 @@ function useAppFaces(): AppFace[] {.then(async (inventory) => {const connected = Object.entries(inventory.services).filter(([, status]) => status.connected).map(([slug]) => slug).sort();const cards = connected.length > 0 ? await loadAppCards() : new Map<string, AppFace>();- if (alive) setFaces(appFaces(connected, cards));+ if (alive) setApps({ faces: appFaces(connected, cards), connected: connected.length > 0 });}).catch(() => {});return () => { alive = false; };}, [state.pluginsOpen]);- return faces;+ return apps;}function AppFaceIcon({ face, className }: { face: AppFace; className?: string }) {@@ -62,8 +67,8 @@ const FAN = ["motion-safe:group-hover/apps:-translate-x-[3px] motion-safe:group-/** `circle` is the collapsed rail's round button. */export function SidebarConnectApps({ circle = false }: { circle?: boolean }) {const { state, dispatch } = useStore();- const faces = useAppFaces();- const label = t("sidebar.connectApps");+ const { faces, connected } = useSidebarApps();+ const label = connected ? t("sidebar.nav.apps") : t("sidebar.connectApps");return (<buttontype="button"diff --git a/src/components/SimpleModelMenu.tsx b/src/components/SimpleModelMenu.tsxindex c51d7f8b06..fe87113b25 100644--- a/src/components/SimpleModelMenu.tsx+++ b/src/components/SimpleModelMenu.tsx@@ -8,7 +8,7 @@ import { cn } from "@/lib/cn";import { t } from "@/lib/i18n";import { BotAvatar } from "./Avatar";import { InstanceProviderMark } from "./ProviderIcons";-import { MENU_GUTTER, MENU_ICON, MENU_LABEL, MENU_LINE, MENU_META, MENU_NOTE, MENU_ROW, MENU_SEPARATOR, MENU_STROKE, MENU_TRAILING } from "./menu-recipe";+import { MENU_GUTTER, MENU_ICON, MENU_LABEL, MENU_LINE, MENU_NOTE, MENU_ROW, MENU_SEPARATOR, MENU_STROKE, MENU_TRAILING, SIMPLE_MENU_META, SIMPLE_MENU_ROW } from "./menu-recipe";import { effortLabel } from "./ModelPicker";export type SimpleThinking =@@ -39,6 +39,16 @@ export interface SimpleModelMenuProps extends SimpleMenuActions {const Gutter = ({ children }: { children?: ReactNode }) => <span className={MENU_GUTTER}>{children}</span>;const Forward = () => <ChevronRight size={16} strokeWidth={MENU_STROKE} className={MENU_TRAILING} aria-hidden="true" />;+/** A model's name and its secondary label, each on its own line so a long name never eats the label beside it. */+function RowLines({ label, children }: { label: ReactNode; children?: ReactNode }) {+ return (+ <span data-simple-model-text className="flex min-w-0 flex-1 flex-col">+ <span className="truncate">{label}</span>+ {children}+ </span>+ );+}+function MenuModel({ instance, row, onPick }: { instance: InstanceInfo; row: MenuModelRow; onPick: SimpleMenuActions["onPick"] }) {const { option } = row;return (@@ -50,11 +60,12 @@ function MenuModel({ instance, row, onPick }: { instance: InstanceInfo; row: Mentitle={[option.label, option.provider, modelBlurb(option)].filter(Boolean).join(" · ")}tabIndex={-1}onClick={() => onPick(instance, row.model ?? option.id, row.variant)}- className={MENU_ROW}+ className={SIMPLE_MENU_ROW}><Gutter />- <span className="min-w-0 flex-1 truncate">{row.label}</span>- {row.route && <span data-simple-route className={MENU_META}>{row.route}</span>}+ <RowLines label={row.label}>+ {row.route && <span data-simple-route className={SIMPLE_MENU_META}>{row.route}</span>}+ </RowLines>{row.current && <Check size={14} className="shrink-0 text-accent" aria-hidden="true" />}</button>);@@ -221,25 +232,27 @@ export function SimpleModelMenu(props: SimpleModelMenuProps) {if (setUp) props.onSetUp(setUp, event.detail === 0);else props.onPickCurrent();}}- className={MENU_ROW}+ className={SIMPLE_MENU_ROW}><Gutter>{current.instance? <InstanceProviderMark instance={current.instance} size={14} subtle />: <span className="size-3.5 rounded-full bg-ink/[0.08]" aria-hidden="true" />}</Gutter>- <span className="min-w-0 flex-1 truncate">{current.label}</span>+ <RowLines label={current.label}>+ {current.meta && <span className={cn(SIMPLE_MENU_META, current.warning && "text-warning")}>{current.meta}</span>}+ </RowLines>{current.pending && <Loader2 size={14} className="shrink-0 animate-spin text-ink-tertiary" aria-hidden="true" />}- {current.meta && <span className={cn(MENU_META, current.warning && "text-warning")}>{current.meta}</span>}<Check size={14} className="shrink-0 text-accent" aria-hidden="true" /></button>)}{menu.follow && (<button type="button" data-menu-row data-follow-bot-model aria-pressed="false" tabIndex={-1} title={props.botModel.title}- onClick={props.onFollowBot} className={MENU_ROW}>+ onClick={props.onFollowBot} className={SIMPLE_MENU_ROW}><Gutter><BotAvatar bot={props.bot} size={16} state="happy" animated={false} label="" /></Gutter>- <span className="min-w-0 flex-1 truncate">{t("model.useBotModel", { name: props.bot.name })}</span>- <span className={MENU_META}>{props.botModel.label}</span>+ <RowLines label={t("model.useBotModel", { name: props.bot.name })}>+ <span className={SIMPLE_MENU_META}>{props.botModel.label}</span>+ </RowLines></button>)}{top && menu.groups.length > 0 && <div role="separator" className={MENU_SEPARATOR} />}diff --git a/src/components/menu-recipe.ts b/src/components/menu-recipe.tsindex 467673922d..07ec831fab 100644--- a/src/components/menu-recipe.ts+++ b/src/components/menu-recipe.ts@@ -9,6 +9,12 @@ export const MENU_HEADING = "px-2 pb-1 pt-2 text-[12px] font-medium leading-4 teexport const MENU_ROW ="group flex h-[30px] w-full min-w-0 shrink-0 items-center gap-2 rounded-md px-2 text-left text-[13px] leading-[18px] text-ink hover:bg-ink/[0.06] focus:bg-ink/[0.06] active:bg-ink/[0.08] disabled:cursor-default disabled:opacity-50 disabled:hover:bg-transparent touch:h-10";+/** Simple mode's rows pair a model name with a second line, so they grow with it instead of clipping at 30px. */+export const SIMPLE_MENU_ROW =+ "group flex min-h-[30px] w-full min-w-0 shrink-0 items-center gap-2 rounded-md px-2 py-1 text-left text-[13px] leading-[18px] text-ink hover:bg-ink/[0.06] focus:bg-ink/[0.06] active:bg-ink/[0.08] disabled:cursor-default disabled:opacity-50 disabled:hover:bg-transparent touch:min-h-10";++export const SIMPLE_MENU_META = "min-w-0 max-w-full truncate text-[12px] leading-4 text-ink-tertiary";+export const MENU_LINE = "flex h-[30px] w-full min-w-0 shrink-0 items-center gap-2 px-2 text-[13px] leading-[18px] touch:h-10";export const MENU_GUTTER = "flex size-4 shrink-0 items-center justify-center";