Skip to content

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

New bot defaults choose where a bot works

Kevinc4d5998705a3
diff --git a/src/components/ComputerPanel.simple.test.ts b/src/components/ComputerPanel.simple.test.ts
index ce5a402a90..9bc80b8bbb 100644
--- a/src/components/ComputerPanel.simple.test.ts
+++ b/src/components/ComputerPanel.simple.test.ts
@@ -102,6 +102,7 @@ vi.mock("@/state/store", async (importOriginal) => ({
}));
const { ComputerPanel } = await import("./ComputerPanel");
+const { WorksOnGrid } = await import("./WorksOnGrid");
const { ComputerFilesPane } = await import("./ComputerFilesPane");
const { CloudBackendPicker } = await import("./CloudBackendPicker");
const { LocalComputerAutoWarning } = await import("./LocalComputerAutoWarning");
@@ -117,6 +118,10 @@ function nodes(value: ReactNode): Node[] {
return [node, ...nodes(node.props.children)];
});
}
+function destinations(rendered: { nodes: Node[] }): Node[] {
+ const grid = rendered.nodes.find((node) => node.type === WorksOnGrid)!;
+ return nodes(WorksOnGrid(grid.props as unknown as Parameters<typeof WorksOnGrid>[0])).filter((node) => node.type === "button");
+}
function text(value: ReactNode): string {
return Children.toArray(value).map((child) => {
if (typeof child === "string" || typeof child === "number") return String(child);
@@ -397,8 +402,7 @@ describe("Where the bot works", () => {
fixture.values = [];
phaseIndex = -1;
const advanced = render(makeBot());
- const group = advanced.nodes.find((node) => node.props.role === "group" && node.props["aria-label"] === "Computer destination")!;
- const card = nodes(group.props.children).filter((node) => node.type === "button")[1]!;
+ const card = destinations(advanced)[1]!;
expect(card.props.disabled).toBe(true);
expect(text(card.props.children)).toBe("Cloud desktopNot with this model");
expect(card.props.title).toBe(tile.props.title);
@@ -473,8 +477,8 @@ describe("Where the bot works", () => {
fixture.dispatch = vi.fn();
const start = makeBot({ computer: patch.computer === "off" ? "cloud" : "off" });
const rendered = render(start);
- const group = rendered.nodes.find((node) => node.props.role === "group" && node.props["aria-label"] === "Computer destination")!;
- const option = nodes(group.props.children).filter((node) => node.type === "button")[index]!;
+ const group = advanced ? null : rendered.nodes.find((node) => node.props.role === "group" && node.props["aria-label"] === "Computer destination")!;
+ const option = (group ? nodes(group.props.children).filter((node) => node.type === "button") : destinations(rendered))[index]!;
(option.props.onClick as () => void)();
calls.push((fixture.dispatch as ReturnType<typeof vi.fn>).mock.calls);
}
diff --git a/src/components/ComputerPanel.tsx b/src/components/ComputerPanel.tsx
index 70d640c707..e8caeb4675 100644
--- a/src/components/ComputerPanel.tsx
+++ b/src/components/ComputerPanel.tsx
@@ -5,7 +5,7 @@ import { Switch } from "./SettingsPrimitives";
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
import { z } from "zod";
import { waitForLocalVmReady } from "@/lib/local-vm-readiness";
-import { CalendarClock, ChevronRight, Columns2, Box, Check, Cloud, Sparkles, Globe, Hand, Loader2, Maximize2, Monitor, Moon, Power, Settings, X } from "lucide-react";
+import { CalendarClock, ChevronRight, Columns2, Globe, Hand, Loader2, Maximize2, Monitor, Moon, Power, Settings, X } from "lucide-react";
import { api, ApiError, currentTaskBot, useStore, type Bot, type ConfigStatus } from "@/state/store";
import { setAdvancedMode, useAdvancedMode } from "@/lib/interface-mode";
import { ComputerFilesPane } from "./ComputerFilesPane";
@@ -19,6 +19,7 @@ import { listenLiveFrames } from "@/lib/live-events";
import { CloudScreenPreview } from "./CloudScreenPreview";
import { isActiveTurnRefusal, isRemoteScreenshotContention } from "@/lib/remote-desktop";
import { CloudBackendPicker } from "./CloudBackendPicker";
+import { placeManagedBy, WORKS_ON_CHOICES, WorksOnGrid } from "./WorksOnGrid";
import { useDesktopCapabilities } from "./DesktopCapabilities";
import { RoutinesSection } from "./bot-settings/RoutinesSection";
import { routineRunLabel, routineRunTone } from "@/lib/routine-display";
@@ -1112,17 +1113,9 @@ export function ComputerPanel({
: undefined;
const cloudView = viewOf("cloud", cloudRefused);
const autoView = viewOf("auto");
- const placeOptions = ([
- [null, "vm.dest.auto", "computer.dest.autoDesc", Sparkles],
- ["cloud", "place.cloud", "computer.dest.cloudDesc", Cloud],
- ["vm", "vm.dest.vm", "computer.dest.vmDesc", Box],
- ["local", "vm.dest.local", "computer.dest.localDesc", Monitor],
- ["browser", "vm.dest.browser", "computer.dest.browserDesc", Globe],
- ["off", "vm.dest.off", "computer.dest.offDesc", Power],
- ] as const).filter(([mode]) => mode === null || mode === "off" || (placeOffered(mode, state.config) && !(mode === "local" && capabilities.localComputer.reasonCode === "remote-server"))).map(([mode, labelKey, descriptionKey, Icon]) => {
+ const placeOptions = WORKS_ON_CHOICES.filter(([mode]) => mode === null || mode === "off" || (placeOffered(mode, state.config) && !(mode === "local" && capabilities.localComputer.reasonCode === "remote-server"))).map(([mode, labelKey, descriptionKey, Icon]) => {
const selected = mode === null ? !profileBot.computer : profileBot.computer === mode;
- const managedKind = mode === "local" ? "thisComputer" : mode === "vm" ? "localVm" : mode === "cloud" ? (profileBot.cloudBackend === "vps" ? "vps" : "box") : null;
- const managedBy = managedPolicy && managedKind && !managedPolicy.computers[managedKind] ? t("policy.managedBy", { organization: managedPolicy.organizationName }) : undefined;
+ const managedBy = placeManagedBy(mode, profileBot.cloudBackend, managedPolicy);
const view = mode === null ? autoView : mode === "cloud" ? cloudView : viewOf(mode);
const disabled = Boolean(managedBy) || placeBlocked(view);
const issue = !managedBy && placeHasIssue(view);
@@ -1686,35 +1679,7 @@ export function ComputerPanel({
<p className="mt-1 text-[12px] leading-5 text-ink-secondary">
{t(state.config?.cloudHome ? "computer.worksOnHintCloudHome" : "computer.worksOnHint")}
</p>
- <div role="group" aria-label={t("computer.destinationAria")} className="mt-3 grid auto-rows-fr grid-cols-2 gap-2">
- {placeOptions.map(({ mode, labelKey, descriptionKey, Icon, selected, managedBy, disabled, unavailableTitle, issue, view }) => (
- <button
- key={mode ?? "auto"}
- disabled={disabled}
- title={unavailableTitle}
- onClick={() => selectPlace(mode)}
- type="button"
- aria-pressed={selected}
- className={cn(
- "min-w-0 rounded-lg border px-2.5 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-card",
- selected
- ? "border-accent/60 bg-accent/10 text-ink"
- : "border-hairline/50 bg-panel/30 text-ink-secondary",
- disabled
- ? "cursor-not-allowed"
- : "hover:border-accent/40 hover:bg-control/60",
- )}
- >
- <span className="flex items-center gap-2 text-[12px] font-medium leading-4">
- {selected ? <Check size={14} className="shrink-0 text-accent" /> : <Icon size={14} className="shrink-0 text-ink-secondary" />}
- <span>{t(labelKey)}</span>
- </span>
- <span className="mt-1.5 block text-[11px] leading-4 text-ink-secondary">
- {managedBy ?? (issue ? view.short : t(descriptionKey))}
- </span>
- </button>
- ))}
- </div>
+ <WorksOnGrid options={placeOptions} onSelect={selectPlace} />
{livePin && (
<p className="mt-2 text-[12px] leading-5 text-ink-secondary" data-testid="place-pinned-note">
{t("place.pinnedNote", { place: t(placeLabelKey(livePin)) })}
diff --git a/src/components/WorksOnGrid.tsx b/src/components/WorksOnGrid.tsx
new file mode 100644
index 0000000000..dc9c4736b1
--- /dev/null
+++ b/src/components/WorksOnGrid.tsx
@@ -0,0 +1,71 @@
+import { Box, Check, Cloud, Globe, Monitor, Power, Sparkles } from "lucide-react";
+import type { LucideIcon } from "lucide-react";
+import type { Bot, ConfigStatus } from "@/state/store";
+import type { PlaceView } from "../../shared/place-view";
+import { cn } from "@/lib/cn";
+import { t } from "@/lib/i18n";
+import type { Place } from "@/lib/place";
+import type { LocaleKey } from "@/locales";
+
+export type WorksOnMode = Place | "off" | null;
+
+export const WORKS_ON_CHOICES = [
+ [null, "vm.dest.auto", "computer.dest.autoDesc", Sparkles],
+ ["cloud", "place.cloud", "computer.dest.cloudDesc", Cloud],
+ ["vm", "vm.dest.vm", "computer.dest.vmDesc", Box],
+ ["local", "vm.dest.local", "computer.dest.localDesc", Monitor],
+ ["browser", "vm.dest.browser", "computer.dest.browserDesc", Globe],
+ ["off", "vm.dest.off", "computer.dest.offDesc", Power],
+] as const satisfies ReadonlyArray<readonly [WorksOnMode, LocaleKey, LocaleKey, LucideIcon]>;
+
+export function placeManagedBy(mode: WorksOnMode, cloudBackend: Bot["cloudBackend"], policy: ConfigStatus["managedPolicy"]): string | undefined {
+ const kind = mode === "local" ? "thisComputer" : mode === "vm" ? "localVm" : mode === "cloud" ? (cloudBackend === "vps" ? "vps" : "box") : null;
+ return policy && kind && !policy.computers[kind] ? t("policy.managedBy", { organization: policy.organizationName }) : undefined;
+}
+
+export interface WorksOnOption {
+ mode: WorksOnMode;
+ labelKey: LocaleKey;
+ descriptionKey: LocaleKey;
+ Icon: LucideIcon;
+ selected: boolean;
+ managedBy?: string;
+ disabled: boolean;
+ unavailableTitle?: string;
+ issue: boolean;
+ view: PlaceView;
+}
+
+export function WorksOnGrid({ options, onSelect }: { options: readonly WorksOnOption[]; onSelect: (mode: WorksOnMode) => void }) {
+ return (
+ <div role="group" aria-label={t("computer.destinationAria")} className="mt-3 grid auto-rows-fr grid-cols-2 gap-2">
+ {options.map(({ mode, labelKey, descriptionKey, Icon, selected, managedBy, disabled, unavailableTitle, issue, view }) => (
+ <button
+ key={mode ?? "auto"}
+ disabled={disabled}
+ title={unavailableTitle}
+ onClick={() => onSelect(mode)}
+ type="button"
+ aria-pressed={selected}
+ className={cn(
+ "min-w-0 rounded-lg border px-2.5 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-card",
+ selected
+ ? "border-accent/60 bg-accent/10 text-ink"
+ : "border-hairline/50 bg-panel/30 text-ink-secondary",
+ disabled
+ ? "cursor-not-allowed"
+ : "hover:border-accent/40 hover:bg-control/60",
+ )}
+ >
+ <span className="flex items-center gap-2 text-[12px] font-medium leading-4">
+ {selected ? <Check size={14} className="shrink-0 text-accent" /> : <Icon size={14} className="shrink-0 text-ink-secondary" />}
+ <span>{t(labelKey)}</span>
+ </span>
+ <span className="mt-1.5 block text-[11px] leading-4 text-ink-secondary">
+ {managedBy ?? (issue ? view.short : t(descriptionKey))}
+ </span>
+ </button>
+ ))}
+ </div>
+ );
+}
diff --git a/src/components/bot-settings/AccessSection.test.ts b/src/components/bot-settings/AccessSection.test.ts
index a1110497df..b787bd884b 100644
--- a/src/components/bot-settings/AccessSection.test.ts
+++ b/src/components/bot-settings/AccessSection.test.ts
@@ -2,7 +2,8 @@ import { Children, createElement, isValidElement, type ReactElement, type ReactN
import { renderToStaticMarkup } from "react-dom/server";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-import { StoreProvider, type Bot, type ConfigStatus } from "@/state/store";
+import { api, StoreProvider, type Bot, type ConfigStatus } from "@/state/store";
+import { BotEditorContext } from "./BotEditorContext";
import type { useBotSettingsDerived } from "./useBotSettingsDerived";
const fixture = vi.hoisted(() => ({
@@ -28,7 +29,7 @@ vi.mock("@/lib/mcp-servers", async (importOriginal) => ({
// DesktopCapabilities reads window.ogb at module scope, and this suite runs in the node environment.
vi.mock("../DesktopCapabilities", () => ({
- useDesktopCapabilities: () => ({ capabilities: { host: { homeDir: undefined } } }),
+ useDesktopCapabilities: () => ({ capabilities: { host: { homeDir: undefined }, localComputer: { available: false, reasonCode: "unsupported" } } }),
}));
const { AccessSection } = await import("./AccessSection");
@@ -208,6 +209,27 @@ describe("AccessSection Works on", () => {
]);
});
+ it("offers the place itself in a bot not made yet, which has no Screen panel to open", () => {
+ const derived = makeDerived();
+ const draft = (bot: Bot) => {
+ let tree!: ReturnType<typeof AccessSection>;
+ function Capture() { tree = AccessSection({ bot, derived }); return tree; }
+ const editor = createElement(BotEditorContext.Provider, { value: { request: api, draft: true } }, createElement(Capture));
+ return { html: renderToStaticMarkup(createElement(StoreProvider, null, editor)), tree };
+ };
+ const { html } = draft(makeBot({ name: "" }));
+ expect(html).not.toContain("Open the Screen panel");
+ expect(html).not.toContain("Auto cloud preference");
+ expect(html).toContain("Works on");
+ expect(html).toContain("Cloud desktop");
+ expect(html).toMatch(/aria-pressed="true"[^>]*>.*?Auto/);
+
+ fixture.config = { box: { configured: true } } as Partial<ConfigStatus>;
+ const chosen = draft(makeBot({ computer: "cloud" }));
+ expect(chosen.html).toMatch(/aria-pressed="true"[^>]*>.*?Cloud desktop/);
+ expect(chosen.html).toContain("Cloud backend");
+ });
+
it("hides the Boat or VPS choice on My Cloud, whose cloud computers are the plan's", () => {
expect(render(makeBot())).toContain("Cloud backend");
fixture.config = { cloudHome: true } as Partial<ConfigStatus>;
diff --git a/src/components/bot-settings/AccessSection.tsx b/src/components/bot-settings/AccessSection.tsx
index 8956778bb4..1e0610777f 100644
--- a/src/components/bot-settings/AccessSection.tsx
+++ b/src/components/bot-settings/AccessSection.tsx
@@ -8,11 +8,14 @@ import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
import type { LocaleKey } from "@/locales";
import { mcpServersForBot, mcpServersOfBot, useMcpServers } from "@/lib/mcp-servers";
-import { placeFacts, placeViewFor, usePlaceSeat } from "@/lib/place-view";
+import { instanceSupportsLocalComputer, localComputerDisabledReason, localComputerSelectable } from "@/lib/local-computer";
+import { placeOffered } from "@/lib/place";
+import { placeBlocked, placeFacts, placeHasIssue, placeViewFor, usePlaceSeat, type PlaceSeat } from "@/lib/place-view";
import { shortPath } from "@/lib/short-path";
import { isOwnThreadFolder } from "../../../shared/thread-folder";
import { useDesktopCapabilities } from "../DesktopCapabilities";
import { CloudBackendPicker } from "../CloudBackendPicker";
+import { placeManagedBy, WORKS_ON_CHOICES, WorksOnGrid, type WorksOnMode } from "../WorksOnGrid";
import { Switch } from "../SettingsPrimitives";
import { PhoneAppsCard } from "./PhoneAppsCard";
import { ProposalStatus } from "./ProposalStatus";
@@ -602,7 +605,7 @@ export function CloudPreference({ bot, patch }: { bot: Bot; patch: ReturnType<ty
if (!cloudPreferenceShown(bot, state.config)) return null;
return (
<>
- {!bot.computer && (
+ {!bot.computer && !draft && (
<div className="mt-3 rounded-lg bg-inset px-3 py-2.5 text-[12px] leading-relaxed text-ink-secondary">
<span className="font-medium text-ink">{t("botAccess.cloud.autoTitle")}</span>{" "}
{t("botAccess.cloud.autoDescription")}
@@ -633,6 +636,35 @@ export function CloudPreference({ bot, patch }: { bot: Bot; patch: ReturnType<ty
);
}
+/** A bot not made yet has no Screen panel to open, so its place is chosen here. */
+function DraftWorksOn({ bot, patch, seat }: { bot: Bot; patch: ReturnType<typeof useBotSettingsDerived>["patch"]; seat: PlaceSeat }) {
+ const { state } = useStore();
+ const { capabilities } = useDesktopCapabilities();
+ const providerSupportsLocal = instanceSupportsLocalComputer(state.instances, bot);
+ const options = WORKS_ON_CHOICES.filter(([mode]) => mode === null || mode === "off" || placeOffered(mode, state.config)).map(([mode, labelKey, descriptionKey, Icon]) => {
+ const view = placeViewFor(placeFacts({
+ bot, place: mode ?? "auto", seat, config: state.config, instances: state.instances,
+ local: {
+ ready: localComputerSelectable({ capabilities, providerSupportsLocal }),
+ reason: localComputerDisabledReason({ capabilities, providerSupportsLocal }) ?? t("computer.unavailableLocal"),
+ },
+ }));
+ const managedBy = placeManagedBy(mode, bot.cloudBackend, state.config?.managedPolicy);
+ return {
+ mode, labelKey, descriptionKey, Icon, view, managedBy,
+ selected: mode === null ? !bot.computer : bot.computer === mode,
+ disabled: Boolean(managedBy) || placeBlocked(view),
+ issue: !managedBy && placeHasIssue(view),
+ };
+ });
+ const choose = (mode: WorksOnMode) => patch(mode === "browser" ? { computer: mode, browser: true } : { computer: mode });
+ return <>
+ <div className="text-[15px] font-medium text-ink">{t("computer.worksOn")}</div>
+ <p className="mt-1 text-[12px] leading-5 text-ink-secondary">{t(state.config?.cloudHome ? "computer.worksOnHintCloudHome" : "computer.worksOnHint")}</p>
+ <WorksOnGrid options={options} onSelect={choose} />
+ </>;
+}
+
export type AccessPart = "worksOn" | "folder" | "apps" | "phone" | "xResearch" | "mcp" | "tools" | "browser" | "webhooks" | "always";
export function AccessSection({
@@ -678,18 +710,20 @@ export function AccessSection({
return (
<div className="flex flex-col gap-4">
{shows("worksOn") && <div className="rounded-xl bg-card p-4" data-testid="access-works-on">
- <div className="text-[15px] font-medium text-ink">{t("access.worksOn", { name: bot.name, short: worksOn.short })}</div>
- <ProposalStatus bot={bot} kind="owner" />
- <button
- type="button"
- onClick={() => {
- dispatch({ type: "toggleSettings", open: false });
- dispatch({ type: "toggleComputer", open: true });
- }}
- className="mt-3 rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover"
- >
- {t("place.action.openComputerPanel")}
- </button>
+ {draft ? <DraftWorksOn bot={bot} patch={patch} seat={placeSeat} /> : <>
+ <div className="text-[15px] font-medium text-ink">{t("access.worksOn", { name: bot.name, short: worksOn.short })}</div>
+ <ProposalStatus bot={bot} kind="owner" />
+ <button
+ type="button"
+ onClick={() => {
+ dispatch({ type: "toggleSettings", open: false });
+ dispatch({ type: "toggleComputer", open: true });
+ }}
+ className="mt-3 rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover"
+ >
+ {t("place.action.openComputerPanel")}
+ </button>
+ </>}
<CloudPreference bot={bot} patch={patch} />
</div>}