Open History to see the last commit
1import * as Effect from "effect/Effect";
2import * as Duration from "effect/Duration";
3import * as Schema from "effect/Schema";
4import * as SchemaTransformation from "effect/SchemaTransformation";
5import { TrimmedNonEmptyString, TrimmedString } from "./baseSchemas.ts";
6import { DEFAULT_GIT_TEXT_GENERATION_MODEL, ProviderOptionSelections } from "./model.ts";
7import { ModelSelection } from "./modelSelection.ts";
8import { ProviderInstanceConfig, ProviderInstanceId } from "./providerInstance.ts";
9
10// ── Client Settings (local-only) ───────────────────────────────
11
12export const TimestampFormat = Schema.Literals(["locale", "12-hour", "24-hour"]);
13export type TimestampFormat = typeof TimestampFormat.Type;
14export const DEFAULT_TIMESTAMP_FORMAT: TimestampFormat = "locale";
15
16export const SidebarProjectSortOrder = Schema.Literals(["updated_at", "created_at", "manual"]);
17export type SidebarProjectSortOrder = typeof SidebarProjectSortOrder.Type;
18export const DEFAULT_SIDEBAR_PROJECT_SORT_ORDER: SidebarProjectSortOrder = "updated_at";
19
20export const SidebarThreadSortOrder = Schema.Literals(["updated_at", "created_at"]);
21export type SidebarThreadSortOrder = typeof SidebarThreadSortOrder.Type;
22export const DEFAULT_SIDEBAR_THREAD_SORT_ORDER: SidebarThreadSortOrder = "updated_at";
23
24export const SidebarProjectGroupingMode = Schema.Literals([
25 "repository",
26 "repository_path",
27 "separate",
28]);
29export type SidebarProjectGroupingMode = typeof SidebarProjectGroupingMode.Type;
30export const DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE: SidebarProjectGroupingMode = "repository";
31export const MIN_SIDEBAR_THREAD_PREVIEW_COUNT = 1;
32export const MAX_SIDEBAR_THREAD_PREVIEW_COUNT = 15;
33export const SidebarThreadPreviewCount = Schema.Int.check(
34 Schema.isBetween({
35 minimum: MIN_SIDEBAR_THREAD_PREVIEW_COUNT,
36 maximum: MAX_SIDEBAR_THREAD_PREVIEW_COUNT,
37 }),
38);
39export type SidebarThreadPreviewCount = typeof SidebarThreadPreviewCount.Type;
40export const DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT: SidebarThreadPreviewCount = 6;
41
42export const ClientSettingsSchema = Schema.Struct({
43 autoOpenPlanSidebar: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
44 confirmThreadArchive: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
45 confirmThreadDelete: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
46 dismissedProviderUpdateNotificationKeys: Schema.Array(TrimmedNonEmptyString).pipe(
47 Schema.withDecodingDefault(Effect.succeed([])),
48 ),
49 diffIgnoreWhitespace: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
50 // Model favorites. Historically keyed by provider kind, now
51 // widened to `ProviderInstanceId` so users can favorite a specific model
52 // on a custom provider instance (e.g. "Codex Personal · gpt-5") without
53 // the UI collapsing it into the same bucket as the default Codex. The
54 // widening is backward-compatible by construction: prior provider-kind
55 // strings satisfy the `ProviderInstanceId` slug schema, so previously
56 // persisted favorites decode unchanged and continue to point at the
57 // default instance for their kind (because `defaultInstanceIdForDriver(kind)`
58 // uses the same slug). The field name is kept as `provider` for storage
59 // stability; new call sites should treat the value as an instance id.
60 favorites: Schema.Array(
61 Schema.Struct({
62 provider: ProviderInstanceId,
63 model: TrimmedNonEmptyString,
64 }),
65 ).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
66 providerModelPreferences: Schema.Record(
67 ProviderInstanceId,
68 Schema.Struct({
69 hiddenModels: Schema.Array(Schema.String).pipe(
70 Schema.withDecodingDefault(Effect.succeed([])),
71 ),
72 modelOrder: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
73 }),
74 ).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
75 sidebarProjectGroupingMode: SidebarProjectGroupingMode.pipe(
76 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE)),
77 ),
78 sidebarProjectGroupingOverrides: Schema.Record(
79 TrimmedNonEmptyString,
80 SidebarProjectGroupingMode,
81 ).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
82 sidebarProjectSortOrder: SidebarProjectSortOrder.pipe(
83 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_SORT_ORDER)),
84 ),
85 sidebarThreadSortOrder: SidebarThreadSortOrder.pipe(
86 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_SORT_ORDER)),
87 ),
88 sidebarThreadPreviewCount: SidebarThreadPreviewCount.pipe(
89 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT)),
90 ),
91 timestampFormat: TimestampFormat.pipe(
92 Schema.withDecodingDefault(Effect.succeed(DEFAULT_TIMESTAMP_FORMAT)),
93 ),
94 wordWrap: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
95});
96export type ClientSettings = typeof ClientSettingsSchema.Type;
97
98export const DEFAULT_CLIENT_SETTINGS: ClientSettings = Schema.decodeSync(ClientSettingsSchema)({});
99
100// ── Server Settings (server-authoritative) ────────────────────
101
102export const ThreadEnvMode = Schema.Literals(["local", "worktree"]);
103export type ThreadEnvMode = typeof ThreadEnvMode.Type;
104
105const makeBinaryPathSetting = (fallback: string) =>
106 TrimmedString.pipe(
107 Schema.decodeTo(
108 Schema.String,
109 SchemaTransformation.transformOrFail({
110 decode: (value) => Effect.succeed(value || fallback),
111 encode: (value) => Effect.succeed(value),
112 }),
113 ),
114 Schema.withDecodingDefault(Effect.succeed(fallback)),
115 );
116
117export type ProviderSettingsFormControl = "text" | "password" | "textarea" | "switch";
118
119export interface ProviderSettingsFormAnnotation {
120 readonly control?: ProviderSettingsFormControl | undefined;
121 readonly placeholder?: string | undefined;
122 readonly hidden?: boolean | undefined;
123 readonly clearWhenEmpty?: "omit" | "persist" | undefined;
124}
125
126export interface ProviderSettingsFormSchemaAnnotation {
127 readonly order?: readonly string[] | undefined;
128}
129
130declare module "effect/Schema" {
131 namespace Annotations {
132 interface Annotations {
133 readonly providerSettingsForm?: ProviderSettingsFormAnnotation | undefined;
134 readonly providerSettingsFormSchema?: ProviderSettingsFormSchemaAnnotation | undefined;
135 }
136 }
137}
138
139export type ProviderSettingsOrder<Fields extends Schema.Struct.Fields> = readonly Extract<
140 keyof Fields,
141 string
142>[];
143
144export function makeProviderSettingsSchema<const Fields extends Schema.Struct.Fields>(
145 fields: Fields,
146 options?: {
147 readonly order?: ProviderSettingsOrder<Fields> | undefined;
148 },
149): Schema.Struct<Fields> {
150 return Schema.Struct(fields).pipe(
151 Schema.annotate({
152 providerSettingsFormSchema:
153 options?.order === undefined ? undefined : { order: options.order },
154 }),
155 );
156}
157
158export const CodexSettings = makeProviderSettingsSchema(
159 {
160 enabled: Schema.Boolean.pipe(
161 Schema.withDecodingDefault(Effect.succeed(true)),
162 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
163 ),
164 binaryPath: makeBinaryPathSetting("codex").pipe(
165 Schema.annotateKey({
166 title: "Binary path",
167 description: "Path to the Codex binary used by this instance.",
168 providerSettingsForm: { placeholder: "codex", clearWhenEmpty: "omit" },
169 }),
170 ),
171 homePath: TrimmedString.pipe(
172 Schema.withDecodingDefault(Effect.succeed("")),
173 Schema.annotateKey({
174 title: "CODEX_HOME path",
175 description: "Custom Codex home and config directory.",
176 providerSettingsForm: {
177 placeholder: "~/.codex",
178 clearWhenEmpty: "omit",
179 },
180 }),
181 ),
182 shadowHomePath: TrimmedString.pipe(
183 Schema.withDecodingDefault(Effect.succeed("")),
184 Schema.annotateKey({
185 title: "Shadow home path",
186 description:
187 "Account-specific Codex home. Keeps auth.json separate while sharing state from CODEX_HOME.",
188 providerSettingsForm: {
189 placeholder: "~/.codex-t3/personal",
190 clearWhenEmpty: "omit",
191 },
192 }),
193 ),
194 customModels: Schema.Array(Schema.String).pipe(
195 Schema.withDecodingDefault(Effect.succeed([])),
196 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
197 ),
198 },
199 {
200 order: ["binaryPath", "homePath", "shadowHomePath"],
201 },
202);
203export type CodexSettings = typeof CodexSettings.Type;
204
205export const ClaudeSettings = makeProviderSettingsSchema(
206 {
207 enabled: Schema.Boolean.pipe(
208 Schema.withDecodingDefault(Effect.succeed(true)),
209 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
210 ),
211 binaryPath: makeBinaryPathSetting("claude").pipe(
212 Schema.annotateKey({
213 title: "Binary path",
214 description: "Path to the Claude binary used by this instance.",
215 providerSettingsForm: { placeholder: "claude", clearWhenEmpty: "omit" },
216 }),
217 ),
218 homePath: TrimmedString.pipe(
219 Schema.withDecodingDefault(Effect.succeed("")),
220 Schema.annotateKey({
221 title: "Claude HOME path",
222 description:
223 "Custom HOME used when running this Claude instance. Keeps .claude.json and .claude separate.",
224 providerSettingsForm: { placeholder: "~", clearWhenEmpty: "omit" },
225 }),
226 ),
227 customModels: Schema.Array(Schema.String).pipe(
228 Schema.withDecodingDefault(Effect.succeed([])),
229 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
230 ),
231 launchArgs: Schema.String.pipe(
232 Schema.withDecodingDefault(Effect.succeed("")),
233 Schema.annotateKey({
234 title: "Launch arguments",
235 description: "Additional CLI arguments passed on session start.",
236 providerSettingsForm: {
237 placeholder: "e.g. --chrome",
238 clearWhenEmpty: "omit",
239 },
240 }),
241 ),
242 },
243 {
244 order: ["binaryPath", "homePath", "launchArgs"],
245 },
246);
247export type ClaudeSettings = typeof ClaudeSettings.Type;
248
249export const CursorSettings = makeProviderSettingsSchema(
250 {
251 enabled: Schema.Boolean.pipe(
252 Schema.withDecodingDefault(Effect.succeed(false)),
253 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
254 ),
255 customModels: Schema.Array(Schema.String).pipe(
256 Schema.withDecodingDefault(Effect.succeed([])),
257 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
258 ),
259 },
260 {
261 order: [],
262 },
263);
264export type CursorSettings = typeof CursorSettings.Type;
265
266export const GrokSettings = makeProviderSettingsSchema(
267 {
268 enabled: Schema.Boolean.pipe(
269 Schema.withDecodingDefault(Effect.succeed(true)),
270 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
271 ),
272 binaryPath: makeBinaryPathSetting("grok").pipe(
273 Schema.annotateKey({
274 title: "Binary path",
275 description: "Path to the Grok CLI binary.",
276 providerSettingsForm: { placeholder: "grok", clearWhenEmpty: "omit" },
277 }),
278 ),
279 customModels: Schema.Array(Schema.String).pipe(
280 Schema.withDecodingDefault(Effect.succeed([])),
281 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
282 ),
283 },
284 {
285 order: ["binaryPath"],
286 },
287);
288export type GrokSettings = typeof GrokSettings.Type;
289
290export const AcpRegistryDistributionPreference = Schema.Literals(["auto", "binary", "npx", "uvx"]);
291export type AcpRegistryDistributionPreference = typeof AcpRegistryDistributionPreference.Type;
292
293export const AcpRegistrySettings = makeProviderSettingsSchema(
294 {
295 enabled: Schema.Boolean.pipe(
296 Schema.withDecodingDefault(Effect.succeed(true)),
297 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
298 ),
299 agentId: TrimmedString.pipe(
300 Schema.withDecodingDefault(Effect.succeed("")),
301 Schema.annotateKey({
302 title: "Registry agent ID",
303 description: "Agent identifier from the official ACP Registry, for example 'devin'.",
304 providerSettingsForm: { placeholder: "devin", clearWhenEmpty: "persist" },
305 }),
306 ),
307 commandPath: TrimmedString.pipe(
308 Schema.withDecodingDefault(Effect.succeed("")),
309 Schema.annotateKey({
310 title: "Executable override",
311 description:
312 "Optional local executable to use instead of installing the registry distribution. Registry arguments and environment are still applied.",
313 providerSettingsForm: { placeholder: "devin", clearWhenEmpty: "omit" },
314 }),
315 ),
316 authMethodId: TrimmedString.pipe(
317 Schema.withDecodingDefault(Effect.succeed("")),
318 Schema.annotateKey({
319 title: "Authentication method",
320 description:
321 "Optional ACP authentication method ID. By default, the first agent-managed method is selected.",
322 providerSettingsForm: { placeholder: "auto", clearWhenEmpty: "omit" },
323 }),
324 ),
325 distribution: AcpRegistryDistributionPreference.pipe(
326 Schema.withDecodingDefault(Effect.succeed("auto")),
327 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
328 ),
329 customModels: Schema.Array(Schema.String).pipe(
330 Schema.withDecodingDefault(Effect.succeed([])),
331 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
332 ),
333 },
334 {
335 order: ["agentId", "commandPath", "authMethodId"],
336 },
337);
338export type AcpRegistrySettings = typeof AcpRegistrySettings.Type;
339
340export const OpenCodeSettings = makeProviderSettingsSchema(
341 {
342 enabled: Schema.Boolean.pipe(
343 Schema.withDecodingDefault(Effect.succeed(true)),
344 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
345 ),
346 binaryPath: makeBinaryPathSetting("opencode").pipe(
347 Schema.annotateKey({
348 title: "Binary path",
349 description: "Path to the OpenCode binary.",
350 providerSettingsForm: {
351 placeholder: "opencode",
352 clearWhenEmpty: "omit",
353 },
354 }),
355 ),
356 serverUrl: TrimmedString.pipe(
357 Schema.withDecodingDefault(Effect.succeed("")),
358 Schema.annotateKey({
359 title: "Server URL",
360 description: "Leave blank to let T3 Code spawn the server when needed.",
361 providerSettingsForm: {
362 placeholder: "http://127.0.0.1:4096",
363 clearWhenEmpty: "omit",
364 },
365 }),
366 ),
367 serverPassword: TrimmedString.pipe(
368 Schema.withDecodingDefault(Effect.succeed("")),
369 Schema.annotateKey({
370 title: "Server password",
371 description: "Stored in plain text on disk.",
372 providerSettingsForm: {
373 control: "password",
374 placeholder: "Optional",
375 clearWhenEmpty: "omit",
376 },
377 }),
378 ),
379 customModels: Schema.Array(Schema.String).pipe(
380 Schema.withDecodingDefault(Effect.succeed([])),
381 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
382 ),
383 },
384 {
385 order: ["binaryPath", "serverUrl", "serverPassword"],
386 },
387);
388export type OpenCodeSettings = typeof OpenCodeSettings.Type;
389
390export const ObservabilitySettings = Schema.Struct({
391 otlpTracesUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
392 otlpMetricsUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
393});
394export type ObservabilitySettings = typeof ObservabilitySettings.Type;
395
396export const DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL = Duration.seconds(30);
397
398export const ServerSettings = Schema.Struct({
399 enableAssistantStreaming: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
400 enableProviderUpdateChecks: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
401 automaticGitFetchInterval: Schema.DurationFromMillis.pipe(
402 Schema.withDecodingDefault(
403 Effect.succeed(Duration.toMillis(DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL)),
404 ),
405 ),
406 defaultThreadEnvMode: ThreadEnvMode.pipe(
407 Schema.withDecodingDefault(Effect.succeed("local" as const satisfies ThreadEnvMode)),
408 ),
409 newWorktreesStartFromOrigin: Schema.Boolean.pipe(
410 Schema.withDecodingDefault(Effect.succeed(false)),
411 ),
412 addProjectBaseDirectory: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
413 textGenerationModelSelection: ModelSelection.pipe(
414 Schema.withDecodingDefault(
415 Effect.succeed({
416 instanceId: ProviderInstanceId.make("codex"),
417 model: DEFAULT_GIT_TEXT_GENERATION_MODEL,
418 }),
419 ),
420 ),
421
422 // Legacy single-instance-per-driver settings. Continues to be the source
423 // of truth until `providerInstances` (below) lands per-driver migration
424 // shims and the server starts hydrating instances from it. Driver-specific
425 // schemas live here for the duration of the migration; once each driver
426 // owns its config in its own package, this struct shrinks to nothing and
427 // is removed entirely.
428 providers: Schema.Struct({
429 codex: CodexSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
430 claudeAgent: ClaudeSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
431 cursor: CursorSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
432 grok: GrokSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
433 opencode: OpenCodeSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
434 }).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
435 // New driver-agnostic instance map. Keyed by `ProviderInstanceId`; values
436 // are `ProviderInstanceConfig` envelopes. The driver-specific config blob
437 // is `Schema.Unknown` at this layer so envelopes with unknown drivers
438 // (forks, downgrades, in-flight PR branches) round-trip without loss.
439 // See providerInstance.ts for the forward/backward compatibility invariant.
440 providerInstances: Schema.Record(ProviderInstanceId, ProviderInstanceConfig).pipe(
441 Schema.withDecodingDefault(Effect.succeed({})),
442 ),
443 observability: ObservabilitySettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
444});
445export type ServerSettings = typeof ServerSettings.Type;
446
447export const DEFAULT_SERVER_SETTINGS: ServerSettings = Schema.decodeSync(ServerSettings)({});
448
449export const ServerSettingsOperation = Schema.Literals([
450 "normalize",
451 "check-exists",
452 "read-file",
453 "read-secret",
454 "remove-secret",
455 "remove-stale-secret",
456 "write-secret",
457 "write-file",
458 "prepare-directory",
459]);
460export type ServerSettingsOperation = typeof ServerSettingsOperation.Type;
461
462export class ServerSettingsError extends Schema.TaggedErrorClass<ServerSettingsError>()(
463 "ServerSettingsError",
464 {
465 settingsPath: Schema.String,
466 operation: ServerSettingsOperation,
467 providerInstanceId: Schema.optional(Schema.String),
468 environmentVariable: Schema.optional(Schema.String),
469 cause: Schema.Defect(),
470 },
471) {
472 override get message(): string {
473 const provider =
474 this.providerInstanceId === undefined ? "" : ` for provider ${this.providerInstanceId}`;
475 const variable =
476 this.environmentVariable === undefined
477 ? ""
478 : ` and environment variable ${this.environmentVariable}`;
479 return `Server settings ${this.operation} failed${provider}${variable} at ${this.settingsPath}.`;
480 }
481}
482
483// ── Unified type ─────────────────────────────────────────────────────
484
485export type UnifiedSettings = ServerSettings & ClientSettings;
486export const DEFAULT_UNIFIED_SETTINGS: UnifiedSettings = {
487 ...DEFAULT_SERVER_SETTINGS,
488 ...DEFAULT_CLIENT_SETTINGS,
489};
490
491// ── Server Settings Patch (replace with a Schema.deepPartial if available) ──────────────────────────────────────────
492
493const ModelSelectionPatch = Schema.Struct({
494 instanceId: Schema.optionalKey(ProviderInstanceId),
495 model: Schema.optionalKey(TrimmedNonEmptyString),
496 options: Schema.optionalKey(ProviderOptionSelections),
497});
498
499const CodexSettingsPatch = Schema.Struct({
500 enabled: Schema.optionalKey(Schema.Boolean),
501 binaryPath: Schema.optionalKey(TrimmedString),
502 homePath: Schema.optionalKey(TrimmedString),
503 shadowHomePath: Schema.optionalKey(TrimmedString),
504 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
505});
506
507const ClaudeSettingsPatch = Schema.Struct({
508 enabled: Schema.optionalKey(Schema.Boolean),
509 binaryPath: Schema.optionalKey(TrimmedString),
510 homePath: Schema.optionalKey(TrimmedString),
511 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
512 launchArgs: Schema.optionalKey(TrimmedString),
513});
514
515const CursorSettingsPatch = Schema.Struct({
516 enabled: Schema.optionalKey(Schema.Boolean),
517 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
518});
519
520const GrokSettingsPatch = Schema.Struct({
521 enabled: Schema.optionalKey(Schema.Boolean),
522 binaryPath: Schema.optionalKey(TrimmedString),
523 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
524});
525
526const OpenCodeSettingsPatch = Schema.Struct({
527 enabled: Schema.optionalKey(Schema.Boolean),
528 binaryPath: Schema.optionalKey(TrimmedString),
529 serverUrl: Schema.optionalKey(TrimmedString),
530 serverPassword: Schema.optionalKey(TrimmedString),
531 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
532});
533
534export const ServerSettingsPatch = Schema.Struct({
535 // Server settings
536 enableAssistantStreaming: Schema.optionalKey(Schema.Boolean),
537 enableProviderUpdateChecks: Schema.optionalKey(Schema.Boolean),
538 automaticGitFetchInterval: Schema.optionalKey(Schema.DurationFromMillis),
539 defaultThreadEnvMode: Schema.optionalKey(ThreadEnvMode),
540 newWorktreesStartFromOrigin: Schema.optionalKey(Schema.Boolean),
541 addProjectBaseDirectory: Schema.optionalKey(TrimmedString),
542 textGenerationModelSelection: Schema.optionalKey(ModelSelectionPatch),
543 observability: Schema.optionalKey(
544 Schema.Struct({
545 otlpTracesUrl: Schema.optionalKey(TrimmedString),
546 otlpMetricsUrl: Schema.optionalKey(TrimmedString),
547 }),
548 ),
549 providers: Schema.optionalKey(
550 Schema.Struct({
551 codex: Schema.optionalKey(CodexSettingsPatch),
552 claudeAgent: Schema.optionalKey(ClaudeSettingsPatch),
553 cursor: Schema.optionalKey(CursorSettingsPatch),
554 grok: Schema.optionalKey(GrokSettingsPatch),
555 opencode: Schema.optionalKey(OpenCodeSettingsPatch),
556 }),
557 ),
558 // Whole-map replacement for the new instance config. Patching individual
559 // entries is intentionally out of scope: the map is small, and partial
560 // patches risk leaving driver-specific config in a half-merged state.
561 // The web UI sends a fully-formed map every time it edits this field.
562 providerInstances: Schema.optionalKey(Schema.Record(ProviderInstanceId, ProviderInstanceConfig)),
563});
564export type ServerSettingsPatch = typeof ServerSettingsPatch.Type;
565
566export const ClientSettingsPatch = Schema.Struct({
567 autoOpenPlanSidebar: Schema.optionalKey(Schema.Boolean),
568 confirmThreadArchive: Schema.optionalKey(Schema.Boolean),
569 confirmThreadDelete: Schema.optionalKey(Schema.Boolean),
570 diffIgnoreWhitespace: Schema.optionalKey(Schema.Boolean),
571 favorites: Schema.optionalKey(
572 Schema.Array(
573 Schema.Struct({
574 provider: ProviderInstanceId,
575 model: TrimmedNonEmptyString,
576 }),
577 ),
578 ),
579 providerModelPreferences: Schema.optionalKey(
580 Schema.Record(
581 ProviderInstanceId,
582 Schema.Struct({
583 hiddenModels: Schema.Array(Schema.String).pipe(
584 Schema.withDecodingDefault(Effect.succeed([])),
585 ),
586 modelOrder: Schema.Array(Schema.String).pipe(
587 Schema.withDecodingDefault(Effect.succeed([])),
588 ),
589 }),
590 ),
591 ),
592 sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),
593 sidebarProjectGroupingOverrides: Schema.optionalKey(
594 Schema.Record(TrimmedNonEmptyString, SidebarProjectGroupingMode),
595 ),
596 sidebarProjectSortOrder: Schema.optionalKey(SidebarProjectSortOrder),
597 sidebarThreadSortOrder: Schema.optionalKey(SidebarThreadSortOrder),
598 sidebarThreadPreviewCount: Schema.optionalKey(SidebarThreadPreviewCount),
599 timestampFormat: Schema.optionalKey(TimestampFormat),
600 wordWrap: Schema.optionalKey(Schema.Boolean),
601});
602export type ClientSettingsPatch = typeof ClientSettingsPatch.Type;