Centralize provider settings under server authority

- Move Codex and Claude config lookups to `settings.providers`
- Update web composer, settings UI, and model selection to use unified settings
- Refresh browser fixtures and contracts for the new settings shape
This commit is contained in:
Julius Marminge committed 2026-03-25 14:26:17 -07:00
1 parent 3f089a454b
commit a9aa5c4a05
12 files changed
+137 -428

No files matched your search

@@ -90,7 +90,7 @@ const makeClaudeTextGeneration = Effect.gen(function* () {
const claudeSettings = yield* Effect.map(
serverSettingsService.getSettings,
(settings) => settings.claude,
(settings) => settings.providers.claudeAgent,
).pipe(Effect.catch(() => Effect.undefined));
const runClaudeCommand = Effect.gen(function* () {
@@ -142,7 +142,7 @@ const makeCodexTextGeneration = Effect.gen(function* () {
const codexSettings = yield* Effect.map(
serverSettingsService.getSettings,
(settings) => settings.codex,
(settings) => settings.providers.codex,
).pipe(Effect.catch(() => Effect.undefined));
const runCodexCommand = Effect.gen(function* () {
+9 -5
View File
@@ -89,18 +89,22 @@ export function deriveProviderStartOptions(
settings: ServerSettings,
): ProviderStartOptions | undefined {
const providerOptions: ProviderStartOptions = {
...(settings.codex
...(settings.providers.codex
? {
codex: {
...(settings.codex.binaryPath ? { binaryPath: settings.codex.binaryPath } : {}),
...(settings.codex.homePath ? { homePath: settings.codex.homePath } : {}),
...(settings.providers.codex.binaryPath
? { binaryPath: settings.providers.codex.binaryPath }
: {}),
...(settings.providers.codex.homePath
? { homePath: settings.providers.codex.homePath }
: {}),
},
}
: {}),
...(settings.claude
...(settings.providers.claudeAgent
? {
claudeAgent: {
binaryPath: settings.claude.binaryPath,
binaryPath: settings.providers.claudeAgent.binaryPath,
},
}
: {}),
-266
View File
@@ -1,266 +0,0 @@
import { describe, expect, it } from "vitest";
import {
DEFAULT_SIDEBAR_PROJECT_SORT_ORDER,
DEFAULT_SIDEBAR_THREAD_SORT_ORDER,
DEFAULT_TIMESTAMP_FORMAT,
} from "./appSettings";
import {
getAppModelOptions,
getCustomModelOptionsByProvider,
getCustomModelsByProvider,
getCustomModelsForProvider,
getDefaultCustomModelsForProvider,
MODEL_PROVIDER_SETTINGS,
normalizeCustomModelSlugs,
patchCustomModels,
resolveAppModelSelectionState,
resolveAppModelSelection,
} from "./modelSelection";
describe("normalizeCustomModelSlugs", () => {
it("normalizes aliases, removes built-ins, and deduplicates values", () => {
expect(
normalizeCustomModelSlugs([
" custom/internal-model ",
"gpt-5.3-codex",
"5.3",
"custom/internal-model",
"",
null,
]),
).toEqual(["custom/internal-model"]);
});
it("normalizes provider-specific aliases for claude", () => {
expect(normalizeCustomModelSlugs(["sonnet"], "claudeAgent")).toEqual([]);
expect(normalizeCustomModelSlugs(["claude/custom-sonnet"], "claudeAgent")).toEqual([
"claude/custom-sonnet",
]);
});
});
describe("getAppModelOptions", () => {
it("appends saved custom models after the built-in options", () => {
const options = getAppModelOptions("codex", ["custom/internal-model"]);
expect(options.map((option) => option.slug)).toEqual([
"gpt-5.4",
"gpt-5.4-mini",
"gpt-5.3-codex",
"gpt-5.3-codex-spark",
"gpt-5.2-codex",
"gpt-5.2",
"custom/internal-model",
]);
});
it("keeps the currently selected custom model available even if it is no longer saved", () => {
const options = getAppModelOptions("codex", [], "custom/selected-model");
expect(options.at(-1)).toEqual({
slug: "custom/selected-model",
name: "custom/selected-model",
isCustom: true,
});
});
it("keeps a saved custom provider model available as an exact slug option", () => {
const options = getAppModelOptions("claudeAgent", ["claude/custom-opus"], "claude/custom-opus");
expect(options.some((option) => option.slug === "claude/custom-opus" && option.isCustom)).toBe(
true,
);
});
});
describe("resolveAppModelSelection", () => {
it("preserves saved custom model slugs instead of falling back to the default", () => {
expect(
resolveAppModelSelection(
"codex",
{ codex: ["galapagos-alpha"], claudeAgent: [] },
"galapagos-alpha",
),
).toBe("galapagos-alpha");
});
it("falls back to the provider default when no model is selected", () => {
expect(resolveAppModelSelection("codex", { codex: [], claudeAgent: [] }, "")).toBe("gpt-5.4");
});
it("resolves display names through the shared resolver", () => {
expect(resolveAppModelSelection("codex", { codex: [], claudeAgent: [] }, "GPT-5.3 Codex")).toBe(
"gpt-5.3-codex",
);
});
it("resolves aliases through the shared resolver", () => {
expect(resolveAppModelSelection("claudeAgent", { codex: [], claudeAgent: [] }, "sonnet")).toBe(
"claude-sonnet-4-6",
);
});
it("resolves transient selected custom models included in app model options", () => {
expect(
resolveAppModelSelection("codex", { codex: [], claudeAgent: [] }, "custom/selected-model"),
).toBe("custom/selected-model");
});
});
describe("timestamp format defaults", () => {
it("defaults timestamp format to locale", () => {
expect(DEFAULT_TIMESTAMP_FORMAT).toBe("locale");
});
});
describe("sidebar sort defaults", () => {
it("defaults project sorting to updated_at", () => {
expect(DEFAULT_SIDEBAR_PROJECT_SORT_ORDER).toBe("updated_at");
});
it("defaults thread sorting to updated_at", () => {
expect(DEFAULT_SIDEBAR_THREAD_SORT_ORDER).toBe("updated_at");
});
});
describe("provider-specific custom models", () => {
it("includes provider-specific custom slugs in non-codex model lists", () => {
const claudeOptions = getAppModelOptions("claudeAgent", ["claude/custom-opus"]);
expect(claudeOptions.some((option) => option.slug === "claude/custom-opus")).toBe(true);
});
});
describe("provider-indexed custom model settings", () => {
const settings = {
customCodexModels: ["custom/codex-model"],
customClaudeModels: ["claude/custom-opus"],
} as const;
it("exports one provider config per provider", () => {
expect(MODEL_PROVIDER_SETTINGS.map((config) => config.provider)).toEqual([
"codex",
"claudeAgent",
]);
});
it("reads custom models for each provider", () => {
expect(getCustomModelsForProvider(settings, "codex")).toEqual(["custom/codex-model"]);
expect(getCustomModelsForProvider(settings, "claudeAgent")).toEqual(["claude/custom-opus"]);
});
it("reads default custom models for each provider", () => {
const defaults = {
customCodexModels: ["default/codex-model"],
customClaudeModels: ["claude/default-opus"],
} as const;
expect(getDefaultCustomModelsForProvider(defaults, "codex")).toEqual(["default/codex-model"]);
expect(getDefaultCustomModelsForProvider(defaults, "claudeAgent")).toEqual([
"claude/default-opus",
]);
});
it("patches custom models for codex", () => {
expect(patchCustomModels("codex", ["custom/codex-model"])).toEqual({
customCodexModels: ["custom/codex-model"],
});
});
it("patches custom models for claude", () => {
expect(patchCustomModels("claudeAgent", ["claude/custom-opus"])).toEqual({
customClaudeModels: ["claude/custom-opus"],
});
});
it("builds a complete provider-indexed custom model record", () => {
expect(getCustomModelsByProvider(settings)).toEqual({
codex: ["custom/codex-model"],
claudeAgent: ["claude/custom-opus"],
});
});
it("builds provider-indexed model options including custom models", () => {
const modelOptionsByProvider = getCustomModelOptionsByProvider(settings);
expect(
modelOptionsByProvider.codex.some((option) => option.slug === "custom/codex-model"),
).toBe(true);
expect(
modelOptionsByProvider.claudeAgent.some((option) => option.slug === "claude/custom-opus"),
).toBe(true);
});
it("normalizes and deduplicates custom model options per provider", () => {
const modelOptionsByProvider = getCustomModelOptionsByProvider({
customCodexModels: [" custom/codex-model ", "gpt-5.4", "custom/codex-model"],
customClaudeModels: [" sonnet ", "claude/custom-opus", "claude/custom-opus"],
});
expect(
modelOptionsByProvider.codex.filter((option) => option.slug === "custom/codex-model"),
).toHaveLength(1);
expect(modelOptionsByProvider.codex.some((option) => option.slug === "gpt-5.4")).toBe(true);
expect(
modelOptionsByProvider.claudeAgent.filter((option) => option.slug === "claude/custom-opus"),
).toHaveLength(1);
expect(
modelOptionsByProvider.claudeAgent.some((option) => option.slug === "claude-sonnet-4-6"),
).toBe(true);
});
});
describe("resolveAppModelSelectionState", () => {
it("falls back to the default git-writing codex selection", () => {
expect(
resolveAppModelSelectionState({
customCodexModels: [],
customClaudeModels: [],
textGenerationModelSelection: undefined,
}),
).toEqual({
provider: "codex",
model: "gpt-5.4-mini",
});
});
it("preserves the selected provider and resolves saved custom models", () => {
expect(
resolveAppModelSelectionState({
customCodexModels: [],
customClaudeModels: ["claude/custom-haiku"],
textGenerationModelSelection: {
provider: "claudeAgent",
model: "claude/custom-haiku",
},
}),
).toEqual({
provider: "claudeAgent",
model: "claude/custom-haiku",
});
});
it("normalizes provider options against the resolved model capabilities", () => {
expect(
resolveAppModelSelectionState({
customCodexModels: [],
customClaudeModels: [],
textGenerationModelSelection: {
provider: "claudeAgent",
model: "claude-haiku-4-5",
options: {
effort: "max",
thinking: false,
fastMode: true,
},
},
}),
).toEqual({
provider: "claudeAgent",
model: "claude-haiku-4-5",
options: {
thinking: false,
},
});
});
});
+4 -7
View File
@@ -12,6 +12,7 @@ import {
WS_CHANNELS,
WS_METHODS,
OrchestrationSessionStatus,
DEFAULT_SERVER_SETTINGS,
} from "@t3tools/contracts";
import { RouterProvider, createMemoryHistory } from "@tanstack/react-router";
import { HttpResponse, http, ws } from "msw";
@@ -30,6 +31,7 @@ import { isMacPlatform } from "../lib/utils";
import { getRouter } from "../router";
import { useStore } from "../store";
import { estimateTimelineMessageHeight } from "./timelineHeight";
import { DEFAULT_CLIENT_SETTINGS } from "~/clientSettings";
const THREAD_ID = "thread-browser-test" as ThreadId;
const UUID_ROUTE_RE = /^\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
@@ -118,13 +120,8 @@ function createBaseServerConfig(): ServerConfig {
],
availableEditors: [],
settings: {
claude: { binaryPath: "" },
codex: { binaryPath: "", homePath: "" },
enableAssistantStreaming: false,
defaultThreadEnvMode: "local" as const,
customCodexModels: [],
customClaudeModels: [],
textGenerationModelSelection: { provider: "codex" as const, model: "gpt-5.4-mini" },
...DEFAULT_SERVER_SETTINGS,
...DEFAULT_CLIENT_SETTINGS,
},
};
}
+4 -9
View File
@@ -121,11 +121,7 @@ import { SidebarTrigger } from "./ui/sidebar";
import { newCommandId, newMessageId, newThreadId } from "~/lib/utils";
import { readNativeApi } from "~/nativeApi";
import { useAppSettings } from "../appSettings";
import {
getCustomModelOptionsByProvider,
getCustomModelsByProvider,
resolveAppModelSelection,
} from "../modelSelection";
import { getCustomModelOptionsByProvider, resolveAppModelSelection } from "../modelSelection";
import { isTerminalFocused } from "../lib/terminalFocus";
import {
type ComposerImageAttachment,
@@ -610,13 +606,12 @@ export default function ChatView({ threadId }: ChatViewProps) {
: null;
const selectedProvider: ProviderKind =
lockedProvider ?? selectedProviderByThreadId ?? threadProvider ?? "codex";
const customModelsByProvider = useMemo(() => getCustomModelsByProvider(settings), [settings]);
const { modelOptions: composerModelOptions, selectedModel } = useEffectiveComposerModelState({
threadId,
selectedProvider,
threadModelSelection: activeThread?.modelSelection,
projectModelSelection: activeProject?.defaultModelSelection,
customModelsByProvider,
settings,
});
const composerProviderState = useMemo(
() =>
@@ -3100,7 +3095,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
scheduleComposerFocus();
return;
}
const resolvedModel = resolveAppModelSelection(provider, customModelsByProvider, model);
const resolvedModel = resolveAppModelSelection(provider, settings, model);
const nextModelSelection: ModelSelection = {
provider,
model: resolvedModel,
@@ -3115,7 +3110,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
scheduleComposerFocus,
setComposerDraftModelSelection,
setStickyComposerModelSelection,
customModelsByProvider,
settings,
],
);
const setPromptFromTraits = useCallback(
@@ -54,13 +54,13 @@ function createBaseServerConfig(): ServerConfig {
],
availableEditors: [],
settings: {
claude: { binaryPath: "" },
codex: { binaryPath: "", homePath: "" },
enableAssistantStreaming: false,
defaultThreadEnvMode: "local" as const,
customCodexModels: [],
customClaudeModels: [],
textGenerationModelSelection: { provider: "codex" as const, model: "gpt-5.4-mini" },
providers: {
codex: { binaryPath: "", homePath: "", customModels: [] },
claudeAgent: { binaryPath: "", customModels: [] },
},
},
};
}
@@ -5,6 +5,7 @@ import {
ClaudeModelOptions,
CodexModelOptions,
DEFAULT_MODEL_BY_PROVIDER,
DEFAULT_SERVER_SETTINGS,
ProjectId,
ThreadId,
} from "@t3tools/contracts";
@@ -21,6 +22,7 @@ import {
useComposerThreadDraft,
useEffectiveComposerModelState,
} from "../../composerDraftStore";
import { DEFAULT_CLIENT_SETTINGS } from "~/clientSettings";
// ── Claude TraitsPicker tests ─────────────────────────────────────────
@@ -38,7 +40,10 @@ function ClaudeTraitsPickerHarness(props: {
selectedProvider: "claudeAgent",
threadModelSelection: props.fallbackModelSelection,
projectModelSelection: null,
customModelsByProvider: { codex: [], claudeAgent: [] },
settings: {
...DEFAULT_SERVER_SETTINGS,
...DEFAULT_CLIENT_SETTINGS,
},
});
const handlePromptChange = useCallback(
(nextPrompt: string) => {
+6 -9
View File
@@ -31,6 +31,7 @@ import {
import { create } from "zustand";
import { createJSONStorage, persist } from "zustand/middleware";
import { createDebouncedStorage, createMemoryStorage } from "./lib/storage";
import { UnifiedSettings } from "./appSettings";
export const COMPOSER_DRAFT_STORAGE_KEY = "t3code:composer-drafts:v1";
const COMPOSER_DRAFT_STORAGE_VERSION = 3;
@@ -616,7 +617,7 @@ export function deriveEffectiveComposerModelState(input: {
selectedProvider: ProviderKind;
threadModelSelection: ModelSelection | null | undefined;
projectModelSelection: ModelSelection | null | undefined;
customModelsByProvider: Record<ProviderKind, readonly string[]>;
settings: UnifiedSettings;
}): EffectiveComposerModelState {
const baseModel = resolveModelSlugForProvider(
input.selectedProvider,
@@ -626,11 +627,7 @@ export function deriveEffectiveComposerModelState(input: {
);
const activeSelection = input.draft?.modelSelectionByProvider?.[input.selectedProvider];
const selectedModel = activeSelection?.model
? resolveAppModelSelection(
input.selectedProvider,
input.customModelsByProvider,
activeSelection.model,
)
? resolveAppModelSelection(input.selectedProvider, input.settings, activeSelection.model)
: baseModel;
const modelOptions =
modelSelectionByProviderToOptions(input.draft?.modelSelectionByProvider) ??
@@ -2160,7 +2157,7 @@ export function useEffectiveComposerModelState(input: {
selectedProvider: ProviderKind;
threadModelSelection: ModelSelection | null | undefined;
projectModelSelection: ModelSelection | null | undefined;
customModelsByProvider: Record<ProviderKind, readonly string[]>;
settings: UnifiedSettings;
}): EffectiveComposerModelState {
const draft = useComposerThreadDraft(input.threadId);
@@ -2171,11 +2168,11 @@ export function useEffectiveComposerModelState(input: {
selectedProvider: input.selectedProvider,
threadModelSelection: input.threadModelSelection,
projectModelSelection: input.projectModelSelection,
customModelsByProvider: input.customModelsByProvider,
settings: input.settings,
}),
[
draft,
input.customModelsByProvider,
input.settings,
input.projectModelSelection,
input.selectedProvider,
input.threadModelSelection,
+15 -62
View File
@@ -10,19 +10,13 @@ import {
resolveSelectableModel,
} from "@t3tools/shared/model";
import { getComposerProviderState } from "./components/chat/composerProviderRegistry";
import { UnifiedSettings } from "./appSettings";
const MAX_CUSTOM_MODEL_COUNT = 32;
export const MAX_CUSTOM_MODEL_LENGTH = 256;
export type CustomModelSettings = {
customCodexModels: readonly string[];
customClaudeModels: readonly string[];
};
export type ProviderCustomModelConfig = {
provider: ProviderKind;
settingsKey: keyof CustomModelSettings;
defaultSettingsKey: keyof CustomModelSettings;
title: string;
description: string;
placeholder: string;
@@ -38,8 +32,6 @@ export interface AppModelOption {
const PROVIDER_CUSTOM_MODEL_CONFIG: Record<ProviderKind, ProviderCustomModelConfig> = {
codex: {
provider: "codex",
settingsKey: "customCodexModels",
defaultSettingsKey: "customCodexModels",
title: "Codex",
description: "Save additional Codex model slugs for the picker and `/model` command.",
placeholder: "your-codex-model-slug",
@@ -47,8 +39,6 @@ const PROVIDER_CUSTOM_MODEL_CONFIG: Record<ProviderKind, ProviderCustomModelConf
},
claudeAgent: {
provider: "claudeAgent",
settingsKey: "customClaudeModels",
defaultSettingsKey: "customClaudeModels",
title: "Claude",
description: "Save additional Claude model slugs for the picker and `/model` command.",
placeholder: "your-claude-model-slug",
@@ -92,41 +82,9 @@ export function normalizeCustomModelSlugs(
return normalizedModels;
}
export function getCustomModelsForProvider(
settings: CustomModelSettings,
provider: ProviderKind,
): readonly string[] {
return settings[PROVIDER_CUSTOM_MODEL_CONFIG[provider].settingsKey];
}
export function getDefaultCustomModelsForProvider(
defaults: CustomModelSettings,
provider: ProviderKind,
): readonly string[] {
return defaults[PROVIDER_CUSTOM_MODEL_CONFIG[provider].defaultSettingsKey];
}
export function patchCustomModels(
provider: ProviderKind,
models: string[],
): Partial<CustomModelSettings> {
return {
[PROVIDER_CUSTOM_MODEL_CONFIG[provider].settingsKey]: models,
};
}
export function getCustomModelsByProvider(
settings: CustomModelSettings,
): Record<ProviderKind, readonly string[]> {
return {
codex: getCustomModelsForProvider(settings, "codex"),
claudeAgent: getCustomModelsForProvider(settings, "claudeAgent"),
};
}
export function getAppModelOptions(
settings: UnifiedSettings,
provider: ProviderKind,
customModels: readonly string[],
selectedModel?: string | null,
): AppModelOption[] {
const options: AppModelOption[] = getModelOptions(provider).map(({ slug, name }) => ({
@@ -137,6 +95,7 @@ export function getAppModelOptions(
const seen = new Set(options.map((option) => option.slug));
const trimmedSelectedModel = selectedModel?.trim().toLowerCase();
const customModels = settings.providers[provider].customModels;
for (const slug of normalizeCustomModelSlugs(customModels, provider)) {
if (seen.has(slug)) {
continue;
@@ -171,57 +130,51 @@ export function getAppModelOptions(
export function resolveAppModelSelection(
provider: ProviderKind,
customModels: Record<ProviderKind, readonly string[]>,
settings: UnifiedSettings,
selectedModel: string | null | undefined,
): string {
const customModelsForProvider = customModels[provider];
const options = getAppModelOptions(provider, customModelsForProvider, selectedModel);
const options = getAppModelOptions(settings, provider, selectedModel);
return resolveSelectableModel(provider, selectedModel, options) ?? getDefaultModel(provider);
}
export function getCustomModelOptionsByProvider(
settings: CustomModelSettings,
settings: UnifiedSettings,
selectedProvider?: ProviderKind | null,
selectedModel?: string | null,
): Record<ProviderKind, ReadonlyArray<{ slug: string; name: string }>> {
const customModelsByProvider = getCustomModelsByProvider(settings);
return {
codex: getAppModelOptions(
settings,
"codex",
customModelsByProvider.codex,
selectedProvider === "codex" ? selectedModel : undefined,
),
claudeAgent: getAppModelOptions(
settings,
"claudeAgent",
customModelsByProvider.claudeAgent,
selectedProvider === "claudeAgent" ? selectedModel : undefined,
),
};
}
export function resolveAppModelSelectionState(
settings: CustomModelSettings & {
textGenerationModelSelection: ModelSelection | undefined;
},
): ModelSelection {
export function resolveAppModelSelectionState(settings: UnifiedSettings): ModelSelection {
const selection = settings.textGenerationModelSelection ?? {
provider: "codex" as const,
model: DEFAULT_GIT_TEXT_GENERATION_MODEL_BY_PROVIDER.codex,
};
const provider = selection.provider;
const customModelsByProvider = getCustomModelsByProvider(settings);
const model = resolveAppModelSelection(provider, customModelsByProvider, selection.model);
const model = resolveAppModelSelection(selection.provider, settings, selection.model);
const { modelOptionsForDispatch } = getComposerProviderState({
provider,
provider: selection.provider,
model,
prompt: "",
modelOptions: {
[provider]: selection.options,
[selection.provider]: selection.options,
},
});
return {
provider,
provider: selection.provider,
model,
...(modelOptionsForDispatch ? { options: modelOptionsForDispatch } : {}),
};
+79 -58
View File
@@ -7,10 +7,8 @@ import { getModelOptions, normalizeModelSlug } from "@t3tools/shared/model";
import { useAppSettings } from "../appSettings";
import {
getCustomModelOptionsByProvider,
getCustomModelsForProvider,
MAX_CUSTOM_MODEL_LENGTH,
MODEL_PROVIDER_SETTINGS,
patchCustomModels,
resolveAppModelSelectionState,
} from "../modelSelection";
import { APP_VERSION } from "../branding";
@@ -61,11 +59,9 @@ const TIMESTAMP_FORMAT_LABELS = {
"24-hour": "24-hour",
} as const;
type InstallBinarySettingsKey = "claudeBinaryPath" | "codexBinaryPath";
type InstallProviderSettings = {
provider: ProviderKind;
title: string;
binaryPathKey: InstallBinarySettingsKey;
binaryPlaceholder: string;
binaryDescription: ReactNode;
homePathKey?: "codexHomePath";
@@ -77,7 +73,6 @@ const INSTALL_PROVIDER_SETTINGS: readonly InstallProviderSettings[] = [
{
provider: "codex",
title: "Codex",
binaryPathKey: "codexBinaryPath",
binaryPlaceholder: "Codex binary path",
binaryDescription: (
<>
@@ -91,7 +86,6 @@ const INSTALL_PROVIDER_SETTINGS: readonly InstallProviderSettings[] = [
{
provider: "claudeAgent",
title: "Claude",
binaryPathKey: "claudeBinaryPath",
binaryPlaceholder: "Claude binary path",
binaryDescription: (
<>
@@ -195,8 +189,8 @@ function SettingsRouteView() {
const [isOpeningKeybindings, setIsOpeningKeybindings] = useState(false);
const [openKeybindingsError, setOpenKeybindingsError] = useState<string | null>(null);
const [openInstallProviders, setOpenInstallProviders] = useState<Record<ProviderKind, boolean>>({
codex: Boolean(settings.codex?.binaryPath || settings.codex?.homePath),
claudeAgent: Boolean(settings.claude?.binaryPath),
codex: Boolean(settings.providers.codex.binaryPath || settings.providers.codex.homePath),
claudeAgent: Boolean(settings.providers.claudeAgent.binaryPath),
});
const [selectedCustomModelProvider, setSelectedCustomModelProvider] =
useState<ProviderKind>("codex");
@@ -211,9 +205,7 @@ function SettingsRouteView() {
>({});
const [showAllCustomModels, setShowAllCustomModels] = useState(false);
const codexBinaryPath = settings.codex?.binaryPath ?? "";
const codexHomePath = settings.codex?.homePath ?? "";
const claudeBinaryPath = settings.claude?.binaryPath ?? "";
const codexHomePath = settings.providers.codex.homePath;
const keybindingsConfigPath = serverConfigQuery.data?.keybindingsConfigPath ?? null;
const availableEditors = serverConfigQuery.data?.availableEditors;
@@ -231,9 +223,11 @@ function SettingsRouteView() {
)!;
const selectedCustomModelInput = customModelInputByProvider[selectedCustomModelProvider];
const selectedCustomModelError = customModelErrorByProvider[selectedCustomModelProvider] ?? null;
const totalCustomModels = settings.customCodexModels.length + settings.customClaudeModels.length;
const totalCustomModels =
settings.providers.codex.customModels.length +
settings.providers.claudeAgent.customModels.length;
const savedCustomModelRows = MODEL_PROVIDER_SETTINGS.flatMap((providerSettings) =>
getCustomModelsForProvider(settings, providerSettings.provider).map((slug) => ({
settings.providers[providerSettings.provider].customModels.map((slug) => ({
key: `${providerSettings.provider}:${slug}`,
provider: providerSettings.provider,
providerTitle: providerSettings.title,
@@ -244,9 +238,9 @@ function SettingsRouteView() {
? savedCustomModelRows
: savedCustomModelRows.slice(0, 5);
const isInstallSettingsDirty =
settings.claude?.binaryPath !== defaults.claude?.binaryPath ||
settings.codex?.binaryPath !== defaults.codex?.binaryPath ||
settings.codex?.homePath !== defaults.codex?.homePath;
settings.providers.claudeAgent.binaryPath !== defaults.providers.claudeAgent.binaryPath ||
settings.providers.codex.binaryPath !== defaults.providers.codex.binaryPath ||
settings.providers.codex.homePath !== defaults.providers.codex.homePath;
const changedSettingLabels = [
...(theme !== "system" ? ["Theme"] : []),
...(settings.timestampFormat !== defaults.timestampFormat ? ["Time format"] : []),
@@ -262,7 +256,8 @@ function SettingsRouteView() {
JSON.stringify(defaults.textGenerationModelSelection ?? null)
? ["Git writing model"]
: []),
...(settings.customCodexModels.length > 0 || settings.customClaudeModels.length > 0
...(settings.providers.codex.customModels.length > 0 ||
settings.providers.claudeAgent.customModels.length > 0
? ["Custom models"]
: []),
...(isInstallSettingsDirty ? ["Provider installs"] : []),
@@ -294,7 +289,7 @@ function SettingsRouteView() {
const addCustomModel = useCallback(
(provider: ProviderKind) => {
const customModelInput = customModelInputByProvider[provider];
const customModels = getCustomModelsForProvider(settings, provider);
const customModels = settings.providers[provider].customModels;
const normalized = normalizeModelSlug(customModelInput, provider);
if (!normalized) {
setCustomModelErrorByProvider((existing) => ({
@@ -325,7 +320,15 @@ function SettingsRouteView() {
return;
}
updateSettings(patchCustomModels(provider, [...customModels, normalized]));
updateSettings({
providers: {
...settings.providers,
[provider]: {
...settings.providers[provider],
customModels: [...customModels, normalized],
},
},
});
setCustomModelInputByProvider((existing) => ({
...existing,
[provider]: "",
@@ -340,13 +343,16 @@ function SettingsRouteView() {
const removeCustomModel = useCallback(
(provider: ProviderKind, slug: string) => {
const customModels = getCustomModelsForProvider(settings, provider);
updateSettings(
patchCustomModels(
provider,
customModels.filter((model) => model !== slug),
),
);
const customModels = settings.providers[provider].customModels;
updateSettings({
providers: {
...settings.providers,
[provider]: {
...settings.providers[provider],
customModels: customModels.filter((model) => model !== slug),
},
},
});
setCustomModelErrorByProvider((existing) => ({
...existing,
[provider]: null,
@@ -699,8 +705,17 @@ function SettingsRouteView() {
label="custom models"
onClick={() => {
updateSettings({
customCodexModels: defaults.customCodexModels,
customClaudeModels: defaults.customClaudeModels,
providers: {
...settings.providers,
codex: {
...settings.providers.codex,
customModels: defaults.providers.codex.customModels,
},
claudeAgent: {
...settings.providers.claudeAgent,
customModels: defaults.providers.claudeAgent.customModels,
},
},
});
setCustomModelErrorByProvider({});
setShowAllCustomModels(false);
@@ -831,10 +846,17 @@ function SettingsRouteView() {
label="provider installs"
onClick={() => {
updateSettings({
claude: { binaryPath: defaults.claude?.binaryPath ?? "" },
codex: {
binaryPath: defaults.codex?.binaryPath ?? "",
homePath: defaults.codex?.homePath ?? "",
providers: {
...settings.providers,
claudeAgent: {
...settings.providers.claudeAgent,
binaryPath: defaults.providers.claudeAgent.binaryPath,
},
codex: {
...settings.providers.codex,
binaryPath: defaults.providers.codex.binaryPath,
homePath: defaults.providers.codex.homePath,
},
},
});
setOpenInstallProviders({
@@ -852,13 +874,15 @@ function SettingsRouteView() {
const isOpen = openInstallProviders[providerSettings.provider];
const isDirty =
providerSettings.provider === "codex"
? settings.codex?.binaryPath !== defaults.codex?.binaryPath ||
settings.codex?.homePath !== defaults.codex?.homePath
: settings.claude?.binaryPath !== defaults.claude?.binaryPath;
? settings.providers.codex.binaryPath !==
defaults.providers.codex.binaryPath ||
settings.providers.codex.homePath !== defaults.providers.codex.homePath
: settings.providers.claudeAgent.binaryPath !==
defaults.providers.claudeAgent.binaryPath;
const binaryPathValue =
providerSettings.binaryPathKey === "claudeBinaryPath"
? (settings.claude?.binaryPath ?? "")
: codexBinaryPath;
providerSettings.provider === "claudeAgent"
? settings.providers.claudeAgent.binaryPath
: settings.providers.codex.binaryPath;
return (
<Collapsible
@@ -900,32 +924,26 @@ function SettingsRouteView() {
<div className="border-t border-border/70 px-4 py-4">
<div className="space-y-3">
<label
htmlFor={`provider-install-${providerSettings.binaryPathKey}`}
htmlFor={`provider-install-${providerSettings.provider}-binary-path`}
className="block"
>
<span className="block text-xs font-medium text-foreground">
{providerSettings.title} binary path
</span>
<Input
id={`provider-install-${providerSettings.binaryPathKey}`}
id={`provider-install-${providerSettings.provider}-binary-path`}
className="mt-1"
value={binaryPathValue}
onChange={(event) =>
updateSettings(
providerSettings.provider === "claudeAgent"
? {
claude: {
...settings.claude,
binaryPath: event.target.value,
},
}
: {
codex: {
...settings.codex,
binaryPath: event.target.value,
},
},
)
updateSettings({
providers: {
...settings.providers,
[providerSettings.provider]: {
...settings.providers[providerSettings.provider],
binaryPath: event.target.value,
},
},
})
}
placeholder={providerSettings.binaryPlaceholder}
spellCheck={false}
@@ -949,9 +967,12 @@ function SettingsRouteView() {
value={codexHomePath}
onChange={(event) =>
updateSettings({
codex: {
...settings.codex,
homePath: event.target.value,
providers: {
...settings.providers,
codex: {
...settings.providers.codex,
homePath: event.target.value,
},
},
})
}
+8 -5
View File
@@ -13,30 +13,33 @@ export type ThreadEnvMode = typeof ThreadEnvMode.Type;
export const CodexSettings = Schema.Struct({
binaryPath: Schema.String.pipe(Schema.withDecodingDefault(() => "")),
homePath: Schema.String.pipe(Schema.withDecodingDefault(() => "")),
customModels: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(() => [])),
});
export type CodexSettings = typeof CodexSettings.Type;
export const ClaudeSettings = Schema.Struct({
binaryPath: Schema.String.pipe(Schema.withDecodingDefault(() => "")),
customModels: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(() => [])),
});
export type ClaudeSettings = typeof ClaudeSettings.Type;
export const ServerSettings = Schema.Struct({
codex: CodexSettings.pipe(Schema.withDecodingDefault(() => ({}))),
claude: ClaudeSettings.pipe(Schema.withDecodingDefault(() => ({}))),
enableAssistantStreaming: Schema.Boolean.pipe(Schema.withDecodingDefault(() => false)),
defaultThreadEnvMode: ThreadEnvMode.pipe(
Schema.withDecodingDefault(() => "local" as const satisfies ThreadEnvMode),
),
customCodexModels: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(() => [])),
customClaudeModels: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(() => [])),
textGenerationModelSelection: ModelSelection.pipe(
Schema.withDecodingDefault(() => ({
provider: "codex" as const,
model: DEFAULT_GIT_TEXT_GENERATION_MODEL_BY_PROVIDER.codex,
})),
),
// Provider specific settings
providers: Schema.Struct({
codex: CodexSettings.pipe(Schema.withDecodingDefault(() => ({}))),
claudeAgent: ClaudeSettings.pipe(Schema.withDecodingDefault(() => ({}))),
}),
});
export type ServerSettings = typeof ServerSettings.Type;