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 "./orchestration.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 launchArgs: TrimmedString.pipe(
195 Schema.withDecodingDefault(Effect.succeed("")),
196 Schema.annotateKey({
197 title: "Launch arguments",
198 description: "Additional CLI arguments passed to codex app-server on session start.",
199 }),
200 ),
201 customModels: Schema.Array(Schema.String).pipe(
202 Schema.withDecodingDefault(Effect.succeed([])),
203 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
204 ),
205 },
206 {
207 order: ["binaryPath", "homePath", "shadowHomePath", "launchArgs"],
208 },
209);
210export type CodexSettings = typeof CodexSettings.Type;
211
212export const ClaudeSettings = makeProviderSettingsSchema(
213 {
214 enabled: Schema.Boolean.pipe(
215 Schema.withDecodingDefault(Effect.succeed(true)),
216 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
217 ),
218 binaryPath: makeBinaryPathSetting("claude").pipe(
219 Schema.annotateKey({
220 title: "Binary path",
221 description: "Path to the Claude binary used by this instance.",
222 providerSettingsForm: { placeholder: "claude", clearWhenEmpty: "omit" },
223 }),
224 ),
225 homePath: TrimmedString.pipe(
226 Schema.withDecodingDefault(Effect.succeed("")),
227 Schema.annotateKey({
228 title: "CLAUDE_CONFIG_DIR path",
229 description:
230 "Custom Claude home and config directory. Keeps .claude.json and .claude separate.",
231 providerSettingsForm: { placeholder: "~/.claude", clearWhenEmpty: "omit" },
232 }),
233 ),
234 customModels: Schema.Array(Schema.String).pipe(
235 Schema.withDecodingDefault(Effect.succeed([])),
236 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
237 ),
238 launchArgs: Schema.String.pipe(
239 Schema.withDecodingDefault(Effect.succeed("")),
240 Schema.annotateKey({
241 title: "Launch arguments",
242 description: "Additional CLI arguments passed on session start.",
243 providerSettingsForm: {
244 placeholder: "e.g. --chrome",
245 clearWhenEmpty: "omit",
246 },
247 }),
248 ),
249 },
250 {
251 order: ["binaryPath", "homePath", "launchArgs"],
252 },
253);
254export type ClaudeSettings = typeof ClaudeSettings.Type;
255
256export const CursorSettings = makeProviderSettingsSchema(
257 {
258 enabled: Schema.Boolean.pipe(
259 Schema.withDecodingDefault(Effect.succeed(false)),
260 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
261 ),
262 binaryPath: makeBinaryPathSetting("cursor-agent").pipe(
263 Schema.annotateKey({
264 title: "Binary path",
265 description: "Path to the Cursor agent binary.",
266 providerSettingsForm: { placeholder: "cursor-agent", clearWhenEmpty: "omit" },
267 }),
268 ),
269 apiEndpoint: TrimmedString.pipe(
270 Schema.withDecodingDefault(Effect.succeed("")),
271 Schema.annotateKey({
272 title: "API endpoint",
273 description: "Override the Cursor API endpoint for this instance.",
274 providerSettingsForm: {
275 placeholder: "https://...",
276 clearWhenEmpty: "omit",
277 },
278 }),
279 ),
280 customModels: Schema.Array(Schema.String).pipe(
281 Schema.withDecodingDefault(Effect.succeed([])),
282 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
283 ),
284 },
285 {
286 order: ["binaryPath", "apiEndpoint"],
287 },
288);
289export type CursorSettings = typeof CursorSettings.Type;
290
291export const GrokSettings = makeProviderSettingsSchema(
292 {
293 enabled: Schema.Boolean.pipe(
294 Schema.withDecodingDefault(Effect.succeed(true)),
295 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
296 ),
297 binaryPath: makeBinaryPathSetting("grok").pipe(
298 Schema.annotateKey({
299 title: "Binary path",
300 description: "Path to the Grok CLI binary.",
301 providerSettingsForm: { placeholder: "grok", clearWhenEmpty: "omit" },
302 }),
303 ),
304 customModels: Schema.Array(Schema.String).pipe(
305 Schema.withDecodingDefault(Effect.succeed([])),
306 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
307 ),
308 },
309 {
310 order: ["binaryPath"],
311 },
312);
313export type GrokSettings = typeof GrokSettings.Type;
314
315export const OpenCodeSettings = makeProviderSettingsSchema(
316 {
317 enabled: Schema.Boolean.pipe(
318 Schema.withDecodingDefault(Effect.succeed(true)),
319 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
320 ),
321 binaryPath: makeBinaryPathSetting("opencode").pipe(
322 Schema.annotateKey({
323 title: "Binary path",
324 description: "Path to the OpenCode binary.",
325 providerSettingsForm: {
326 placeholder: "opencode",
327 clearWhenEmpty: "omit",
328 },
329 }),
330 ),
331 serverUrl: TrimmedString.pipe(
332 Schema.withDecodingDefault(Effect.succeed("")),
333 Schema.annotateKey({
334 title: "Server URL",
335 description: "Leave blank to let T3 Code spawn the server when needed.",
336 providerSettingsForm: {
337 placeholder: "http://127.0.0.1:4096",
338 clearWhenEmpty: "omit",
339 },
340 }),
341 ),
342 serverPassword: TrimmedString.pipe(
343 Schema.withDecodingDefault(Effect.succeed("")),
344 Schema.annotateKey({
345 title: "Server password",
346 description: "Stored in plain text on disk.",
347 providerSettingsForm: {
348 control: "password",
349 placeholder: "Optional",
350 clearWhenEmpty: "omit",
351 },
352 }),
353 ),
354 customModels: Schema.Array(Schema.String).pipe(
355 Schema.withDecodingDefault(Effect.succeed([])),
356 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
357 ),
358 },
359 {
360 order: ["binaryPath", "serverUrl", "serverPassword"],
361 },
362);
363export type OpenCodeSettings = typeof OpenCodeSettings.Type;
364
365export const ObservabilitySettings = Schema.Struct({
366 otlpTracesUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
367 otlpMetricsUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
368});
369export type ObservabilitySettings = typeof ObservabilitySettings.Type;
370
371export const DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL = Duration.seconds(30);
372
373export const ServerSettings = Schema.Struct({
374 enableAssistantStreaming: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
375 enableProviderUpdateChecks: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
376 automaticGitFetchInterval: Schema.DurationFromMillis.pipe(
377 Schema.withDecodingDefault(
378 Effect.succeed(Duration.toMillis(DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL)),
379 ),
380 ),
381 defaultThreadEnvMode: ThreadEnvMode.pipe(
382 Schema.withDecodingDefault(Effect.succeed("local" as const satisfies ThreadEnvMode)),
383 ),
384 newWorktreesStartFromOrigin: Schema.Boolean.pipe(
385 Schema.withDecodingDefault(Effect.succeed(false)),
386 ),
387 addProjectBaseDirectory: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
388 textGenerationModelSelection: ModelSelection.pipe(
389 Schema.withDecodingDefault(
390 Effect.succeed({
391 instanceId: ProviderInstanceId.make("codex"),
392 model: DEFAULT_GIT_TEXT_GENERATION_MODEL,
393 }),
394 ),
395 ),
396
397 // Legacy single-instance-per-driver settings. Continues to be the source
398 // of truth until `providerInstances` (below) lands per-driver migration
399 // shims and the server starts hydrating instances from it. Driver-specific
400 // schemas live here for the duration of the migration; once each driver
401 // owns its config in its own package, this struct shrinks to nothing and
402 // is removed entirely.
403 providers: Schema.Struct({
404 codex: CodexSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
405 claudeAgent: ClaudeSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
406 cursor: CursorSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
407 grok: GrokSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
408 opencode: OpenCodeSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
409 }).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
410 // New driver-agnostic instance map. Keyed by `ProviderInstanceId`; values
411 // are `ProviderInstanceConfig` envelopes. The driver-specific config blob
412 // is `Schema.Unknown` at this layer so envelopes with unknown drivers
413 // (forks, downgrades, in-flight PR branches) round-trip without loss.
414 // See providerInstance.ts for the forward/backward compatibility invariant.
415 providerInstances: Schema.Record(ProviderInstanceId, ProviderInstanceConfig).pipe(
416 Schema.withDecodingDefault(Effect.succeed({})),
417 ),
418 observability: ObservabilitySettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
419});
420export type ServerSettings = typeof ServerSettings.Type;
421
422export const DEFAULT_SERVER_SETTINGS: ServerSettings = Schema.decodeSync(ServerSettings)({});
423
424export const ServerSettingsOperation = Schema.Literals([
425 "normalize",
426 "check-exists",
427 "read-file",
428 "read-secret",
429 "remove-secret",
430 "remove-stale-secret",
431 "write-secret",
432 "write-file",
433 "prepare-directory",
434]);
435export type ServerSettingsOperation = typeof ServerSettingsOperation.Type;
436
437export class ServerSettingsError extends Schema.TaggedErrorClass<ServerSettingsError>()(
438 "ServerSettingsError",
439 {
440 settingsPath: Schema.String,
441 operation: ServerSettingsOperation,
442 providerInstanceId: Schema.optional(Schema.String),
443 environmentVariable: Schema.optional(Schema.String),
444 cause: Schema.Defect(),
445 },
446) {
447 override get message(): string {
448 const provider =
449 this.providerInstanceId === undefined ? "" : ` for provider ${this.providerInstanceId}`;
450 const variable =
451 this.environmentVariable === undefined
452 ? ""
453 : ` and environment variable ${this.environmentVariable}`;
454 return `Server settings ${this.operation} failed${provider}${variable} at ${this.settingsPath}.`;
455 }
456}
457
458// ── Unified type ─────────────────────────────────────────────────────
459
460export type UnifiedSettings = ServerSettings & ClientSettings;
461export const DEFAULT_UNIFIED_SETTINGS: UnifiedSettings = {
462 ...DEFAULT_SERVER_SETTINGS,
463 ...DEFAULT_CLIENT_SETTINGS,
464};
465
466// ── Server Settings Patch (replace with a Schema.deepPartial if available) ──────────────────────────────────────────
467
468const ModelSelectionPatch = Schema.Struct({
469 instanceId: Schema.optionalKey(ProviderInstanceId),
470 model: Schema.optionalKey(TrimmedNonEmptyString),
471 options: Schema.optionalKey(ProviderOptionSelections),
472});
473
474const CodexSettingsPatch = Schema.Struct({
475 enabled: Schema.optionalKey(Schema.Boolean),
476 binaryPath: Schema.optionalKey(TrimmedString),
477 homePath: Schema.optionalKey(TrimmedString),
478 shadowHomePath: Schema.optionalKey(TrimmedString),
479 launchArgs: Schema.optionalKey(TrimmedString),
480 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
481});
482
483const ClaudeSettingsPatch = Schema.Struct({
484 enabled: Schema.optionalKey(Schema.Boolean),
485 binaryPath: Schema.optionalKey(TrimmedString),
486 homePath: Schema.optionalKey(TrimmedString),
487 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
488 launchArgs: Schema.optionalKey(TrimmedString),
489});
490
491const CursorSettingsPatch = Schema.Struct({
492 enabled: Schema.optionalKey(Schema.Boolean),
493 binaryPath: Schema.optionalKey(TrimmedString),
494 apiEndpoint: Schema.optionalKey(TrimmedString),
495 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
496});
497
498const GrokSettingsPatch = Schema.Struct({
499 enabled: Schema.optionalKey(Schema.Boolean),
500 binaryPath: Schema.optionalKey(TrimmedString),
501 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
502});
503
504const OpenCodeSettingsPatch = Schema.Struct({
505 enabled: Schema.optionalKey(Schema.Boolean),
506 binaryPath: Schema.optionalKey(TrimmedString),
507 serverUrl: Schema.optionalKey(TrimmedString),
508 serverPassword: Schema.optionalKey(TrimmedString),
509 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
510});
511
512export const ServerSettingsPatch = Schema.Struct({
513 // Server settings
514 enableAssistantStreaming: Schema.optionalKey(Schema.Boolean),
515 enableProviderUpdateChecks: Schema.optionalKey(Schema.Boolean),
516 automaticGitFetchInterval: Schema.optionalKey(Schema.DurationFromMillis),
517 defaultThreadEnvMode: Schema.optionalKey(ThreadEnvMode),
518 newWorktreesStartFromOrigin: Schema.optionalKey(Schema.Boolean),
519 addProjectBaseDirectory: Schema.optionalKey(TrimmedString),
520 textGenerationModelSelection: Schema.optionalKey(ModelSelectionPatch),
521 observability: Schema.optionalKey(
522 Schema.Struct({
523 otlpTracesUrl: Schema.optionalKey(TrimmedString),
524 otlpMetricsUrl: Schema.optionalKey(TrimmedString),
525 }),
526 ),
527 providers: Schema.optionalKey(
528 Schema.Struct({
529 codex: Schema.optionalKey(CodexSettingsPatch),
530 claudeAgent: Schema.optionalKey(ClaudeSettingsPatch),
531 cursor: Schema.optionalKey(CursorSettingsPatch),
532 grok: Schema.optionalKey(GrokSettingsPatch),
533 opencode: Schema.optionalKey(OpenCodeSettingsPatch),
534 }),
535 ),
536 // Whole-map replacement for the new instance config. Patching individual
537 // entries is intentionally out of scope: the map is small, and partial
538 // patches risk leaving driver-specific config in a half-merged state.
539 // The web UI sends a fully-formed map every time it edits this field.
540 providerInstances: Schema.optionalKey(Schema.Record(ProviderInstanceId, ProviderInstanceConfig)),
541});
542export type ServerSettingsPatch = typeof ServerSettingsPatch.Type;
543
544export const ClientSettingsPatch = Schema.Struct({
545 autoOpenPlanSidebar: Schema.optionalKey(Schema.Boolean),
546 confirmThreadArchive: Schema.optionalKey(Schema.Boolean),
547 confirmThreadDelete: Schema.optionalKey(Schema.Boolean),
548 diffIgnoreWhitespace: Schema.optionalKey(Schema.Boolean),
549 favorites: Schema.optionalKey(
550 Schema.Array(
551 Schema.Struct({
552 provider: ProviderInstanceId,
553 model: TrimmedNonEmptyString,
554 }),
555 ),
556 ),
557 providerModelPreferences: Schema.optionalKey(
558 Schema.Record(
559 ProviderInstanceId,
560 Schema.Struct({
561 hiddenModels: Schema.Array(Schema.String).pipe(
562 Schema.withDecodingDefault(Effect.succeed([])),
563 ),
564 modelOrder: Schema.Array(Schema.String).pipe(
565 Schema.withDecodingDefault(Effect.succeed([])),
566 ),
567 }),
568 ),
569 ),
570 sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),
571 sidebarProjectGroupingOverrides: Schema.optionalKey(
572 Schema.Record(TrimmedNonEmptyString, SidebarProjectGroupingMode),
573 ),
574 sidebarProjectSortOrder: Schema.optionalKey(SidebarProjectSortOrder),
575 sidebarThreadSortOrder: Schema.optionalKey(SidebarThreadSortOrder),
576 sidebarThreadPreviewCount: Schema.optionalKey(SidebarThreadPreviewCount),
577 timestampFormat: Schema.optionalKey(TimestampFormat),
578 wordWrap: Schema.optionalKey(Schema.Boolean),
579});
580export type ClientSettingsPatch = typeof ClientSettingsPatch.Type;