Skip to content

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

Sidebar: quieter Simple rows, sidebar stays open beside the bot panel, pinned pages as tiles (#6732)

Milind Soni2e836a99bea9
diff --git a/DESIGN.md b/DESIGN.md
index 9d3947de9b..07f6f5fc1f 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -121,7 +121,8 @@ are never tracked. Titles of 17px and up keep `tracking-[-0.01em]`.
| Body, rows, menu rows (`MENU_ROW`) | 13 / 18px | 415 | `ink` or `ink-secondary` |
| Names in lists (bots in the sidebar 14 / 20px) | 13 / 18px | 500 | `ink` |
| Sidebar group labels ("Bots", "Tools", a department) | 13 / 18px | 415 | `ink-secondary` |
-| Pinned bot captions | 12 / 16px | 415 | `ink` |
+| Sidebar places (the rows under "Tools") | 14 / 20px | 415 | `ink` |
+| Pinned bot and page captions | 12 / 16px | 415 | `ink` |
| Speaker names in transcripts (people and bots) | 13px | 600 | bot colour, else `ink-secondary` |
| Meta, hints, menu group labels | 12 / 16px | 415 (menu group labels 500) | `ink-tertiary` |
| Timestamps | 12 / 16px | 500 | `ink-tertiary` or `ink-secondary` |
@@ -163,7 +164,9 @@ element's job and never a pixel value:
- **No in-between values** (`rounded-[10px]`, `rounded-[14px]`). Pick the step
for the element's job.
- **A nested shape is smaller than its container.** A card (12) in a dialog
- (14) is right; a 12px card inside a 12px menu is not.
+ (14) is right; a 12px card inside a 12px menu is not. A pinned page's 60px
+ plate (12) is the exception: it stands where a bot's avatar stands in its
+ tile and shares no corner with it.
## 6. Space and layout
@@ -181,7 +184,12 @@ element's job and never a pixel value:
variant.
- **Sidebar rows:** Simple's rows have 8px padding and a 10px gap after the
36px avatar; every row hovers at `bg-ink/[0.06]`. The sidebar is 280px wide
- in both modes; pinned bots are 95 × 92px tiles with a 60px avatar.
+ in both modes; pinned bots and, in Simple, pinned pages are 95 × 92px tiles
+ with a 60px avatar or plate.
+- **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.
- **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
@@ -203,7 +211,8 @@ element's job and never a pixel value:
menus included. The only exceptions are a glyph on a filled control (the
send arrow) and deliberately heavy marks (a check, a filled badge).
- **Icons are bare.** Don't put them in tinted squares or circles. A bot's
- avatar is the only mark that gets a plate.
+ avatar is the only mark that gets a plate, and a pinned page's tile, which
+ stands beside bots' avatars, puts its 24px icon on a 60px `bg-card` plate.
- **Decorative icons get `aria-hidden="true"`.** An icon-only button needs an
`aria-label`, and a `title` when its meaning isn't obvious.
- **One icon, one meaning.** If an icon already means something in the app,
diff --git a/docs/verification/chat-ui.md b/docs/verification/chat-ui.md
index f1425f41e2..ca8702fe9c 100644
--- a/docs/verification/chat-ui.md
+++ b/docs/verification/chat-ui.md
@@ -134,8 +134,10 @@ unasserted user outcome.
`scripts/testing/usage-details-ui.e2e.test.ts` checks the header's **More** menu,
usage breakdown, clipboard success and refusal, and responsive geometry at
-390, 800, 1100 and 1600 px. It checks that opening bot settings folds the sidebar
-without changing its saved density and closing settings restores it. Evidence
+390, 800, 1100 and 1600 px. It checks that opening Advanced's bot settings at 1100
+folds the sidebar without changing its saved density and closing settings
+restores it, and that Simple's 320px bot panel keeps the 280px sidebar open
+beside a chat of at least 440 at 1040 px, folding it at 1039. Evidence
includes screenshots and a `.usage-details.json` next to the fixture log.
These are renderer checks, not native Windows caption-button verification.
diff --git a/scripts/testing/usage-details-ui.e2e.test.ts b/scripts/testing/usage-details-ui.e2e.test.ts
index a73d12c778..1fd6072b04 100644
--- a/scripts/testing/usage-details-ui.e2e.test.ts
+++ b/scripts/testing/usage-details-ui.e2e.test.ts
@@ -119,6 +119,32 @@ if (!enabled) console.log("skipping usage details UI: set OMB_UI_E2E=1 to instal
await expect.poll(() => evaluate("getComputedStyle(document.querySelector('[role=dialog]')).position")).toBe("static");
await ui("press", "--keys", "Escape");
expect(await evaluate("Boolean(document.querySelector('[aria-label=Inspector]'))")).toBe(true);
+ // Simple's 320 bot panel keeps the open sidebar beside it from 1040 wide (280 + a 440 chat + 320); narrower, or
+ // beside a wider panel (Advanced's above) under 1280, the sidebar folds to its avatars.
+ await openMore();
+ await activate('[role="menu"][aria-label="More"] button[data-menu-key="inspector"]');
+ await expect.poll(() => evaluate("Boolean(document.querySelector('[aria-label=Inspector]'))")).toBe(false);
+ await evaluate(`(() => { localStorage.setItem("omb-advanced-mode", "0"); window.dispatchEvent(new StorageEvent("storage", { key: "omb-advanced-mode", storageArea: localStorage })); return true; })()`);
+ await agentBrowser(browser.binary, sessionEnv(browser), ["set", "viewport", "1040", "900"]);
+ await expect.poll(() => evaluate("innerWidth")).toBe(1040);
+ await activate('[data-chathead-pill][aria-expanded="false"]');
+ const besidePanel = () => evaluate(`(() => {
+ const width = selector => document.querySelector(selector)?.getBoundingClientRect().width ?? 0;
+ return { sidebar: width('[data-sidebar]'), panel: width('[role=dialog][aria-labelledby=bot-settings-title]'), chat: width('main'),
+ scroll: document.documentElement.scrollWidth, moving: (document.querySelector('[role=dialog][aria-labelledby=bot-settings-title]')?.getAnimations() ?? []).length > 0 };
+ })()`);
+ // The panel slides in: measure once it has landed.
+ await expect.poll(async () => { const at = await besidePanel(); return Math.round(at.panel) === 320 && !at.moving; }, { timeout: 10_000 }).toBe(true);
+ const open1040 = await besidePanel();
+ expect(open1040.sidebar).toBe(280);
+ expect(open1040.chat).toBeGreaterThanOrEqual(440);
+ expect(open1040.scroll).toBeLessThanOrEqual(1040);
+ await ui("screenshot", "--out", `${handle.logPath}.bot-panel-1040.png`);
+ await agentBrowser(browser.binary, sessionEnv(browser), ["set", "viewport", "1039", "900"]);
+ await expect.poll(async () => (await besidePanel()).sidebar).toBe(92);
+ await agentBrowser(browser.binary, sessionEnv(browser), ["set", "viewport", "1040", "900"]);
+ await expect.poll(async () => (await besidePanel()).sidebar).toBe(280);
+ geometry.push({ botPanel1040: open1040 });
const consoleResult = await ui("console");
expect((consoleResult.messages ?? []).filter((row: { type?: string }) => row.type === "error")).toEqual([]);
const evidence = handle.logPath + ".usage-details.json";
diff --git a/src/App.tsx b/src/App.tsx
index e0f0f680ce..2ca901069c 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -22,7 +22,8 @@ import { Sidebar } from "@/components/Sidebar";
import { ChatView } from "@/components/ChatView";
import { GroupView } from "@/components/GroupView";
import { ForkPanel } from "@/components/ForkPanel";
-import { SIDEBAR_AND_PANEL_FIT, SIDEBAR_INLINE, TWO_SIDE_PANELS_FIT, useMediaQuery } from "@/lib/use-media-query";
+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 { preloadConnectedApps } from "@/lib/connected-apps";
import {
ActivityPanel, AnnouncementsPage, BotSettingsDialog, CloudAddDialog, ComputerPanel, FilesView, InspectorPanel, KeyboardShortcutsModal, LocalVmWorkspace,
@@ -98,7 +99,8 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
useInboxLoader(`${inboxVersion(state.bots) ?? ""}|${needsYou}`);
useEffect(() => { refreshPublishedApps(); }, []);
const inboxReady = useInboxReady();
- const inboxShown = useInboxPanel().open && inboxReady;
+ const inboxPanel = useInboxPanel();
+ const inboxShown = inboxPanel.open && inboxReady;
// A Switch AI pick lands once its stopped turn's chat is idle, wherever the person is by then.
useAiSwitchKeeper({ bots: state.bots, dispatch });
const showThreads = useShowThreads();
@@ -110,6 +112,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
const remoteClient = window.ogb?.remoteClient?.active === true;
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 sidebarInline = useMediaQuery(SIDEBAR_INLINE, false);
useEffect(() => {
if (!sidebarInline && state.forkPanel) dispatch({ type: "closeForkPanel" });
@@ -174,8 +177,15 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
const notificationFeed = useNotificationFeed() && !remoteClient;
const advanced = useAdvancedMode();
const roomPanelOpen = useRoomPanelShown({ group, state, simple: !advanced && !remoteClient });
- const sidePanelOpen = (Boolean(bot) && (state.settingsOpen || state.computerOpen || state.inspectorOpen || state.activityOpen)) || Boolean(state.forkPanel) || roomPanelOpen || (notificationFeed && state.notificationsOpen) || inboxShown;
- const collapseSidebar = sidePanelOpen && !sidebarAndPanelFit;
+ const sidePanels: OpenSidePanels = {
+ simple: !advanced, remoteClient, bot: Boolean(bot) && state.settingsOpen, room: roomPanelOpen, inbox: inboxShown, inboxWide: inboxPanel.wide === true,
+ notifications: notificationFeed && state.notificationsOpen,
+ wide: (Boolean(bot) && (state.computerOpen || state.inspectorOpen || state.activityOpen)) || Boolean(state.forkPanel),
+ };
+ // 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;
const calendarFocus = state.activeView === "routines" && state.routinesFocus.view === "calendar";
const notificationTray = notificationFeed && !calendarFocus;
@@ -382,6 +392,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
<div className={framed ? "relative flex min-h-0 flex-1" : "contents"}>
{!calendarFocus && <Sidebar
collapseToIcons={collapseSidebar}
+ besidePanel={sidebarBesidePanel}
open={drawerOpen}
onClose={closeDrawer}
/>}
diff --git a/src/components/BotModelBadge.tsx b/src/components/BotModelBadge.tsx
index 8460d395b5..095c0eeb57 100644
--- a/src/components/BotModelBadge.tsx
+++ b/src/components/BotModelBadge.tsx
@@ -40,7 +40,7 @@ export function BotModelBadge({ bot, instances, avatarSize }: {
);
}
-/** Simple mode's faded engine mark. It has no title of its own, so hovering it still shows the row's tooltip with the model and engine. */
+/** Simple mode's faded engine mark, which the row shows on hover, keyboard focus and touch screens. It has no title of its own, so hovering it still shows the row's tooltip with the model and engine. */
export function BotEngineMark({ bot, instances, className }: { bot: Pick<Bot, "modelSelection">; instances: InstanceInfo[]; className?: string }) {
const model = botModel(bot, instances);
if (!model) return null;
diff --git a/src/components/Sidebar.simple-layout.test.ts b/src/components/Sidebar.simple-layout.test.ts
index c1bca0da49..f2694e2718 100644
--- a/src/components/Sidebar.simple-layout.test.ts
+++ b/src/components/Sidebar.simple-layout.test.ts
@@ -291,6 +291,34 @@ describe("Simple-mode sidebar layout", () => {
}
expect(width()).toBe("360px");
});
+ it("keeps to 280px while open beside a side panel in a window under 1280, whatever width was saved", () => {
+ fixture.storage.set(SIMPLE_SIDEBAR_WIDTH_KEY, "400");
+ const beside = (besidePanel: boolean) => {
+ fixture.index = 0;
+ fixture.values = [];
+ const root = drawSidebar({ open: false, onClose: () => {}, besidePanel }) as ReactElement<Props>;
+ const handle = nodes(root.props.children).find((node) => node.type === SidebarResizeHandle)!.props as Parameters<typeof SidebarResizeHandle>[0];
+ return { max: root.props.style!["--sidebar-max"], value: handle.sizing.valueNow, className: String(root.props.className) };
+ };
+ expect(beside(false)).toMatchObject({ max: "calc(100vw - 320px)", value: 400 });
+ const open = beside(true);
+ expect(open).toMatchObject({ max: "280px", value: 280 });
+ expect(open.className).toContain("md:max-w-[var(--sidebar-max)]");
+ expect(open.className).not.toContain("w-[92px]");
+ });
+
+ it("puts the pinned pages in Simple's tiles after the bots, and shows the tiles for pages alone", () => {
+ fixture.storage.set("omb-web-panels", JSON.stringify([{ id: "board", name: "Fleet board", url: "http://127.0.0.1:7841/" }]));
+ fixture.state = { ...fixture.state, activeView: "web-panel", webPanelId: "board" };
+ const grid = () => render().tree.find((node) => node.type === SidebarTileGrid)?.props as Parameters<typeof SidebarTileGrid>[0] | undefined;
+ expect(grid()).toMatchObject({ primary: null, pinned: [], openPage: "board", dispatch: fixture.dispatch });
+ expect(grid()!.pages!.map((page) => page.name)).toEqual(["Fleet board"]);
+ fixture.values = [];
+ fixture.advanced = true;
+ expect(grid()).toBeUndefined();
+ fixture.storage.delete("omb-web-panels");
+ });
+
const edge = (tree: ReactElement<Props>[]) => tree.find((node) => node.type === SidebarResizeHandle)?.props as Parameters<typeof SidebarResizeHandle>[0] | undefined;
it("becomes a rail when its edge is dragged narrow, keeping the Simple order with a hairline between sections", () => {
diff --git a/src/components/Sidebar.simple-mode.test.ts b/src/components/Sidebar.simple-mode.test.ts
index c0c0a0eeba..de97d7804a 100644
--- a/src/components/Sidebar.simple-mode.test.ts
+++ b/src/components/Sidebar.simple-mode.test.ts
@@ -167,6 +167,21 @@ describe("bot-first sidebar", () => {
expect(markup).toMatch(/data-bot-actions="atlas"[^>]*class="[^"]*end-\[3px\] top-1\.5 size-6 translate-y-0\b/);
});
+ it("shows a Simple row's engine mark only while the row is hovered, focused or on a touch screen, and Advanced's always", () => {
+ fixture.showThreads = false;
+ fixture.state = { ...fixture.state, instances: [{ instanceId: "fake", driverKind: "claudeAgent", displayName: "Claude" }] as unknown as AppState["instances"] };
+ const candidate = { ...bot, tasks: [], projects: [], messages: [{ id: "m", role: "bot", kind: "text", text: "Done.", at: 1 }] } as Bot;
+ const badgeClass = (markup: string) => /<span data-testid="model-badge"[^>]*class="([^"]*)"/.exec(markup)?.[1]?.split(" ") ?? [];
+ const simple = badgeClass(renderToStaticMarkup(createElement(BotListItem, rowProps("comfortable", candidate))));
+ expect(simple).toEqual(expect.arrayContaining(["opacity-0", "group-hover:opacity-100", "group-focus-within:opacity-100", "touch:opacity-100", "motion-reduce:transition-none"]));
+ // The row it reveals on is the hover group, so focus anywhere in the row (its ⋯ too) shows the mark.
+ expect(renderToStaticMarkup(createElement(BotListItem, rowProps("comfortable", candidate)))).toMatch(/^<div class="group relative/);
+ fixture.advanced = true;
+ const advanced = renderToStaticMarkup(createElement(BotListItem, rowProps("comfortable", candidate)));
+ expect(advanced).toContain('data-testid="model-badge"');
+ expect(badgeClass(advanced)).not.toContain("opacity-0");
+ });
+
it("fades the collapsed rail's engine badge in both modes", () => {
fixture.showThreads = false;
fixture.state = { ...fixture.state, instances: [{ instanceId: "fake", driverKind: "claudeAgent", displayName: "Claude" }] as unknown as AppState["instances"] };
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 936d0cb103..964247919f 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -2,7 +2,7 @@ import { OrganizationIdentity } from "./OrganizationIdentity";
import { memo, useCallback, useEffect, useMemo, useRef, useState, type CSSProperties, type Dispatch } from "react";
import { createPortal } from "react-dom";
import { Archive, Bot as BotIcon, Check, ChevronRight, ClipboardCopy, Crown, FolderInput, FolderPlus, LayoutTemplate, Loader2, MessageSquarePlus, MoreHorizontal, Pencil, Phone, Pin, Plus, Search, SquarePen, TextQuote, Trash2, Users, X } from "lucide-react";
-import { sidebarState } from "./sidebar-state"; import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select"; import { useStoreRef } from "@/state/store-ref"; import { sameDrawnBots } from "@/lib/drawn-bots";
+import { sidebarState } from "./sidebar-state"; import { useWebPanels } from "@/lib/web-panel-preferences"; import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select"; import { useStoreRef } from "@/state/store-ref"; import { sameDrawnBots } from "@/lib/drawn-bots";
import { api, formatTime, visibleMessages, currentTaskBot, botOpensTo, openBot, openThread, type Action, type AppState, type Bot, type BotProject, type Group, type InstanceInfo, type Message } from "@/state/store";
import { approvalModeFor } from "../../shared/approval-mode";
import { liveActivityLabel, sidebarMessage } from "@/lib/live-activity";
@@ -833,7 +833,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
)}
</span>
)}
- {simpleRow && <BotEngineMark bot={bot} instances={instances} className="ms-auto" />}
+ {simpleRow && <BotEngineMark bot={bot} instances={instances} className="ms-auto opacity-0 transition-opacity duration-150 motion-reduce:transition-none group-hover:opacity-100 group-focus-within:opacity-100 touch:opacity-100" />}
{!simpleRow && unread && <span className="size-2 shrink-0 rounded-full bg-accent" aria-label={t("task.unreadMany")} />}
</div>}
{simpleRow && <RowStatusText working={working} failed={failed} unread={unread} />}
@@ -918,10 +918,10 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
);
});
-export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons = false }: {
+export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons = false, besidePanel = false }: {
open: boolean;
onClose: () => void;
- collapseToIcons?: boolean;
+ collapseToIcons?: boolean; besidePanel?: boolean;
}) {
const state = useStoreSelector(sidebarState, sameFields), dispatch = useStoreDispatch();
const now = useRelativeNow();
@@ -986,14 +986,14 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
const simple = !advanced && density !== "icons";
const simpleDesk = simple && !phone;
const rail = !advanced && density === "icons";
- const sidePanelOpen = state.computerOpen || state.inspectorOpen;
+ const sidePanelOpen = state.computerOpen || state.inspectorOpen || besidePanel;
const sizing = useSidebarWidth({ simple: !advanced, sidePanelOpen, sidebarRef });
const [searchOpen, setSearchOpen] = useState(false);
const searchShown = searchOpen || query !== "";
const searchToggleRef = useRef<HTMLButtonElement>(null);
const closeSearch = () => { setSearchOpen(false); setQuery(""); searchToggleRef.current?.focus(); };
const pinnedCircles = usePinnedCircles();
- const universalPins = useUniversalPins();
+ const universalPins = useUniversalPins(), pinnedPages = useWebPanels();
const [pinnedCircleThreadsCollapsed, setPinnedCircleThreadsCollapsed] = useState(true);
useEffect(() => {
@@ -1125,7 +1125,7 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
const layout = sections.arrange(naturalSectionIds);
const sectionIds = layout.sectionIds;
const showPinnedCircleThreads = !simpleDesk && pinnedCircleThreadListVisible(pinnedCircles, density, pinnedBots.length);
- const tiles = simpleDesk && (primary !== null || pinnedBots.length > 0);
+ const tiles = simpleDesk && (primary !== null || pinnedBots.length > 0 || pinnedPages.length > 0);
const { interactive: layoutInteractive, collapsed: sectionCollapsed, toggle: toggleSection } = sections;
const archivedBots = state.bots.filter((bot) => bot.hidden && !bot.movedTo);
const archivedEntry = remoteClient ? undefined : { count: archivedBots.length, open: () => setArchivedBotsOpen(true) };
@@ -1359,8 +1359,8 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
onToggle={layoutInteractive ? () => toggleSection(PINNED_THREADS_SECTION_ID) : undefined}
/>
)}
- {tiles && <SidebarTileGrid primary={primary} pinned={pinnedBots} row={botRow} corner={corner} />}
- {simpleDesk && !tiles && <SidebarNoBots />}
+ {tiles && <SidebarTileGrid primary={primary} pinned={pinnedBots} row={botRow} corner={corner} pages={pinnedPages} openPage={state.activeView === "web-panel" ? state.webPanelId : undefined} dispatch={dispatch} />}
+ {simpleDesk && primary === null && pinnedBots.length === 0 && <SidebarNoBots />}
</GlassBar>
{!collapseToIcons && !phone && <SidebarResizeHandle sizing={sizing} sidebarRef={sidebarRef} avatars={density === "icons"} avatarsWidth={rail ? 92 : 80}
diff --git a/src/components/SidebarFooterNav.test.ts b/src/components/SidebarFooterNav.test.ts
index 4d3b47dcb7..92f00b71f2 100644
--- a/src/components/SidebarFooterNav.test.ts
+++ b/src/components/SidebarFooterNav.test.ts
@@ -102,6 +102,20 @@ describe("sidebar footer places", () => {
expect(fixture.dispatch).toHaveBeenLastCalledWith({ type: "showWebPanel", id: "panel-1" });
});
+ it("draws a labelled place like a bot row: a 16px icon, a 10px gap, a regular 14/20 label, radius 12 and the ink hover", () => {
+ fixture.advanced = true;
+ fixture.panels = [{ id: "panel-1", name: "Fleet board", url: "http://127.0.0.1:7841/" }];
+ const html = render("comfortable").html;
+ const row = /<button type="button" data-sidebar-nav="web-panel-panel-1"[^>]*class="([^"]*)"[^>]*>([\s\S]*?)<\/button>/.exec(html)!;
+ const classes = row[1]!.split(" ");
+ expect(classes).toEqual(expect.arrayContaining(["rounded-xl", "gap-2.5", "hover:bg-ink/[0.06]"]));
+ expect(classes).not.toContain("gap-3");
+ expect(classes).not.toContain("hover:bg-raised/50");
+ expect(row[2]).toMatch(/<svg[^>]*width="16" height="16"[^>]*class="lucide lucide-globe/);
+ expect(row[2]).toContain('<span class="flex-1 truncate text-[14px] leading-5">Fleet board</span>');
+ expect(html).not.toContain("font-medium");
+ });
+
it("shows a pinned panel as an icon with its name as the label in the toolbar layout", () => {
fixture.advanced = true;
fixture.panels = [{ id: "panel-1", name: "Fleet board", url: "http://127.0.0.1:7841/" }];
diff --git a/src/components/SidebarFooterNav.tsx b/src/components/SidebarFooterNav.tsx
index 66e94d6bd5..7c3046b470 100644
--- a/src/components/SidebarFooterNav.tsx
+++ b/src/components/SidebarFooterNav.tsx
@@ -47,12 +47,13 @@ function NavRow({
aria-current={active ? "page" : undefined}
className={cn(
"relative flex items-center rounded-xl transition-colors",
- rail ? "size-9 shrink-0 justify-center" : iconsOnly ? "mx-auto size-[46px] shrink-0 justify-center" : "w-full min-h-9 gap-3 px-3 py-1.5 text-left",
- active ? "bg-raised text-ink" : "text-ink hover:bg-raised/50",
+ // A labelled row follows the bot rows: a 16px icon, a 10px gap, a regular 14/20 label and the ink hover.
+ rail ? "size-9 shrink-0 justify-center" : iconsOnly ? "mx-auto size-[46px] shrink-0 justify-center" : "w-full min-h-9 gap-2.5 px-3 py-1.5 text-left",
+ active ? "bg-raised text-ink" : "text-ink hover:bg-ink/[0.06]",
)}
>
{icon(active)}
- {!iconsOnly && <span className="flex-1 truncate text-[14px] font-medium leading-5">{label}</span>}
+ {!iconsOnly && <span className="flex-1 truncate text-[14px] leading-5">{label}</span>}
{attention && (
<span
data-testid="routines-attention"
@@ -122,7 +123,8 @@ export function SidebarFooterNav({
const iconsOnly = density === "icons";
const toolsLayout = useSidebarToolsLayout();
const toolbar = advanced && !iconsOnly && toolsLayout === "toolbar";
- const iconSize = iconsOnly && !rail ? 20 : 18;
+ // 16 in rows, toolbars and 36px buttons; the avatars-only column's 46px buttons keep 20.
+ const iconSize = iconsOnly && !rail ? 20 : 16;
const tone = (active: boolean) => (active ? "text-accent" : "text-ink-secondary");
const automationsNeedYou = useAutomationsNeedYou();
const automationsRow = <NavRow
diff --git a/src/components/SidebarTiles.page.dom.test.ts b/src/components/SidebarTiles.page.dom.test.ts
new file mode 100644
index 0000000000..a03efb9726
--- /dev/null
+++ b/src/components/SidebarTiles.page.dom.test.ts
@@ -0,0 +1,41 @@
+// @vitest-environment happy-dom
+import { act, createElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import type { Action } from "@/state/store";
+import { SidebarPageTile } from "./SidebarTiles";
+
+(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+let host: HTMLElement;
+let root: Root;
+const dispatch = vi.fn<(action: Action) => void>();
+
+beforeEach(() => {
+ host = document.createElement("div");
+ document.body.append(host);
+ root = createRoot(host);
+});
+afterEach(() => {
+ act(() => root.unmount());
+ host.remove();
+ dispatch.mockReset();
+});
+
+describe("a pinned page's tile without a favicon", () => {
+ it("falls back to the web icon when its site has no favicon, and opens its page from the keyboard", async () => {
+ await act(async () => {
+ root.render(createElement(SidebarPageTile, { panel: { id: "board", name: "Fleet board", url: "http://127.0.0.1:7841/" }, open: false, dispatch }));
+ });
+ const image = host.querySelector("img")!;
+ expect(image.getAttribute("src")).toBe("http://127.0.0.1:7841/favicon.ico");
+ await act(async () => { image.dispatchEvent(new Event("error")); });
+ expect(host.querySelector("img")).toBeNull();
+ expect(host.querySelector("svg.lucide-globe")?.getAttribute("width")).toBe("24");
+ const tile = host.querySelector<HTMLButtonElement>("[data-sidebar-page=board]")!;
+ expect(tile.tagName).toBe("BUTTON");
+ await act(async () => { tile.click(); });
+ expect(dispatch).toHaveBeenCalledWith({ type: "showWebPanel", id: "board" });
+ });
+});
diff --git a/src/components/SidebarTiles.test.ts b/src/components/SidebarTiles.test.ts
index 05d98b9de1..84fdd04ec8 100644
--- a/src/components/SidebarTiles.test.ts
+++ b/src/components/SidebarTiles.test.ts
@@ -12,7 +12,8 @@ vi.mock("@/lib/interface-mode", async (original) => ({
vi.mock("./DesktopCapabilities", () => ({ useDesktopCapabilities: () => ({}) }));
import { BotListItem, botRowProps } from "./Sidebar";
-import { SidebarBotTile, SidebarTileGrid } from "./SidebarTiles";
+import { pageFaviconUrl, SidebarBotTile, SidebarPageTile, SidebarTileGrid } from "./SidebarTiles";
+import type { WebPanel } from "@/lib/web-panels";
const bot = (extra: Partial<Bot> = {}): Bot => ({
id: "mausbot", threadId: "t", name: "MausBot", title: "", description: "", notifications: true, color: "chrome",
@@ -153,3 +154,47 @@ describe("the tile grid", () => {
expect(across(width - gutters - 8)).toBe(columns);
});
});
+
+describe("a pinned page's tile", () => {
+ const site: WebPanel = { id: "board", name: "Fleet board", url: "http://127.0.0.1:7841/dash?tab=1" };
+ const chatPage: WebPanel = { id: "report", name: "Weekly report", page: { botId: "mausbot", threadId: "t", messageId: "m" } };
+ const draw = (panel: WebPanel, open = false) => renderToStaticMarkup(createElement(SidebarPageTile, { panel, open, dispatch }));
+
+ it("is a bot tile's size, with its mark on a 60px card plate where the avatar is, over the same 12px caption", () => {
+ const html = draw(site);
+ expect(html).toMatch(/<button type="button" data-sidebar-tile="page" data-sidebar-page="board" title="Fleet board" class="[^"]*\bh-\[92px\] w-\[95px\][^"]*\brounded-xl\b/);
+ expect(html).toMatch(/<span aria-hidden="true" class="flex size-\[60px\] shrink-0 items-center justify-center rounded-xl bg-card text-ink-secondary">/);
+ expect(html).toMatch(/class="mt-1\.5 w-full min-w-0 truncate text-center text-\[12px\] leading-4 text-ink">Fleet board</);
+ expect(html).not.toContain("aria-current");
+ });
+
+ it("shows a site's own favicon at 24px, asked of that site with no referrer, and a bot's page the page icon", () => {
+ expect(pageFaviconUrl(site)).toBe("http://127.0.0.1:7841/favicon.ico");
+ expect(draw(site)).toMatch(/<img src="http:\/\/127\.0\.0\.1:7841\/favicon\.ico" alt="" width="24" height="24" referrerPolicy="no-referrer" class="size-6"\/>/);
+ expect(pageFaviconUrl(chatPage)).toBeNull();
+ const page = draw(chatPage);
+ expect(page).not.toContain("<img");
+ expect(page).toMatch(/<svg[^>]*width="24" height="24"[^>]*class="lucide lucide-app-window/);
+ });
+
+ it("opens its page on a click and is marked current while that page is on screen", () => {
+ expect(draw(site, true)).toContain('aria-current="page"');
+ expect(draw(site, true)).toContain("[--tile:var(--color-raised)]");
+ let tree: ReactNode;
+ function Capture() { tree = SidebarPageTile({ panel: site, open: false, dispatch }); return tree; }
+ renderToStaticMarkup(createElement(Capture));
+ (find(tree, "data-sidebar-page")!.props.onClick as () => void)();
+ expect(dispatch).toHaveBeenCalledWith({ type: "showWebPanel", id: "board" });
+ });
+
+ it("follows the bots in the grid, and fills a grid of pages alone", () => {
+ const main = bot({ chiefOfStaff: true });
+ const row = (candidate: Bot) => botRowProps({ ...initialState, bots: [main], selectedId: "", activeView: "chat" }, dispatch, candidate, { density: "comfortable", query: "", onMenu });
+ const order = (html: string) => [...html.matchAll(/data-sidebar-tile="([^"]+)"/g)].map(([, kind]) => kind);
+ const html = renderToStaticMarkup(createElement(SidebarTileGrid, { primary: main, pinned: [], row, pages: [site, chatPage], openPage: "report", dispatch }));
+ expect(order(html)).toEqual(["primary", "page", "page"]);
+ expect(html.indexOf('data-sidebar-page="board"')).toBeLessThan(html.indexOf('data-sidebar-page="report"'));
+ expect(html).toMatch(/data-sidebar-page="report"[^>]*aria-current="page"/);
+ expect(order(renderToStaticMarkup(createElement(SidebarTileGrid, { primary: null, pinned: [], row, pages: [site], dispatch })))).toEqual(["page"]);
+ });
+});
diff --git a/src/components/SidebarTiles.tsx b/src/components/SidebarTiles.tsx
index 7ed07359bd..6be88e7e3f 100644
--- a/src/components/SidebarTiles.tsx
+++ b/src/components/SidebarTiles.tsx
@@ -1,12 +1,13 @@
-import { Crown, Loader2, Phone } from "lucide-react";
-import { memo, useLayoutEffect, useRef, useState, type KeyboardEvent, type MouseEvent } from "react";
+import { AppWindow, Crown, Globe, Loader2, Phone } from "lucide-react";
+import { memo, useLayoutEffect, useRef, useState, type Dispatch, type KeyboardEvent, type MouseEvent } from "react";
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
import { useLiveMedia } from "@/lib/live-call-media";
import { stateForBot } from "@/lib/mascot";
import { useShowThreads } from "@/lib/thread-preferences";
-import { api, openBotRow, useStore, type Bot } from "@/state/store";
+import { api, openBotRow, useStore, type Action, type Bot } from "@/state/store";
+import type { WebPanel } from "@/lib/web-panels";
import { useChiefStepOpen } from "@/lib/default-bot";
import { BotAvatar } from "./Avatar";
@@ -21,6 +22,12 @@ import { useBotUnread } from "./unread-notice";
const RING = "ring-2 ring-[var(--tile)]";
+/** A tile's box and its fill, which the dots' rings take as well: a bot's and a pinned page's are the same. */
+const TILE = "flex h-[92px] w-[95px] shrink-0 cursor-pointer flex-col items-center rounded-xl bg-[var(--tile)] px-2 pb-1 pt-1.5 transition-colors duration-150";
+const tileFill = (selected: boolean) => selected ? "[--tile:var(--color-raised)]" : "[--tile:var(--color-panel)] hover:[--tile:color-mix(in_srgb,var(--color-ink)_6%,var(--color-panel))]";
+/** A tile's one-line caption, under its 60px mark. */
+const CAPTION = "min-w-0 truncate text-center text-[12px] leading-4 text-ink";
+
type TileProps = BotRowProps & PinnedCircleDragProps & { primary?: boolean };
export const SidebarBotTile = memo(function SidebarBotTile({ primary = false, drag, dragging, drop, prevId, nextId, ...row }: TileProps) {
@@ -75,8 +82,7 @@ export const SidebarBotTile = memo(function SidebarBotTile({ primary = false, dr
onKeyDown={onKeyDown}
onContextMenu={(event) => openBotContextMenu(onMenu, bot.id, event)}
className={cn(
- "flex h-[92px] w-[95px] shrink-0 cursor-pointer flex-col items-center rounded-xl bg-[var(--tile)] px-2 pb-1 pt-1.5 transition-colors duration-150", SIMPLE_ROW_FOCUS,
- selected ? "[--tile:var(--color-raised)]" : "[--tile:var(--color-panel)] hover:[--tile:color-mix(in_srgb,var(--color-ink)_6%,var(--color-panel))]",
+ TILE, SIMPLE_ROW_FOCUS, tileFill(selected),
pinnedCircleDragClass({ drag, dragging, drop }),
)}
>
@@ -119,7 +125,7 @@ export const SidebarBotTile = memo(function SidebarBotTile({ primary = false, dr
title={tooltip}
onCommit={rename}
onEditingChange={setRenaming}
- className="min-w-0 truncate text-center text-[12px] leading-4 text-ink"
+ className={CAPTION}
inputClassName="w-full rounded bg-inset px-1 text-center text-[12px] leading-4"
/>
</span>
@@ -127,6 +133,34 @@ export const SidebarBotTile = memo(function SidebarBotTile({ primary = false, dr
);
});
+/** Where a pinned web page's own icon is: its site's /favicon.ico, asked of that site alone and never of a favicon
+ * service, since a pinned address can be private. A bot's page in a chat has none. */
+export function pageFaviconUrl(panel: WebPanel): string | null {
+ if (!panel.url) return null;
+ try {
+ return new URL("/favicon.ico", panel.url).href;
+ } catch {
+ return null;
+ }
+}
+
+/** A pinned page in the tiles, after the bots: its site's icon, or the page or web icon, on a 60px plate where a bot
+ * has its avatar, over its name. It opens the page, as its frame-bar chip and Advanced's Tools row do. */
+export function SidebarPageTile({ panel, open, dispatch }: { panel: WebPanel; open: boolean; dispatch: Dispatch<Action> }) {
+ const [noFavicon, setNoFavicon] = useState(false);
+ const favicon = noFavicon ? null : pageFaviconUrl(panel);
+ return (
+ <button type="button" data-sidebar-tile="page" data-sidebar-page={panel.id} title={panel.name} aria-current={open ? "page" : undefined}
+ onClick={() => dispatch({ type: "showWebPanel", id: panel.id })} className={cn(TILE, SIMPLE_ROW_FOCUS, tileFill(open))}>
+ <span aria-hidden="true" className="flex size-[60px] shrink-0 items-center justify-center rounded-xl bg-card text-ink-secondary">
+ {favicon ? <img src={favicon} alt="" width={24} height={24} referrerPolicy="no-referrer" className="size-6" onError={() => setNoFavicon(true)} />
+ : panel.page ? <AppWindow size={24} /> : <Globe size={24} />}
+ </span>
+ <span className={cn("mt-1.5 w-full", CAPTION)}>{panel.name}</span>
+ </button>
+ );
+}
+
/** The sidebar while the first run's Chief step is open over an app with no bots of the person's own yet. */
export function SidebarNoBots() {
const { state } = useStore();
@@ -166,15 +200,21 @@ function useBesideCorner(corner: boolean, count: number) {
return { ref, beside };
}
-export function SidebarTileGrid({ primary, pinned, row, corner = false }: { primary: Bot | null; pinned: Bot[]; row: (bot: Bot) => BotRowProps; corner?: boolean }) {
+export function SidebarTileGrid({ primary, pinned, row, corner = false, pages = [], openPage, dispatch }: {
+ primary: Bot | null; pinned: Bot[]; row: (bot: Bot) => BotRowProps; corner?: boolean;
+ /** Pinned pages, after the bots; `openPage` is the one on screen. */
+ pages?: readonly WebPanel[]; openPage?: string; dispatch?: Dispatch<Action>;
+}) {
const order = usePinnedCircleDrag(pinned);
- const besideCorner = useBesideCorner(corner, (primary ? 1 : 0) + order.ranked.length);
- if (!primary && order.ranked.length === 0) return null;
+ const shownPages = dispatch ? pages : [];
+ const besideCorner = useBesideCorner(corner, (primary ? 1 : 0) + order.ranked.length + shownPages.length);
+ if (!primary && order.ranked.length === 0 && shownPages.length === 0) return null;
return (
<div ref={besideCorner.ref} data-sidebar-tiles="" data-beside-corner={besideCorner.beside ? "" : undefined}
className="flex max-h-[40vh] flex-wrap justify-center gap-x-1 gap-y-3 overflow-y-auto px-3 pb-4 pt-2.5" {...order.frameProps}>
{primary && <SidebarBotTile {...row(primary)} primary />}
{order.ranked.map((bot) => <SidebarBotTile key={bot.id} {...row(bot)} {...order.dragProps(bot)} />)}
+ {dispatch && shownPages.map((panel) => <SidebarPageTile key={panel.id} panel={panel} open={panel.id === openPage} dispatch={dispatch} />)}
<span role="status" className="sr-only">{order.moved}</span>
</div>
);
diff --git a/src/components/sidebar-state.ts b/src/components/sidebar-state.ts
index bbed71e37d..01cad40275 100644
--- a/src/components/sidebar-state.ts
+++ b/src/components/sidebar-state.ts
@@ -3,6 +3,6 @@ import type { AppState } from "@/state/store";
/** What the sidebar list draws: a change anywhere else in the store leaves it alone. */
export const sidebarState = (s: AppState) => ({
bots: s.bots, groups: s.groups, sections: s.sections, pendingQueued: s.pendingQueued, instances: s.instances, config: s.config, selectedId: s.selectedId,
- activeView: s.activeView, computerOpen: s.computerOpen, inspectorOpen: s.inspectorOpen, deletingBots: s.deletingBots, revealThread: s.revealThread,
+ activeView: s.activeView, webPanelId: s.webPanelId, computerOpen: s.computerOpen, inspectorOpen: s.inspectorOpen, deletingBots: s.deletingBots, revealThread: s.revealThread,
liveCall: s.liveCall, cloudHowTo: s.cloudHowTo, routineRuns: s.routineRuns, mascotMotion: s.activeView === "chat" && s.mascotMotion?.botId === s.selectedId ? s.mascotMotion : null,
});
diff --git a/src/lib/sidebar-fold.test.ts b/src/lib/sidebar-fold.test.ts
new file mode 100644
index 0000000000..b1fddd1834
--- /dev/null
+++ b/src/lib/sidebar-fold.test.ts
@@ -0,0 +1,47 @@
+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";
+
+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]);
+/** What the media queries say at a window `width` wide. */
+const fitsAt = (width: number) => ({ wide: width >= minWidth(SIDEBAR_AND_PANEL_FIT), narrow: width >= minWidth(SIDEBAR_AND_NARROW_PANEL_FIT) });
+const folds = (panels: Partial<OpenSidePanels>, width: number) => sidebarFoldsForPanel({ ...none, ...panels }, fitsAt(width));
+
+describe("when the sidebar folds beside a side panel", () => {
+ it("sets the narrow fit at the open sidebar, a 440 chat and a 320 panel", () => {
+ expect(minWidth(SIDEBAR_AND_NARROW_PANEL_FIT)).toBe(280 + 440 + 320);
+ });
+
+ it("never folds with no side panel open, at any width", () => {
+ for (const width of [800, 1039, 1040, 1279, 1280]) expect(folds({}, width)).toBe(false);
+ });
+
+ 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 }],
+ ])("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);
+ expect(folds(panels, 1100)).toBe(false);
+ expect(folds(panels, 1280)).toBe(false);
+ });
+
+ it.each([
+ ["Advanced's bot panel", { simple: false, bot: true }],
+ ["a remote client's bot panel", { remoteClient: true, bot: true }],
+ ["Advanced's inbox", { simple: false, inbox: true }],
+ ["a widened inbox", { inbox: true, inboxWide: true }],
+ ["Computer, Inspector, Activity or Fork", { wide: true }],
+ ["the bot panel with a wide one", { bot: true, wide: true }],
+ ])("keeps folding beside %s until 1280, since it is wider than 320", (_name, panels) => {
+ expect(onlyNarrowSidePanels({ ...none, ...panels })).toBe(false);
+ expect(folds(panels, 1040)).toBe(true);
+ expect(folds(panels, 1279)).toBe(true);
+ expect(folds(panels, 1280)).toBe(false);
+ });
+});
diff --git a/src/lib/sidebar-fold.ts b/src/lib/sidebar-fold.ts
new file mode 100644
index 0000000000..e35e6845d9
--- /dev/null
+++ b/src/lib/sidebar-fold.ts
@@ -0,0 +1,38 @@
+/** The side panels open beside the chat, and which of them are 320px wide or less. */
+export interface OpenSidePanels {
+ /** Simple mode: the bot panel and the inbox are 320 wide; Advanced draws them wider. */
+ simple: boolean;
+ /** A remote client's bot panel is 400 wide. */
+ remoteClient: boolean;
+ /** The bot panel (Simple 320, Advanced up to 420). */
+ bot: boolean;
+ /** A room's panel, 320 in both modes. */
+ room: boolean;
+ /** The inbox: 320 in Simple, 380 in Advanced, wider still when widened. */
+ inbox: boolean;
+ inboxWide: boolean;
+ /** Notifications, 300. */
+ notifications: boolean;
+ /** Computer (360 and up), Inspector (up to 460), Activity (400), Fork (360). */
+ wide: boolean;
+}
+
+export function anySidePanel(panels: OpenSidePanels): boolean {
+ return panels.bot || panels.room || panels.inbox || panels.notifications || panels.wide;
+}
+
+/** Whether every open side panel is 320px wide or less, so the open sidebar (280) and a chat of at least 440 fit beside
+ * it from SIDEBAR_AND_NARROW_PANEL_FIT up. */
+export function onlyNarrowSidePanels(panels: OpenSidePanels): boolean {
+ if (panels.wide) return false;
+ if (panels.bot && (!panels.simple || panels.remoteClient)) return false;
+ if (panels.inbox && (!panels.simple || panels.inboxWide)) return false;
+ 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 {
+ 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 812c4a24b8..b517d80bbf 100644
--- a/src/lib/use-media-query.ts
+++ b/src/lib/use-media-query.ts
@@ -15,8 +15,12 @@ export function useMediaQuery(query: string, fallback = false): boolean {
export const TWO_SIDE_PANELS_FIT = "(min-width: 1536px)";
+/** The open sidebar, a chat of at least 440 and any side panel (the widest are up to 460). */
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)";
+
/** Tailwind's md breakpoint. */
export const SIDEBAR_INLINE = "(min-width: 768px)";