Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
feat(sidebar): pinned web panels, a dashboard one click away (#3806)
Azad Jagtap23a71697e7b5
diff --git a/src/App.tsx b/src/App.tsxindex 1bf0102fe2..50008b6342 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -64,6 +64,7 @@ import { ChatNotice } from "@/components/ChatErrorBanner";import { loadingLine } from "@/lib/app-loading";import { useAiSwitchKeeper } from "@/lib/ai-switch";import { useChiefStepOpen } from "@/lib/default-bot";+import { WebPanelPage } from "@/components/WebPanelPage";function Shell({ viewer }: { viewer: WelcomeViewer | null }) {const { state, dispatch } = useStore();@@ -134,7 +135,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {const [localVmWorkspaceBotId, setLocalVmWorkspaceBotId] = useState<string | null>(null);const menuButtonRef = useRef<HTMLButtonElement>(null);const previousViewRef = useRef(state.activeView);- const calendarOriginRef = useRef<"chat" | "team-map">("chat");+ const calendarOriginRef = useRef<"chat" | "team-map" | "web-panel">("chat");const loading = loadingLine({ connected: state.connected, hydrated: state.hydrated === true, developer: import.meta.env.DEV });const group = state.groups.find((g) => g.id === state.selectedId);const chiefStep = useChiefStepOpen();@@ -216,7 +217,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {useEffect(() => {if (state.activeView === "routines" && previousViewRef.current !== "routines") {- calendarOriginRef.current = previousViewRef.current === "team-map" ? "team-map" : "chat";+ calendarOriginRef.current = previousViewRef.current === "team-map" || previousViewRef.current === "web-panel" ? previousViewRef.current : "chat";}previousViewRef.current = state.activeView;}, [state.activeView]);@@ -246,8 +247,12 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {dispatch({ type: "showTeamMap" });return;}+ if (calendarOriginRef.current === "web-panel" && state.webPanelId) {+ dispatch({ type: "showWebPanel", id: state.webPanelId });+ return;+ }dispatch({ type: "select", id: state.selectedId });- }, [dispatch, state.selectedId]);+ }, [dispatch, state.selectedId, state.webPanelId]);const openCalendarRoom = useCallback((id: string) => {dispatch({ type: "select", id });}, [dispatch]);@@ -333,6 +338,8 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {<TeamMapPage />) : state.activeView === "files" ? (<FilesView />+ ) : state.activeView === "web-panel" ? (+ <WebPanelPage />) : state.activeView === "routines" ? (<TriggersPage onBack={closeCalendar} onOpenRoom={openCalendarRoom} />) : !remoteClient && localVmWorkspaceBotId ? (diff --git a/src/components/PinnedPanelsSettings.tsx b/src/components/PinnedPanelsSettings.tsxnew file mode 100644index 0000000000..4ed9c2ed47--- /dev/null+++ b/src/components/PinnedPanelsSettings.tsx@@ -0,0 +1,91 @@+import { useState } from "react";++import { t } from "@/lib/i18n";+import { setWebPanels, useWebPanels } from "@/lib/web-panel-preferences";+import { MAX_WEB_PANELS, MAX_WEB_PANEL_NAME, newWebPanelId, validateWebPanel } from "@/lib/web-panels";++import { Card } from "./SettingsPrimitives";++const field = "min-w-0 rounded-lg border bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none";++/** Settings → General: pages pinned to the sidebar (Advanced mode). */+export function PinnedPanelsSettings() {+ const panels = useWebPanels();+ const [name, setName] = useState("");+ const [url, setUrl] = useState("");+ const [error, setError] = useState<"name" | "url" | "self" | "">("");+ const full = panels.length >= MAX_WEB_PANELS;++ const add = () => {+ const check = validateWebPanel({ name, url }, window.location.origin);+ if (!check.ok) {+ setError(check.error);+ return;+ }+ setWebPanels([...panels, { id: newWebPanelId(panels), name: check.name, url: check.url }]);+ setName("");+ setUrl("");+ setError("");+ };++ return (+ <Card title={t("webPanels.settings.title")} subtitle={t("webPanels.settings.subtitle")}>+ <div className="flex flex-col gap-3">+ {panels.length > 0 && (+ <ul className="flex flex-col divide-y divide-hairline/40 rounded-lg border border-hairline/40">+ {panels.map((panel) => (+ <li key={panel.id} className="flex items-center gap-3 px-3 py-2">+ <div className="min-w-0 flex-1">+ <p className="truncate text-[14px] font-medium text-ink">{panel.name}</p>+ <p className="truncate text-[12px] text-ink-secondary" title={panel.url}>{panel.url}</p>+ </div>+ <button+ type="button"+ className="ui-button text-danger"+ onClick={() => setWebPanels(panels.filter((entry) => entry.id !== panel.id))}+ >+ {t("webPanels.settings.remove")}+ </button>+ </li>+ ))}+ </ul>+ )}+ <div className="flex flex-col gap-2 sm:flex-row">+ <input+ aria-label={t("webPanels.settings.name")}+ placeholder={t("webPanels.settings.name")}+ value={name}+ maxLength={MAX_WEB_PANEL_NAME}+ disabled={full}+ aria-invalid={error === "name"}+ onChange={(event) => { setName(event.target.value); setError(""); }}+ className={`${field} sm:w-40 ${error === "name" ? "border-danger/60" : "border-hairline/40 focus:border-focus"}`}+ />+ <input+ aria-label={t("webPanels.settings.url")}+ placeholder="https://"+ type="url"+ inputMode="url"+ value={url}+ disabled={full}+ aria-invalid={error === "url" || error === "self"}+ onChange={(event) => { setUrl(event.target.value); setError(""); }}+ onKeyDown={(event) => { if (event.key === "Enter") add(); }}+ className={`${field} flex-1 ${error === "url" || error === "self" ? "border-danger/60" : "border-hairline/40 focus:border-focus"}`}+ />+ <button type="button" className="ui-button" disabled={full} onClick={add}>+ {t("webPanels.settings.add")}+ </button>+ </div>+ {error && (+ <p role="alert" className="text-[12px] text-danger">+ {t(error === "name" ? "webPanels.settings.nameInvalid" : error === "self" ? "webPanels.settings.urlSelf" : "webPanels.settings.urlInvalid", { max: MAX_WEB_PANEL_NAME })}+ </p>+ )}+ <p className="text-[12px] leading-relaxed text-ink-secondary">+ {full ? t("webPanels.settings.full", { max: MAX_WEB_PANELS }) : t("webPanels.settings.help")}+ </p>+ </div>+ </Card>+ );+}diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsxindex ef474bda26..6270243fe6 100644--- a/src/components/SettingsModal.tsx+++ b/src/components/SettingsModal.tsx@@ -47,6 +47,7 @@ import { ProfileFields } from "./ProfileSettings";import { ThreadConcurrencySettings } from "./ThreadConcurrencySettings";import { AutomaticRecoverySettings } from "./AutomaticRecoverySettings";import { ThreadCleanupSettings } from "./ThreadCleanupSettings";+import { PinnedPanelsSettings } from "./PinnedPanelsSettings";import { DefaultBotSettings } from "./NewBotDialog";import { WorkspaceBackupSettings } from "./WorkspaceBackupSettings";import { CompanyBackupSettings } from "./CompanyBackupSettings";@@ -79,7 +80,7 @@ export const SECTIONS: Array<{icon: typeof User;keywords: string[];}> = [- { id: "general", group: "you", labelKey: "settings.section.general", icon: User, keywords: ["profile", "name", "email", "about me", "about", "suggestions", "suggested", "memory", "analytics", "updates", "product updates", "newsletter", "email updates", "effort", "new bots", "reasoning", "threads", "parallel", "concurrency", "cleanup", "retention", "event log", "event-log", "log size", "automatic recovery", "backup model", "fallback", "routines", "conversation", "schedule", "usage", "limit", "plan", "upgrade", "cloud desktop hours", "storage", ...talkShortcutKeywords()] },+ { id: "general", group: "you", labelKey: "settings.section.general", icon: User, keywords: ["profile", "pinned panels", "web panel", "dashboard", "pin a page", "name", "email", "about me", "about", "suggestions", "suggested", "memory", "analytics", "updates", "product updates", "newsletter", "email updates", "effort", "new bots", "reasoning", "threads", "parallel", "concurrency", "cleanup", "retention", "event log", "event-log", "log size", "automatic recovery", "backup model", "fallback", "routines", "conversation", "schedule", "usage", "limit", "plan", "upgrade", "cloud desktop hours", "storage", ...talkShortcutKeywords()] },{ id: "appearance", group: "you", labelKey: "settings.section.appearance", icon: Palette, keywords: ["skin", "theme", "appearance", "chat width", "width", "wide", "full width", "bubble", "bubbles", "tools", "tool calls", "threads", "show threads", "hide threads", "sidebar", "density", "compact", "comfortable", "avatars", "display", "run", "this run", "run card", "commands", "notifications", "sound", "sounds", "mute", "silent", "chime", "pinned", "circles", "universal", "groups", "top", "send", "enter", "return", "shift+enter", "ctrl+enter", "cmd+enter", "⌘+enter", "new line", "keyboard", "ime", "japanese", "message color", "my messages", "toolbar", "tools layout", "footer", "routines", "triggers", "team map", "color", "colour", "cloud color", "server color", "tint", "sidebar color", "sidebar picture", "picture", "image", "banner", "background"] },{ id: "companion", group: "you", labelKey: "settings.section.companion", icon: TabletSmartphone, keywords: ["companion", "device", "phone", "desktop", "client", "host", "pair", "pairing", "mobile", "https", "secure", "tailscale", "wifi", "remote", "advanced", "domain", "dns", "self-hosted", "server", "caddy"] },{ id: "engines", group: "ai", labelKey: "settings.section.engines", icon: Terminal, keywords: ["models", "model providers", "engines", "claude", "codex", "grok", "providers", "cli", "sign in", "subscription"] },@@ -352,6 +353,7 @@ export function SettingsModal() {<AutomaticRecoverySettings /><ThreadCleanupSettings />+ <PinnedPanelsSettings />{!remoteActive && <ReplayTourRow />}<UpdatesRow />diff --git a/src/components/SidebarFooterNav.test.ts b/src/components/SidebarFooterNav.test.tsindex de5d1dac78..65be8d65f3 100644--- a/src/components/SidebarFooterNav.test.ts+++ b/src/components/SidebarFooterNav.test.ts@@ -8,6 +8,7 @@ const fixture = vi.hoisted(() => ({dispatch: vi.fn(),state: {} as Record<string, unknown>,toolsLayout: "rows" as SidebarToolsLayout,+ panels: [] as { id: string; name: string; url: string }[],}));vi.mock("@/lib/interface-mode", () => ({ useAdvancedMode: () => fixture.advanced, setAdvancedMode: () => {} }));vi.mock("@/state/store", () => ({ useStore: () => ({ state: fixture.state, dispatch: fixture.dispatch }) }));@@ -15,6 +16,7 @@ vi.mock("@/lib/sidebar-preferences", async (importOriginal) => ({...await importOriginal<typeof import("@/lib/sidebar-preferences")>(),useSidebarToolsLayout: () => fixture.toolsLayout,}));+vi.mock("@/lib/web-panel-preferences", () => ({ useWebPanels: () => fixture.panels }));vi.mock("./UpdateIndicator", () => ({ UpdateIndicator: () => null }));import { SidebarAppsButton, SidebarBottomButtons, SidebarFooterNav } from "./SidebarFooterNav";@@ -39,6 +41,7 @@ beforeEach(() => {fixture.dispatch.mockReset();fixture.state = { activeView: "chat", routineRuns: [], pluginsOpen: false };fixture.toolsLayout = "rows";+ fixture.panels = [];vi.stubGlobal("window", {});});afterEach(() => vi.unstubAllGlobals());@@ -85,6 +88,29 @@ describe("sidebar footer places", () => {expect(render("comfortable").html).toMatch(/data-sidebar-nav="automations"[^>]*aria-current="page"/);});+ it("adds a row per pinned web panel after Team map, in Advanced mode only", () => {+ fixture.panels = [{ id: "panel-1", name: "Fleet board", url: "http://127.0.0.1:7841/" }];+ fixture.state = { ...fixture.state, activeView: "web-panel", webPanelId: "panel-1" };+ expect(render("comfortable").html).toBe("");+ fixture.advanced = true;+ const { html, nodes: tree } = render("comfortable");+ expect(html.indexOf('data-sidebar-nav="web-panel-panel-1"')).toBeGreaterThan(html.indexOf('data-sidebar-nav="team-map"'));+ expect(html).toContain(">Fleet board</span>");+ expect(html).toMatch(/aria-current="page"[^>]*>[\s\S]*Fleet board/);+ const row = tree.find((node) => node.props.id === "web-panel-panel-1" && typeof node.props.onClick === "function")!;+ (row.props.onClick as () => void)();+ expect(fixture.dispatch).toHaveBeenLastCalledWith({ type: "showWebPanel", id: "panel-1" });+ });++ 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/" }];+ const { html } = render("comfortable", { toolsLayout: "toolbar" });+ expect(html).toContain('data-sidebar-nav="web-panel-panel-1"');+ expect(html).not.toContain(">Fleet board</span>");+ expect(html).toContain('aria-label="Fleet board"');+ });+it("keeps the guided tour's anchors on the rows", () => {fixture.advanced = true;const { html } = render("comfortable");diff --git a/src/components/SidebarFooterNav.tsx b/src/components/SidebarFooterNav.tsxindex 7899f8e071..9d7247f823 100644--- a/src/components/SidebarFooterNav.tsx+++ b/src/components/SidebarFooterNav.tsx@@ -1,4 +1,4 @@-import { FolderOpen, Puzzle, UsersRound, Zap } from "lucide-react";+import { FolderOpen, Globe, Puzzle, UsersRound, Zap } from "lucide-react";import type { ReactNode } from "react";import { useAppTriggers } from "@/lib/app-triggers";@@ -6,6 +6,7 @@ import { cn } from "@/lib/cn";import { useCloudFilesReady } from "@/lib/cloud-files";import { t } from "@/lib/i18n";import { useAdvancedMode } from "@/lib/interface-mode";+import { useWebPanels } from "@/lib/web-panel-preferences";import { isRoutineProblemRun } from "@/lib/routines";import { useSidebarToolsLayout, type SidebarDensity } from "@/lib/sidebar-preferences";import { useStore } from "@/state/store";@@ -113,6 +114,7 @@ export function SidebarFooterNav({}) {const { state, dispatch } = useStore();const advanced = useAdvancedMode();+ const webPanels = useWebPanels();const iconsOnly = density === "icons";const toolsLayout = useSidebarToolsLayout();const toolbar = advanced && !iconsOnly && toolsLayout === "toolbar";@@ -167,6 +169,17 @@ export function SidebarFooterNav({/>)}{filesRow}+ {advanced && webPanels.map((panel) => (+ <NavRow+ key={panel.id}+ id={`web-panel-${panel.id}`}+ label={panel.name}+ iconsOnly={iconsOnly || toolbar}+ active={state.activeView === "web-panel" && state.webPanelId === panel.id}+ icon={(active) => <Globe size={iconSize} className={tone(active)} />}+ onClick={() => dispatch({ type: "showWebPanel", id: panel.id })}+ />+ ))}</>);diff --git a/src/components/WebPanelPage.test.ts b/src/components/WebPanelPage.test.tsnew file mode 100644index 0000000000..5cb63ec0e9--- /dev/null+++ b/src/components/WebPanelPage.test.ts@@ -0,0 +1,47 @@+// @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";++(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++const fixture = vi.hoisted(() => ({+ panels: [] as Array<{ id: string; name: string; url: string }>,+ state: { webPanelId: "panel-1" } as { webPanelId?: string },+ dispatch: vi.fn(),+}));+vi.mock("@/lib/web-panel-preferences", () => ({ useWebPanels: () => fixture.panels }));+vi.mock("@/state/store", () => ({ useStore: () => ({ state: fixture.state, dispatch: fixture.dispatch }) }));++const { WebPanelPage } = await import("./WebPanelPage");++let root: Root;+let host: HTMLElement;+beforeEach(() => {+ fixture.dispatch.mockReset();+ host = document.createElement("div");+ document.body.append(host);+ root = createRoot(host);+});+afterEach(() => { act(() => root.unmount()); host.remove(); });++describe("a pinned web panel's page", () => {+ it("frames another site's page", () => {+ fixture.panels = [{ id: "panel-1", name: "Fleet board", url: "http://127.0.0.1:7841/" }];+ act(() => root.render(createElement(WebPanelPage)));+ expect(host.querySelector("iframe")?.getAttribute("src")).toBe("http://127.0.0.1:7841/");+ });++ it("never frames a page on the app's own origin, and offers the browser instead", () => {+ fixture.panels = [{ id: "panel-1", name: "Me", url: `${window.location.origin}/` }];+ act(() => root.render(createElement(WebPanelPage)));+ expect(host.querySelector("iframe")).toBeNull();+ expect(host.textContent).toContain("Open in browser");+ });++ it("goes back to the chat when its panel was removed", () => {+ fixture.panels = [];+ act(() => root.render(createElement(WebPanelPage)));+ expect(fixture.dispatch).toHaveBeenCalledWith({ type: "showChat" });+ });+});diff --git a/src/components/WebPanelPage.tsx b/src/components/WebPanelPage.tsxnew file mode 100644index 0000000000..d87aee3add--- /dev/null+++ b/src/components/WebPanelPage.tsx@@ -0,0 +1,77 @@+// A pinned web page shown in place of the chat, like Team map. The page is+// framed with a sandbox and no referrer; a page that refuses framing (or+// never loads) falls back to a button that opens it in the browser.+import { ExternalLink, Globe, RotateCw } from "lucide-react";+import { useEffect, useState } from "react";++import { openExternalLink } from "@/lib/app-links";+import { t } from "@/lib/i18n";+import { useWebPanels } from "@/lib/web-panel-preferences";+import { isAppOrigin } from "@/lib/web-panels";+import { useStore } from "@/state/store";++const LOAD_TIMEOUT_MS = 10_000;++export function WebPanelPage() {+ const { state, dispatch } = useStore();+ const panels = useWebPanels();+ const panel = panels.find((entry) => entry.id === state.webPanelId);+ const [reloads, setReloads] = useState(0);+ const [status, setStatus] = useState<"loading" | "loaded" | "failed">("loading");++ // A removed panel leaves nothing to show: go back to the conversation.+ useEffect(() => {+ if (!panel) dispatch({ type: "showChat" });+ }, [panel, dispatch]);++ useEffect(() => {+ setStatus("loading");+ const timer = setTimeout(() => setStatus((current) => (current === "loading" ? "failed" : current)), LOAD_TIMEOUT_MS);+ return () => clearTimeout(timer);+ }, [panel?.url, reloads]);++ if (!panel) return null;+ const openInBrowser = () => void openExternalLink(panel.url).catch(() => undefined);++ return (+ <main className="flex min-w-0 flex-1 flex-col bg-app" aria-label={panel.name}>+ <header className="flex items-center gap-2 border-b border-hairline/40 px-4 py-2.5">+ <Globe size={16} className="shrink-0 text-ink-secondary" />+ <h1 className="min-w-0 flex-1 truncate text-[14px] font-semibold text-ink" title={panel.url}>{panel.name}</h1>+ <button+ type="button"+ className="ui-icon-button shrink-0"+ aria-label={t("webPanels.page.reload")}+ title={t("webPanels.page.reload")}+ onClick={() => setReloads((n) => n + 1)}+ >+ <RotateCw size={16} />+ </button>+ <button type="button" className="ui-button" onClick={openInBrowser}>+ <ExternalLink size={14} />+ {t("webPanels.page.openInBrowser")}+ </button>+ </header>+ {status === "failed" || isAppOrigin(panel.url, window.location.origin) ? (+ <div className="flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center">+ <p className="text-[14px] font-medium text-ink">{t("webPanels.page.cantEmbed")}</p>+ <p className="max-w-sm text-[13px] text-ink-secondary">{t("webPanels.page.cantEmbedBody")}</p>+ <button type="button" className="ui-button ui-button-primary" onClick={openInBrowser}>+ {t("webPanels.page.openInBrowser")}+ </button>+ </div>+ ) : (+ <iframe+ key={`${panel.id}:${reloads}`}+ src={panel.url}+ title={panel.name}+ sandbox="allow-scripts allow-same-origin allow-forms allow-popups"+ referrerPolicy="no-referrer"+ onLoad={() => setStatus("loaded")}+ onError={() => setStatus("failed")}+ className="min-h-0 w-full flex-1 border-0 bg-app"+ />+ )}+ </main>+ );+}diff --git a/src/lib/web-panel-preferences.ts b/src/lib/web-panel-preferences.tsnew file mode 100644index 0000000000..b4b10467b0--- /dev/null+++ b/src/lib/web-panel-preferences.ts@@ -0,0 +1,72 @@+import { useSyncExternalStore } from "react";++import { parseWebPanels, type WebPanel } from "./web-panels";++export const WEB_PANELS_KEY = "omb-web-panels";++// Same shape as thread-preferences: a renderer preference that survives+// blocked storage for this session and follows other windows' edits.+let sessionPanels: WebPanel[] | undefined;+let cachedRaw: string | null | undefined;+let cachedPanels: WebPanel[] = [];+const listeners = new Set<() => void>();+const NONE: WebPanel[] = [];++function storage(): Storage | undefined {+ try {+ return globalThis.localStorage;+ } catch {+ return undefined;+ }+}++function readPanels(): WebPanel[] {+ if (sessionPanels !== undefined) return sessionPanels;+ let raw: string | null = null;+ try {+ raw = storage()?.getItem(WEB_PANELS_KEY) ?? null;+ } catch {+ return NONE;+ }+ // useSyncExternalStore needs a stable snapshot for an unchanged value.+ if (raw !== cachedRaw) {+ cachedRaw = raw;+ cachedPanels = parseWebPanels(raw);+ }+ return cachedPanels;+}++function notify() {+ for (const listener of listeners) listener();+}++function onStorage(event: StorageEvent) {+ if (event.key !== WEB_PANELS_KEY && event.key !== null) return;+ if (event.storageArea && event.storageArea !== storage()) return;+ sessionPanels = undefined;+ notify();+}++function subscribe(listener: () => void): () => void {+ listeners.add(listener);+ if (listeners.size === 1 && typeof window !== "undefined") window.addEventListener("storage", onStorage);+ return () => {+ listeners.delete(listener);+ if (listeners.size === 0 && typeof window !== "undefined") window.removeEventListener("storage", onStorage);+ };+}++export function setWebPanels(panels: readonly WebPanel[]): void {+ const raw = JSON.stringify(panels);+ sessionPanels = parseWebPanels(raw);+ try {+ storage()?.setItem(WEB_PANELS_KEY, raw);+ } catch {+ // Kept for this session when storage is full or blocked.+ }+ notify();+}++export function useWebPanels(): WebPanel[] {+ return useSyncExternalStore(subscribe, readPanels, () => NONE);+}diff --git a/src/lib/web-panels.test.ts b/src/lib/web-panels.test.tsnew file mode 100644index 0000000000..dfa1018afb--- /dev/null+++ b/src/lib/web-panels.test.ts@@ -0,0 +1,54 @@+import { describe, expect, it } from "vitest";++import { isAppOrigin, MAX_WEB_PANELS, newWebPanelId, parseWebPanels, validateWebPanel } from "./web-panels";++describe("pinned web panels", () => {+ it("accepts absolute http and https pages and trims the name", () => {+ expect(validateWebPanel({ name: " Board ", url: "http://127.0.0.1:7841/" })).toEqual({+ ok: true, name: "Board", url: "http://127.0.0.1:7841/",+ });+ expect(validateWebPanel({ name: "CI", url: " https://ci.example.com/runs?x=1 " })).toMatchObject({ ok: true });+ });++ it.each([+ ["javascript:alert(1)"], ["data:text/html,hi"], ["file:///etc/hosts"], ["/relative"], [""],+ ["ftp://example.com"], ["https://user:[email protected]/"], ["https://[email protected]/"],+ ])("refuses %s", (url) => {+ expect(validateWebPanel({ name: "x", url })).toEqual({ ok: false, error: "url" });+ });++ it("refuses a page on the app's own origin, which the frame would run with the app's access", () => {+ expect(validateWebPanel({ name: "Me", url: "http://127.0.0.1:5173/settings" }, "http://127.0.0.1:5173")).toEqual({ ok: false, error: "self" });+ expect(validateWebPanel({ name: "Board", url: "http://127.0.0.1:7841/" }, "http://127.0.0.1:5173")).toMatchObject({ ok: true });+ expect(isAppOrigin("not a url", "http://127.0.0.1:5173")).toBe(false);+ });++ it("needs a name of 1 to 40 characters", () => {+ expect(validateWebPanel({ name: " ", url: "https://a.example" })).toEqual({ ok: false, error: "name" });+ expect(validateWebPanel({ name: "a".repeat(40), url: "https://a.example" })).toMatchObject({ ok: true });+ expect(validateWebPanel({ name: "a".repeat(41), url: "https://a.example" })).toEqual({ ok: false, error: "name" });+ });++ it("reads a stored list defensively: bad entries dropped, duplicates ignored, at most six", () => {+ const many = Array.from({ length: 9 }, (_, i) => ({ id: `p${i}`, name: `P${i}`, url: `https://p${i}.example/` }));+ expect(parseWebPanels(JSON.stringify(many))).toHaveLength(MAX_WEB_PANELS);+ const mixed = [+ { id: "a", name: "A", url: "https://a.example/" },+ { id: "a", name: "dup", url: "https://dup.example/" },+ { id: "b", name: "B", url: "javascript:alert(1)" },+ { name: "no id", url: "https://c.example/" },+ "nonsense",+ ];+ expect(parseWebPanels(JSON.stringify(mixed))).toEqual([{ id: "a", name: "A", url: "https://a.example/" }]);+ expect(parseWebPanels("{not json")).toEqual([]);+ expect(parseWebPanels(null)).toEqual([]);+ expect(parseWebPanels('{"id":"x"}')).toEqual([]);+ });++ it("gives each new panel an unused id", () => {+ expect(newWebPanelId([])).toBe("panel-1");+ expect(newWebPanelId([{ id: "panel-2", name: "A", url: "https://a.example/" }])).toBe("panel-3");+ expect(newWebPanelId([{ id: "panel-1", name: "A", url: "https://a.example/" }, { id: "panel-2", name: "B", url: "https://b.example/" }]))+ .toBe("panel-3");+ });+});diff --git a/src/lib/web-panels.ts b/src/lib/web-panels.tsnew file mode 100644index 0000000000..59d77b1f7f--- /dev/null+++ b/src/lib/web-panels.ts@@ -0,0 +1,78 @@+// Pinned web panels: a few pages (a local dashboard, a CI page) the person+// keeps one click away in the sidebar. Renderer-only data — no bot sees it,+// no server stores it. Only plain http(s) pages without credentials are+// accepted, because the URL is framed in the app and handed to the browser.++export interface WebPanel {+ id: string;+ name: string;+ url: string;+}++export const MAX_WEB_PANELS = 6;+export const MAX_WEB_PANEL_NAME = 40;++export type WebPanelInput = { name: string; url: string };+export type WebPanelCheck =+ | { ok: true; name: string; url: string }+ | { ok: false; error: "name" | "url" | "self" };++/** A trimmed name of 1–40 characters and an absolute http(s) URL with no+ * user name or password in it, never on `appOrigin`. */+export function validateWebPanel(input: WebPanelInput, appOrigin?: string): WebPanelCheck {+ const name = input.name.trim();+ if (!name || name.length > MAX_WEB_PANEL_NAME) return { ok: false, error: "name" };+ let parsed: URL;+ try {+ parsed = new URL(input.url.trim());+ } catch {+ return { ok: false, error: "url" };+ }+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return { ok: false, error: "url" };+ if (parsed.username || parsed.password || !parsed.hostname) return { ok: false, error: "url" };+ if (appOrigin && isAppOrigin(parsed.href, appOrigin)) return { ok: false, error: "self" };+ return { ok: true, name, url: parsed.href };+}++/** Security: the frame keeps its page's origin (allow-same-origin), so a page on the app's own origin would run with+ * the app's own access. Such a page is never framed. */+export function isAppOrigin(url: string, appOrigin: string): boolean {+ try {+ return new URL(url).origin === appOrigin;+ } catch {+ return false;+ }+}++/** The stored list, keeping only entries that still validate, at most six.+ * Never throws: a corrupt value reads as no panels. */+export function parseWebPanels(raw: string | null | undefined): WebPanel[] {+ if (!raw) return [];+ let value: unknown;+ try {+ value = JSON.parse(raw);+ } catch {+ return [];+ }+ if (!Array.isArray(value)) return [];+ const panels: WebPanel[] = [];+ const seen = new Set<string>();+ for (const entry of value) {+ if (panels.length >= MAX_WEB_PANELS) break;+ if (!entry || typeof entry !== "object") continue;+ const { id, name, url } = entry as Record<string, unknown>;+ if (typeof id !== "string" || !id || seen.has(id) || typeof name !== "string" || typeof url !== "string") continue;+ const check = validateWebPanel({ name, url });+ if (!check.ok) continue;+ seen.add(id);+ panels.push({ id, name: check.name, url: check.url });+ }+ return panels;+}++export function newWebPanelId(existing: readonly WebPanel[]): string {+ let n = existing.length + 1;+ const taken = new Set(existing.map((panel) => panel.id));+ while (taken.has(`panel-${n}`)) n++;+ return `panel-${n}`;+}diff --git a/src/locales/en.json b/src/locales/en.jsonindex 7802809972..8428c7b913 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -5932,6 +5932,21 @@"sidebar.nav.triggers": "Triggers","sidebar.nav.apps": "Apps","sidebar.nav.files": "Files",+ "webPanels.settings.title": "Pinned panels",+ "webPanels.settings.subtitle": "Keep a few web pages, like a local dashboard, one click away in the sidebar (Advanced mode).",+ "webPanels.settings.name": "Name",+ "webPanels.settings.url": "Page address",+ "webPanels.settings.add": "Pin page",+ "webPanels.settings.remove": "Remove",+ "webPanels.settings.nameInvalid": "Give the panel a name of up to {max} characters.",+ "webPanels.settings.urlInvalid": "Use a full http:// or https:// address without a user name or password.",+ "webPanels.settings.urlSelf": "That's this app's own address. Pin a different page.",+ "webPanels.settings.help": "Pages open inside the app. Bots can't see them.",+ "webPanels.settings.full": "You've pinned the maximum of {max} pages. Remove one to add another.",+ "webPanels.page.reload": "Reload",+ "webPanels.page.openInBrowser": "Open in browser",+ "webPanels.page.cantEmbed": "This page can't be shown inside the app",+ "webPanels.page.cantEmbedBody": "Some sites refuse to be embedded. Open it in your browser instead.","botAccess.tools.title": "Tool selection","botAccess.tools.description": "Advanced: narrow the tools offered to this bot. Existing approvals still apply.","botAccess.tools.corrupt": "Invalid saved selection. This bot cannot start until it is repaired.",diff --git a/src/state/store.test.ts b/src/state/store.test.tsindex 463fc178b6..aff61e4b11 100644--- a/src/state/store.test.ts+++ b/src/state/store.test.ts@@ -2536,6 +2536,14 @@ describe("activity panel", () => {expect(reducer(suggested, { type: "showFiles", suggest: [] }).filesSuggest).toBeNull();expect(reducer(suggested, { type: "showTeamMap" })).toMatchObject({ activeView: "team-map", filesSuggest: null });});++ it("a pinned web panel replaces the main view like the team map, and chat comes back", () => {+ const open = { ...initialState, activityOpen: true, computerOpen: true, settingsOpen: true };+ const panel = reducer(open, { type: "showWebPanel", id: "panel-1" });+ expect(panel).toMatchObject({ activeView: "web-panel", webPanelId: "panel-1", activityOpen: false, computerOpen: false, settingsOpen: false });+ expect(reducer(panel, { type: "showTeamMap" })).toMatchObject({ activeView: "team-map", webPanelId: "panel-1" });+ expect(reducer(panel, { type: "showChat" }).activeView).toBe("chat");+ });});describe("live config frames", () => {diff --git a/src/state/store.tsx b/src/state/store.tsxindex c13b030ef7..c348a3d3b7 100644--- a/src/state/store.tsx+++ b/src/state/store.tsx@@ -571,9 +571,9 @@ export interface AppState {liveCallVersion: number;liveCallLookupSeq: number;selectedId: string;- activeView: "chat" | "team-map" | "routines" | "files";+ activeView: "chat" | "team-map" | "routines" | "files" | "web-panel";/** Folders a finished move left on this computer, for Files to offer sharing. */- filesSuggest: string[] | null;+ filesSuggest: string[] | null; webPanelId?: string;routines: Routine[];routineRuns: RoutineRun[];routinesLoadState: "loading" | "ready" | "error";@@ -653,7 +653,7 @@ export type Action =| { type: "botsOrdered"; botIds: string[] }| { type: "sectionDeleted"; section: string; sections: string[] }| { type: "showRoutines"; section?: "schedule" | "logs"; view?: "calendar" | "list"; botId?: string; routineId?: string; runStatus?: RoutineRunStatusFilter }- | { type: "showTeamMap" }+ | { type: "showTeamMap" } | { type: "showWebPanel"; id: string }| { type: "showFiles"; suggest?: string[] }| { type: "showChat" }| { type: "routinesHydrated"; routines: Routine[]; runs: RoutineRun[] }@@ -996,11 +996,11 @@ export function reducer(state: AppState, action: Action): AppState {case "showChat":return state.activeView === "chat" ? state : { ...state, activeView: "chat" };case "showTeamMap":- case "showFiles":+ case "showFiles": case "showWebPanel":return {...state,- activeView: action.type === "showFiles" ? "files" : "team-map",- filesSuggest: action.type === "showFiles" && action.suggest?.length ? action.suggest : null,+ activeView: action.type === "showFiles" ? "files" : action.type === "showWebPanel" ? "web-panel" : "team-map",+ filesSuggest: action.type === "showFiles" && action.suggest?.length ? action.suggest : null, webPanelId: action.type === "showWebPanel" ? action.id : state.webPanelId,settingsOpen: false, computerOpen: false, inspectorOpen: false, activityOpen: false, appSettingsOpen: false, pluginsOpen: false,};case "routinesHydrated":@@ -2283,7 +2283,7 @@ export function StoreProvider({ children }: { children: ReactNode }) {};const wrapped: React.Dispatch<Action> = (action) => {- if (["select", "newTask", "switchTask", "newGroupTask", "switchGroupTask", "showChat", "showRoutines", "showTeamMap", "showFiles"].includes(action.type)) selectionRevision.current++;+ if (["select", "newTask", "switchTask", "newGroupTask", "switchGroupTask", "showChat", "showRoutines", "showTeamMap", "showFiles", "showWebPanel"].includes(action.type)) selectionRevision.current++;// Pin before any await or optimistic state change.action = pinBotThreadAction(action, stateRef.current.bots);if (action.type === "taskSwitched") action = { ...action, bot: withTaskWrites(action.bot) as Bot };