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.

settings page

Theo Brownef8883d0495aa
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index fcc120a46..c741deec8 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -5,7 +5,15 @@ import net from "node:net";
import os from "node:os";
import path from "node:path";
-import { app, BrowserWindow, dialog, ipcMain, Menu, shell } from "electron";
+import {
+ app,
+ BrowserWindow,
+ dialog,
+ ipcMain,
+ Menu,
+ type MenuItemConstructorOptions,
+ shell,
+} from "electron";
import { showDesktopConfirmDialog } from "./confirmDialog";
import { fixPath } from "./fixPath";
@@ -16,6 +24,7 @@ const PICK_FOLDER_CHANNEL = "desktop:pick-folder";
const CONFIRM_CHANNEL = "desktop:confirm";
const CONTEXT_MENU_CHANNEL = "desktop:context-menu";
const OPEN_EXTERNAL_CHANNEL = "desktop:open-external";
+const MENU_ACTION_CHANNEL = "desktop:menu-action";
const ROOT_DIR = path.resolve(__dirname, "../../..");
const BACKEND_ENTRY = path.join(ROOT_DIR, "apps/server/dist/index.mjs");
const WEB_ENTRY = path.join(ROOT_DIR, "apps/web/dist/index.html");
@@ -33,6 +42,80 @@ let restartAttempt = 0;
let restartTimer: ReturnType<typeof setTimeout> | null = null;
let isQuitting = false;
+function dispatchMenuAction(action: string): void {
+ const existingWindow = BrowserWindow.getFocusedWindow() ?? mainWindow ?? BrowserWindow.getAllWindows()[0];
+ const targetWindow = existingWindow ?? createWindow();
+ if (!existingWindow) {
+ mainWindow = targetWindow;
+ }
+
+ const send = () => {
+ if (targetWindow.isDestroyed()) return;
+ targetWindow.webContents.send(MENU_ACTION_CHANNEL, action);
+ if (!targetWindow.isVisible()) {
+ targetWindow.show();
+ }
+ targetWindow.focus();
+ };
+
+ if (targetWindow.webContents.isLoadingMainFrame()) {
+ targetWindow.webContents.once("did-finish-load", send);
+ return;
+ }
+
+ send();
+}
+
+function configureApplicationMenu(): void {
+ const template: MenuItemConstructorOptions[] = [];
+
+ if (process.platform === "darwin") {
+ template.push({
+ label: app.name,
+ submenu: [
+ { role: "about" },
+ {
+ label: "Settings...",
+ accelerator: "CmdOrCtrl+,",
+ click: () => dispatchMenuAction("open-settings"),
+ },
+ { type: "separator" },
+ { role: "services" },
+ { type: "separator" },
+ { role: "hide" },
+ { role: "hideOthers" },
+ { role: "unhide" },
+ { type: "separator" },
+ { role: "quit" },
+ ],
+ });
+ }
+
+ template.push(
+ {
+ label: "File",
+ submenu: [
+ ...(process.platform === "darwin"
+ ? []
+ : [
+ {
+ label: "Settings...",
+ accelerator: "CmdOrCtrl+,",
+ click: () => dispatchMenuAction("open-settings"),
+ },
+ { type: "separator" as const },
+ ]),
+ { role: process.platform === "darwin" ? "close" : "quit" },
+ ],
+ },
+ { role: "editMenu" },
+ { role: "viewMenu" },
+ { role: "windowMenu" },
+ );
+
+ Menu.setApplicationMenu(Menu.buildFromTemplate(template));
+}
+
function resolveResourcePath(fileName: string): string | null {
const candidates = [
path.join(__dirname, "../resources", fileName),
@@ -322,6 +405,7 @@ app.on("before-quit", () => {
app.whenReady().then(() => {
configureAppIdentity();
+ configureApplicationMenu();
void bootstrap();
app.on("activate", () => {
diff --git a/apps/desktop/src/preload.ts b/apps/desktop/src/preload.ts
index fb90831fc..464832b33 100644
--- a/apps/desktop/src/preload.ts
+++ b/apps/desktop/src/preload.ts
@@ -4,6 +4,7 @@ const PICK_FOLDER_CHANNEL = "desktop:pick-folder";
const CONFIRM_CHANNEL = "desktop:confirm";
const CONTEXT_MENU_CHANNEL = "desktop:context-menu";
const OPEN_EXTERNAL_CHANNEL = "desktop:open-external";
+const MENU_ACTION_CHANNEL = "desktop:menu-action";
const wsUrl = process.env.T3CODE_DESKTOP_WS_URL ?? null;
contextBridge.exposeInMainWorld("desktopBridge", {
@@ -13,4 +14,15 @@ contextBridge.exposeInMainWorld("desktopBridge", {
showContextMenu: (items: { id: string; label: string }[]) =>
ipcRenderer.invoke(CONTEXT_MENU_CHANNEL, items) as Promise<string | null>,
openExternal: (url: string) => ipcRenderer.invoke(OPEN_EXTERNAL_CHANNEL, url) as Promise<boolean>,
+ onMenuAction: (listener: (action: string) => void) => {
+ const wrappedListener = (_event: Electron.IpcRendererEvent, action: unknown) => {
+ if (typeof action !== "string") return;
+ listener(action);
+ };
+
+ ipcRenderer.on(MENU_ACTION_CHANNEL, wrappedListener);
+ return () => {
+ ipcRenderer.removeListener(MENU_ACTION_CHANNEL, wrappedListener);
+ };
+ },
});
diff --git a/apps/server/src/codexAppServerManager.ts b/apps/server/src/codexAppServerManager.ts
index 6122ec601..912f9b2db 100644
--- a/apps/server/src/codexAppServerManager.ts
+++ b/apps/server/src/codexAppServerManager.ts
@@ -163,9 +163,14 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
updatedAt: now,
};
- const child = spawn("codex", ["app-server"], {
+ const codexBinaryPath = input.codexBinaryPath?.trim() || "codex";
+ const codexHomePath = input.codexHomePath?.trim();
+ const child = spawn(codexBinaryPath, ["app-server"], {
cwd: resolvedCwd,
- env: process.env,
+ env: {
+ ...process.env,
+ ...(codexHomePath ? { CODEX_HOME: codexHomePath } : {}),
+ },
stdio: ["pipe", "pipe", "pipe"],
});
const output = readline.createInterface({ input: child.stdout });
diff --git a/apps/web/src/appSettings.ts b/apps/web/src/appSettings.ts
new file mode 100644
index 000000000..cd3da7224
--- /dev/null
+++ b/apps/web/src/appSettings.ts
@@ -0,0 +1,109 @@
+import { useCallback, useSyncExternalStore } from "react";
+import { z } from "zod";
+
+const APP_SETTINGS_STORAGE_KEY = "t3code:app-settings:v1";
+
+const appSettingsSchema = z.object({
+ codexBinaryPath: z.string().trim().max(4096).default(""),
+ codexHomePath: z.string().trim().max(4096).default(""),
+ confirmThreadDelete: z.boolean().default(true),
+});
+
+export type AppSettings = z.infer<typeof appSettingsSchema>;
+
+const DEFAULT_APP_SETTINGS: AppSettings = appSettingsSchema.parse({});
+
+let listeners: Array<() => void> = [];
+let cachedRawSettings: string | null | undefined;
+let cachedSnapshot: AppSettings = DEFAULT_APP_SETTINGS;
+
+function emitChange(): void {
+ for (const listener of listeners) {
+ listener();
+ }
+}
+
+function parsePersistedSettings(value: string | null): AppSettings {
+ if (!value) {
+ return DEFAULT_APP_SETTINGS;
+ }
+
+ try {
+ const parsed = JSON.parse(value) as unknown;
+ return appSettingsSchema.parse(parsed);
+ } catch {
+ return DEFAULT_APP_SETTINGS;
+ }
+}
+
+export function getAppSettingsSnapshot(): AppSettings {
+ if (typeof window === "undefined") {
+ return DEFAULT_APP_SETTINGS;
+ }
+
+ const raw = window.localStorage.getItem(APP_SETTINGS_STORAGE_KEY);
+ if (raw === cachedRawSettings) {
+ return cachedSnapshot;
+ }
+
+ cachedRawSettings = raw;
+ cachedSnapshot = parsePersistedSettings(raw);
+ return cachedSnapshot;
+}
+
+function persistSettings(next: AppSettings): void {
+ if (typeof window === "undefined") return;
+
+ const raw = JSON.stringify(next);
+ try {
+ if (raw !== cachedRawSettings) {
+ window.localStorage.setItem(APP_SETTINGS_STORAGE_KEY, raw);
+ }
+ } catch {
+ // Best-effort persistence only.
+ }
+
+ cachedRawSettings = raw;
+ cachedSnapshot = next;
+}
+
+function subscribe(listener: () => void): () => void {
+ listeners.push(listener);
+
+ const onStorage = (event: StorageEvent) => {
+ if (event.key === APP_SETTINGS_STORAGE_KEY) {
+ emitChange();
+ }
+ };
+
+ window.addEventListener("storage", onStorage);
+ return () => {
+ listeners = listeners.filter((entry) => entry !== listener);
+ window.removeEventListener("storage", onStorage);
+ };
+}
+
+export function useAppSettings() {
+ const settings = useSyncExternalStore(subscribe, getAppSettingsSnapshot, () => DEFAULT_APP_SETTINGS);
+
+ const updateSettings = useCallback((patch: Partial<AppSettings>) => {
+ const next = appSettingsSchema.parse({
+ ...getAppSettingsSnapshot(),
+ ...patch,
+ });
+ persistSettings(next);
+ emitChange();
+ }, []);
+
+ const resetSettings = useCallback(() => {
+ persistSettings(DEFAULT_APP_SETTINGS);
+ emitChange();
+ }, []);
+
+ return {
+ settings,
+ updateSettings,
+ resetSettings,
+ defaults: DEFAULT_APP_SETTINGS,
+ } as const;
+}
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 9b5288a4f..9039149da 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -35,6 +35,7 @@ import { projectSearchEntriesQueryOptions } from "~/lib/projectReactQuery";
import { serverConfigQueryOptions, serverQueryKeys } from "~/lib/serverReactQuery";
import { isElectron } from "../env";
+import { useAppSettings } from "../appSettings";
import { buildBootstrapInput } from "../historyBootstrap";
import {
type ComposerTriggerKind,
@@ -376,6 +377,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
const { state, dispatch } = useStore();
const api = useNativeApi();
const { resolvedTheme } = useTheme();
+ const { settings: appSettings } = useAppSettings();
const queryClient = useQueryClient();
const createWorktreeMutation = useMutation(
gitCreateWorktreeMutationOptions({ api, queryClient }),
@@ -642,6 +644,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
const runtimeApprovalPolicy = state.runtimeMode === "full-access" ? "never" : "on-request";
const runtimeSandboxMode =
state.runtimeMode === "full-access" ? "danger-full-access" : "workspace-write";
+ const codexBinaryPath = appSettings.codexBinaryPath.trim();
+ const codexHomePath = appSettings.codexHomePath.trim();
const gitCwd = activeThread?.worktreePath ?? activeProject?.cwd ?? null;
const composerTrigger = useMemo(
() => detectComposerTrigger(prompt, composerCursor),
@@ -1515,6 +1519,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
cwd: cwdOverride ?? activeThread.worktreePath ?? activeProject.cwd,
model: selectedModel || undefined,
resumeThreadId: priorCodexThreadId ?? undefined,
+ ...(codexBinaryPath.length > 0 ? { codexBinaryPath } : {}),
+ ...(codexHomePath.length > 0 ? { codexHomePath } : {}),
approvalPolicy: runtimeApprovalPolicy,
sandboxMode: runtimeSandboxMode,
});
@@ -1555,6 +1561,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
activeProject,
activeThread,
api,
+ codexBinaryPath,
+ codexHomePath,
dispatch,
runtimeApprovalPolicy,
runtimeSandboxMode,
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index e89d85810..9291843ea 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -1,11 +1,11 @@
-import { MonitorIcon, MoonIcon, SunIcon, TerminalIcon } from "lucide-react";
+import { TerminalIcon } from "lucide-react";
import { useCallback, useEffect, useMemo, useState } from "react";
import type { ResolvedKeybindingsConfig } from "@t3tools/contracts";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useNavigate, useParams } from "@tanstack/react-router";
+import { useAppSettings } from "../appSettings";
import { isElectron } from "../env";
import { APP_STAGE_LABEL } from "../branding";
-import { useTheme } from "../hooks/useTheme";
import { DEFAULT_MODEL } from "../model-logic";
import { derivePendingApprovals } from "../session-logic";
import { useStore } from "../store";
@@ -18,7 +18,6 @@ import { toastManager } from "./ui/toast";
import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "../worktreeCleanup";
import { createThread } from "../threadFactory";
-const THEME_CYCLE = { system: "light", light: "dark", dark: "system" } as const;
const EMPTY_KEYBINDINGS: ResolvedKeybindingsConfig = [];
function formatRelativeTime(iso: string): string {
@@ -117,6 +116,7 @@ export default function Sidebar() {
const { state, dispatch } = useStore();
const api = useNativeApi();
const navigate = useNavigate();
+ const { settings: appSettings } = useAppSettings();
const params = useParams({ strict: false });
const routeThreadId = typeof params.threadId === "string" ? params.threadId : null;
const { data: keybindings = EMPTY_KEYBINDINGS } = useQuery({
@@ -127,7 +127,6 @@ export default function Sidebar() {
const removeWorktreeMutation = useMutation(
gitRemoveWorktreeMutationOptions({ api, queryClient }),
);
- const { theme, setTheme } = useTheme();
const [addingProject, setAddingProject] = useState(false);
const [newCwd, setNewCwd] = useState("");
const [isPickingFolder, setIsPickingFolder] = useState(false);
@@ -272,6 +271,17 @@ export default function Sidebar() {
const thread = state.threads.find((t) => t.id === threadId);
if (!thread) return;
+ if (appSettings.confirmThreadDelete) {
+ const confirmed = await api.dialogs.confirm(
+ [
+ `Delete thread \"${thread.title}\"?`,
+ "This permanently clears conversation history for this thread.",
+ ].join("\n"),
+ );
+ if (!confirmed) {
+ return;
+ }
+ }
const threadProject = state.projects.find((project) => project.id === thread.projectId);
const orphanedWorktreePath = getOrphanedWorktreePathForThread(state.threads, threadId);
const displayWorktreePath = orphanedWorktreePath
@@ -349,7 +359,16 @@ export default function Sidebar() {
});
}
},
- [api, dispatch, navigate, removeWorktreeMutation, routeThreadId, state.projects, state.threads],
+ [
+ api,
+ appSettings.confirmThreadDelete,
+ dispatch,
+ navigate,
+ removeWorktreeMutation,
+ routeThreadId,
+ state.projects,
+ state.threads,
+ ],
);
const handleProjectContextMenu = useCallback(
@@ -436,25 +455,10 @@ export default function Sidebar() {
<span className="truncate text-sm font-semibold tracking-tight text-foreground">
T3 <span className="font-normal text-muted-foreground">Code</span>
</span>
- <span className="rounded border border-border bg-secondary px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground">
+ <span className="rounded-full bg-muted/50 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-widest text-muted-foreground/60">
{APP_STAGE_LABEL}
</span>
</div>
- <button
- type="button"
- className="rounded-md p-1.5 text-muted-foreground/80 transition-colors duration-150 hover:bg-accent hover:text-muted-foreground"
- onClick={() => setTheme(THEME_CYCLE[theme])}
- aria-label={`Theme: ${theme}`}
- title={`Theme: ${theme}`}
- >
- {theme === "system" ? (
- <MonitorIcon className="size-3.5" />
- ) : theme === "light" ? (
- <SunIcon className="size-3.5" />
- ) : (
- <MoonIcon className="size-3.5" />
- )}
- </button>
</div>
{/* New thread (global) */}
diff --git a/apps/web/src/routeTree.gen.ts b/apps/web/src/routeTree.gen.ts
index a005a05e5..880d5ef64 100644
--- a/apps/web/src/routeTree.gen.ts
+++ b/apps/web/src/routeTree.gen.ts
@@ -11,6 +11,7 @@
import { Route as rootRouteImport } from './routes/__root'
import { Route as ChatRouteImport } from './routes/_chat'
import { Route as ChatIndexRouteImport } from './routes/_chat.index'
+import { Route as ChatSettingsRouteImport } from './routes/_chat.settings'
import { Route as ChatThreadIdRouteImport } from './routes/_chat.$threadId'
const ChatRoute = ChatRouteImport.update({
@@ -22,6 +23,11 @@ const ChatIndexRoute = ChatIndexRouteImport.update({
path: '/',
getParentRoute: () => ChatRoute,
} as any)
+const ChatSettingsRoute = ChatSettingsRouteImport.update({
+ id: '/settings',
+ path: '/settings',
+ getParentRoute: () => ChatRoute,
+} as any)
const ChatThreadIdRoute = ChatThreadIdRouteImport.update({
id: '/$threadId',
path: '/$threadId',
@@ -31,23 +37,26 @@ const ChatThreadIdRoute = ChatThreadIdRouteImport.update({
export interface FileRoutesByFullPath {
'/': typeof ChatIndexRoute
'/$threadId': typeof ChatThreadIdRoute
+ '/settings': typeof ChatSettingsRoute
}
export interface FileRoutesByTo {
'/$threadId': typeof ChatThreadIdRoute
+ '/settings': typeof ChatSettingsRoute
'/': typeof ChatIndexRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
'/_chat': typeof ChatRouteWithChildren
'/_chat/$threadId': typeof ChatThreadIdRoute
+ '/_chat/settings': typeof ChatSettingsRoute
'/_chat/': typeof ChatIndexRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
- fullPaths: '/' | '/$threadId'
+ fullPaths: '/' | '/$threadId' | '/settings'
fileRoutesByTo: FileRoutesByTo
- to: '/$threadId' | '/'
- id: '__root__' | '/_chat' | '/_chat/$threadId' | '/_chat/'
+ to: '/$threadId' | '/settings' | '/'
+ id: '__root__' | '/_chat' | '/_chat/$threadId' | '/_chat/settings' | '/_chat/'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
@@ -70,6 +79,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ChatIndexRouteImport
parentRoute: typeof ChatRoute
}
+ '/_chat/settings': {
+ id: '/_chat/settings'
+ path: '/settings'
+ fullPath: '/settings'
+ preLoaderRoute: typeof ChatSettingsRouteImport
+ parentRoute: typeof ChatRoute
+ }
'/_chat/$threadId': {
id: '/_chat/$threadId'
path: '/$threadId'
@@ -82,11 +98,13 @@ declare module '@tanstack/react-router' {
interface ChatRouteChildren {
ChatThreadIdRoute: typeof ChatThreadIdRoute
+ ChatSettingsRoute: typeof ChatSettingsRoute
ChatIndexRoute: typeof ChatIndexRoute
}
const ChatRouteChildren: ChatRouteChildren = {
ChatThreadIdRoute: ChatThreadIdRoute,
+ ChatSettingsRoute: ChatSettingsRoute,
ChatIndexRoute: ChatIndexRoute,
}
diff --git a/apps/web/src/routes/_chat.settings.tsx b/apps/web/src/routes/_chat.settings.tsx
new file mode 100644
index 000000000..740707add
--- /dev/null
+++ b/apps/web/src/routes/_chat.settings.tsx
@@ -0,0 +1,259 @@
+import { createFileRoute } from "@tanstack/react-router";
+
+import { useAppSettings } from "../appSettings";
+import { isElectron } from "../env";
+import { useTheme } from "../hooks/useTheme";
+import { useStore } from "../store";
+import { Button } from "../components/ui/button";
+import { Input } from "../components/ui/input";
+import { Switch } from "../components/ui/switch";
+
+const THEME_OPTIONS = [
+ {
+ value: "system",
+ label: "System",
+ description: "Match your OS appearance setting.",
+ },
+ {
+ value: "light",
+ label: "Light",
+ description: "Always use the light theme.",
+ },
+ {
+ value: "dark",
+ label: "Dark",
+ description: "Always use the dark theme.",
+ },
+] as const;
+
+const RUNTIME_MODE_OPTIONS = [
+ {
+ value: "full-access",
+ label: "Full access",
+ description: "Allow commands to run without confirmation prompts.",
+ },
+ {
+ value: "approval-required",
+ label: "Supervised",
+ description: "Require approval prompts before command execution.",
+ },
+] as const;
+
+function SettingsRouteView() {
+ const { theme, setTheme, resolvedTheme } = useTheme();
+ const { state, dispatch } = useStore();
+ const { settings, defaults, updateSettings } = useAppSettings();
+
+ const codexBinaryPath = settings.codexBinaryPath;
+ const codexHomePath = settings.codexHomePath;
+
+ return (
+ <div className="flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground">
+ {isElectron && (
+ <div className="drag-region flex h-[52px] shrink-0 items-center border-b border-border px-5">
+ <span className="text-xs font-medium tracking-wide text-muted-foreground/70">Settings</span>
+ </div>
+ )}
+
+ <div className="flex-1 overflow-y-auto p-6">
+ <div className="mx-auto flex w-full max-w-3xl flex-col gap-6">
+ <header className="space-y-1">
+ <h1 className="text-2xl font-semibold tracking-tight text-foreground">Settings</h1>
+ <p className="text-sm text-muted-foreground">
+ Configure app-level preferences for this device.
+ </p>
+ </header>
+
+ <section className="rounded-2xl border border-border bg-card p-5">
+ <div className="mb-4">
+ <h2 className="text-sm font-medium text-foreground">Appearance</h2>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Choose how T3 Code handles light and dark mode.
+ </p>
+ </div>
+
+ <div className="space-y-2" role="radiogroup" aria-label="Theme preference">
+ {THEME_OPTIONS.map((option) => {
+ const selected = theme === option.value;
+ return (
+ <button
+ key={option.value}
+ type="button"
+ role="radio"
+ aria-checked={selected}
+ className={`flex w-full items-start justify-between rounded-lg border px-3 py-2 text-left transition-colors ${
+ selected
+ ? "border-primary/60 bg-primary/8 text-foreground"
+ : "border-border bg-background text-muted-foreground hover:bg-accent"
+ }`}
+ onClick={() => setTheme(option.value)}
+ >
+ <span className="flex flex-col">
+ <span className="text-sm font-medium">{option.label}</span>
+ <span className="text-xs">{option.description}</span>
+ </span>
+ {selected ? (
+ <span className="rounded bg-primary/14 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary">
+ Selected
+ </span>
+ ) : null}
+ </button>
+ );
+ })}
+ </div>
+
+ <p className="mt-4 text-xs text-muted-foreground">
+ Active theme: <span className="font-medium text-foreground">{resolvedTheme}</span>
+ </p>
+ </section>
+
+ <section className="rounded-2xl border border-border bg-card p-5">
+ <div className="mb-4">
+ <h2 className="text-sm font-medium text-foreground">Codex App Server</h2>
+ <p className="mt-1 text-xs text-muted-foreground">
+ These overrides apply to new sessions and let you use a non-default Codex install.
+ </p>
+ </div>
+
+ <div className="space-y-4">
+ <label className="block space-y-1">
+ <span className="text-xs font-medium text-foreground">Codex binary path</span>
+ <Input
+ value={codexBinaryPath}
+ onChange={(event) => updateSettings({ codexBinaryPath: event.target.value })}
+ placeholder="codex"
+ spellCheck={false}
+ />
+ <span className="text-xs text-muted-foreground">
+ Leave blank to use <code>codex</code> from your PATH.
+ </span>
+ </label>
+
+ <label className="block space-y-1">
+ <span className="text-xs font-medium text-foreground">CODEX_HOME path</span>
+ <Input
+ value={codexHomePath}
+ onChange={(event) => updateSettings({ codexHomePath: event.target.value })}
+ placeholder="/Users/you/.codex"
+ spellCheck={false}
+ />
+ <span className="text-xs text-muted-foreground">
+ Optional custom Codex home/config directory.
+ </span>
+ </label>
+
+ <div className="flex items-center justify-between gap-2 text-xs text-muted-foreground">
+ <p>
+ Binary source: <span className="font-medium text-foreground">{codexBinaryPath || "PATH"}</span>
+ </p>
+ <Button
+ size="xs"
+ variant="outline"
+ onClick={() =>
+ updateSettings({
+ codexBinaryPath: defaults.codexBinaryPath,
+ codexHomePath: defaults.codexHomePath,
+ })
+ }
+ >
+ Reset codex overrides
+ </Button>
+ </div>
+ </div>
+ </section>
+
+ <section className="rounded-2xl border border-border bg-card p-5">
+ <div className="mb-4">
+ <h2 className="text-sm font-medium text-foreground">Runtime Mode</h2>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Select the default execution policy for this client.
+ </p>
+ </div>
+
+ <div className="space-y-2" role="radiogroup" aria-label="Runtime mode preference">
+ {RUNTIME_MODE_OPTIONS.map((option) => {
+ const selected = state.runtimeMode === option.value;
+ return (
+ <button
+ key={option.value}
+ type="button"
+ role="radio"
+ aria-checked={selected}
+ className={`flex w-full items-start justify-between rounded-lg border px-3 py-2 text-left transition-colors ${
+ selected
+ ? "border-primary/60 bg-primary/8 text-foreground"
+ : "border-border bg-background text-muted-foreground hover:bg-accent"
+ }`}
+ onClick={() => {
+ dispatch({
+ type: "SET_RUNTIME_MODE",
+ mode: option.value,
+ });
+ }}
+ >
+ <span className="flex flex-col">
+ <span className="text-sm font-medium">{option.label}</span>
+ <span className="text-xs">{option.description}</span>
+ </span>
+ {selected ? (
+ <span className="rounded bg-primary/14 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary">
+ Selected
+ </span>
+ ) : null}
+ </button>
+ );
+ })}
+ </div>
+ </section>
+
+ <section className="rounded-2xl border border-border bg-card p-5">
+ <div className="mb-4">
+ <h2 className="text-sm font-medium text-foreground">Safety</h2>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Additional guardrails for destructive local actions.
+ </p>
+ </div>
+
+ <div className="flex items-center justify-between rounded-lg border border-border bg-background px-3 py-2">
+ <div>
+ <p className="text-sm font-medium text-foreground">Confirm thread deletion</p>
+ <p className="text-xs text-muted-foreground">
+ Ask for confirmation before deleting a thread and its chat history.
+ </p>
+ </div>
+ <Switch
+ checked={settings.confirmThreadDelete}
+ onCheckedChange={(checked) =>
+ updateSettings({
+ confirmThreadDelete: Boolean(checked),
+ })
+ }
+ aria-label="Confirm thread deletion"
+ />
+ </div>
+
+ {settings.confirmThreadDelete !== defaults.confirmThreadDelete ? (
+ <div className="mt-3 flex justify-end">
+ <Button
+ size="xs"
+ variant="outline"
+ onClick={() =>
+ updateSettings({
+ confirmThreadDelete: defaults.confirmThreadDelete,
+ })
+ }
+ >
+ Restore default
+ </Button>
+ </div>
+ ) : null}
+ </section>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+export const Route = createFileRoute("/_chat/settings")({
+ component: SettingsRouteView,
+});
diff --git a/apps/web/src/routes/_chat.tsx b/apps/web/src/routes/_chat.tsx
index 702e873b0..ed931773e 100644
--- a/apps/web/src/routes/_chat.tsx
+++ b/apps/web/src/routes/_chat.tsx
@@ -1,5 +1,5 @@
-import { Outlet, createFileRoute } from "@tanstack/react-router";
-import { Activity, Suspense, lazy, type ReactNode } from "react";
+import { Outlet, createFileRoute, useNavigate } from "@tanstack/react-router";
+import { Activity, Suspense, lazy, type ReactNode, useEffect } from "react";
import Sidebar from "../components/Sidebar";
import { useMediaQuery } from "../hooks/useMediaQuery";
@@ -48,6 +48,23 @@ const DiffPanelWrapper = (props: { children: ReactNode; sheet: boolean }) => {
function ChatRouteLayout() {
const { state } = useStore();
const shouldUseDiffSheet = useMediaQuery(DIFF_INLINE_LAYOUT_MEDIA_QUERY);
+ const navigate = useNavigate();
+
+ useEffect(() => {
+ const onMenuAction = window.desktopBridge?.onMenuAction;
+ if (typeof onMenuAction !== "function") {
+ return;
+ }
+
+ const unsubscribe = onMenuAction((action) => {
+ if (action !== "open-settings") return;
+ void navigate({ to: "/settings" });
+ });
+
+ return () => {
+ unsubscribe?.();
+ };
+ }, [navigate]);
const diffLoadingFallback =
!state.diffOpen || shouldUseDiffSheet ? (
diff --git a/apps/web/src/vite-env.d.ts b/apps/web/src/vite-env.d.ts
index 3438d5d7b..93076c718 100644
--- a/apps/web/src/vite-env.d.ts
+++ b/apps/web/src/vite-env.d.ts
@@ -8,6 +8,7 @@ interface DesktopBridge {
confirm: (message: string) => Promise<boolean>;
showContextMenu: (items: readonly { id: string; label: string }[]) => Promise<string | null>;
openExternal: (url: string) => Promise<boolean>;
+ onMenuAction: (listener: (action: string) => void) => () => void;
}
declare global {
diff --git a/packages/contracts/src/provider.test.ts b/packages/contracts/src/provider.test.ts
index df9c8e9b3..15910a432 100644
--- a/packages/contracts/src/provider.test.ts
+++ b/packages/contracts/src/provider.test.ts
@@ -37,6 +37,28 @@ describe("providerSessionStartInputSchema", () => {
}),
).toThrow();
});
+
+ it("accepts optional codex binary and home path overrides", () => {
+ const parsed = providerSessionStartInputSchema.parse({
+ codexBinaryPath: "/opt/codex/bin/codex",
+ codexHomePath: "/Users/theo/.codex",
+ });
+ expect(parsed.codexBinaryPath).toBe("/opt/codex/bin/codex");
+ expect(parsed.codexHomePath).toBe("/Users/theo/.codex");
+ });
+
+ it("rejects blank codex overrides", () => {
+ expect(() =>
+ providerSessionStartInputSchema.parse({
+ codexBinaryPath: " ",
+ }),
+ ).toThrow();
+ expect(() =>
+ providerSessionStartInputSchema.parse({
+ codexHomePath: " ",
+ }),
+ ).toThrow();
+ });
});
describe("providerSendTurnInputSchema", () => {
diff --git a/packages/contracts/src/provider.ts b/packages/contracts/src/provider.ts
index 65877a6a1..06a7582a8 100644
--- a/packages/contracts/src/provider.ts
+++ b/packages/contracts/src/provider.ts
@@ -50,6 +50,8 @@ export const providerSessionStartInputSchema = z.object({
cwd: z.string().min(1).optional(),
model: z.string().trim().min(1).optional(),
resumeThreadId: z.string().trim().min(1).optional(),
+ codexBinaryPath: z.string().trim().min(1).optional(),
+ codexHomePath: z.string().trim().min(1).optional(),
approvalPolicy: providerApprovalPolicySchema.default("never"),
sandboxMode: providerSandboxModeSchema.default("workspace-write"),
});