Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Fold the header model pill beside the bot panel, glide the panel, keep the sidebar still (#7045)

Milind Soni00e8896134fa
diff --git a/DESIGN.md b/DESIGN.md
index 0c3afee821..70e626add1 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -185,9 +185,15 @@ element's job and never a pixel value:
in both modes; pinned bots are 95 × 92px tiles with a 60px avatar. Pinned
pages never join them: a bot's pages are in its bot panel's Library tab.
- **The sidebar stays open beside a side panel** while the chat keeps 440px:
- from 1040px with a 320px panel (Simple's bot panel, a room, Simple's inbox,
- Notifications), from 1280px with a wider one. Narrower, it folds to its
- avatars.
+ from 1040px with a 320px panel (a room, Simple's inbox, Notifications), from
+ 1280px with a wider one. Narrower, it folds to its avatars.
+- **Simple's bot panel never moves the sidebar.** Opening or closing it leaves
+ the sidebar's width and its pinned bots exactly as they were. The chat makes
+ the room; under 920px, where the chat would get less than 320px, the panel
+ floats over the chat's edge instead.
+- **The chat header's model pill folds to its AI's mark** while a side panel
+ narrows the chat, in a round button the size of the header's others; its
+ label still names the model.
- **Group with space before you group with lines.** Add a divider only between
groups that space alone can't separate. Never a divider under a heading.
- **No cards inside cards.** If a card needs sections, use spacing and a group
@@ -265,6 +271,11 @@ Motion explains a change. It never decorates.
- **Use the tokens:** `animate-pop-in` / `pop-out` (menus, 200ms),
`animate-panel-in` (240ms), `animate-msg-in` (180ms), `animate-fade-in`.
Movement eases with `cubic-bezier(0.22, 1, 0.36, 1)`; fades use `ease-out`.
+- **Panes keep their width while they move.** A side panel slides in and out
+ over the window's edge at its full width (`animate-panel-beside-in`, 240ms)
+ while the room it takes grows or shrinks, so the chat glides and nothing in
+ the panel rewraps. Words leaving a control fade, drift a few pixels and soften
+ rather than being cut off; they never wrap mid-way.
- **300ms ceiling.** Only first-run onboarding may run longer.
- **Nothing scales in from zero.** Things grow from about 96% and fade.
- **Hover and press transitions are 120ms** on colour and opacity only. Don't
diff --git a/src/App.tsx b/src/App.tsx
index d546fe389d..7009109711 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -23,8 +23,8 @@ import { ChatView } from "@/components/ChatView";
import { HandoffExchangeHost } from "@/components/HandoffExchange";
import { GroupView } from "@/components/GroupView";
import { ForkPanel } from "@/components/ForkPanel";
-import { SIDEBAR_AND_NARROW_PANEL_FIT, SIDEBAR_AND_PANEL_FIT, SIDEBAR_INLINE, TWO_SIDE_PANELS_FIT, useMediaQuery } from "@/lib/use-media-query";
-import { anySidePanel, sidebarFoldsForPanel, type OpenSidePanels } from "@/lib/sidebar-fold";
+import { SIDEBAR_AND_BOT_PANEL_FIT, SIDEBAR_AND_NARROW_PANEL_FIT, SIDEBAR_AND_PANEL_FIT, SIDEBAR_INLINE, TWO_SIDE_PANELS_FIT, useMediaQuery } from "@/lib/use-media-query";
+import { anySidePanel, botPanelFloats, panelsMovingSidebar, sidebarFoldsForPanel, type OpenSidePanels } from "@/lib/sidebar-fold";
import { preloadConnectedApps } from "@/lib/connected-apps";
import {
ActivityPanel, AnnouncementsPage, BotSettingsDialog, CloudAddDialog, ComputerPanel, FilesView, InboxPanel, InspectorPanel, KeyboardShortcutsModal, LocalVmWorkspace,
@@ -116,6 +116,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
const twoSidePanelsFit = useMediaQuery(TWO_SIDE_PANELS_FIT, true);
const sidebarAndPanelFit = useMediaQuery(SIDEBAR_AND_PANEL_FIT, true);
const sidebarAndNarrowPanelFit = useMediaQuery(SIDEBAR_AND_NARROW_PANEL_FIT, true);
+ const sidebarAndBotPanelFit = useMediaQuery(SIDEBAR_AND_BOT_PANEL_FIT, true);
const sidebarInline = useMediaQuery(SIDEBAR_INLINE, false);
useEffect(() => {
if (!sidebarInline && state.forkPanel) dispatch({ type: "closeForkPanel" });
@@ -188,8 +189,8 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
};
// A 320 panel leaves room for the open sidebar from 1040 up; a wider one from 1280. Narrower, the sidebar folds.
const collapseSidebar = sidebarFoldsForPanel(sidePanels, { wide: sidebarAndPanelFit, narrow: sidebarAndNarrowPanelFit });
- // Open beside a panel below 1280, the sidebar keeps to 280 so the chat keeps its 440.
- const sidebarBesidePanel = anySidePanel(sidePanels) && !sidebarAndPanelFit;
+ // Open beside a panel below 1280, the sidebar keeps to 280 so the chat keeps its 440; Simple's bot panel never moves it.
+ const sidebarBesidePanel = anySidePanel(panelsMovingSidebar(sidePanels)) && !sidebarAndPanelFit;
const calendarFocus = state.activeView === "routines" && state.routinesFocus.view === "calendar";
const notificationTray = notificationFeed && !calendarFocus;
@@ -368,7 +369,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
<BotLimitPopup />
<ConversationShareDialogs />
{!framed && strips}
- <div className="relative flex min-h-0 flex-1">
+ <div className="relative flex min-h-0 flex-1 overflow-x-clip">
{!calendarFocus && <button
type="button"
ref={menuButtonRef}
@@ -395,7 +396,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
<div data-window-card={framed ? "" : undefined}
className={framed ? "relative flex min-w-0 flex-1 flex-col overflow-hidden rounded-t-[12px] rounded-bl-[12px] bg-app" : "contents"}>
{framed && strips}
- <div className={framed ? "relative flex min-h-0 flex-1" : "contents"}>
+ <div className={framed ? "relative flex min-h-0 flex-1 overflow-x-clip" : "contents"}>
{!calendarFocus && <Sidebar
collapseToIcons={collapseSidebar}
besidePanel={sidebarBesidePanel}
@@ -456,7 +457,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
{state.settingsOpen && bot && (
remoteClient
? <RemoteAgentSettingsPanel bot={bot} overlay={state.computerOpen && !twoSidePanelsFit} />
- : <BotSettingsDialog key={`settings:${bot.id}`} bot={bot} overlay={(state.inspectorOpen || state.computerOpen || (notificationFeed && state.notificationsOpen)) && !twoSidePanelsFit} />
+ : <BotSettingsDialog key={`settings:${bot.id}`} bot={bot} overlay={((state.inspectorOpen || state.computerOpen || (notificationFeed && state.notificationsOpen)) && !twoSidePanelsFit) || botPanelFloats(sidePanels, sidebarAndBotPanelFit)} />
)}
{state.computerOpen && bot && (
remoteClient ? (
diff --git a/src/components/BotSettingsDialog.tsx b/src/components/BotSettingsDialog.tsx
index dd9865808b..37de70e8ab 100644
--- a/src/components/BotSettingsDialog.tsx
+++ b/src/components/BotSettingsDialog.tsx
@@ -27,7 +27,7 @@ import { useAdvancedMode } from "@/lib/interface-mode";
import { BotPanel } from "./bot-panel/PanelShell";
import { LibraryTab } from "./bot-panel/LibraryTab";
import type { SimplePageId } from "./bot-panel/page-registry";
-import { BOT_PANEL_ID, sidePanelCls } from "./bot-panel/side-panel";
+import { BOT_PANEL_ID, sidePanelCls, useSidePanelLeave } from "./bot-panel/side-panel";
import { HistoryRollbackDialog, useBotHistory, useBotOverview } from "./bot-settings/useBotOverview";
import { useOwnerOrAdmin } from "@/lib/use-owner-or-admin";
import { ShareBotButton, useTeamName } from "./bot-access/ShareBotButton";
@@ -50,6 +50,7 @@ export function BotSettingsDialog({ bot, overlay = false }: {
const section = state.botSettingsSection;
const derived = useBotSettingsDerived(bot);
const dialogRef = useRef<HTMLElement | null>(null);
+ useSidePanelLeave(dialogRef);
const { dragProps } = useCaptionChrome();
const [query, setQuery] = useState("");
const collapsed = !state.botSettingsExpandAccordion;
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index b651e2d869..73378e5d1c 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -1037,7 +1037,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
<ThreadContextWarning bot={bot} messages={messages} />
{phone && <UsageAlert engine={bot.modelSelection?.instanceId} />}
{/* 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} />}
+ {!phone && (!advanced || canWrite === false) && <ModelPicker key={bot.threadId} bot={bot} threadId={bot.threadId} folded={state.settingsOpen || state.computerOpen} />}
<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} />}
<PinnedMessagesMenu
pins={pinnedPreview(messages, bot.pinnedMessageId, bot.name)}
diff --git a/src/components/ModelPicker.dom.test.ts b/src/components/ModelPicker.dom.test.ts
index d3292ab7f3..4f900dbd75 100644
--- a/src/components/ModelPicker.dom.test.ts
+++ b/src/components/ModelPicker.dom.test.ts
@@ -527,3 +527,32 @@ describe("while the bot is working", () => {
expect(chip().disabled).toBe(true);
});
});
+
+describe("the header pill beside an open side panel", () => {
+ const renderFolded = (folded: boolean) => flushSync(() => root.render(createElement(ModelPicker, { bot: scout(), threadId: "thread-scout", folded })));
+ const pill = () => host.querySelector<HTMLButtonElement>("[data-model-pill]")!;
+
+ it("folds to its AI's mark, still names the model and its reasoning, and opens the same menu", async () => {
+ renderFolded(true);
+ expect(pill().hasAttribute("data-folded")).toBe(true);
+ expect(pill().getAttribute("aria-label")).toContain("Claude Opus 5.5");
+ expect(pill().getAttribute("aria-label")).toBe(pill().title.split("\n")[0]);
+ await openWith("click");
+ expect(menu()).not.toBeNull();
+ expect(chip().getAttribute("aria-expanded")).toBe("true");
+ });
+
+ it("opens back out to the full pill, named by its words again, when the panel closes", () => {
+ renderFolded(true);
+ renderFolded(false);
+ expect(pill().hasAttribute("data-folded")).toBe(false);
+ expect(pill().hasAttribute("aria-label")).toBe(false);
+ expect(pill().textContent).toContain("Claude Opus 5.5");
+ });
+
+ it("never folds the picker that sits inside a row", () => {
+ flushSync(() => root.render(createElement(ModelPicker, { bot: scout(), threadId: "thread-scout", contained: true, folded: true })));
+ expect(host.querySelector("[data-model-pill]")).toBeNull();
+ expect(chip().hasAttribute("aria-label")).toBe(false);
+ });
+});
diff --git a/src/components/ModelPicker.simple.test.ts b/src/components/ModelPicker.simple.test.ts
index b9c9abc41e..4bff6b4890 100644
--- a/src/components/ModelPicker.simple.test.ts
+++ b/src/components/ModelPicker.simple.test.ts
@@ -135,6 +135,8 @@ function open(forBot: Bot, options: { contained?: boolean; thread?: boolean } =
}
type Rendered = ReturnType<typeof render>;
+/** The class of the button a trigger element draws (Simple's trigger is its own component). */
+const buttonClass = (trigger: ReactElement) => /^<button[^>]*\sclass="([^"]*)"/.exec(renderToStaticMarkup(trigger))?.[1] ?? "";
const pane = (rendered: Rendered) =>
rendered.nodes.find((node) => node.type === SimpleModelMenu) as ReactElement<ComponentProps<typeof SimpleModelMenu>> | undefined;
const list = (rendered: Rendered): SimpleMenu => pane(rendered)!.props.menu;
@@ -370,11 +372,11 @@ describe("the model picker in Simple mode", () => {
expect(markup.replace(/title="[^"]*"/, "")).not.toContain("High");
expect(String(chip.props.title)).toContain("High thinking");
expect(String(chip.props.title)).not.toContain("effort");
- expect(String(chip.props.className)).toContain("h-9");
- expect(String(chip.props.className)).toContain("rounded-full");
- expect(String(chip.props.className)).not.toMatch(/\bborder\b|bg-control/);
+ expect(buttonClass(chip)).toContain("h-9");
+ expect(buttonClass(chip)).toContain("rounded-full");
+ expect(buttonClass(chip)).not.toMatch(/\bborder\b|bg-control/);
expect(markup).not.toContain("@max-4xl/chathead");
- expect(markup).toContain('<span class="min-w-0 truncate max-w-[160px]">Opus 5.5</span>');
+ expect(markup).toContain('<span data-model-pill-words="" class="min-w-0 truncate max-w-[160px]">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")!;
@@ -383,7 +385,7 @@ describe("the model picker in Simple mode", () => {
});
it("puts the header chip on an opaque surface, so scrolled transcript text cannot read through it", () => {
- const classes = () => String(render(bot()).nodes.find((node) => node.props["data-tour"] === "model")!.props.className);
+ const classes = () => buttonClass(render(bot()).nodes.find((node) => node.props["data-tour"] === "model")!);
expect(classes().split(" ")).toEqual(expect.arrayContaining(["bg-composer", "ring-[0.5px]", "shadow-(--shadow-float)"]));
expect(classes()).not.toMatch(/hover:bg-ink|aria-expanded:bg-ink/);
fixture.advanced = true;
@@ -403,11 +405,11 @@ describe("the model picker in Simple mode", () => {
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-[72%]");
- expect(String(contained.props.className)).not.toMatch(/\bshrink-0\b/);
+ expect(buttonClass(contained)).toContain("min-w-0 max-w-[72%]");
+ expect(buttonClass(contained)).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-[72%]");
+ expect(buttonClass(loose)).toContain("shrink-0");
+ expect(buttonClass(loose)).not.toContain("max-w-[72%]");
});
it("puts the provider before a model the catalog names in one bare word, on the chip and the current row", () => {
diff --git a/src/components/ModelPicker.tsx b/src/components/ModelPicker.tsx
index ab9c082840..574c71fa6e 100644
--- a/src/components/ModelPicker.tsx
+++ b/src/components/ModelPicker.tsx
@@ -36,7 +36,7 @@ import { COMPACT_SQUARE } from "@/lib/compact-chip";
import { useAiSwitch } from "@/lib/ai-switch";
import { usePickerPane } from "@/lib/model-picker-pane";
import { threadsOnOwnModel } from "../../shared/thread-model";
-import { ThreadModelsLine } from "./ThreadModelsLine";
+import { ThreadModelsLine } from "./ThreadModelsLine"; import { SimpleModelTrigger } from "./ModelPickerTrigger";
import { USAGE_WARN_WIDENS, UsageBars, UsageMenuRows } from "./EngineUsage";
import { Select } from "./Select";
@@ -206,14 +206,14 @@ export function ModelPicker({
className,
contained = false,
label,
- size = "md", quiet = false,
+ size = "md", quiet = false, folded = false,
}: {
bot: Bot;
threadId?: string;
className?: string;
contained?: boolean;
label?: ReactNode;
- size?: "sm" | "md"; quiet?: boolean;
+ size?: "sm" | "md"; quiet?: boolean; /** The header's pill folds to its mark while a side panel narrows the chat. */ folded?: 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);
@@ -647,29 +647,7 @@ export function ModelPicker({
)}
/>
</button>
- ) : (
- <button
- {...triggerProps}
- className={cn(
- "group flex items-center rounded-full text-[13px] leading-[18px] text-ink-secondary disabled:cursor-not-allowed disabled:text-ink-tertiary",
- contained
- ? "min-w-0 max-w-[72%] 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" : contained ? "h-8 pl-2.5 pr-2" : "h-9 pl-3 pr-2.5",
- )}
- >
- <span className="relative mr-1.5 flex shrink-0 group-disabled:opacity-50">
- {active
- ? <InstanceProviderMark instance={active} size={14} subtle />
- : <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={cn("min-w-0 truncate", !contained && "max-w-[160px]")}>{modelName(active, selection.model)}</span>
- {selection.variant !== undefined && <span className="shrink-0 whitespace-pre">{variantSuffix(active, selection.model, selection.variant)}</span>}
- <UsageBars engine={selection.instanceId} className="ml-1.5" />
- <ChevronDown size={12} strokeWidth={2} aria-hidden="true" className="ml-1 shrink-0 text-ink-tertiary group-hover:text-ink-secondary" />
- </button>
- );
+ ) : <SimpleModelTrigger {...triggerProps} active={active} selection={selection} attention={attention} contained={contained} size={size} folded={folded} summary={summary} />;
const simpleMenu = simpleView ? simpleModelMenu({
instances,
diff --git a/src/components/ModelPickerTrigger.tsx b/src/components/ModelPickerTrigger.tsx
new file mode 100644
index 0000000000..4aa90a0b37
--- /dev/null
+++ b/src/components/ModelPickerTrigger.tsx
@@ -0,0 +1,60 @@
+import type { ComponentProps } from "react";
+import { ChevronDown } from "lucide-react";
+
+import { cn } from "@/lib/cn";
+import { modelName, variantSuffix } from "@/lib/simple-model-menu";
+import type { InstanceInfo, ModelSelection } from "@/state/store";
+import { ELEVATED_FLOAT, ELEVATED_HOVER } from "./elevated";
+import { UsageBars } from "./EngineUsage";
+import { InstanceProviderMark } from "./ProviderIcons";
+
+/** Simple mode's model button: the AI's mark, then the model, its reasoning and usage bars and a chevron.
+ *
+ * In the chat header, `folded` (a side panel narrows the chat) leaves only the mark, in a round button the size of the
+ * header's others; `summary` then names the model for screen readers. styles.css (`[data-model-pill]`) glides the
+ * width and eases the words out and back in; the fold is off with reduced motion. */
+export function SimpleModelTrigger({ active, selection, attention, contained, size, folded = false, summary, className, ...button }: ComponentProps<"button"> & {
+ active: InstanceInfo | undefined;
+ selection: ModelSelection;
+ attention: string | undefined;
+ contained: boolean;
+ size: "sm" | "md";
+ folded?: boolean;
+ summary: string;
+}) {
+ const header = !contained && size === "md";
+ return (
+ <button
+ {...button}
+ data-model-pill={header ? "" : undefined}
+ data-folded={header && folded ? "" : undefined}
+ aria-label={header && folded ? summary : undefined}
+ className={cn(
+ "group flex items-center rounded-full text-[13px] leading-[18px] text-ink-secondary disabled:cursor-not-allowed disabled:text-ink-tertiary",
+ contained
+ ? "min-w-0 max-w-[72%] 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" : contained ? "h-8 pl-2.5 pr-2" : "h-9 min-w-9 justify-center pl-3 pr-2.5",
+ className,
+ )}
+ >
+ <span data-model-pill-mark={header ? "" : undefined} className="relative me-1.5 flex shrink-0 group-disabled:opacity-50">
+ {active
+ ? <InstanceProviderMark instance={active} size={14} subtle />
+ : <span className="size-3.5 rounded-full bg-ink/[0.08]" aria-hidden="true" />}
+ {attention && <span data-model-attention className="absolute -bottom-0.5 -end-0.5 size-1.5 rounded-full bg-warning ring-[1.5px] ring-app" />}
+ </span>
+ {/* The fold's track: a grid column going from 1fr to 0fr shrinks the pill to its mark without measuring it. */}
+ <span data-model-pill-rest={header ? "" : undefined} className={cn("min-w-0", header ? "grid" : "contents")}>
+ <span className={header ? "flex min-w-0 items-center overflow-hidden whitespace-nowrap" : "contents"}>
+ <span data-model-pill-words={header ? "" : undefined} className={cn("min-w-0 truncate", !contained && "max-w-[160px]")}>{modelName(active, selection.model)}</span>
+ {selection.variant !== undefined && <span data-model-pill-words={header ? "" : undefined} className="shrink-0 whitespace-pre">{variantSuffix(active, selection.model, selection.variant)}</span>}
+ <span data-model-pill-tail={header ? "" : undefined} className={header ? "flex shrink-0 items-center" : "contents"}>
+ <UsageBars engine={selection.instanceId} className="ms-1.5" />
+ <ChevronDown size={12} strokeWidth={2} aria-hidden="true" className="ms-1 shrink-0 text-ink-tertiary group-hover:text-ink-secondary" />
+ </span>
+ </span>
+ </span>
+ </button>
+ );
+}
diff --git a/src/components/bot-panel/side-panel.dom.test.ts b/src/components/bot-panel/side-panel.dom.test.ts
new file mode 100644
index 0000000000..3a6e505235
--- /dev/null
+++ b/src/components/bot-panel/side-panel.dom.test.ts
@@ -0,0 +1,102 @@
+// @vitest-environment happy-dom
+// A side panel's way out: the real panel goes at once (focus and keys with it), and an inert copy slides out after it.
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import { leaveSidePanel, sidePanelCls } from "./side-panel";
+
+let row: HTMLDivElement;
+let finish: () => void;
+const animate = vi.fn(() => ({ finished: new Promise<void>((resolve) => { finish = resolve; }) }));
+
+function panel(): HTMLElement {
+ const aside = document.createElement("aside");
+ aside.id = "bot-panel";
+ aside.setAttribute("role", "dialog");
+ aside.tabIndex = -1;
+ aside.innerHTML = '<h2 id="bot-settings-title">Scout</h2><button type="button">Close</button>'
+ + '<svg><defs><linearGradient id="mascot-grad"></linearGradient></defs></svg><iframe src="about:blank"></iframe>';
+ aside.getBoundingClientRect = () => ({ width: 320 }) as DOMRect;
+ row.append(document.createElement("main"), aside);
+ return aside;
+}
+const copies = () => row.querySelectorAll<HTMLElement>("[data-side-panel-leaving]");
+
+beforeEach(() => {
+ delete document.documentElement.dataset.reducedMotion;
+ row = document.createElement("div");
+ document.body.append(row);
+ Object.defineProperty(HTMLElement.prototype, "animate", { value: animate, configurable: true });
+ animate.mockClear();
+});
+afterEach(() => {
+ row.remove();
+ delete (HTMLElement.prototype as { animate?: unknown }).animate;
+});
+
+describe("closing a side panel beside the chat", () => {
+ it("leaves an inert, unnamed copy that slides out over its width and then goes", async () => {
+ const aside = panel();
+ leaveSidePanel(aside);
+ aside.remove();
+ await Promise.resolve();
+ const [copy] = copies();
+ expect(copy).toBeDefined();
+ expect(copy!.getAttribute("aria-hidden")).toBe("true");
+ expect(copy!.inert).toBe(true);
+ expect(copy!.hasAttribute("role")).toBe(false);
+ expect(copy!.hasAttribute("tabindex")).toBe(false);
+ expect([...copy!.querySelectorAll("[id]")].map((node) => node.id)).toEqual(["mascot-grad"]);
+ expect(copy!.querySelector("iframe")).toBeNull();
+ expect(copy!.id).toBe("");
+ expect(animate).toHaveBeenCalledWith(
+ [{ marginInlineEnd: "0px", opacity: 1 }, { marginInlineEnd: "-320px", opacity: 0 }],
+ expect.objectContaining({ duration: 240, easing: "cubic-bezier(0.22, 1, 0.36, 1)" }),
+ );
+ finish();
+ await Promise.resolve();
+ await Promise.resolve();
+ expect(copies()).toHaveLength(0);
+ });
+
+ it("leaves nothing with reduced motion, or when another bot's panel takes its place", async () => {
+ document.documentElement.dataset.reducedMotion = "true";
+ const first = panel();
+ leaveSidePanel(first);
+ first.remove();
+ await Promise.resolve();
+ expect(copies()).toHaveLength(0);
+
+ delete document.documentElement.dataset.reducedMotion;
+ const second = panel();
+ leaveSidePanel(second);
+ second.remove();
+ row.append(document.createElement("aside"));
+ await Promise.resolve();
+ expect(copies()).toHaveLength(0);
+ expect(animate).not.toHaveBeenCalled();
+ });
+
+ it("gives the room at once to a panel that arrives while the copy is still sliding out", async () => {
+ const aside = panel();
+ leaveSidePanel(aside);
+ aside.remove();
+ await Promise.resolve();
+ expect(copies()).toHaveLength(1);
+ row.append(document.createElement("aside"));
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ expect(copies()).toHaveLength(0);
+ });
+});
+
+describe("the panel's way in", () => {
+ it("slides in at its full width from md up, floating or beside the chat, and holds still with reduced motion", () => {
+ for (const overlay of [false, true]) {
+ const cls = sidePanelCls(overlay, true);
+ expect(cls).toContain("md:animate-panel-beside-in");
+ expect(cls).toContain("md:w-(--side-panel-w)");
+ expect(cls).toContain("[--side-panel-w:320px]");
+ expect(cls).toContain("motion-reduce:animate-none");
+ }
+ expect(sidePanelCls(false, false)).toContain("[--side-panel-w:min(420px,42vw)]");
+ });
+});
diff --git a/src/components/bot-panel/side-panel.ts b/src/components/bot-panel/side-panel.ts
index dff95c133c..d599f4efe4 100644
--- a/src/components/bot-panel/side-panel.ts
+++ b/src/components/bot-panel/side-panel.ts
@@ -1,11 +1,80 @@
+import { useLayoutEffect, type RefObject } from "react";
+
import { cn } from "@/lib/cn";
export const BOT_PANEL_ID = "bot-panel";
+/** From md up the panel keeps its width while it slides in from the window's edge: `panel-beside-in` (styles.css)
+ * grows the room it takes from nothing, so beside the chat the chat narrows with it instead of jumping, and nothing in
+ * the panel rewraps on the way. */
export const sidePanelCls = (overlay: boolean, simple = false) => cn(
- "animate-sheet-in md:animate-panel-in absolute inset-0 z-40 flex h-full min-w-0 flex-col outline-none focus-visible:outline-none",
+ "animate-sheet-in md:animate-panel-beside-in absolute inset-0 z-40 flex h-full min-w-0 flex-col outline-none focus-visible:outline-none! motion-reduce:animate-none",
+ simple ? "[--side-panel-w:320px]" : "[--side-panel-w:min(420px,42vw)]",
simple && !overlay ? "border-l-[0.5px] border-ink/[0.06] bg-app" : "border-l border-hairline/40 bg-panel",
overlay
- ? cn("md:inset-auto md:right-0 md:top-0 md:bottom-0 md:shadow-2xl", simple ? "md:w-[320px]" : "md:w-[min(420px,42vw)]")
- : cn("md:static md:z-auto md:shrink-0", simple ? "md:w-[320px]" : "md:w-[min(420px,42vw)]"),
+ ? "md:inset-auto md:right-0 md:top-0 md:bottom-0 md:w-(--side-panel-w) md:shadow-2xl"
+ : "md:static md:z-auto md:w-(--side-panel-w) md:shrink-0",
);
+
+const LEAVE_MS = 240;
+const LEAVE_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
+
+function reducedMotion(doc: Document): boolean {
+ return doc.documentElement.dataset.reducedMotion === "true" || doc.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;
+}
+
+/** The panel is gone the moment it closes: focus has gone back and its keys are off. Beside the chat, an inert copy
+ * of it is left in its place and slides back out over the window's edge, giving the chat its room back over the
+ * same 240ms it took. A floating panel, reduced motion, or another panel taking this one's place (a different bot's,
+ * or Computer) leaves no copy, or ends it. */
+export function leaveSidePanel(panel: HTMLElement): void {
+ const parent = panel.parentElement, doc = panel.ownerDocument;
+ if (!parent || typeof panel.animate !== "function" || reducedMotion(doc)) return;
+ const position = doc.defaultView?.getComputedStyle(panel).position;
+ if (position && position !== "static") return;
+ const width = panel.getBoundingClientRect().width;
+ if (width <= 0) return;
+ const before = new Set(parent.querySelectorAll(":scope > aside"));
+ const next = panel.nextSibling;
+ const copy = panel.cloneNode(true) as HTMLElement;
+ // HTML ids go (no duplicates for labels or tests to find); SVG ones stay, since the copy's marks fill through them.
+ for (const node of [copy, ...copy.querySelectorAll("[id]")]) if (!(node instanceof SVGElement)) node.removeAttribute("id");
+ // A copy starts scrolled to the top: note where each scrolled part of the panel was, while it still has a layout.
+ const from = [panel, ...panel.querySelectorAll<HTMLElement>("*")], to = [copy, ...copy.querySelectorAll<HTMLElement>("*")];
+ const scrolled = from.flatMap((node, index) => node.scrollTop ? [[to[index]!, node.scrollTop] as const] : []);
+ for (const node of copy.querySelectorAll("iframe, video, audio")) node.remove();
+ for (const name of ["role", "aria-labelledby", "aria-modal", "tabindex"]) copy.removeAttribute(name);
+ copy.setAttribute("aria-hidden", "true");
+ copy.inert = true;
+ copy.dataset.sidePanelLeaving = "";
+ Object.assign(copy.style, { animation: "none", pointerEvents: "none" });
+ // After the commit that removed it: by then a panel that replaces it has been placed.
+ queueMicrotask(() => {
+ if (panel.isConnected || !parent.isConnected) return;
+ if ([...parent.querySelectorAll(":scope > aside")].some((node) => !before.has(node))) return;
+ parent.insertBefore(copy, next?.parentNode === parent ? next : null);
+ for (const [node, top] of scrolled) node.scrollTop = top;
+ const motion = copy.animate(
+ [{ marginInlineEnd: "0px", opacity: 1 }, { marginInlineEnd: `${-width}px`, opacity: 0 }],
+ { duration: LEAVE_MS, easing: LEAVE_EASE, fill: "forwards" },
+ );
+ // A panel that arrives a little later (one that loads first, like Computer) takes the room at once.
+ let arrivals: MutationObserver | null = null;
+ const done = () => { arrivals?.disconnect(); copy.remove(); };
+ if (typeof MutationObserver === "function") {
+ arrivals = new MutationObserver((changes) => {
+ if (changes.some((change) => [...change.addedNodes].some((node) => node instanceof HTMLElement && node.tagName === "ASIDE"))) done();
+ });
+ arrivals.observe(parent, { childList: true });
+ }
+ motion.finished.then(done, done);
+ });
+}
+
+/** Leaves the panel's sliding copy behind when the panel unmounts (`leaveSidePanel`). */
+export function useSidePanelLeave(ref: RefObject<HTMLElement | null>): void {
+ useLayoutEffect(() => {
+ const panel = ref.current;
+ return () => { if (panel) leaveSidePanel(panel); };
+ }, [ref]);
+}
diff --git a/src/lib/sidebar-fold.test.ts b/src/lib/sidebar-fold.test.ts
index b1fddd1834..bb6ee7fd12 100644
--- a/src/lib/sidebar-fold.test.ts
+++ b/src/lib/sidebar-fold.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
-import { onlyNarrowSidePanels, sidebarFoldsForPanel, type OpenSidePanels } from "./sidebar-fold";
-import { SIDEBAR_AND_NARROW_PANEL_FIT, SIDEBAR_AND_PANEL_FIT } from "./use-media-query";
+import { anySidePanel, botPanelFloats, onlyNarrowSidePanels, panelsMovingSidebar, sidebarFoldsForPanel, type OpenSidePanels } from "./sidebar-fold";
+import { SIDEBAR_AND_BOT_PANEL_FIT, SIDEBAR_AND_NARROW_PANEL_FIT, SIDEBAR_AND_PANEL_FIT } from "./use-media-query";
const none: OpenSidePanels = { simple: true, remoteClient: false, bot: false, room: false, inbox: false, inboxWide: false, notifications: false, wide: false };
const minWidth = (query: string) => Number(/min-width: (\d+)px/.exec(query)![1]);
@@ -19,11 +19,10 @@ describe("when the sidebar folds beside a side panel", () => {
});
it.each([
- ["Simple's bot panel", { bot: true }],
["a room's panel", { room: true }],
["Simple's inbox", { inbox: true }],
["Notifications", { notifications: true }],
- ["the bot panel with Notifications", { bot: true, notifications: true }],
+ ["Simple's bot panel with Notifications", { bot: true, notifications: true }],
])("keeps the sidebar open beside %s from 1040 up, and folds it narrower", (_name, panels) => {
expect(folds(panels, 1039)).toBe(true);
expect(folds(panels, 1040)).toBe(false);
@@ -45,3 +44,26 @@ describe("when the sidebar folds beside a side panel", () => {
expect(folds(panels, 1280)).toBe(false);
});
});
+
+describe("Simple's bot panel and the sidebar", () => {
+ it("never folds or narrows the sidebar, at any width: the chat makes the room, and below 920 the panel floats", () => {
+ expect(minWidth(SIDEBAR_AND_BOT_PANEL_FIT)).toBe(280 + 320 + 320);
+ for (const width of [760, 900, 919, 920, 1039, 1040, 1100, 1279, 1280, 1600]) {
+ expect(folds({ bot: true }, width)).toBe(false);
+ expect(anySidePanel(panelsMovingSidebar({ ...none, bot: true }))).toBe(false);
+ expect(botPanelFloats({ ...none, bot: true }, width >= minWidth(SIDEBAR_AND_BOT_PANEL_FIT))).toBe(width < 920);
+ }
+ });
+
+ it("leaves the rule for every other panel as it was, beside the bot panel too", () => {
+ expect(folds({ bot: true, wide: true }, 1100)).toBe(true);
+ expect(folds({ bot: true, room: true }, 1039)).toBe(true);
+ expect(anySidePanel(panelsMovingSidebar({ ...none, bot: true, inbox: true }))).toBe(true);
+ });
+
+ it("keeps Advanced's and a remote client's wider bot panels on the old rule", () => {
+ expect(folds({ simple: false, bot: true }, 1100)).toBe(true);
+ expect(folds({ remoteClient: true, bot: true }, 1100)).toBe(true);
+ expect(botPanelFloats({ ...none, simple: false, bot: true }, false)).toBe(false);
+ });
+});
diff --git a/src/lib/sidebar-fold.ts b/src/lib/sidebar-fold.ts
index e35e6845d9..c4af5c5e7c 100644
--- a/src/lib/sidebar-fold.ts
+++ b/src/lib/sidebar-fold.ts
@@ -30,9 +30,27 @@ export function onlyNarrowSidePanels(panels: OpenSidePanels): boolean {
return true;
}
-/** Whether the sidebar folds to its column of avatars: only while a side panel is open and the window is too narrow
- * for the sidebar, a chat of at least 440 and that panel. */
-export function sidebarFoldsForPanel(panels: OpenSidePanels, fits: { wide: boolean; narrow: boolean }): boolean {
+/** Simple's own bot panel (not a remote client's): the one panel that never moves the sidebar. */
+function simpleBotPanel(panels: OpenSidePanels): boolean {
+ return panels.bot && panels.simple && !panels.remoteClient;
+}
+
+/** The open panels that make room for themselves out of the sidebar. Simple's bot panel is not one: opening or closing
+ * it leaves the sidebar's width, and its pinned bots, exactly as they were. */
+export function panelsMovingSidebar(panels: OpenSidePanels): OpenSidePanels {
+ return simpleBotPanel(panels) ? { ...panels, bot: false } : panels;
+}
+
+/** Whether Simple's bot panel floats over the chat's edge instead of standing beside it: in a window too narrow for
+ * the open sidebar, a chat of 320 and the panel (`fits`, SIDEBAR_AND_BOT_PANEL_FIT). */
+export function botPanelFloats(panels: OpenSidePanels, fits: boolean): boolean {
+ return simpleBotPanel(panels) && !fits;
+}
+
+/** Whether the sidebar folds to its column of avatars: only while a side panel that moves it is open and the window is
+ * too narrow for the sidebar, a chat of at least 440 and that panel. */
+export function sidebarFoldsForPanel(open: OpenSidePanels, fits: { wide: boolean; narrow: boolean }): boolean {
+ const panels = panelsMovingSidebar(open);
if (!anySidePanel(panels) || fits.wide) return false;
return !(fits.narrow && onlyNarrowSidePanels(panels));
}
diff --git a/src/lib/use-media-query.ts b/src/lib/use-media-query.ts
index b517d80bbf..719f600ee4 100644
--- a/src/lib/use-media-query.ts
+++ b/src/lib/use-media-query.ts
@@ -21,6 +21,10 @@ export const SIDEBAR_AND_PANEL_FIT = "(min-width: 1280px)";
/** The open sidebar (280), a chat of at least 440 and a side panel of 320 or less (sidebar-fold.ts). */
export const SIDEBAR_AND_NARROW_PANEL_FIT = "(min-width: 1040px)";
+/** The open sidebar (280), a chat of at least 320 and Simple's bot panel (320); narrower, that panel floats over the
+ * chat instead of folding the sidebar (sidebar-fold.ts). */
+export const SIDEBAR_AND_BOT_PANEL_FIT = "(min-width: 920px)";
+
/** Tailwind's md breakpoint. */
export const SIDEBAR_INLINE = "(min-width: 768px)";
diff --git a/src/styles.css b/src/styles.css
index ab840b5fc6..ad077e726f 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -118,6 +118,7 @@
@theme {
--animate-panel-in: panel-in 0.24s cubic-bezier(0.22, 1, 0.36, 1);
+ --animate-panel-beside-in: panel-beside-in 0.24s cubic-bezier(0.22, 1, 0.36, 1);
--animate-sheet-in: sheet-in 0.26s cubic-bezier(0.22, 1, 0.36, 1);
--animate-workspace-in: workspace-in 0.18s cubic-bezier(0.22, 1, 0.36, 1);
--animate-pop-in: pop-in 0.2s cubic-bezier(0.22, 1, 0.36, 1);
@@ -1668,6 +1669,53 @@ body {
}
:root[data-reduced-motion="true"] [data-sidebar-bot-row] { transition: none; }
+/* The chat header's model pill folds to its AI's mark while a side panel narrows the chat (ModelPickerTrigger).
+ The pill glides over the panel's own 240ms on the motion curve: its padding and the mark's gap close, and the rest
+ rides a grid column from 1fr to 0fr, so no width is measured and the first paint lands folded or open with no jump.
+ The words never wrap (nowrap) and are never cut hard: they fade, drift 4px toward the mark and soften as the column
+ closes, the name first and the bars and chevron a beat later; opening, they wait for the column to start widening.
+ A transition takes its timing from the state it goes to, so each state below carries the timing that reaches it. */
+[data-model-pill] {
+ transition-property: color, background-color, padding;
+ transition-duration: 120ms, 120ms, 240ms;
+ transition-timing-function: ease-out, ease-out, cubic-bezier(0.22, 1, 0.36, 1);
+}
+[data-model-pill][data-folded] { padding-inline: 0; }
+[data-model-pill] [data-model-pill-mark] { transition: margin 240ms cubic-bezier(0.22, 1, 0.36, 1); }
+[data-model-pill][data-folded] [data-model-pill-mark] { margin-inline-end: 0; }
+[data-model-pill] [data-model-pill-rest] {
+ grid-template-columns: 1fr;
+ transition: grid-template-columns 240ms cubic-bezier(0.22, 1, 0.36, 1);
+}
+[data-model-pill][data-folded] [data-model-pill-rest] { grid-template-columns: 0fr; }
+/* Folding, the column's closing edge fades instead of cutting the words off. */
+[data-model-pill][data-folded] [data-model-pill-rest] > * { mask-image: linear-gradient(to right, #000 calc(100% - 12px), transparent); }
+[dir="rtl"] [data-model-pill][data-folded] [data-model-pill-rest] > * { mask-image: linear-gradient(to left, #000 calc(100% - 12px), transparent); }
+[data-model-pill] [data-model-pill-words],
+[data-model-pill] [data-model-pill-tail] {
+ transition-property: opacity, translate, filter;
+ transition-duration: 180ms, 200ms, 180ms;
+ transition-timing-function: ease-out, cubic-bezier(0.22, 1, 0.36, 1), ease-out;
+ transition-delay: 70ms;
+}
+[data-model-pill] [data-model-pill-tail] { transition-delay: 110ms; }
+[data-model-pill][data-folded] [data-model-pill-words],
+[data-model-pill][data-folded] [data-model-pill-tail] {
+ opacity: 0;
+ translate: -4px 0;
+ filter: blur(2px);
+ transition-duration: 140ms, 200ms, 140ms;
+ transition-delay: 0ms;
+}
+[data-model-pill][data-folded] [data-model-pill-tail] { transition-delay: 40ms; }
+[dir="rtl"] [data-model-pill][data-folded] [data-model-pill-words],
+[dir="rtl"] [data-model-pill][data-folded] [data-model-pill-tail] { translate: 4px 0; }
+@media (prefers-reduced-motion: reduce) {
+ [data-model-pill], [data-model-pill] * { transition: none !important; }
+}
+:root[data-reduced-motion="true"] [data-model-pill],
+:root[data-reduced-motion="true"] [data-model-pill] * { transition: none !important; }
+
/* Liquid glass: the surface for centred pop-ups (Settings, Apps, Triggers).
Every value is derived from the active skin's own tokens, so each of the
ten skins gets a glass of its own colour and no skin block changes. The
@@ -2200,6 +2248,10 @@ body {
from { transform: translateX(28px); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
+/* A side panel's room grows from nothing as it slides in over the window's edge (bot-panel/side-panel.ts). */
+@keyframes panel-beside-in {
+ from { margin-inline-end: calc(-1 * var(--side-panel-w)); opacity: 0; }
+}
@keyframes sheet-in {
from { transform: translateY(32px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
@@ -2518,6 +2570,7 @@ html[data-cloud-intent-morph] [data-tour="composer"] { view-transition-name: clo
:root[data-reduced-motion="true"] .animate-spot-in,
:root[data-reduced-motion="true"] .animate-pop-in,
:root[data-reduced-motion="true"] .animate-pop-out,
+:root[data-reduced-motion="true"] .md\:animate-panel-beside-in,
:root[data-reduced-motion="true"] .step-open,
:root[data-reduced-motion="true"] .check-in,
:root[data-reduced-motion="true"] .progress-fill,