Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Launch: rarely opened screens and the public-suffix library leave the start-up bundle (#6772)
Milind Soni2dedbf5ffdf5
diff --git a/shared/browser-mates.ts b/shared/browser-mates.tsnew file mode 100644index 0000000000..367adce105--- /dev/null+++ b/shared/browser-mates.ts@@ -0,0 +1,6 @@+/** The other bots that use this bot's named browser profile, and so share what it is signed in to. A guest browser is+ * the bot's own temporary one (server/host/browser.ts sessionFor), so it has none. */+export function browserMatesOf(bots: ReadonlyArray<{ id: string; browserProfile?: string | null }>, botId: string): string[] {+ const profile = bots.find((bot) => bot.id === botId)?.browserProfile;+ return profile && profile !== "guest" ? bots.filter((bot) => bot.id !== botId && bot.browserProfile === profile).map((bot) => bot.id) : [];+}diff --git a/shared/logins.ts b/shared/logins.tsindex dad27b4058..9b275a2945 100644--- a/shared/logins.ts+++ b/shared/logins.ts@@ -5,6 +5,9 @@* secrets.*/import { getDomain } from "tldts";+import { browserMatesOf } from "./browser-mates.ts";++export { browserMatesOf };/** Where a login came from: the sign-in card's Save, Settings, or the person's* 1Password or Bitwarden vault (read-only here). */@@ -165,13 +168,6 @@ export function loginOriginCheck(pageUrl: string, login: LoginPlace): { ok: truereturn loginMatchesHost(login, page.pageHost) ? page : { ok: false, pageHost: page.pageHost, reason: "host" };}-/** The other bots that use this bot's named browser profile, and so share what it is signed in to. A guest browser is- * the bot's own temporary one (server/host/browser.ts sessionFor), so it has none. */-export function browserMatesOf(bots: ReadonlyArray<{ id: string; browserProfile?: string | null }>, botId: string): string[] {- const profile = bots.find((bot) => bot.id === botId)?.browserProfile;- return profile && profile !== "guest" ? bots.filter((bot) => bot.id !== botId && bot.browserProfile === profile).map((bot) => bot.id) : [];-}-/** The bots a login is kept to that it is still not filled for, because they share a browser with a bot it isn't kept to. */export function loginHeldBackFor(login: { bots: LoginBots }, bots: ReadonlyArray<{ id: string; browserProfile?: string | null }>): string[] {const kept = login.bots;diff --git a/src/App.tsx b/src/App.tsxindex d3105c1a09..2deb456449 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -26,12 +26,12 @@ import { SIDEBAR_AND_NARROW_PANEL_FIT, SIDEBAR_AND_PANEL_FIT, SIDEBAR_INLINE, TWimport { anySidePanel, sidebarFoldsForPanel, type OpenSidePanels } from "@/lib/sidebar-fold";import { preloadConnectedApps } from "@/lib/connected-apps";import {- ActivityPanel, AnnouncementsPage, BotSettingsDialog, CloudAddDialog, ComputerPanel, FilesView, InspectorPanel, KeyboardShortcutsModal, LocalVmWorkspace,+ ActivityPanel, AnnouncementsPage, BotSettingsDialog, CloudAddDialog, ComputerPanel, FilesView, InboxPanel, InspectorPanel, KeyboardShortcutsModal, LocalVmWorkspace,PluginsPanel, preloadScreens, PublishedAppsPage, RemoteAgentSettingsPanel, RemoteDesktopPanel, RoomPanel, SettingsModal, TeamFilesPage, TeamMapPage, TriggersPage,} from "@/components/lazy-screens";import { useAdvancedMode } from "@/lib/interface-mode";import { useRoomPanelShown } from "@/lib/room-panel";-import { WorkspaceBackupRecovery } from "@/components/WorkspaceBackupSettings";+import { WorkspaceBackupRecovery } from "@/components/WorkspaceBackupRecovery";import { NotificationRail, NotificationsPanel } from "@/components/NotificationsPanel";import { useNotificationFeed } from "@/lib/notification-preferences";import { UpdateBanner } from "@/components/UpdateBanner";@@ -47,7 +47,6 @@ import { useTeamChats } from "@/state/team-chats";import { needsYouVersion, useTeamPeopleLoader } from "@/state/team-people";import { useTeamPresence } from "@/state/team-presence";import { inboxVersion, useInboxLoader, useInboxPanel, useInboxReady } from "@/state/inbox";-import { InboxPanel } from "@/components/inbox/InboxPanel";import { PlacesRail } from "@/components/PlacesRail";import { NewLocalFromMenu } from "@/components/PlaceAddSheet";import { CloudHowTo } from "@/components/CloudHowTo";diff --git a/src/components/CallView.tsx b/src/components/CallView.tsxindex 1549035bf9..e54d279445 100644--- a/src/components/CallView.tsx+++ b/src/components/CallView.tsx@@ -28,7 +28,7 @@ import { useDesktopCapabilities } from "./DesktopCapabilities";import { callCapabilityHelp, type CallCapabilityHelp } from "@/lib/call-capability";import { onCallStartRequest } from "@/lib/call-start-request";import { CALL_ENDPOINT_MS, listensHere, missingListenKey, speechBridge } from "@/lib/speech";-import { VoiceSetupDialog } from "./VoiceSetupDialog";+import { VoiceSetupDialog } from "./lazy-screens";import { openBotSettings } from "./bot-panel/panel-link";import { MENU_SHEET } from "./menu-recipe";diff --git a/src/components/CallView.voiceSetup.test.ts b/src/components/CallView.voiceSetup.test.tsindex 854318ee53..4118206979 100644--- a/src/components/CallView.voiceSetup.test.ts+++ b/src/components/CallView.voiceSetup.test.ts@@ -56,7 +56,8 @@ vi.mock("./MenuMotion", async (importOriginal) => ({...await importOriginal<typeof import("./MenuMotion")>(),useMenuMotion: (open: boolean) => ({ shown: open, closing: false, className: "", exitProps: {} }),}));-vi.mock("./VoiceSetupDialog", () => ({+vi.mock("./lazy-screens", async (importOriginal) => ({+ ...await importOriginal<typeof import("./lazy-screens")>(),VoiceSetupDialog: (props: Record<string, unknown>) => {fixture.dialog = props;return createElement("div", { "data-voice-setup-stub": (props.bot as Bot).id });diff --git a/src/components/DigestChip.tsx b/src/components/DigestChip.tsxindex b40631e46a..f63f429629 100644--- a/src/components/DigestChip.tsx+++ b/src/components/DigestChip.tsx@@ -8,7 +8,7 @@ import { formatDuration } from "@/lib/usage-trace";import type { Message } from "@/state/store";import { traceRootId } from "../../shared/usage-trace";import { EXCERPT_SUMMARY_HEADER } from "../../shared/wire";-import { TraceDialog } from "./usage/TraceView";+import { TraceDialog } from "./lazy-screens";const WORK_KEY: Record<"noFiles" | "oneFile" | "files", Record<"oneTool" | "tools", LocaleKey>> = {noFiles: { oneTool: "chat.digestChipNoFilesOne", tools: "chat.digestChipNoFiles" },diff --git a/src/components/Sidebar.departments.test.ts b/src/components/Sidebar.departments.test.tsindex 61b9d79bfd..521bc462e3 100644--- a/src/components/Sidebar.departments.test.ts+++ b/src/components/Sidebar.departments.test.ts@@ -53,7 +53,7 @@ const drawSidebar = (Sidebar as unknown as { type: (props: import("react").Compoimport { NEW_DEPARTMENT } from "./SidebarBotDrag";import { SidebarSectionHeader } from "./SidebarSectionHeader";import { ConfirmDialog } from "./ConfirmDialog";-import { TeamDialog } from "./TeamDialog";+import { TeamDialog } from "./lazy-screens";const bot = (id: string, extra: Partial<Bot> = {}): Bot => ({id, threadId: `${id}-thread`, name: id, title: "", description: "", notifications: true,diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsxindex 964247919f..179a601b60 100644--- a/src/components/Sidebar.tsx+++ b/src/components/Sidebar.tsx@@ -28,11 +28,9 @@ import { LocalComputerAutoWarning } from "./LocalComputerAutoWarning";import { nextRename } from "@/lib/rename";import { useDesktopCapabilities, windowFramed } from "./DesktopCapabilities";import { MIN_QUERY, SearchResults } from "./SearchResults";-import { ImportDialog, ShareDepartmentDialog, TeamLibraryPanel } from "./lazy-screens";+import { ImportDialog, ShareDepartmentDialog, TeamDialog, TeamLibraryPanel, TeamSettingsDialog } from "./lazy-screens";import { SidebarNewChatPanel } from "./SidebarNewChatPanel";import { openCommandPalette } from "./CommandPalette";-import { TeamSettingsDialog } from "./TeamSettingsDialog";-import { TeamDialog } from "./TeamDialog";import { RenameTitle } from "./RenameTitle";import { BotProjectDialog, FolderActions, FolderIcon, navigateThreadMenu } from "./BotProjects";import { NewTaskFolderDialog } from "./NewTaskFolderDialog";diff --git a/src/components/SignInRequestCard.tsx b/src/components/SignInRequestCard.tsxindex 25932d4a0a..37297ab4f0 100644--- a/src/components/SignInRequestCard.tsx+++ b/src/components/SignInRequestCard.tsx@@ -2,7 +2,7 @@ import { useState } from "react";import { Check, Hand, KeyRound, Loader2, LockKeyhole, LogIn, RefreshCw, X } from "lucide-react";import type { ComputerHelpRef } from "../../shared/wire";-import { browserMatesOf } from "../../shared/logins";+import { browserMatesOf } from "../../shared/browser-mates";import { signInOutcome } from "../../shared/sign-in-request";import { cn } from "@/lib/cn";import { t } from "@/lib/i18n";diff --git a/src/components/WorkspaceBackupRecovery.tsx b/src/components/WorkspaceBackupRecovery.tsxnew file mode 100644index 0000000000..f5721c541f--- /dev/null+++ b/src/components/WorkspaceBackupRecovery.tsx@@ -0,0 +1,107 @@+import { useEffect, useRef, useState, type ReactNode } from "react";+import { Loader2 } from "lucide-react";+import { api } from "@/state/store";+import { t } from "@/lib/i18n";+import { applyWorkspaceClientState, WORKSPACE_RESTORE_MARKER } from "@/lib/workspace-backup-client";++export type BackupStatus = { busy: boolean; pendingRestore?: boolean; restarts?: boolean; lastRestoreId?: string };+const buttonClass = "cursor-pointer inline-flex items-center justify-center gap-2 rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-accent-ink disabled:opacity-40";++/** A renderer reload cannot apply a restore; the owning server must restart. A server that restarts itself (My Cloud)+ * is waited for, then the page carries on as after a reload. */+export function WorkspaceBackupRestartNotice({ onRetry, serverRestarts = false }: { onRetry?: () => void; serverRestarts?: boolean } = {}) {+ const [restarting, setRestarting] = useState(false);+ const [error, setError] = useState(false);+ const [slow, setSlow] = useState(false);+ const lock = useRef(false);+ const retry = useRef(onRetry);+ retry.current = onRetry;+ useEffect(() => {+ if (!serverRestarts) return;+ let alive = true;+ let timer: ReturnType<typeof setTimeout>;+ // A restored workspace may not know this browser's session: a reload shows sign-in.+ const check = () => api("/api/workspace-backup/status", { timeoutMs: 10_000 }).then((status: BackupStatus) => status.pendingRestore === false ? "installed" : "wait",+ (cause: unknown) => cause instanceof Error && "status" in cause && cause.status === 401 ? "signedOut" : "wait").then((state) => {+ if (!alive) return;+ if (state === "wait") timer = setTimeout(check, 3_000);+ else if (state === "installed" && retry.current) retry.current();+ else window.location.reload();+ });+ timer = setTimeout(check, 3_000);+ // Keeps waiting (and keeps the restore marker), but says so when the restart takes much longer than usual.+ const slowTimer = setTimeout(() => { if (alive) setSlow(true); }, 180_000);+ return () => { alive = false; clearTimeout(timer); clearTimeout(slowTimer); };+ }, [serverRestarts]);+ if (serverRestarts) return <div role="status" className="flex max-w-lg items-center gap-3 text-[14px]">+ <Loader2 aria-hidden="true" size={15} className="shrink-0 animate-spin" />+ <div className="flex flex-col gap-2"><p>{t("backup.serverRestarting")}</p>{slow && <p>{t("backup.serverRestartSlow")}</p>}</div>+ </div>;+ const relaunch = typeof window !== "undefined" && !window.ogb?.remoteClient?.active ? window.ogb?.relaunch : undefined;+ const restart = async () => {+ if (!relaunch || lock.current || restarting) return;+ lock.current = true; setRestarting(true); setError(false);+ try {+ if (!await relaunch()) throw new Error("Restart unavailable");+ } catch {+ lock.current = false; setRestarting(false); setError(true);+ }+ };+ return <div role="status" className="flex max-w-lg flex-col gap-4 text-[14px]">+ <p>{t(relaunch ? "backup.restartDesktop" : "backup.restart")}</p>+ {relaunch && <button type="button" className={`${buttonClass} self-start`} disabled={restarting} onClick={() => void restart()}>{restarting ? t("settings.updates.restartingShort") : t("backup.restartAction")}</button>}+ {!relaunch && onRetry && <button type="button" className={`${buttonClass} self-start`} onClick={onRetry}>{t("connectors.action.retry")}</button>}+ {error && <p role="alert" className="text-[13px] text-danger">{t("backup.restartFailed")}</p>}+ </div>;+}++function pendingRestoreId(): string | null {+ try { return localStorage.getItem(WORKSPACE_RESTORE_MARKER); } catch { return null; }+}++/** Do not mount stale composer caches before the initiating browser recovers. */+export function WorkspaceBackupRecovery({ children }: { children: ReactNode }) {+ const [restoreId] = useState(pendingRestoreId);+ const [ready, setReady] = useState(!restoreId);+ const [error, setError] = useState<string | null>(null);+ const [restartRequired, setRestartRequired] = useState(false);+ const [serverRestarts, setServerRestarts] = useState(false);+ const [attempt, setAttempt] = useState(0);+ useEffect(() => {+ if (!restoreId) return;+ let alive = true;+ setError(null);+ void (async () => {+ const status: BackupStatus = await api("/api/workspace-backup/status");+ if (!alive) return;+ if (status.pendingRestore) { setServerRestarts(status.restarts === true); setRestartRequired(true); return; }+ if (status.lastRestoreId !== restoreId) {+ localStorage.removeItem(WORKSPACE_RESTORE_MARKER);+ setReady(true);+ return;+ }+ const result = await api("/api/workspace-backup/client-state", { method: "POST", body: JSON.stringify({ restoreId }) });+ if (!alive) return;+ applyWorkspaceClientState(result.clientState);+ localStorage.removeItem(WORKSPACE_RESTORE_MARKER);+ window.location.reload();+ })().catch((cause) => { if (alive) setError(cause instanceof Error ? cause.message : String(cause)); });+ return () => { alive = false; };+ }, [restoreId, attempt]);+ if (ready) return children;+ const continueWithoutDrafts = () => {+ try {+ localStorage.removeItem(WORKSPACE_RESTORE_MARKER);+ window.location.reload();+ } catch (cause) { setError(cause instanceof Error ? cause.message : String(cause)); }+ };+ return <main className="flex h-dvh flex-col items-center justify-center gap-4 bg-app p-6 text-ink">+ {restartRequired ? <WorkspaceBackupRestartNotice serverRestarts={serverRestarts} onRetry={() => { setRestartRequired(false); setAttempt((value) => value + 1); }} /> : <p className="max-w-lg text-[14px]">{t("backup.recovering")}</p>}+ {error && <p role="alert" className="max-w-lg break-words text-[13px] text-danger">{error}</p>}+ {error && <button type="button" className={buttonClass} onClick={() => { setRestartRequired(false); setAttempt((value) => value + 1); }}>{t("connectors.action.retry")}</button>}+ {error && <>+ <p className="max-w-lg text-[13px] text-ink-secondary">{t("backup.skipDraftsHint")}</p>+ <button type="button" className="cursor-pointer rounded-lg border border-hairline/50 bg-control px-3 py-2 text-[13px] font-medium text-ink" onClick={continueWithoutDrafts}>{t("backup.skipDrafts")}</button>+ </>}+ </main>;+}diff --git a/src/components/WorkspaceBackupSettings.tsx b/src/components/WorkspaceBackupSettings.tsxindex ba2b9bedfe..b662bce69e 100644--- a/src/components/WorkspaceBackupSettings.tsx+++ b/src/components/WorkspaceBackupSettings.tsx@@ -3,61 +3,14 @@ import { Loader2 } from "lucide-react";import type { WorkspaceBackupSummary } from "../../shared/workspace-backup";import { api } from "@/state/store";import { intlLocale, t } from "@/lib/i18n";-import { applyWorkspaceClientState, collectWorkspaceClientState, WORKSPACE_RESTORE_MARKER } from "@/lib/workspace-backup-client";+import { collectWorkspaceClientState, WORKSPACE_RESTORE_MARKER } from "@/lib/workspace-backup-client";import { LearnMore, SETTINGS_INPUT, SettingRow, SettingsField, SettingsRows } from "./SettingsPrimitives";import { SettingsDialog } from "./settings/SettingsDialog";+import { WorkspaceBackupRestartNotice, type BackupStatus } from "./WorkspaceBackupRecovery";-type BackupStatus = { busy: boolean; pendingRestore?: boolean; restarts?: boolean; lastRestoreId?: string };-const buttonClass = "cursor-pointer inline-flex items-center justify-center gap-2 rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-accent-ink disabled:opacity-40";-const validPassword = (value: string) => value.length >= 12 && value.length <= 1024;+export { WorkspaceBackupRecovery, WorkspaceBackupRestartNotice } from "./WorkspaceBackupRecovery";-/** A renderer reload cannot apply a restore; the owning server must restart. A server that restarts itself (My Cloud)- * is waited for, then the page carries on as after a reload. */-export function WorkspaceBackupRestartNotice({ onRetry, serverRestarts = false }: { onRetry?: () => void; serverRestarts?: boolean } = {}) {- const [restarting, setRestarting] = useState(false);- const [error, setError] = useState(false);- const [slow, setSlow] = useState(false);- const lock = useRef(false);- const retry = useRef(onRetry);- retry.current = onRetry;- useEffect(() => {- if (!serverRestarts) return;- let alive = true;- let timer: ReturnType<typeof setTimeout>;- // A restored workspace may not know this browser's session: a reload shows sign-in.- const check = () => api("/api/workspace-backup/status", { timeoutMs: 10_000 }).then((status: BackupStatus) => status.pendingRestore === false ? "installed" : "wait",- (cause: unknown) => cause instanceof Error && "status" in cause && cause.status === 401 ? "signedOut" : "wait").then((state) => {- if (!alive) return;- if (state === "wait") timer = setTimeout(check, 3_000);- else if (state === "installed" && retry.current) retry.current();- else window.location.reload();- });- timer = setTimeout(check, 3_000);- // Keeps waiting (and keeps the restore marker), but says so when the restart takes much longer than usual.- const slowTimer = setTimeout(() => { if (alive) setSlow(true); }, 180_000);- return () => { alive = false; clearTimeout(timer); clearTimeout(slowTimer); };- }, [serverRestarts]);- if (serverRestarts) return <div role="status" className="flex max-w-lg items-center gap-3 text-[14px]">- <Loader2 aria-hidden="true" size={15} className="shrink-0 animate-spin" />- <div className="flex flex-col gap-2"><p>{t("backup.serverRestarting")}</p>{slow && <p>{t("backup.serverRestartSlow")}</p>}</div>- </div>;- const relaunch = typeof window !== "undefined" && !window.ogb?.remoteClient?.active ? window.ogb?.relaunch : undefined;- const restart = async () => {- if (!relaunch || lock.current || restarting) return;- lock.current = true; setRestarting(true); setError(false);- try {- if (!await relaunch()) throw new Error("Restart unavailable");- } catch {- lock.current = false; setRestarting(false); setError(true);- }- };- return <div role="status" className="flex max-w-lg flex-col gap-4 text-[14px]">- <p>{t(relaunch ? "backup.restartDesktop" : "backup.restart")}</p>- {relaunch && <button type="button" className={`${buttonClass} self-start`} disabled={restarting} onClick={() => void restart()}>{restarting ? t("settings.updates.restartingShort") : t("backup.restartAction")}</button>}- {!relaunch && onRetry && <button type="button" className={`${buttonClass} self-start`} onClick={onRetry}>{t("connectors.action.retry")}</button>}- {error && <p role="alert" className="text-[13px] text-danger">{t("backup.restartFailed")}</p>}- </div>;-}+const validPassword = (value: string) => value.length >= 12 && value.length <= 1024;export function WorkspaceBackupSummaryView({ summary }: { summary: WorkspaceBackupSummary }) {return <div className="rounded-[12px] border-[0.5px] border-(--settings-edge) bg-menu p-3">@@ -267,54 +220,3 @@ export function WorkspaceBackupSettings({ layout = BOTH_ROWS }: { layout?: (rows)}</>;}--function pendingRestoreId(): string | null {- try { return localStorage.getItem(WORKSPACE_RESTORE_MARKER); } catch { return null; }-}--/** Do not mount stale composer caches before the initiating browser recovers. */-export function WorkspaceBackupRecovery({ children }: { children: ReactNode }) {- const [restoreId] = useState(pendingRestoreId);- const [ready, setReady] = useState(!restoreId);- const [error, setError] = useState<string | null>(null);- const [restartRequired, setRestartRequired] = useState(false);- const [serverRestarts, setServerRestarts] = useState(false);- const [attempt, setAttempt] = useState(0);- useEffect(() => {- if (!restoreId) return;- let alive = true;- setError(null);- void (async () => {- const status: BackupStatus = await api("/api/workspace-backup/status");- if (!alive) return;- if (status.pendingRestore) { setServerRestarts(status.restarts === true); setRestartRequired(true); return; }- if (status.lastRestoreId !== restoreId) {- localStorage.removeItem(WORKSPACE_RESTORE_MARKER);- setReady(true);- return;- }- const result = await api("/api/workspace-backup/client-state", { method: "POST", body: JSON.stringify({ restoreId }) });- if (!alive) return;- applyWorkspaceClientState(result.clientState);- localStorage.removeItem(WORKSPACE_RESTORE_MARKER);- window.location.reload();- })().catch((cause) => { if (alive) setError(cause instanceof Error ? cause.message : String(cause)); });- return () => { alive = false; };- }, [restoreId, attempt]);- if (ready) return children;- const continueWithoutDrafts = () => {- try {- localStorage.removeItem(WORKSPACE_RESTORE_MARKER);- window.location.reload();- } catch (cause) { setError(cause instanceof Error ? cause.message : String(cause)); }- };- return <main className="flex h-dvh flex-col items-center justify-center gap-4 bg-app p-6 text-ink">- {restartRequired ? <WorkspaceBackupRestartNotice serverRestarts={serverRestarts} onRetry={() => { setRestartRequired(false); setAttempt((value) => value + 1); }} /> : <p className="max-w-lg text-[14px]">{t("backup.recovering")}</p>}- {error && <p role="alert" className="max-w-lg break-words text-[13px] text-danger">{error}</p>}- {error && <button type="button" className={buttonClass} onClick={() => { setRestartRequired(false); setAttempt((value) => value + 1); }}>{t("connectors.action.retry")}</button>}- {error && <>- <p className="max-w-lg text-[13px] text-ink-secondary">{t("backup.skipDraftsHint")}</p>- <button type="button" className="cursor-pointer rounded-lg border border-hairline/50 bg-control px-3 py-2 text-[13px] font-medium text-ink" onClick={continueWithoutDrafts}>{t("backup.skipDrafts")}</button>- </>}- </main>;-}diff --git a/src/components/bot-access/HeaderShare.dom.test.ts b/src/components/bot-access/HeaderShare.dom.test.tsindex eec44c4bc9..869000b960 100644--- a/src/components/bot-access/HeaderShare.dom.test.ts+++ b/src/components/bot-access/HeaderShare.dom.test.ts@@ -17,6 +17,7 @@ vi.mock("@/state/store", async (importOriginal) => ({const { setTeamPeople } = await import("@/state/team-people");const { HeaderShare, sharedWith } = await import("./HeaderShare");+await (await import("../lazy-screens")).ShareBotDialog.preload();const RUI = { email: "[email protected]", name: "Rui", role: "admin" };const MEMBERS = ["Marta", "Bob", "Cara", "Dan", "Eve"].map((name) => ({ email: `${name.toLowerCase()}@acme.test`, name, role: "member" }));diff --git a/src/components/bot-access/ShareBotButton.tsx b/src/components/bot-access/ShareBotButton.tsxindex 4528dd9e16..a4b6303d2a 100644--- a/src/components/bot-access/ShareBotButton.tsx+++ b/src/components/bot-access/ShareBotButton.tsx@@ -5,7 +5,8 @@ import { Share } from "lucide-react";import { t } from "@/lib/i18n";import { useStore, type Bot } from "@/state/store";import { saveAccess } from "./access";-import { ShareBotDialog, type AccessChange } from "./ShareBotDialog";+import { ShareBotDialog } from "../lazy-screens";+import type { AccessChange } from "./ShareBotDialog";const TOAST_MS = 6_000;diff --git a/src/components/bot-access/ShareBotDialog.dom.test.ts b/src/components/bot-access/ShareBotDialog.dom.test.tsindex 696f91c0e1..78b7dc6445 100644--- a/src/components/bot-access/ShareBotDialog.dom.test.ts+++ b/src/components/bot-access/ShareBotDialog.dom.test.ts@@ -21,6 +21,7 @@ vi.mock("@/state/store", async (importOriginal) => ({const { setTeamPeople } = await import("@/state/team-people");const { ShareBotButton } = await import("./ShareBotButton");+await (await import("../lazy-screens")).ShareBotDialog.preload();const ADA = { email: "[email protected]", name: "Ada", role: "admin" };const BOB = { email: "[email protected]", name: "Bob", role: "member" };diff --git a/src/components/lazy-screens.test.ts b/src/components/lazy-screens.test.tsindex fd5b3001b0..3bf40c3cfc 100644--- a/src/components/lazy-screens.test.ts+++ b/src/components/lazy-screens.test.ts@@ -1,6 +1,6 @@// @vitest-environment happy-domimport { existsSync, readFileSync } from "node:fs";-import { dirname, join, sep } from "node:path";+import { dirname, join, relative, sep } from "node:path";import { fileURLToPath } from "node:url";import { createElement, useState } from "react";import { flushSync } from "react-dom";@@ -155,7 +155,7 @@ describe("preloadScreens", () => {it("a page on this machine fetches nothing ahead: each screen loads when it opens", () => {vi.useFakeTimers();const preloads = stubPreloads();- expect(preloads.length).toBe(24);+ expect(preloads.length).toBe(31);for (const host of ["127.0.0.1", "localhost", "[::1]"]) preloadScreens(host);vi.runAllTimers();for (const preload of preloads) expect(preload).not.toHaveBeenCalled();@@ -253,7 +253,7 @@ describe("launch bundle", () => {}}// join() writes backslashes on Windows.- return new Set([...seen].map((file) => file.slice(srcRoot.length + 1).split(sep).join("/")));+ return new Set([...seen].map((file) => relative(srcRoot, file).split(sep).join("/")));};it("leaves the on-request screens out of it", () => {@@ -264,9 +264,12 @@ describe("launch bundle", () => {"ActivityPanel", "BotSettingsDialog", "CloudAddDialog", "ComputerPanel", "InspectorPanel", "KeyboardShortcutsModal","LocalVmWorkspace", "NewBotDialog", "PhoneAppDialog", "PhoneSetupFlow", "PluginsPanel", "published-apps/PublishedAppsPage", "RemoteAgentSettingsPanel", "remote-desktop-panel", "RoutineCalendarPage","RoutinesPage", "SettingsModal", "ShareDepartmentDialog", "ImportDialog", "TeamLibraryPanel", "TeamMapPage", "team-files/TeamFilesPage", "TriggersPage", "WebhookTrigger", "room-panel/RoomPanel",+ "inbox/InboxPanel", "TeamDialog", "TeamSettingsDialog", "VoiceSetupDialog", "usage/TraceView", "bot-access/ShareBotDialog", "CommandAllowlistDialog", "WorkspaceBackupSettings",].map((name) => `components/${name}.tsx`);expect(deferred.filter((file) => reached.has(file))).toEqual([]);expect(reached.has("lib/template-details.ts"), "the team library brings the YAML parser in").toBe(false);+ expect(reached.has("../shared/browser-mates.ts")).toBe(true);+ expect(reached.has("../shared/logins.ts"), "saved logins bring the public-suffix list in").toBe(false);});it("the sign-in and home pages leave the app out", () => {diff --git a/src/components/lazy-screens.tsx b/src/components/lazy-screens.tsxindex 847f742185..2ac8711591 100644--- a/src/components/lazy-screens.tsx+++ b/src/components/lazy-screens.tsx@@ -82,6 +82,13 @@ export const SettingsModal = lazyScreen("SettingsModal", async () => (await impoexport const TeamMapPage = lazyScreen("TeamMapPage", async () => (await import("./TeamMapPage")).TeamMapPage);export const PublishedAppsPage = lazyScreen("PublishedAppsPage", async () => (await import("./published-apps/PublishedAppsPage")).PublishedAppsPage);export const AnnouncementsPage = lazyScreen("AnnouncementsPage", async () => (await import("./announcements/AnnouncementsPage")).AnnouncementsPage);+export const InboxPanel = lazyScreen("InboxPanel", async () => (await import("./inbox/InboxPanel")).InboxPanel);+export const TeamDialog = lazyScreen("TeamDialog", async () => (await import("./TeamDialog")).TeamDialog);+export const TeamSettingsDialog = lazyScreen("TeamSettingsDialog", async () => (await import("./TeamSettingsDialog")).TeamSettingsDialog);+export const VoiceSetupDialog = lazyScreen("VoiceSetupDialog", async () => (await import("./VoiceSetupDialog")).VoiceSetupDialog);+export const TraceDialog = lazyScreen("TraceDialog", async () => (await import("./usage/TraceView")).TraceDialog);+export const ShareBotDialog = lazyScreen("ShareBotDialog", async () => (await import("./bot-access/ShareBotDialog")).ShareBotDialog);+export const CommandAllowlistDialog = lazyScreen("CommandAllowlistDialog", async () => (await import("./CommandAllowlistDialog")).CommandAllowlistDialog);// Rarely opened, so never fetched ahead. The team library is what brings the YAML parser in.export const CloudAddDialog = lazyScreen("CloudAddDialog", async () => (await import("./CloudAddDialog")).CloudAddDialog);@@ -96,7 +103,8 @@ export const TeamFilesPage = lazyScreen("TeamFilesPage", async () => (await impo// Most opened first: a Cloud page fetches these in this order.const SCREENS = [SettingsModal, BotSettingsDialog, PluginsPanel, ComputerPanel, TriggersPage, ActivityPanel, FilesView, InspectorPanel, KeyboardShortcutsModal,- LocalVmWorkspace, NewBotDialog, RemoteAgentSettingsPanel, RemoteDesktopPanel, RoomPanel, TeamMapPage, PublishedAppsPage,+ LocalVmWorkspace, NewBotDialog, RemoteAgentSettingsPanel, RemoteDesktopPanel, RoomPanel, TeamMapPage, PublishedAppsPage, InboxPanel,+ TeamSettingsDialog, TeamDialog, VoiceSetupDialog, TraceDialog, ShareBotDialog, CommandAllowlistDialog,];if (typeof location !== "undefined" && new URLSearchParams(location.search).has("desktop-settings")) {diff --git a/src/components/settings/closed-scale.test.ts b/src/components/settings/closed-scale.test.tsindex 6a01f7871b..6c1fef16bb 100644--- a/src/components/settings/closed-scale.test.ts+++ b/src/components/settings/closed-scale.test.ts@@ -72,6 +72,7 @@ const FILES = ["src/components/VpsComputersCard.tsx","src/components/WindowFrameBar.tsx","src/components/WorkersAiKeyCard.tsx",+ "src/components/WorkspaceBackupRecovery.tsx","src/components/WorkspaceBackupSettings.tsx","src/components/keys/KeyPanels.tsx","src/components/keys/KeyRow.tsx",@@ -123,7 +124,7 @@ const DEBT: Record<string, number> = {"src/components/UsageSection.tsx": 11,"src/components/VaultSettings.tsx": 6,"src/components/VpsComputersCard.tsx": 5,- "src/components/WorkspaceBackupSettings.tsx": 1,+ "src/components/WorkspaceBackupRecovery.tsx": 1,"src/components/keys/KeyRow.tsx": 3,"src/components/keys/KeysPage.tsx": 2,"src/components/usage/TraceWaterfall.tsx": 14,diff --git a/src/components/thread-approval.tsx b/src/components/thread-approval.tsxindex 40772de1e2..e4bded9ad5 100644--- a/src/components/thread-approval.tsx+++ b/src/components/thread-approval.tsx@@ -5,7 +5,7 @@ import type { Bot } from "@/state/store";import { useStoreDispatch, useStoreSelector } from "@/state/store-select";import { approvalModeFor, type ApprovalMode } from "../../shared/approval-mode";import type { ApprovalModeSelector } from "./ApprovalModeSelector";-import { CommandAllowlistDialog } from "./CommandAllowlistDialog";+import { CommandAllowlistDialog } from "./lazy-screens";import { useDesktopCapabilities } from "./DesktopCapabilities";import { LocalComputerAutoWarning } from "./LocalComputerAutoWarning";