Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

feat(settings): add bot workspace sharing mode (#23)

Leo093fb394b760
diff --git a/apps/server/src/serverSettings.test.ts b/apps/server/src/serverSettings.test.ts
index 521865839..3ebf646cc 100644
--- a/apps/server/src/serverSettings.test.ts
+++ b/apps/server/src/serverSettings.test.ts
@@ -923,6 +923,23 @@ it.layer(NodeServices.layer)("server settings", (it) => {
}).pipe(Effect.provide(makeServerSettingsLayer())),
);
+ it.effect("persists shared bot sandbox and browser sharing", () =>
+ Effect.gen(function* () {
+ const serverSettings = yield* ServerSettingsModule.ServerSettingsService;
+ const serverConfig = yield* ServerConfig.ServerConfig;
+ const fileSystem = yield* FileSystem.FileSystem;
+
+ const next = yield* serverSettings.updateSettings({
+ botSandboxBrowserSharing: "shared",
+ });
+
+ assert.equal(next.botSandboxBrowserSharing, "shared");
+ const raw = yield* fileSystem.readFileString(serverConfig.settingsPath);
+ // @effect-diagnostics-next-line preferSchemaOverJson:off
+ assert.equal(JSON.parse(raw).botSandboxBrowserSharing, "shared");
+ }).pipe(Effect.provide(makeServerSettingsLayer())),
+ );
+
it.effect("writes non-default settings and explicit optional provider defaults to disk", () =>
Effect.gen(function* () {
const serverSettings = yield* ServerSettingsModule.ServerSettingsService;
diff --git a/apps/web/src/components/settings/BotSandboxBrowserSharingSettings.test.tsx b/apps/web/src/components/settings/BotSandboxBrowserSharingSettings.test.tsx
new file mode 100644
index 000000000..12a451092
--- /dev/null
+++ b/apps/web/src/components/settings/BotSandboxBrowserSharingSettings.test.tsx
@@ -0,0 +1,76 @@
+import type { ReactElement } from "react";
+import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
+
+import { visitElements } from "../../test/reactElementTree";
+import { reactHookHarness as hooks } from "../../test/reactHookHarness";
+
+vi.mock("react", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("react")>();
+ const { reactHookHarness } = await import("../../test/reactHookHarness");
+ return {
+ ...actual,
+ useCallback: reactHookHarness.useCallback,
+ useMemo: reactHookHarness.useMemo,
+ useRef: reactHookHarness.useRef,
+ useState: reactHookHarness.useState,
+ };
+});
+
+vi.mock("react/compiler-runtime", async () => {
+ const { reactHookHarness } = await import("../../test/reactHookHarness");
+ return { c: reactHookHarness.useMemoCache };
+});
+
+import { BotSandboxBrowserSharingSettings } from "./SettingsPanels";
+
+function renderSetting(
+ value: "separate" | "shared",
+ onChange: (value: "separate" | "shared") => void,
+) {
+ hooks.beginRender();
+ return BotSandboxBrowserSharingSettings({ value, onChange }) as ReactElement<
+ Record<string, unknown>
+ >;
+}
+
+function findElement(
+ tree: ReactElement<Record<string, unknown>>,
+ predicate: (props: Record<string, unknown>) => boolean,
+) {
+ const element = visitElements(tree, ({ props }) => predicate(props));
+ if (!element) throw new Error("Expected setting element was not rendered.");
+ return element;
+}
+
+function call(handler: unknown, ...args: ReadonlyArray<unknown>) {
+ if (typeof handler !== "function") throw new Error("Expected an event handler.");
+ handler(...args);
+}
+
+describe("BotSandboxBrowserSharingSettings", () => {
+ beforeEach(() => hooks.reset());
+
+ it("asks before changing the workspace mode", () => {
+ const onChange = vi.fn();
+ let tree = renderSetting("separate", onChange);
+ call(
+ findElement(tree, (props) => props.onValueChange !== undefined).props.onValueChange,
+ "shared",
+ );
+ tree = renderSetting("separate", onChange);
+
+ expect(onChange).not.toHaveBeenCalled();
+ call(findElement(tree, (props) => props.children === "Change mode").props.onClick);
+ expect(onChange).toHaveBeenCalledWith("shared");
+ });
+
+ it("ignores invalid values", () => {
+ const onChange = vi.fn();
+ const tree = renderSetting("separate", onChange);
+ call(
+ findElement(tree, (props) => props.onValueChange !== undefined).props.onValueChange,
+ "per-thread",
+ );
+ expect(onChange).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx
index e057b8b92..775c47af9 100644
--- a/apps/web/src/components/settings/SettingsPanels.tsx
+++ b/apps/web/src/components/settings/SettingsPanels.tsx
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useAtomValue } from "@effect/atom-react";
import {
type BackgroundActivityProfile,
+ type BotSandboxBrowserSharing,
type DesktopUpdateChannel,
ProviderDriverKind,
type ScopedThreadRef,
@@ -163,6 +164,11 @@ const TIMESTAMP_FORMAT_LABELS = {
"24-hour": "24-hour",
} as const;
+const BOT_SANDBOX_BROWSER_SHARING_LABELS: Record<BotSandboxBrowserSharing, string> = {
+ shared: "Shared",
+ separate: "Separate",
+};
+
const BACKGROUND_ACTIVITY_PROFILE_LABELS: Record<BackgroundActivityProfile, string> = {
balanced: "Balanced",
performance: "Performance",
@@ -525,6 +531,9 @@ export function useSettingsRestore(onRestored?: () => void) {
DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks
? ["Provider update checks"]
: []),
+ ...(settings.botSandboxBrowserSharing !== DEFAULT_UNIFIED_SETTINGS.botSandboxBrowserSharing
+ ? ["Sandbox and browser sharing"]
+ : []),
...(isBackgroundActivityDirty ? ["Background activity"] : []),
...(settings.defaultThreadEnvMode !== DEFAULT_UNIFIED_SETTINGS.defaultThreadEnvMode
? ["New thread mode"]
@@ -581,6 +590,7 @@ export function useSettingsRestore(onRestored?: () => void) {
settings.glassOpacity,
settings.enableLegacyTokenStreaming,
settings.enableProviderUpdateChecks,
+ settings.botSandboxBrowserSharing,
settings.sidebarAutoSettleAfterDays,
settings.sidebarAutoSettleOnMerge,
settings.sidebarProjectGroupingMode,
@@ -672,6 +682,7 @@ export function useSettingsRestore(onRestored?: () => void) {
sidebarAutoSettleOnMerge: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge,
enableLegacyTokenStreaming: DEFAULT_UNIFIED_SETTINGS.enableLegacyTokenStreaming,
enableProviderUpdateChecks: DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks,
+ botSandboxBrowserSharing: DEFAULT_UNIFIED_SETTINGS.botSandboxBrowserSharing,
backgroundActivity: DEFAULT_UNIFIED_SETTINGS.backgroundActivity,
backgroundActivityProfile: DEFAULT_UNIFIED_SETTINGS.backgroundActivityProfile,
automaticGitFetchInterval: DEFAULT_UNIFIED_SETTINGS.automaticGitFetchInterval,
@@ -1852,6 +1863,82 @@ function LegacyFeaturesSection() {
);
}
+export function BotSandboxBrowserSharingSettings({
+ value,
+ onChange,
+}: {
+ readonly value: BotSandboxBrowserSharing;
+ readonly onChange: (value: BotSandboxBrowserSharing) => void;
+}) {
+ const [pendingValue, setPendingValue] = useState<BotSandboxBrowserSharing | null>(null);
+
+ return (
+ <>
+ <SettingsRow
+ {...searchableSetting("sandbox-browser-sharing")}
+ description="Shared uses one sandbox and browser for every bot. Separate gives each bot its own sandbox and browser profile."
+ resetAction={
+ value !== DEFAULT_UNIFIED_SETTINGS.botSandboxBrowserSharing ? (
+ <SettingResetButton
+ label="sandbox and browser sharing"
+ onClick={() => setPendingValue(DEFAULT_UNIFIED_SETTINGS.botSandboxBrowserSharing)}
+ />
+ ) : null
+ }
+ control={
+ <Select
+ value={value}
+ onValueChange={(nextValue) => {
+ if ((nextValue === "shared" || nextValue === "separate") && nextValue !== value) {
+ setPendingValue(nextValue);
+ }
+ }}
+ >
+ <SelectTrigger className="w-full sm:w-40" aria-label="Sandbox and browser sharing">
+ <SelectValue>{BOT_SANDBOX_BROWSER_SHARING_LABELS[value]}</SelectValue>
+ </SelectTrigger>
+ <SelectPopup align="end" alignItemWithTrigger={false}>
+ <SelectItem hideIndicator value="shared">
+ Shared
+ </SelectItem>
+ <SelectItem hideIndicator value="separate">
+ Separate
+ </SelectItem>
+ </SelectPopup>
+ </Select>
+ }
+ />
+
+ <Dialog open={pendingValue !== null} onOpenChange={(open) => !open && setPendingValue(null)}>
+ <DialogPopup>
+ <DialogHeader>
+ <DialogTitle>Change bot workspace mode?</DialogTitle>
+ <DialogDescription>
+ {pendingValue === "shared"
+ ? "Active tasks keep their current workspace. The next turn moves each bot into the shared workspace and browser. Files and cookies do not move."
+ : "Active tasks keep their current workspace. The next turn creates a separate workspace and browser for each bot. Shared files and cookies stay in the shared workspace."}
+ </DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <Button variant="outline" onClick={() => setPendingValue(null)}>
+ Cancel
+ </Button>
+ <Button
+ onClick={() => {
+ const nextValue = pendingValue;
+ setPendingValue(null);
+ if (nextValue) onChange(nextValue);
+ }}
+ >
+ Change mode
+ </Button>
+ </DialogFooter>
+ </DialogPopup>
+ </Dialog>
+ </>
+ );
+}
+
export function GeneralSettingsPanel() {
const settings = usePrimarySettings();
const updateSettings = useUpdatePrimarySettings();
@@ -1908,6 +1995,11 @@ export function GeneralSettingsPanel() {
return (
<SettingsPageContainer>
<SettingsSection title="General">
+ <BotSandboxBrowserSharingSettings
+ value={settings.botSandboxBrowserSharing}
+ onChange={(value) => updateSettings({ botSandboxBrowserSharing: value })}
+ />
+
<SettingsRow
{...searchableSetting("project-grouping")}
description="Combine matching repositories across environments."
diff --git a/apps/web/src/components/settings/settingsSearch.test.ts b/apps/web/src/components/settings/settingsSearch.test.ts
index 09fd7a9a6..e16c36bf2 100644
--- a/apps/web/src/components/settings/settingsSearch.test.ts
+++ b/apps/web/src/components/settings/settingsSearch.test.ts
@@ -75,6 +75,13 @@ describe("searchSettings", () => {
expect(searchableSetting("archive")).toEqual({ id: "archive", title: "Archived threads" });
});
+ it("routes sandbox and browser sharing to General settings", () => {
+ expect(searchSettings("sandbox and browser sharing")[0]).toMatchObject({
+ id: "sandbox-browser-sharing",
+ to: "/settings/general",
+ });
+ });
+
it("routes appearance settings to their current section", () => {
expect(searchSettings("theme")[0]).toMatchObject({
id: "theme",
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts
index 80daa75a5..9ae82120d 100644
--- a/apps/web/src/components/settings/settingsSearch.ts
+++ b/apps/web/src/components/settings/settingsSearch.ts
@@ -113,6 +113,11 @@ export const SETTINGS_SEARCH_ITEMS = [
title: "Project grouping",
to: "/settings/general",
},
+ {
+ id: "sandbox-browser-sharing",
+ title: "Sandbox and browser sharing",
+ to: "/settings/general",
+ },
{
id: "auto-settle-inactive-threads",
title: "Auto-settle inactive threads",
diff --git a/docs/user/bots.md b/docs/user/bots.md
index d4025b0f0..247267014 100644
--- a/docs/user/bots.md
+++ b/docs/user/bots.md
@@ -12,6 +12,8 @@ Open a bot to edit its profile in the panel beside the conversation.
Akeru Bot stores the profile in the connected environment. Other clients connected to the same environment see the same bot configuration. Workspace-disabled tools stay unavailable to all bots.
+Settings controls whether bots share their workspace and browser. **Separate** is the default and gives each bot its own workspace identity and browser profile. **Shared** lets bots share files and cookies. Bots use a local workspace. Remote sandbox options stay unavailable.
+
Use the panel button to collapse or reopen the editor. The default shortcut is **Mod+Alt+B**, and you can change `Right Panel: Toggle` in the keybinding settings. On a narrow screen, the same button opens a sheet.
Bot replies support headings, links, tables, task lists, code blocks, math, and Mermaid diagrams.
diff --git a/packages/contracts/src/orchestration.ts b/packages/contracts/src/orchestration.ts
index 5f884ff8f..16f0ae560 100644
--- a/packages/contracts/src/orchestration.ts
+++ b/packages/contracts/src/orchestration.ts
@@ -300,6 +300,10 @@ export type BotEngine = typeof BotEngine.Type;
export const BotSandbox = Schema.Literals(["local", "vercel", "akeru-cloud", "upstash"]);
export type BotSandbox = typeof BotSandbox.Type;
+export const BotSandboxBrowserSharing = Schema.Literals(["shared", "separate"]);
+export type BotSandboxBrowserSharing = typeof BotSandboxBrowserSharing.Type;
+export const DEFAULT_BOT_SANDBOX_BROWSER_SHARING: BotSandboxBrowserSharing = "separate";
+
export const BotUsageCap = Schema.Struct({
unit: Schema.Literal("tokens"),
limit: Schema.Int.check(Schema.isGreaterThan(0)),
diff --git a/packages/contracts/src/settings.test.ts b/packages/contracts/src/settings.test.ts
index b6c8f0b33..dcc0182e6 100644
--- a/packages/contracts/src/settings.test.ts
+++ b/packages/contracts/src/settings.test.ts
@@ -209,6 +209,19 @@ describe("ClientSettings sidebar", () => {
});
});
+describe("ServerSettings bot sandbox and browser sharing", () => {
+ it("defaults to separate and accepts shared as an opt-in", () => {
+ expect(decodeServerSettings({}).botSandboxBrowserSharing).toBe("separate");
+ expect(
+ decodeServerSettingsPatch({ botSandboxBrowserSharing: "shared" }).botSandboxBrowserSharing,
+ ).toBe("shared");
+ });
+
+ it("rejects unsupported sharing modes", () => {
+ expect(() => decodeServerSettingsPatch({ botSandboxBrowserSharing: "per-thread" })).toThrow();
+ });
+});
+
describe("ServerSettings.providerInstances (slice-2 invariant)", () => {
it("defaults text generation to Luna at low reasoning effort", () => {
expect(DEFAULT_SERVER_SETTINGS.textGenerationModelSelection).toEqual({
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index 65eeb4ad8..887cfe178 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -9,7 +9,11 @@ import {
DEFAULT_TEXT_GENERATION_REASONING_EFFORT,
ProviderOptionSelections,
} from "./model.ts";
-import { ModelSelection } from "./orchestration.ts";
+import {
+ BotSandboxBrowserSharing,
+ DEFAULT_BOT_SANDBOX_BROWSER_SHARING,
+ ModelSelection,
+} from "./orchestration.ts";
import {
DEFAULT_PREVIEW_APPEARANCE,
DEFAULT_PREVIEW_ZOOM_FACTOR,
@@ -652,6 +656,9 @@ export const ServerSettings = Schema.Struct({
productFeedbackEndpoint: ProductFeedbackEndpoint.pipe(
Schema.withDecodingDefault(Effect.succeed(DEFAULT_PRODUCT_FEEDBACK_ENDPOINT)),
),
+ botSandboxBrowserSharing: BotSandboxBrowserSharing.pipe(
+ Schema.withDecodingDefault(Effect.succeed(DEFAULT_BOT_SANDBOX_BROWSER_SHARING)),
+ ),
/**
* Whether agents may drive the in-app preview browser. Turning this off
* withholds the MCP credential, so the `t3-code` server (and with it every
@@ -880,6 +887,7 @@ export const ServerSettingsPatch = Schema.Struct({
enableProviderUpdateChecks: Schema.optionalKey(Schema.Boolean),
productFeedbackEnabled: Schema.optionalKey(Schema.Boolean),
productFeedbackEndpoint: Schema.optionalKey(ProductFeedbackEndpoint),
+ botSandboxBrowserSharing: Schema.optionalKey(BotSandboxBrowserSharing),
enableAgentBrowserAccess: Schema.optionalKey(Schema.Boolean),
voice: Schema.optionalKey(
Schema.Struct({