Skip to content

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

Sidebar: pinned pages leave Simple's tiles; a bot's pages stay in its Library tab (#6760)

Milind Sonia90bf36551c2
diff --git a/DESIGN.md b/DESIGN.md
index 409245ccf8..0c3afee821 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -122,7 +122,7 @@ are never tracked. Titles of 17px and up keep `tracking-[-0.01em]`.
| 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` |
| Sidebar places (the rows under "Tools") | 14 / 20px | 415 | `ink` |
-| Pinned bot and page captions | 12 / 16px | 415 | `ink` |
+| Pinned bot 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` |
@@ -164,9 +164,7 @@ 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. 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.
+ (14) is right; a 12px card inside a 12px menu is not.
## 6. Space and layout
@@ -184,8 +182,8 @@ 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 and, in Simple, pinned pages are 95 × 92px tiles
- with a 60px avatar or plate.
+ 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
@@ -211,8 +209,7 @@ 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, and a pinned page's tile, which
- stands beside bots' avatars, puts its 24px icon on a 60px `bg-card` plate.
+ avatar is the only mark that gets a 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/src/components/Sidebar.simple-layout.test.ts b/src/components/Sidebar.simple-layout.test.ts
index f2694e2718..c8bb12e42c 100644
--- a/src/components/Sidebar.simple-layout.test.ts
+++ b/src/components/Sidebar.simple-layout.test.ts
@@ -307,15 +307,18 @@ describe("Simple-mode sidebar layout", () => {
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/" }]));
+ it("keeps Simple's tiles to bots, even with pages pinned: a bot's pages are in its bot panel's Library tab", () => {
+ fixture.storage.set("omb-web-panels", JSON.stringify([
+ { id: "board", name: "Fleet board", url: "http://127.0.0.1:7841/" },
+ { id: "report", name: "Weekly report", page: { botId: "atlas", threadId: "atlas-thread", messageId: "m" } },
+ ]));
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"]);
+ expect(render().tree.some((node) => node.type === SidebarTileGrid)).toBe(false);
fixture.values = [];
- fixture.advanced = true;
- expect(grid()).toBeUndefined();
+ fixture.state = { ...fixture.state, bots: [bot("chief", { chiefOfStaff: true, pinned: true }), bot("atlas", { pinned: true }), bot("bea")] };
+ const grid = render().tree.find((node) => node.type === SidebarTileGrid)!.props as Record<string, unknown>;
+ expect(Object.keys(grid).sort()).toEqual(["corner", "pinned", "primary", "row"]);
+ expect([(grid.primary as Bot).id, ...(grid.pinned as Bot[]).map((candidate) => candidate.id)]).toEqual(["chief", "atlas"]);
fixture.storage.delete("omb-web-panels");
});
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 179a601b60..f0abddd9a5 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 { 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 { 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 { 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";
@@ -991,7 +991,7 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
const searchToggleRef = useRef<HTMLButtonElement>(null);
const closeSearch = () => { setSearchOpen(false); setQuery(""); searchToggleRef.current?.focus(); };
const pinnedCircles = usePinnedCircles();
- const universalPins = useUniversalPins(), pinnedPages = useWebPanels();
+ const universalPins = useUniversalPins();
const [pinnedCircleThreadsCollapsed, setPinnedCircleThreadsCollapsed] = useState(true);
useEffect(() => {
@@ -1123,7 +1123,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 || pinnedPages.length > 0);
+ const tiles = simpleDesk && (primary !== null || pinnedBots.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) };
@@ -1357,8 +1357,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} pages={pinnedPages} openPage={state.activeView === "web-panel" ? state.webPanelId : undefined} dispatch={dispatch} />}
- {simpleDesk && primary === null && pinnedBots.length === 0 && <SidebarNoBots />}
+ {tiles && <SidebarTileGrid primary={primary} pinned={pinnedBots} row={botRow} corner={corner} />}
+ {simpleDesk && !tiles && <SidebarNoBots />}
</GlassBar>
{!collapseToIcons && !phone && <SidebarResizeHandle sizing={sizing} sidebarRef={sidebarRef} avatars={density === "icons"} avatarsWidth={rail ? 92 : 80}
diff --git a/src/components/SidebarTiles.page.dom.test.ts b/src/components/SidebarTiles.page.dom.test.ts
deleted file mode 100644
index a03efb9726..0000000000
--- a/src/components/SidebarTiles.page.dom.test.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-// @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 84fdd04ec8..05d98b9de1 100644
--- a/src/components/SidebarTiles.test.ts
+++ b/src/components/SidebarTiles.test.ts
@@ -12,8 +12,7 @@ vi.mock("@/lib/interface-mode", async (original) => ({
vi.mock("./DesktopCapabilities", () => ({ useDesktopCapabilities: () => ({}) }));
import { BotListItem, botRowProps } from "./Sidebar";
-import { pageFaviconUrl, SidebarBotTile, SidebarPageTile, SidebarTileGrid } from "./SidebarTiles";
-import type { WebPanel } from "@/lib/web-panels";
+import { SidebarBotTile, SidebarTileGrid } from "./SidebarTiles";
const bot = (extra: Partial<Bot> = {}): Bot => ({
id: "mausbot", threadId: "t", name: "MausBot", title: "", description: "", notifications: true, color: "chrome",
@@ -154,47 +153,3 @@ 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 6be88e7e3f..7ed07359bd 100644
--- a/src/components/SidebarTiles.tsx
+++ b/src/components/SidebarTiles.tsx
@@ -1,13 +1,12 @@
-import { AppWindow, Crown, Globe, Loader2, Phone } from "lucide-react";
-import { memo, useLayoutEffect, useRef, useState, type Dispatch, type KeyboardEvent, type MouseEvent } from "react";
+import { Crown, Loader2, Phone } from "lucide-react";
+import { memo, useLayoutEffect, useRef, useState, 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 Action, type Bot } from "@/state/store";
-import type { WebPanel } from "@/lib/web-panels";
+import { api, openBotRow, useStore, type Bot } from "@/state/store";
import { useChiefStepOpen } from "@/lib/default-bot";
import { BotAvatar } from "./Avatar";
@@ -22,12 +21,6 @@ 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) {
@@ -82,7 +75,8 @@ export const SidebarBotTile = memo(function SidebarBotTile({ primary = false, dr
onKeyDown={onKeyDown}
onContextMenu={(event) => openBotContextMenu(onMenu, bot.id, event)}
className={cn(
- TILE, SIMPLE_ROW_FOCUS, tileFill(selected),
+ "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))]",
pinnedCircleDragClass({ drag, dragging, drop }),
)}
>
@@ -125,7 +119,7 @@ export const SidebarBotTile = memo(function SidebarBotTile({ primary = false, dr
title={tooltip}
onCommit={rename}
onEditingChange={setRenaming}
- className={CAPTION}
+ className="min-w-0 truncate text-center text-[12px] leading-4 text-ink"
inputClassName="w-full rounded bg-inset px-1 text-center text-[12px] leading-4"
/>
</span>
@@ -133,34 +127,6 @@ 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();
@@ -200,21 +166,15 @@ function useBesideCorner(corner: boolean, count: number) {
return { ref, beside };
}
-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>;
-}) {
+export function SidebarTileGrid({ primary, pinned, row, corner = false }: { primary: Bot | null; pinned: Bot[]; row: (bot: Bot) => BotRowProps; corner?: boolean }) {
const order = usePinnedCircleDrag(pinned);
- 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;
+ const besideCorner = useBesideCorner(corner, (primary ? 1 : 0) + order.ranked.length);
+ if (!primary && order.ranked.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 01cad40275..bbed71e37d 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, webPanelId: s.webPanelId, computerOpen: s.computerOpen, inspectorOpen: s.inspectorOpen, deletingBots: s.deletingBots, revealThread: s.revealThread,
+ activeView: s.activeView, 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,
});