Skip to content

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

app_settings: cards and window preferences in the app

aivsomkar58c1ee29ec25
diff --git a/scripts/testing/file-size-ratchet.test.ts b/scripts/testing/file-size-ratchet.test.ts
index 22a6803814..6d4df2119d 100644
--- a/scripts/testing/file-size-ratchet.test.ts
+++ b/scripts/testing/file-size-ratchet.test.ts
@@ -34,6 +34,7 @@ const LINES: Record<string, number> = {
"src/components/LocalComputerSection.tsx": 1437,
"src/components/CursorAvatar.tsx": 1324,
"server/skills.ts": 1379,
+ "shared/wire.ts": 1004,
"server/composio.ts": 1038,
"server/vps-computer.ts": 1287,
"scripts/mcp-server.ts": 1411,
diff --git a/shared/live-approval.ts b/shared/live-approval.ts
index 0187312b03..444ffd9dae 100644
--- a/shared/live-approval.ts
+++ b/shared/live-approval.ts
@@ -7,13 +7,13 @@ export type LiveCardKind = "approval" | "review" | "question";
/** "approval": a provider or peer ask the voice may decide with a strict yes/no.
* "review": a harness-native proposal (skill, routine, profile, default
- * model, team setup, an MCP server change, a quota-switch offer) that must be
+ * model, team setup, an MCP server change, an app setting, a quota-switch offer) that must be
* reviewed on screen.
* "question": a provider question. An expired proposal is settled: nothing
* can answer it any more. */
export function liveCardKind(card: OptionCardData | undefined): LiveCardKind | null {
if (!card?.requestId || card.answered || card.dismissed || card.expired) return null;
- if (card.skillRequest || card.routineRequest || card.profileRequest || card.modelRequest || card.teamSetupRequest || card.mcpRequest || card.quotaSwitch || card.lendingLift) {
+ if (card.skillRequest || card.routineRequest || card.profileRequest || card.modelRequest || card.teamSetupRequest || card.mcpRequest || card.appSettingRequest || card.quotaSwitch || card.lendingLift) {
return "review";
}
return card.tool ? "approval" : "question";
diff --git a/src/components/ApprovalCard.tsx b/src/components/ApprovalCard.tsx
index 914b460b4a..74e062b6d4 100644
--- a/src/components/ApprovalCard.tsx
+++ b/src/components/ApprovalCard.tsx
@@ -81,7 +81,7 @@ const staleRoutineCard = (card: OptionCardData) => Boolean(card.routineRequest &
/** Cards whose server-written title and first option say what approving does. */
export const titledCard = (card: OptionCardData | undefined) =>
- Boolean(card?.teamSetupRequest || card?.mcpRequest || card?.lendingLift || isSkillSwitchAction(card?.skillRequest?.action));
+ Boolean(card?.teamSetupRequest || card?.mcpRequest || card?.appSettingRequest || card?.lendingLift || isSkillSwitchAction(card?.skillRequest?.action));
export function titledCardAction(card: OptionCardData): string {
if (card.mcpRequest) return mcpRequestActionLabel(card.mcpRequest.action);
@@ -159,6 +159,8 @@ function plainWhen(schedule: RoutineRequestSchedule): string {
}
export function appliedChange(card: OptionCardData, name: string): { line: string; canUndo: boolean; cancels?: boolean } | undefined {
+ const setting = card.appSettingRequest;
+ if (setting) return { line: t("approval.applied.appSetting", { name, title: `${setting.label}: ${approvalDetailText(card)}` }), canUndo: true };
const routine = card.routineRequest;
if (routine) {
const operation = routine.operation;
diff --git a/src/components/OptionCard.tsx b/src/components/OptionCard.tsx
index 1310f87ba7..92add292e6 100644
--- a/src/components/OptionCard.tsx
+++ b/src/components/OptionCard.tsx
@@ -49,6 +49,7 @@ export function OptionCard({
const options = parseChoices(card.options, MAX_CHOICES) ?? [];
const optionLabel = (option: string): string => {
+ if (card.appSettingRequest) return option === "Cancel" ? t("common.cancel") : option === options[0] ? t("approval.action.change") : option;
if (!card.mcpRequest) return option;
if (option === "Cancel") return t("mcp.cancel");
return option === options[0] ? mcpRequestActionLabel(card.mcpRequest.action) : option;
diff --git a/src/components/PendingApproval.tsx b/src/components/PendingApproval.tsx
index 5d5f08515a..7532c7123f 100644
--- a/src/components/PendingApproval.tsx
+++ b/src/components/PendingApproval.tsx
@@ -135,7 +135,7 @@ function approvalWords(pending: Pending, botName?: string): { line: string; summ
const detail = (pending.commandAllowlist?.command ?? ask?.detail ?? (card ? approvalDetailText(card) : pending.detail)).trim();
if (outbound) return { line: outbound.headline, ...(outbound.summary ? { summary: outbound.summary } : {}), detail };
if (ask) return { line: ask.line, detail };
- if (card?.mcpRequest || card?.lendingLift) return { line: card.title, inline: detail, detail };
+ if (card?.mcpRequest || card?.lendingLift || card?.appSettingRequest) return { line: card.title, inline: detail, detail };
if (isDurable(pending)) return { line: label(pending), detail };
const action = COMMAND_TOOLS.has(pending.tool) ? t("approval.tool.runCommand") : toolLabel(pending.tool);
return { line: botName ? t("approval.card.namedWantsTo", { name: botName, action }) : label(pending), inline: detail, detail };
diff --git a/src/lib/chat-width.ts b/src/lib/chat-width.ts
index 3b40226625..e63af945c4 100644
--- a/src/lib/chat-width.ts
+++ b/src/lib/chat-width.ts
@@ -1,4 +1,5 @@
import { CHAT_WIDTH_IDS } from "../../shared/app-settings";
+import { reportWindowPrefs } from "./window-prefs";
export { CHAT_WIDTH_IDS };
export type ChatWidthId = (typeof CHAT_WIDTH_IDS)[number];
@@ -36,4 +37,5 @@ export function applyChatWidth(id: ChatWidthId): void {
} catch {
// Storage can be full or blocked in private mode; the width still applies this session.
}
+ reportWindowPrefs();
}
diff --git a/src/lib/config-status-frame.ts b/src/lib/config-status-frame.ts
new file mode 100644
index 0000000000..84ede750aa
--- /dev/null
+++ b/src/lib/config-status-frame.ts
@@ -0,0 +1,47 @@
+import type { ConfigStatus } from "@/state/config-status";
+
+// A section left out here is wiped from state.config whenever a config frame lands.
+export type ConfigStatusFrame = Pick<
+ ConfigStatus,
+ "awakeLimit" | "pausedBots" | "xai" | "mistral" | "cerebras" | "groq" | "greenference" | "modelgo" | "meta" | "deepseek" | "xResearch" | "treg" | "postiz" | "anthropic" | "openai" | "openrouter" | "openaiCompat" | "fleet" | "composio" | "box" | "vps" | "rooms" | "mcp" | "threads" | "automaticRecovery" | "cacheKeepWarm" | "localVm" | "opencodeGo" | "tts" | "decider" | "helpers" | "imageGen" | "live" | "savedKeys" | "profile" | "everyBotRules" | "language" | "features" | "onboarding" | "browserEngine" | "browserProfiles" | "edition" | "budgets" | "billing" | "managedPolicy" | "cloudHome" | "team" | "workspaceBanner"
+>;
+
+export function configStatusFromFrame(frame: ConfigStatusFrame): ConfigStatus {
+ return {
+ xai: frame.xai,
+ mistral: frame.mistral,
+ cerebras: frame.cerebras,
+ groq: frame.groq, greenference: frame.greenference, modelgo: frame.modelgo, deepseek: frame.deepseek,
+ meta: frame.meta, xResearch: frame.xResearch, treg: frame.treg, postiz: frame.postiz,
+ anthropic: frame.anthropic,
+ openai: frame.openai,
+ openrouter: frame.openrouter,
+ openaiCompat: frame.openaiCompat,
+ fleet: frame.fleet,
+ composio: frame.composio,
+ box: frame.box,
+ vps: frame.vps,
+ rooms: frame.rooms,
+ mcp: frame.mcp,
+ threads: frame.threads,
+ automaticRecovery: frame.automaticRecovery,
+ cacheKeepWarm: frame.cacheKeepWarm,
+ localVm: frame.localVm,
+ opencodeGo: frame.opencodeGo,
+ tts: frame.tts,
+ decider: frame.decider, helpers: frame.helpers,
+ imageGen: frame.imageGen,
+ live: frame.live, savedKeys: frame.savedKeys,
+ profile: frame.profile, everyBotRules: frame.everyBotRules,
+ language: frame.language,
+ features: frame.features,
+ onboarding: frame.onboarding,
+ browserEngine: frame.browserEngine,
+ browserProfiles: frame.browserProfiles,
+ edition: frame.edition,
+ budgets: frame.budgets,
+ billing: frame.billing,
+ managedPolicy: frame.managedPolicy,
+ ...(frame.cloudHome ? { cloudHome: true } : {}), ...(frame.team ? { team: frame.team } : {}), ...(frame.awakeLimit !== undefined ? { awakeLimit: frame.awakeLimit } : {}), ...(frame.pausedBots ? { pausedBots: frame.pausedBots } : {}), ...(frame.workspaceBanner ? { workspaceBanner: frame.workspaceBanner } : {}),
+ };
+}
diff --git a/src/lib/fonts.ts b/src/lib/fonts.ts
index b103690a13..faa70f0fe9 100644
--- a/src/lib/fonts.ts
+++ b/src/lib/fonts.ts
@@ -1,4 +1,5 @@
import { FONT_IDS } from "../../shared/app-settings";
+import { reportWindowPrefs } from "./window-prefs";
export { FONT_IDS };
export type FontId = (typeof FONT_IDS)[number];
@@ -35,4 +36,5 @@ export function applyFont(id: FontId): void {
getStore()?.setItem(FONT_KEY, id);
} catch {
}
+ reportWindowPrefs();
}
diff --git a/src/lib/interface-mode.ts b/src/lib/interface-mode.ts
index cd235551ee..275946035c 100644
--- a/src/lib/interface-mode.ts
+++ b/src/lib/interface-mode.ts
@@ -2,6 +2,7 @@ import { useSyncExternalStore } from "react";
import { hasPriorRun } from "./prior-run";
import { SIMPLE_ONLY } from "./simple-only";
+import { reportWindowPrefs } from "./window-prefs";
export const ADVANCED_MODE_KEY = "omb-advanced-mode";
@@ -69,6 +70,7 @@ export function setAdvancedMode(enabled: boolean): void {
} catch {
}
notify();
+ reportWindowPrefs();
}
export function useAdvancedMode(): boolean {
diff --git a/src/lib/notification-preferences.ts b/src/lib/notification-preferences.ts
index d44fd8c6f0..76011300e3 100644
--- a/src/lib/notification-preferences.ts
+++ b/src/lib/notification-preferences.ts
@@ -1,4 +1,5 @@
import { useSyncExternalStore } from "react";
+import { reportWindowPrefs } from "./window-prefs";
export const NOTIFICATION_SOUNDS_KEY = "omb-notification-sounds";
export const NOTIFICATION_FEED_KEY = "omb-notification-feed";
@@ -63,6 +64,7 @@ export function setNotificationSounds(enabled: boolean): void {
} catch {
}
notify();
+ reportWindowPrefs();
}
export function useNotificationSounds(): boolean {
diff --git a/src/lib/send-key.ts b/src/lib/send-key.ts
index fde4c48a67..5f332b2b4b 100644
--- a/src/lib/send-key.ts
+++ b/src/lib/send-key.ts
@@ -3,6 +3,7 @@ import { useSyncExternalStore } from "react";
import { SEND_KEYS } from "../../shared/app-settings";
import { activeLocale } from "./i18n";
import { isMacPlatform } from "./keyboard-shortcuts";
+import { reportWindowPrefs } from "./window-prefs";
export const SEND_KEY_KEY = "omb-send-key";
@@ -46,7 +47,7 @@ function storage(): Storage | undefined {
}
}
-function sendKey(): SendKey {
+export function readSendKey(): SendKey {
if (sessionChoice !== undefined) return sessionChoice;
try {
return parseSendKey(storage()?.getItem(SEND_KEY_KEY));
@@ -86,8 +87,9 @@ export function setSendKey(mode: SendKey): void {
} catch {
}
notify();
+ reportWindowPrefs();
}
export function useSendKey(): SendKey {
- return useSyncExternalStore(subscribe, sendKey, () => defaultSendKey());
+ return useSyncExternalStore(subscribe, readSendKey, () => defaultSendKey());
}
diff --git a/src/lib/skins.ts b/src/lib/skins.ts
index d660e65379..be0494d05e 100644
--- a/src/lib/skins.ts
+++ b/src/lib/skins.ts
@@ -1,6 +1,7 @@
import { SKIN_IDS } from "../../shared/app-settings";
import { paintAuroraField } from "./aurora-field";
import { hasPriorRun } from "./prior-run";
+import { reportWindowPrefs } from "./window-prefs";
export { SKIN_IDS };
export type SkinId = (typeof SKIN_IDS)[number];
@@ -133,6 +134,7 @@ export function applySkinChoice(choice: SkinChoice): void {
}
followSystem(choice === "system");
paintSkin(resolveSkin(choice));
+ reportWindowPrefs();
}
export function applySkin(id: SkinId): void {
diff --git a/src/lib/window-prefs.ts b/src/lib/window-prefs.ts
new file mode 100644
index 0000000000..84cd222a12
--- /dev/null
+++ b/src/lib/window-prefs.ts
@@ -0,0 +1,41 @@
+// The window's own preferences, as the server's app_settings tool reaches them: a `window-pref` frame is applied with
+// the preference's setter, and every setter reports the current values back so a bot can read them.
+import { WINDOW_PREFS, type WindowPrefFrame, type WindowPrefId } from "../../shared/app-settings";
+import { applyChatWidth, readChatWidth } from "./chat-width";
+import { applyFont, readFont } from "./fonts";
+import { readAdvancedMode, setAdvancedMode } from "./interface-mode";
+import { notificationSoundsEnabled, setNotificationSounds } from "./notification-preferences";
+import { readSendKey, setSendKey } from "./send-key";
+import { applySkinChoice, readSkinChoice } from "./skins";
+
+type Pref<I extends WindowPrefId> = { read(): unknown; write(value: ReturnType<(typeof WINDOW_PREFS)[I]["parse"]>): void };
+const PREFS: { [I in WindowPrefId]: Pref<I> } = {
+ "appearance.skin": { read: readSkinChoice, write: applySkinChoice },
+ "appearance.advanced": { read: readAdvancedMode, write: setAdvancedMode },
+ "appearance.font": { read: readFont, write: applyFont },
+ "appearance.chatWidth": { read: readChatWidth, write: applyChatWidth },
+ "general.sendKey": { read: readSendKey, write: setSendKey },
+ "general.notificationSounds": { read: notificationSoundsEnabled, write: setNotificationSounds },
+};
+
+export function applyWindowPref(frame: WindowPrefFrame): void {
+ const schema = WINDOW_PREFS[frame.id];
+ const parsed = schema?.safeParse(frame.value);
+ if (!parsed?.success) return;
+ (PREFS[frame.id] as Pref<typeof frame.id>).write(parsed.data as never);
+}
+
+export function windowPrefValues(): Record<WindowPrefId, unknown> {
+ return Object.fromEntries((Object.keys(PREFS) as WindowPrefId[]).map((id) => [id, PREFS[id].read()])) as Record<WindowPrefId, unknown>;
+}
+
+let report: ReturnType<typeof setTimeout> | null = null;
+/** Tells the server the window's values, once the burst of setters at start-up has settled. */
+export function reportWindowPrefs(): void {
+ if (typeof fetch !== "function" || typeof window === "undefined") return;
+ if (report) clearTimeout(report);
+ report = setTimeout(() => {
+ report = null;
+ fetch("/api/window-prefs", { method: "PUT", headers: { "content-type": "application/json" }, body: JSON.stringify({ values: windowPrefValues() }) }).catch(() => undefined);
+ }, 200);
+}
diff --git a/src/state/store.tsx b/src/state/store.tsx
index a66fbbb808..fa2abdc01b 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -45,6 +45,7 @@ import {
import type { Routine, RoutineInput, RoutineRun, RoutineRunStatusFilter } from "@/lib/routines";
import type { WebhookAttempt, WebhookIngressStatus, WebhookTrigger } from "@/lib/webhooks";
import { duplicateBotProfile, restrictedCopyRequest } from "@/lib/bot-duplicate";
+import { applyWindowPref } from "@/lib/window-prefs";
import { botShowsUnread } from "@/lib/bot-unread";
import { placeUnreadDivider, threadOpensUnread, threadReadCursor, unreadDividerFor, type UnreadDivider } from "@/lib/unread-divider";
import type { ComputerStart } from "@/lib/computer-start";
@@ -70,7 +71,7 @@ import { reconcileSnapshotQueues, rememberConsumedQueueId, replaceBotQueues } fr
export type { MausColor } from "@/lib/mascot";
export type { RoutineRunCardData } from "../../shared/routine-run";
-export interface OptionCardData extends Pick<WireOptionCard, "fixedOptions" | "lendingLift" | "webhookRequest" | "appTriggerRequest" | "yourComputer" | "computerAsk" | "waitRequest" | "stopped" | "accessRequest" | "mcpRequest" | "summaryCode" | "summaryParams"> {
+export interface OptionCardData extends Pick<WireOptionCard, "fixedOptions" | "lendingLift" | "webhookRequest" | "appTriggerRequest" | "yourComputer" | "computerAsk" | "waitRequest" | "stopped" | "accessRequest" | "mcpRequest" | "appSettingRequest" | "summaryCode" | "summaryParams"> {
title: string;
subtitle: string;
options: string[];
@@ -396,51 +397,8 @@ function openedUnreadDivider(state: AppState, threadId: string, unread: boolean,
import type { BrowserEngineSummary, BrowserProfile, ConfigStatus, ManagedPolicySummary } from "./config-status";
export type { BrowserEngineSummary, BrowserProfile, ConfigStatus, ManagedPolicySummary };
-// A section left out here is wiped from state.config whenever a config frame lands.
-export type ConfigStatusFrame = Pick<
- ConfigStatus,
- "awakeLimit" | "pausedBots" | "xai" | "mistral" | "cerebras" | "groq" | "greenference" | "modelgo" | "meta" | "deepseek" | "xResearch" | "treg" | "postiz" | "anthropic" | "openai" | "openrouter" | "openaiCompat" | "fleet" | "composio" | "box" | "vps" | "rooms" | "mcp" | "threads" | "automaticRecovery" | "cacheKeepWarm" | "localVm" | "opencodeGo" | "tts" | "decider" | "helpers" | "imageGen" | "live" | "savedKeys" | "profile" | "everyBotRules" | "language" | "features" | "onboarding" | "browserEngine" | "browserProfiles" | "edition" | "budgets" | "billing" | "managedPolicy" | "cloudHome" | "team" | "workspaceBanner"
->;
-
-export function configStatusFromFrame(frame: ConfigStatusFrame): ConfigStatus {
- return {
- xai: frame.xai,
- mistral: frame.mistral,
- cerebras: frame.cerebras,
- groq: frame.groq, greenference: frame.greenference, modelgo: frame.modelgo, deepseek: frame.deepseek,
- meta: frame.meta, xResearch: frame.xResearch, treg: frame.treg, postiz: frame.postiz,
- anthropic: frame.anthropic,
- openai: frame.openai,
- openrouter: frame.openrouter,
- openaiCompat: frame.openaiCompat,
- fleet: frame.fleet,
- composio: frame.composio,
- box: frame.box,
- vps: frame.vps,
- rooms: frame.rooms,
- mcp: frame.mcp,
- threads: frame.threads,
- automaticRecovery: frame.automaticRecovery,
- cacheKeepWarm: frame.cacheKeepWarm,
- localVm: frame.localVm,
- opencodeGo: frame.opencodeGo,
- tts: frame.tts,
- decider: frame.decider, helpers: frame.helpers,
- imageGen: frame.imageGen,
- live: frame.live, savedKeys: frame.savedKeys,
- profile: frame.profile, everyBotRules: frame.everyBotRules,
- language: frame.language,
- features: frame.features,
- onboarding: frame.onboarding,
- browserEngine: frame.browserEngine,
- browserProfiles: frame.browserProfiles,
- edition: frame.edition,
- budgets: frame.budgets,
- billing: frame.billing,
- managedPolicy: frame.managedPolicy,
- ...(frame.cloudHome ? { cloudHome: true } : {}), ...(frame.team ? { team: frame.team } : {}), ...(frame.awakeLimit !== undefined ? { awakeLimit: frame.awakeLimit } : {}), ...(frame.pausedBots ? { pausedBots: frame.pausedBots } : {}), ...(frame.workspaceBanner ? { workspaceBanner: frame.workspaceBanner } : {}),
- };
-}
+import { configStatusFromFrame, type ConfigStatusFrame } from "@/lib/config-status-frame";
+export { configStatusFromFrame, type ConfigStatusFrame };
export type { EngineInstall } from "./engine-install";
@@ -3231,6 +3189,9 @@ export function StoreProvider({ children }: { children: ReactNode }) {
}
break;
}
+ case "window-pref":
+ applyWindowPref(frame);
+ break;
case "config":
rawDispatch({
type: "configStatus",