A desktop coding agent with free access to frontier models.
TypeScript
feat: assistant models in the picker
ogsamrat2ca026bddc52
diff --git a/apps/app/src/components/model-select.tsx b/apps/app/src/components/model-select.tsxindex 3f77b9e6..e33c4c43 100644--- a/apps/app/src/components/model-select.tsx+++ b/apps/app/src/components/model-select.tsx@@ -61,6 +61,7 @@ import {} from "@/app/utils";import { isSupportedModelProvider, providerCatalogRank } from "@/app/lib/provider-catalog";import { useModelModeFilter } from "@/react-app/domains/session/surface/model-modes";+import { claudeModelOptions, useClaudeModels, useModelPickGate } from "@/react-app/domains/session/surface/claude-models";function getProviderDisplayName(providerId: string) {return providerId@@ -265,7 +266,12 @@ export function ModelSelect({// Only the models the open project's mode allows (sandbox or not: model-modes.ts).const modeAllows = useModelModeFilter((state) => state.allows);const allOptions = useModelOptions(open, fallbackOptions, denAuth.isSignedIn);- const catalogOptions = React.useMemo(() => allOptions.filter((option) => modeAllows(option)), [allOptions, modeAllows]);+ // Claude is listed in every project: picking it sets the project's sandbox up (claude-models.ts).+ const claudeCatalog = useClaudeModels((state) => state.catalog);+ const catalogOptions = React.useMemo(+ () => [...allOptions.filter((option) => modeAllows(option)), ...claudeModelOptions({ catalog: claudeCatalog })],+ [allOptions, claudeCatalog, modeAllows],+ );const modelOptions = React.useMemo(() => dedupeModelOptions(overlaySelectedBehavior(@@ -379,8 +385,17 @@ export function ModelSelect({&& Boolean(effectiveBehaviorLabel);const applyModel = (option: ModelOption, behavior?: string | null) => {+ const next = { providerID: option.providerID, modelID: option.modelID };+ // The route may take the pick instead (a new-chat popup, Claude, a message).+ if (useModelPickGate.getState().intercept(next, sessionId ?? null)) {+ setSearch("");+ setThinkingFor(null);+ setPane("root");+ onOpenChange(false);+ return;+ }useModelCollectionsStore.getState().recordRecent(option);- onChange({ providerID: option.providerID, modelID: option.modelID }, behavior);+ onChange(next, behavior);if (behavior !== undefined) {onBehaviorChange?.(behavior);}diff --git a/apps/app/src/react-app/domains/session/surface/claude-models.ts b/apps/app/src/react-app/domains/session/surface/claude-models.tsnew file mode 100644index 00000000..81c41e2e--- /dev/null+++ b/apps/app/src/react-app/domains/session/surface/claude-models.ts@@ -0,0 +1,161 @@+// Claude in the model picker. The server's capability `claude_code` lists the+// Claude models: `catalog` (what every account sees) and `models` (what this+// account may run); the local server passes both through+// GET /workspace/:id/claude/status (claude-code/runtime.ts available()).+// Claude runs only in the sandbox, on its own runtime (claude-code/), never in+// the chat engine: picking it sets the project's sandbox up and opens a Claude+// chat. A chat keeps one model; another pick in a chat that already ran offers+// a new chat instead.+import { useEffect } from "react";+import { create } from "zustand";++import type { ModelOption, ModelRef } from "@/app/types";+import type { OmniRushServerClient, OmniRushWorkspaceBox, OmniRushWorkspaceBoxSetupAction } from "@/app/lib/omnirush-server";++export type ClaudeCatalogEntry = { id: string; name: string };+export type ClaudeModelsState = {+ workspaceId: string | null;+ catalog: ClaudeCatalogEntry[];+ /** The ids this account may run. */+ models: string[];+ /** Why none may run (the capability's access.reason), null while some may. */+ reason: string | null;+};++const CLAUDE_ID = /^claude-[a-z0-9][a-z0-9.-]{0,62}$/;+const EMPTY: ClaudeModelsState = { workspaceId: null, catalog: [], models: [], reason: null };++export const useClaudeModels = create<ClaudeModelsState>(() => EMPTY);++/** A Claude model of the picker: the omnirush provider with a Claude catalog id (the chat engine's catalog never has one). */+export function isClaudeModel(model: ModelRef | null | undefined): boolean {+ return model?.providerID === "omnirush" && CLAUDE_ID.test(model.modelID);+}++export function claudeModelName(state: Pick<ClaudeModelsState, "catalog">, id: string): string {+ return state.catalog.find((entry) => entry.id === id)?.name ?? id;+}++/** The picker's Claude entries: every catalog model, in every project (allowed or not: picking explains). */+export function claudeModelOptions(state: Pick<ClaudeModelsState, "catalog">): ModelOption[] {+ return state.catalog.map((entry) => ({+ providerID: "omnirush",+ modelID: entry.id,+ title: entry.name,+ description: "Runs in the sandbox",+ group: "Claude",+ behaviorTitle: "",+ behaviorLabel: "",+ behaviorDescription: "",+ behaviorValue: null,+ isFree: false,+ }));+}++/** "Claude Sonnet 5.5 isn't available on your account yet." */+export function claudeUnavailableMessage(name: string, reason: string | null): string {+ if (reason === "client_outdated") return `${name} needs the latest OmniRush. Update the app to use it.`;+ if (reason === "account_not_usable") return `${name} isn't available while your account is paused.`;+ if (reason === "claude_off") return `${name} isn't available right now. Try again later.`;+ return `${name} isn't available on your account yet.`;+}++export type ModelPick =+ | { kind: "same" }+ | { kind: "switch" }+ | { kind: "claude" }+ | { kind: "new_chat" }+ | { kind: "unavailable"; message: string };++/**+ * What picking `next` does. `current` is the chat's model and `started` says it+ * already ran (its model is fixed: one model per chat). An unavailable Claude+ * model is explained first, wherever it is picked; a different model in a+ * started chat offers a new chat; in a fresh chat a Claude model opens Claude+ * and any other model is simply switched to.+ */+export function decideModelPick(input: { next: ModelRef; current: ModelRef | null; started: boolean; claude: ClaudeModelsState }): ModelPick {+ const { next, current, started, claude } = input;+ const same = Boolean(current && current.providerID === next.providerID && current.modelID === next.modelID);+ if (same) return { kind: "same" };+ if (isClaudeModel(next) && !claude.models.includes(next.modelID)) {+ return { kind: "unavailable", message: claudeUnavailableMessage(claudeModelName(claude, next.modelID), claude.reason) };+ }+ if (started && current) return { kind: "new_chat" };+ return isClaudeModel(next) ? { kind: "claude" } : { kind: "switch" };+}++/** "Start a new chat with Claude Sonnet 5.5?" and why. */+export function newChatPrompt(currentName: string, nextName: string): { title: string; message: string } {+ return {+ title: `Start a new chat with ${nextName}?`,+ message: `This chat runs on ${currentName}, and a chat keeps one model. A new chat on ${nextName} starts in this project; this chat stays as it is.`,+ };+}++/**+ * The next step that sets this project's sandbox up for Claude, the same steps+ * the required sandbox takes (Settings' sandbox card, the composer chip):+ * "on" turns the project's sandbox on; a setup action runs this computer's+ * own setup (Linux user namespaces, the Windows WSL install; the macOS VM+ * sets itself up once on); null: nothing to do (on and set up, or it cannot run here).+ */+export function claudeSandboxStep(box: Pick<OmniRushWorkspaceBox, "on" | "setup"> | null): "on" | OmniRushWorkspaceBoxSetupAction | null {+ if (!box) return null;+ if (!box.on) return "on";+ const need = box.setup?.need;+ if ((need === "linux_allow" || need === "win_install") && !box.setup?.declined) return need;+ return null;+}++/** Set the project's sandbox up for Claude: on, then this computer's setup step (each at most once). */+export async function setUpClaudeSandbox(client: Pick<OmniRushServerClient, "getWorkspaceBox" | "setWorkspaceBox" | "setupWorkspaceBox">, workspaceId: string): Promise<OmniRushWorkspaceBox | null> {+ let box = await client.getWorkspaceBox(workspaceId, { fresh: true }).catch(() => null);+ const done = new Set<string>();+ for (let step = claudeSandboxStep(box); step && !done.has(step); step = claudeSandboxStep(box)) {+ done.add(step);+ box = step === "on" ? await client.setWorkspaceBox(workspaceId, "on") : await client.setupWorkspaceBox(workspaceId, step);+ }+ return box;+}++type StatusClient = { claude: Pick<OmniRushServerClient["claude"], "request"> };++/** The open project's Claude models, read from its server (again when the window comes back). */+export function useClaudeModelSync(client: StatusClient | null, workspaceId: string | null) {+ useEffect(() => {+ if (!client || !workspaceId) {+ useClaudeModels.setState(EMPTY);+ return;+ }+ let closed = false;+ const load = () => {+ void client.claude.request<{ models?: unknown; catalog?: unknown; reason?: unknown }>(workspaceId, "status").then((status) => {+ if (!closed) useClaudeModels.setState(parseClaudeStatus(workspaceId, status));+ }, () => {+ // An older or unreachable server: no Claude entries, nothing breaks.+ if (!closed) useClaudeModels.setState({ ...EMPTY, workspaceId });+ });+ };+ const onVisible = () => { if (document.visibilityState === "visible") load(); };+ load();+ document.addEventListener("visibilitychange", onVisible);+ return () => { closed = true; document.removeEventListener("visibilitychange", onVisible); };+ }, [client, workspaceId]);+}++export function parseClaudeStatus(workspaceId: string, status: { models?: unknown; catalog?: unknown; reason?: unknown } | null | undefined): ClaudeModelsState {+ const catalog = Array.isArray(status?.catalog)+ ? status.catalog.flatMap((entry): ClaudeCatalogEntry[] => entry && typeof entry.id === "string" && CLAUDE_ID.test(entry.id)+ ? [{ id: entry.id, name: typeof entry.name === "string" && entry.name.trim() ? entry.name.trim() : entry.id }] : [])+ : [];+ const models = Array.isArray(status?.models) ? status.models.filter((id): id is string => typeof id === "string" && CLAUDE_ID.test(id)) : [];+ return { workspaceId, catalog, models, reason: typeof status?.reason === "string" ? status.reason : null };+}++/**+ * The open route's handler for a model pick (set by the session route): true+ * when it took the pick (a popup, a message, Claude), so the picker does not+ * switch the chat's model itself.+ */+export const useModelPickGate = create<{ intercept: (next: ModelRef, sessionId: string | null) => boolean }>(() => ({ intercept: () => false }));diff --git a/apps/app/src/react-app/shell/claude-route.tsx b/apps/app/src/react-app/shell/claude-route.tsxindex 845cc0dc..f4df19ce 100644--- a/apps/app/src/react-app/shell/claude-route.tsx+++ b/apps/app/src/react-app/shell/claude-route.tsx@@ -1,5 +1,5 @@import { useCallback, useEffect, useState } from "react";-import { Link, useParams } from "react-router";+import { Link, useParams, useSearchParams } from "react-router";import { Button } from "@/components/ui/button";import { isDesktopRuntime } from "@/app/lib/runtime-env";import { useBootState } from "./boot-state";@@ -28,6 +28,9 @@ function WorkspaceClaudeRoute({workspaceId}: {workspaceId: string | undefined})const [prompt, setPrompt] = useState(""), [command, setCommand] = useState("");const [consent, setConsent] = useState(false), [busy, setBusy] = useState(false);const [error, setError] = useState(""), [notice, setNotice] = useState("");+ // The model a new session starts on: the picker's choice (?model=) when this account may run it.+ const [searchParams] = useSearchParams();+ const [models, setModels] = useState<Array<{id: string; name: string}>>([]), [model, setModel] = useState("");const request = useCallback(async <T,>(route: string, body?: unknown): Promise<T> => {if (!endpoint) throw new Error("Workspace server is unavailable");endpoint.signal.throwIfAborted();@@ -40,12 +43,15 @@ function WorkspaceClaudeRoute({workspaceId}: {workspaceId: string | undefined})}, [connecting, markRouteReady]);const refresh = useCallback(async () => {const [status, items] = await Promise.all([- request<{allowed: boolean; sandboxReady: boolean}>("status"),+ request<{allowed: boolean; sandboxReady: boolean; models?: string[]; catalog?: Array<{id: string; name: string}>}>("status"),request<Session[]>("sessions"),]);setAllowed(status.allowed); setReady(status.sandboxReady);+ const runnable = (status.models ?? []).map(id => ({id, name: status.catalog?.find(entry => entry.id === id)?.name ?? id}));+ setModels(runnable);+ setModel(current => runnable.some(entry => entry.id === current) ? current : runnable.find(entry => entry.id === searchParams.get("model"))?.id ?? runnable[0]?.id ?? "");setSessions(items); setLoaded(true);- }, [request]);+ }, [request, searchParams]);useEffect(() => {setLoaded(false); setAllowed(false); setReady(false);if (endpoint) void refresh().catch(e => {@@ -111,16 +117,17 @@ function WorkspaceClaudeRoute({workspaceId}: {workspaceId: string | undefined})}return <main className="mx-auto h-full max-w-5xl space-y-4 overflow-auto p-6" aria-label={surface === "full" ? "Claude Code workspace" : "Saved sessions"}><header className="flex items-center justify-between">{surface === "full"- ? <div><h1 className="text-xl font-semibold">Claude Code</h1><p className="text-sm text-muted-foreground">Opus 5.5 · Private sandbox sessions</p></div>+ ? <div><h1 className="text-xl font-semibold">Claude Code</h1><p className="text-sm text-muted-foreground">{models.find(entry => entry.id === model)?.name ?? "Claude"} · Private sandbox sessions</p></div>: <div><h1 className="text-xl font-semibold">Saved sessions</h1><p className="text-sm text-muted-foreground">Export or recover the sessions saved here.</p></div>}<Link to={`/workspace/${workspaceId}/session`}>Back to chats</Link></header>{error && <p role="alert" className="rounded border border-destructive p-3">{error}</p>}{notice && <p role="status" data-testid="claude-notice" className="sticky top-0 z-10 rounded border bg-background p-3">{notice}</p>}<>- {allowed && !ready && <p>Start Docker Desktop or Docker Engine, then <button onClick={() => void act(refresh)}>check again</button>.</p>}+ {allowed && !ready && <p role="status" data-testid="claude-needs-docker">Claude needs Docker on this computer for now. Install and start Docker Desktop or Docker Engine, then <button className="underline" onClick={() => void act(refresh)}>check again</button>.</p>}<section className="flex flex-wrap items-center gap-3 rounded border p-3" aria-label="Session controls"><select aria-label="Claude session" value={selected ?? ""} onChange={e => { setSession(undefined); setEvents([]); setSelected(e.target.value || undefined); }} className="max-w-64 rounded border bg-background p-2"><option value="">Choose a session</option>{sessions.map(item => <option key={item.id} value={item.id}>{new Date(item.createdAt).toLocaleString()} · {item.id.slice(0,8)}</option>)}</select>+ {surface === "full" && models.length > 1 && <select aria-label="Claude model" value={model} onChange={e => setModel(e.target.value)} className="rounded border bg-background p-2">{models.map(entry => <option key={entry.id} value={entry.id}>{entry.name}</option>)}</select>}{surface === "full" && <><label className="flex items-center gap-2 text-sm"><input type="checkbox" checked={consent} onChange={e => setConsent(e.target.checked)} />Retain private traces and full project snapshots</label>- <Button disabled={!allowed || !ready || busy || !consent} onClick={() => void act(async () => { setNotice("Preparing the sandbox and copying your project. The first setup may take several minutes."); const created = await request<Session>("sessions", {captureConsent: true}); await refresh(); setSelected(created.id); setNotice("Sandbox ready. Changes stay in this session’s project copy."); })}>New Claude session</Button></>}+ <Button disabled={!allowed || !ready || busy || !consent} onClick={() => void act(async () => { setNotice("Preparing the sandbox and copying your project. The first setup may take several minutes."); const created = await request<Session>("sessions", {captureConsent: true, ...(model ? {model} : {})}); await refresh(); setSelected(created.id); setNotice("Sandbox ready. Changes stay in this session’s project copy."); })}>New Claude session</Button></>}</section>{session && <><div className="space-y-1 text-sm" aria-label="Fixed session model">diff --git a/apps/app/src/react-app/shell/session-route.tsx b/apps/app/src/react-app/shell/session-route.tsxindex 688c41c7..ea084720 100644--- a/apps/app/src/react-app/shell/session-route.tsx+++ b/apps/app/src/react-app/shell/session-route.tsx@@ -142,6 +142,8 @@ import { useSessionFindStore } from "@/react-app/domains/session/surface/find-stimport { useModelPicker } from "@/react-app/domains/session/modals/use-model-picker";import { getSessionModelSelection, resolveSendVariant, useSessionModelStore } from "@/react-app/domains/session/surface/session-model-store";import { chatStarted, markChatStarted, useProjectModelModes } from "@/react-app/domains/session/surface/model-modes";+import { claudeModelName, claudeModelOptions, decideModelPick, isClaudeModel, newChatPrompt, setUpClaudeSandbox, useClaudeModels, useClaudeModelSync, useModelPickGate } from "@/react-app/domains/session/surface/claude-models";+import { ConfirmModal } from "@/react-app/design-system/modals/confirm-modal";import { useWorkbenchStore } from "@/react-app/domains/session/chat/workbench-store";import { resolveWorkbenchPaneEndpoint } from "@/react-app/domains/session/chat/pane-runtime";import {@@ -1001,6 +1003,7 @@ export function SessionRoute() {const modelModes = useProjectModelModes(selectedWorkspaceEndpoint?.client ?? null, selectedWorkspaceEndpoint?.workspaceId ?? null, selectedSessionId || null);const modelModesRef = useRef(modelModes);modelModesRef.current = modelModes;+ useClaudeModelSync(selectedWorkspaceEndpoint?.client ?? null, selectedWorkspaceEndpoint?.workspaceId ?? null);// The default as this project may use it: one its mode does not allow moves to the allowed default.const projectDefaultModel = modelModes.fallback(local.prefs.defaultModel ?? null) ?? local.prefs.defaultModel ?? null;/**@@ -2838,18 +2841,64 @@ export function SessionRoute() {})(): modelVariantValue;+ // Every list the route shows: the project's allowed models and Claude (listed everywhere).+ const claudeCatalog = useClaudeModels((state) => state.catalog);+ const pickerOptions = useMemo(+ () => [...modelPicker.options.filter((option) => modelModes.allowsNew(option)), ...claudeModelOptions({ catalog: claudeCatalog })],+ [claudeCatalog, modelModes, modelPicker.options],+ );+ // A pick the picker should not just switch to (claude-models.ts decideModelPick).+ const [newChatOffer, setNewChatOffer] = useState<{ next: ModelRef; current: ModelRef } | null>(null);+ const modelTitle = (ref: ModelRef) => isClaudeModel(ref)+ ? claudeModelName(useClaudeModels.getState(), ref.modelID)+ : modelPicker.options.find((option) => option.providerID === ref.providerID && option.modelID === ref.modelID)?.title ?? resolveModelDisplayName(ref.modelID);+ /** Claude: set the project's sandbox up (as the required sandbox does) and open a Claude chat on `model`. */+ const openClaudeChat = (model: ModelRef) => {+ const endpoint = selectedWorkspaceEndpoint;+ if (!selectedWorkspaceId) return;+ if (endpoint?.client) {+ void setUpClaudeSandbox(endpoint.client, endpoint.workspaceId).catch(() => {+ toast.error("The sandbox could not be set up for Claude. Check Settings > General > Sandbox.", { id: "claude-sandbox" });+ });+ }+ navigate(`/workspace/${encodeURIComponent(selectedWorkspaceId)}/claude?model=${encodeURIComponent(model.modelID)}`);+ };+ const handleModelPick = (next: ModelRef, sessionId: string | null): boolean => {+ const current = sessionId ? getSessionModelSelection(sessionId)?.model ?? null : null;+ const pick = decideModelPick({ next, current, started: Boolean(sessionId && chatStarted(sessionId)), claude: useClaudeModels.getState() });+ if (pick.kind === "unavailable") toast(pick.message, { id: `claude-unavailable:${next.modelID}` });+ else if (pick.kind === "new_chat" && current) setNewChatOffer({ next, current });+ else if (pick.kind === "claude") openClaudeChat(next);+ return pick.kind !== "switch" && pick.kind !== "same";+ };+ const modelPickRef = useRef(handleModelPick);+ modelPickRef.current = handleModelPick;+ useEffect(() => {+ useModelPickGate.setState({ intercept: (next, sessionId) => modelPickRef.current(next, sessionId) });+ return () => useModelPickGate.setState({ intercept: () => false });+ }, []);+ const confirmNewChat = async () => {+ const offer = newChatOffer;+ setNewChatOffer(null);+ if (!offer || !selectedWorkspaceId) return;+ if (isClaudeModel(offer.next)) {+ openClaudeChat(offer.next);+ return;+ }+ const sessionId = await handleCreateTaskInWorkspace(selectedWorkspaceId);+ if (!sessionId) return;+ useSessionModelStore.getState().setModel(sessionId, offer.next, null);+ local.setPrefs((previous) => ({ ...previous, defaultModel: offer.next, modelVariant: null }));+ };+const applySessionRouteModelSelection = useCallback((next: ModelRef,targetSessionId: string | null,behavior?: { value: string | null },) => {const explicitBehavior = behavior !== undefined;- // One model per chat: a chat that sent a prompt keeps its model.- const fixed = targetSessionId && chatStarted(targetSessionId) ? getSessionModelSelection(targetSessionId)?.model : null;- if (fixed && (fixed.providerID !== next.providerID || fixed.modelID !== next.modelID)) {- toast(modelModesRef.current.fixedNote(fixed, next), { id: `model-fixed:${targetSessionId}` });- return;- }+ // One model per chat (a started chat offers a new one), and Claude opens its own chat.+ if (modelPickRef.current(next, targetSessionId)) return;useModelCollectionsStore.getState().recordRecent(next);if (targetSessionId) {const sessionStore = useSessionModelStore.getState();@@ -4051,6 +4100,15 @@ export function SessionRoute() {extensionsActive={extensionsMainOpen}onAccessibleTargetsChange={setPaletteAccessibleTargets}/>+ <ConfirmModal+ open={newChatOffer !== null}+ title={newChatOffer ? newChatPrompt(modelTitle(newChatOffer.current), modelTitle(newChatOffer.next)).title : ""}+ message={newChatOffer ? newChatPrompt(modelTitle(newChatOffer.current), modelTitle(newChatOffer.next)).message : ""}+ confirmLabel="Start new chat"+ cancelLabel="Keep this chat"+ onConfirm={() => void confirmNewChat()}+ onCancel={() => setNewChatOffer(null)}+ /><CreateWorkspaceModalopen={createWorkspaceOpen}onClose={() => {@@ -4131,7 +4189,7 @@ export function SessionRoute() {onOpenAutomations={() => navigate(automationsRoute())}onOpenDashboard={() => navigate(dashboardRoute())}onCreateWorkspace={handleOpenCreateWorkspace}- modelOptions={modelPicker.options.filter((option) => modelModes.allowsNew(option))}+ modelOptions={pickerOptions}selectedModel={paletteSelectedModel}selectedModelBehavior={paletteSelectedModelBehavior}onSelectModel={(next, behavior) => {@@ -4172,7 +4230,7 @@ export function SessionRoute() {/><ModelPickerModalopen={modelPicker.open}- options={modelPicker.options.filter((option) => modelModes.allowsNew(option))}+ options={pickerOptions}organizationModelsEmpty={organizationModelsEmpty}organizationModelsSettingsUrl={organizationModelsSettingsUrl}diff --git a/apps/app/tests/claude-models.test.ts b/apps/app/tests/claude-models.test.tsnew file mode 100644index 00000000..70a50b15--- /dev/null+++ b/apps/app/tests/claude-models.test.ts@@ -0,0 +1,113 @@+import { describe, expect, test } from "bun:test";++import {+ claudeModelOptions,+ claudeSandboxStep,+ decideModelPick,+ isClaudeModel,+ newChatPrompt,+ parseClaudeStatus,+ setUpClaudeSandbox,+ type ClaudeModelsState,+} from "../src/react-app/domains/session/surface/claude-models";++const opus = { providerID: "omnirush", modelID: "claude-opus-5-5" };+const sonnet = { providerID: "omnirush", modelID: "claude-sonnet-5-5" };+const astra = { providerID: "omnirush", modelID: "gpt-6-astra" };+const sol = { providerID: "omnirush", modelID: "gpt-6.1-sol" };+const catalog = [{ id: opus.modelID, name: "Claude Opus 5.5" }, { id: sonnet.modelID, name: "Claude Sonnet 5.5" }];+const allowed: ClaudeModelsState = { workspaceId: "w", catalog, models: [opus.modelID, sonnet.modelID], reason: null };+const denied: ClaudeModelsState = { workspaceId: "w", catalog, models: [], reason: "not_allowed" };++describe("picker entries", () => {+ test("every catalog model is listed, allowed or not, under Claude", () => {+ for (const state of [allowed, denied]) {+ const options = claudeModelOptions(state);+ expect(options.map((option) => [option.providerID, option.modelID, option.title, option.group])).toEqual([+ ["omnirush", "claude-opus-5-5", "Claude Opus 5.5", "Claude"],+ ["omnirush", "claude-sonnet-5-5", "Claude Sonnet 5.5", "Claude"],+ ]);+ }+ expect(claudeModelOptions({ catalog: [] })).toEqual([]);+ });++ test("only omnirush Claude ids are Claude models", () => {+ expect(isClaudeModel(opus)).toBe(true);+ expect(isClaudeModel(astra)).toBe(false);+ expect(isClaudeModel({ providerID: "anthropic", modelID: "claude-opus-5-5" })).toBe(false);+ });++ test("the status answer is read defensively", () => {+ expect(parseClaudeStatus("w", { models: [opus.modelID, 7, "gpt-6-astra"], catalog: [...catalog, { id: "bad id" }, null], reason: null }))+ .toEqual({ workspaceId: "w", catalog, models: [opus.modelID], reason: null });+ expect(parseClaudeStatus("w", null)).toEqual({ workspaceId: "w", catalog: [], models: [], reason: null });+ });+});++describe("popup decision", () => {+ test("a fresh chat just switches, or opens Claude", () => {+ expect(decideModelPick({ next: sol, current: astra, started: false, claude: allowed })).toEqual({ kind: "switch" });+ expect(decideModelPick({ next: sonnet, current: astra, started: false, claude: allowed })).toEqual({ kind: "claude" });+ expect(decideModelPick({ next: opus, current: null, started: false, claude: allowed })).toEqual({ kind: "claude" });+ });++ test("a started chat on another model offers a new chat, Claude or not", () => {+ expect(decideModelPick({ next: sol, current: astra, started: true, claude: allowed })).toEqual({ kind: "new_chat" });+ expect(decideModelPick({ next: sonnet, current: astra, started: true, claude: allowed })).toEqual({ kind: "new_chat" });+ expect(decideModelPick({ next: astra, current: astra, started: true, claude: allowed })).toEqual({ kind: "same" });+ });++ test("an account without Claude is told plainly, wherever it picks, with no switch", () => {+ for (const started of [false, true]) {+ expect(decideModelPick({ next: sonnet, current: astra, started, claude: denied }))+ .toEqual({ kind: "unavailable", message: "Claude Sonnet 5.5 isn't available on your account yet." });+ }+ expect(decideModelPick({ next: opus, current: null, started: false, claude: { ...denied, reason: "client_outdated" } }))+ .toEqual({ kind: "unavailable", message: "Claude Opus 5.5 needs the latest OmniRush. Update the app to use it." });+ // A model the account may run alongside one it may not.+ expect(decideModelPick({ next: sonnet, current: null, started: false, claude: { ...allowed, models: [opus.modelID] } }).kind).toBe("unavailable");+ });++ test("the popup names both models", () => {+ expect(newChatPrompt("GPT 6 Astra", "Claude Sonnet 5.5").title).toBe("Start a new chat with Claude Sonnet 5.5?");+ });+});++describe("auto sandbox", () => {+ const box = (on: boolean, need: string = "none", declined = false) => ({ on, setup: { need, declined } }) as never;++ test("the next step: on, then this computer's setup, then nothing", () => {+ expect(claudeSandboxStep(null)).toBeNull();+ expect(claudeSandboxStep(box(false))).toBe("on");+ expect(claudeSandboxStep(box(true, "linux_allow"))).toBe("linux_allow");+ expect(claudeSandboxStep(box(true, "win_install"))).toBe("win_install");+ expect(claudeSandboxStep(box(true, "win_install", true))).toBeNull();+ expect(claudeSandboxStep(box(true, "mac_vm"))).toBeNull();+ expect(claudeSandboxStep(box(true, "cannot_run"))).toBeNull();+ expect(claudeSandboxStep(box(true))).toBeNull();+ });++ test("a native project is turned on and set up once, with no loop", async () => {+ const calls: string[] = [];+ const client = {+ getWorkspaceBox: async () => { calls.push("get"); return box(false); },+ setWorkspaceBox: async (_: string, mode: string | null) => { calls.push(`set:${mode}`); return box(true, "linux_allow"); },+ // The step did not take (the person closed the prompt): never asked again in a loop.+ setupWorkspaceBox: async (_: string, action: string) => { calls.push(`setup:${action}`); return box(true, "linux_allow"); },+ };+ const result = await setUpClaudeSandbox(client as never, "w");+ expect(calls).toEqual(["get", "set:on", "setup:linux_allow"]);+ expect((result as { on: boolean }).on).toBe(true);+ });++ test("a sandbox project already set up is left alone", async () => {+ const calls: string[] = [];+ const client = {+ getWorkspaceBox: async () => { calls.push("get"); return box(true); },+ setWorkspaceBox: async () => { throw new Error("must not change"); },+ setupWorkspaceBox: async () => { throw new Error("must not change"); },+ };+ await setUpClaudeSandbox(client as never, "w");+ expect(calls).toEqual(["get"]);+ });+});diff --git a/apps/server/src/box/service.ts b/apps/server/src/box/service.tsindex 7a4f71e7..e2a4764b 100644--- a/apps/server/src/box/service.ts+++ b/apps/server/src/box/service.ts@@ -306,6 +306,18 @@ export class BoxService {return detectRuntime({ boxHome: this.home, env: this.env, ...this.detectOptions(), ...extra });}+ /**+ * The docker CLI of this machine's box backend when it is a Docker engine+ * (Docker Engine/Desktop, OrbStack, Rancher): runtimes that drive docker+ * themselves (Claude Code, claude-code/runtime.ts) use the same engine.+ * Null for the boxd backends (bubblewrap, the WSL distro, the VM), Podman and+ * a CLI that needs leading arguments (a docker context, wsl.exe).+ */+ async dockerCli(): Promise<string | null> {+ const runtime = await this.detect().catch(() => null);+ return runtime?.ok && runtime.name === "docker" && !runtime.prefix?.length && !runtime.wsl ? runtime.bin : null;+ }+/*** Save the machine's backend ("auto", one backend id, "native"). Projects* are planned again with it (a running box keeps going until its projectdiff --git a/apps/server/src/server.ts b/apps/server/src/server.tsindex 054b6375..df32ddae 100644--- a/apps/server/src/server.ts+++ b/apps/server/src/server.ts@@ -1541,14 +1541,20 @@ export async function startServer(config: ServerConfig): Promise<ServeResult> {bestPracticesReloads,);+ // Claude Code drives docker itself: the box backend's Docker engine when it is one, else `docker` on PATH.+ let claudeDocker: string | undefined;const claudeRuntime = new ClaudeRuntime({+ get docker() { return claudeDocker; },directory: join(runtimeStorageDir(config), "claude-sessions"), surface: "gui", fetch: externalFetch,access: () => gatewayBroker.claudeAccess(),authorize: context => gatewayBroker.claudeGrant(context),revoke: context => gatewayBroker.revokeClaudeGrant(context),});registerClaudeRoutes({routes, runtime: claudeRuntime,- workspace: ctx => resolveWorkspaceWithoutBootstrap(config, ctx.params.id),+ workspace: async ctx => {+ claudeDocker = (await boxServiceFor(config).dockerCli().catch(() => null)) ?? undefined;+ return resolveWorkspaceWithoutBootstrap(config, ctx.params.id);+ },owner: ctx => requireClientScope(ctx, "owner"),writable: () => ensureWritable(config),upload: id => uploadClaudeSession(claudeRuntime, id, (owner, route, init) => gatewayBroker.nativeCaptureRequest(owner, route, init), owner => {