Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

settings.ts

1,009 lines42.8 KB

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 { ThreadEnvMode } from "./environment.ts";
7import {
8 DEFAULT_TEXT_GENERATION_MODEL,
9 DEFAULT_TEXT_GENERATION_REASONING_EFFORT,
10 ProviderOptionSelections,
11} from "./model.ts";
12import { ModelSelection } from "./orchestration.ts";
13import {
14 DEFAULT_PREVIEW_APPEARANCE,
15 DEFAULT_PREVIEW_ZOOM_FACTOR,
16 FILL_PREVIEW_VIEWPORT,
17 PreviewAppearancePreference,
18 PreviewViewportSetting,
19 PreviewZoomFactor,
20} from "./preview.ts";
21import {
22 ProviderInstanceConfig,
23 ProviderInstanceId,
24 type ProviderDriverKind,
25} from "./providerInstance.ts";
26​
27// ── Client Settings (local-only) ───────────────────────────────
28​
29export const TimestampFormat = Schema.Literals(["locale", "12-hour", "24-hour"]);
30export type TimestampFormat = typeof TimestampFormat.Type;
31export const DEFAULT_TIMESTAMP_FORMAT: TimestampFormat = "locale";
32​
33export const SidebarProjectSortOrder = Schema.Literals(["updated_at", "created_at", "manual"]);
34export type SidebarProjectSortOrder = typeof SidebarProjectSortOrder.Type;
35export const DEFAULT_SIDEBAR_PROJECT_SORT_ORDER: SidebarProjectSortOrder = "updated_at";
36​
37export const SidebarThreadSortOrder = Schema.Literals(["updated_at", "created_at"]);
38export type SidebarThreadSortOrder = typeof SidebarThreadSortOrder.Type;
39export const DEFAULT_SIDEBAR_THREAD_SORT_ORDER: SidebarThreadSortOrder = "updated_at";
40​
41export const SidebarProjectGroupingMode = Schema.Literals([
42 "repository",
43 "repository_path",
44 "separate",
45]);
46export type SidebarProjectGroupingMode = typeof SidebarProjectGroupingMode.Type;
47export const DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE: SidebarProjectGroupingMode = "repository";
48export const MIN_SIDEBAR_THREAD_PREVIEW_COUNT = 1;
49export const MAX_SIDEBAR_THREAD_PREVIEW_COUNT = 15;
50export const SidebarThreadPreviewCount = Schema.Int.check(
51 Schema.isBetween({
52 minimum: MIN_SIDEBAR_THREAD_PREVIEW_COUNT,
53 maximum: MAX_SIDEBAR_THREAD_PREVIEW_COUNT,
54 }),
55);
56export type SidebarThreadPreviewCount = typeof SidebarThreadPreviewCount.Type;
57export const DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT: SidebarThreadPreviewCount = 6;
58export const MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS = 1;
59export const MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS = 90;
60export const SidebarAutoSettleAfterDays = Schema.Number.check(
61 Schema.isBetween({
62 minimum: MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
63 maximum: MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
64 }),
65);
66export type SidebarAutoSettleAfterDays = typeof SidebarAutoSettleAfterDays.Type;
67export const DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS: SidebarAutoSettleAfterDays = 3;
68export const MIN_GLASS_OPACITY = 40;
69export const MAX_GLASS_OPACITY = 100;
70export const GlassOpacity = Schema.Int.check(
71 Schema.isBetween({
72 minimum: MIN_GLASS_OPACITY,
73 maximum: MAX_GLASS_OPACITY,
74 }),
75);
76export type GlassOpacity = typeof GlassOpacity.Type;
77export const DEFAULT_GLASS_OPACITY: GlassOpacity = 80;
78​
79export const MIN_APPEARANCE_CONTRAST = 50;
80export const MAX_APPEARANCE_CONTRAST = 200;
81export const AppearanceContrast = Schema.Int.check(
82 Schema.isBetween({ minimum: MIN_APPEARANCE_CONTRAST, maximum: MAX_APPEARANCE_CONTRAST }),
83);
84export type AppearanceContrast = typeof AppearanceContrast.Type;
85export const DEFAULT_APPEARANCE_CONTRAST: AppearanceContrast = 100;
86/**
87 * Font size preferences, in CSS pixels. The ranges are deliberately narrow:
88 * the interface size scales every rem-based dimension in the app, so the
89 * bounds keep layouts intact rather than offering unusable extremes.
90 */
91export const MIN_INTERFACE_FONT_SIZE = 12;
92export const MAX_INTERFACE_FONT_SIZE = 20;
93export const InterfaceFontSize = Schema.Int.check(
94 Schema.isBetween({ minimum: MIN_INTERFACE_FONT_SIZE, maximum: MAX_INTERFACE_FONT_SIZE }),
95);
96export type InterfaceFontSize = typeof InterfaceFontSize.Type;
97export const DEFAULT_INTERFACE_FONT_SIZE: InterfaceFontSize = 16;
98​
99export const MIN_PROMPT_FONT_SIZE = 12;
100export const MAX_PROMPT_FONT_SIZE = 20;
101export const PromptFontSize = Schema.Int.check(
102 Schema.isBetween({ minimum: MIN_PROMPT_FONT_SIZE, maximum: MAX_PROMPT_FONT_SIZE }),
103);
104export type PromptFontSize = typeof PromptFontSize.Type;
105export const DEFAULT_PROMPT_FONT_SIZE: PromptFontSize = 14;
106​
107export const MIN_CODE_FONT_SIZE = 10;
108export const MAX_CODE_FONT_SIZE = 18;
109export const CodeFontSize = Schema.Int.check(
110 Schema.isBetween({ minimum: MIN_CODE_FONT_SIZE, maximum: MAX_CODE_FONT_SIZE }),
111);
112export type CodeFontSize = typeof CodeFontSize.Type;
113export const DEFAULT_CODE_FONT_SIZE: CodeFontSize = 13;
114​
115export const MIN_TERMINAL_FONT_SIZE = 8;
116export const MAX_TERMINAL_FONT_SIZE = 20;
117export const TerminalFontSize = Schema.Int.check(
118 Schema.isBetween({ minimum: MIN_TERMINAL_FONT_SIZE, maximum: MAX_TERMINAL_FONT_SIZE }),
119);
120export type TerminalFontSize = typeof TerminalFontSize.Type;
121export const DEFAULT_TERMINAL_FONT_SIZE: TerminalFontSize = 12;
122​
123export const EnvironmentIdentificationMode = Schema.Literals(["artwork", "pill", "none"]);
124export type EnvironmentIdentificationMode = typeof EnvironmentIdentificationMode.Type;
125export const DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE: EnvironmentIdentificationMode = "artwork";
126​
127export const QuitConfirmationMode = Schema.Literals(["direct", "hold", "double-click"]);
128export type QuitConfirmationMode = typeof QuitConfirmationMode.Type;
129export const DEFAULT_QUIT_CONFIRMATION_MODE: QuitConfirmationMode = "hold";
130​
131const LegacyConfirmQuit = Schema.Boolean.pipe(
132 Schema.decodeTo(
133 QuitConfirmationMode,
134 SchemaTransformation.transform({
135 decode: (confirmQuit): QuitConfirmationMode => (confirmQuit ? "hold" : "direct"),
136 encode: (mode) => mode === "hold",
137 }),
138 ),
139);
140​
141const QuitConfirmationModeSetting = Schema.Union([QuitConfirmationMode, LegacyConfirmQuit]);
142​
143/**
144 * A user-chosen font family (a single name or a comma-separated list). Empty
145 * means "use the app default"; clients compose their own fallback stacks.
146 */
147export const FontFamilyPreference = Schema.String.check(Schema.isMaxLength(200));
148export type FontFamilyPreference = typeof FontFamilyPreference.Type;
149​
150/**
151 * The environment's theme, set with `t3 theme set <id>`. Each client applies
152 * it once per value — live when connected, on its next connect otherwise — so
153 * setting it switches every client, while a theme a user picks in Settings
154 * afterwards sticks until the next set. Empty means "no environment theme",
155 * which is also how it is cleared.
156 */
157export const DefaultThemePreference = Schema.String.check(Schema.isMaxLength(64));
158// Deliberately absent from ServerSettingsPatch: `t3 theme set` checks that an
159// id is syntactically valid and actually resolvable, and a generic RPC patch
160// would let a client write a theme no client can resolve, bypassing both.
161export type DefaultThemePreference = typeof DefaultThemePreference.Type;
162​
163/**
164 * Defaults for the in-app preview browser, applied whenever a tab is opened
165 * without an explicit viewport/zoom/appearance — by the user opening a browser
166 * tab, or by an agent calling `preview_open` with no size. Recording quality is
167 * client-local for the same reason: the Chromium guest being captured belongs
168 * to the desktop app.
169 */
170export const DEFAULT_BROWSER_VIEWPORT: PreviewViewportSetting = FILL_PREVIEW_VIEWPORT;
171export const DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW = true;
172export const BROWSER_RECORDING_FRAME_RATES = [30, 60] as const;
173export const BrowserRecordingFrameRate = Schema.Literals(BROWSER_RECORDING_FRAME_RATES);
174export type BrowserRecordingFrameRate = typeof BrowserRecordingFrameRate.Type;
175export const DEFAULT_BROWSER_RECORDING_FRAME_RATE: BrowserRecordingFrameRate = 30;
176​
177export const ClientSettingsSchema = Schema.Struct({
178 appearanceContrast: AppearanceContrast.pipe(
179 Schema.withDecodingDefault(Effect.succeed(DEFAULT_APPEARANCE_CONTRAST)),
180 ),
181 browserDefaultViewport: PreviewViewportSetting.pipe(
182 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BROWSER_VIEWPORT)),
183 ),
184 browserDefaultZoomFactor: PreviewZoomFactor.pipe(
185 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PREVIEW_ZOOM_FACTOR)),
186 ),
187 browserDefaultAppearance: PreviewAppearancePreference.pipe(
188 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PREVIEW_APPEARANCE)),
189 ),
190 browserRecordingFrameRate: BrowserRecordingFrameRate.pipe(
191 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BROWSER_RECORDING_FRAME_RATE)),
192 ),
193 /**
194 * Whether an agent opening a preview pops the floating mini player into
195 * view. Only applies when the agent didn't ask either way — an explicit
196 * `open`/`show` on `preview_open` still wins, since that is the agent
197 * deliberately showing or hiding its work.
198 */
199 browserAutoShowFloatingPreview: Schema.Boolean.pipe(
200 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW)),
201 ),
202 // Desktop-only. Boolean values from older settings files decode to their
203 // equivalent mode and encode back as the canonical string value.
204 confirmQuit: QuitConfirmationModeSetting.pipe(
205 Schema.withDecodingDefault(Effect.succeed(DEFAULT_QUIT_CONFIRMATION_MODE)),
206 ),
207 confirmThreadArchive: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
208 confirmThreadDelete: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
209 confirmThreadUnpin: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
210 dismissedProviderUpdateNotificationKeys: Schema.Array(TrimmedNonEmptyString).pipe(
211 Schema.withDecodingDefault(Effect.succeed([])),
212 ),
213 diffIgnoreWhitespace: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
214 environmentIdentificationMode: EnvironmentIdentificationMode.pipe(
215 Schema.withDecodingDefault(Effect.succeed(DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE)),
216 ),
217 glassOpacity: GlassOpacity.pipe(
218 Schema.withDecodingDefault(Effect.succeed(DEFAULT_GLASS_OPACITY)),
219 ),
220 fontSizeInterface: InterfaceFontSize.pipe(
221 Schema.withDecodingDefault(Effect.succeed(DEFAULT_INTERFACE_FONT_SIZE)),
222 ),
223 fontSizePrompt: PromptFontSize.pipe(
224 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PROMPT_FONT_SIZE)),
225 ),
226 fontSizeCode: CodeFontSize.pipe(
227 Schema.withDecodingDefault(Effect.succeed(DEFAULT_CODE_FONT_SIZE)),
228 ),
229 fontSizeTerminal: TerminalFontSize.pipe(
230 Schema.withDecodingDefault(Effect.succeed(DEFAULT_TERMINAL_FONT_SIZE)),
231 ),
232 fontFamilyCode: FontFamilyPreference.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
233 fontFamilyComposer: FontFamilyPreference.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
234 fontFamilySans: FontFamilyPreference.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
235 fontFamilyTerminal: FontFamilyPreference.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
236 // Grayscale `-webkit-font-smoothing: antialiased` (thinner strokes);
237 // disabling restores the platform's heavier default. No effect off macOS.
238 fontSmoothing: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
239 // Model favorites. Historically keyed by provider kind, now
240 // widened to `ProviderInstanceId` so users can favorite a specific model
241 // on a custom provider instance (e.g. "Codex Personal · gpt-5") without
242 // the UI collapsing it into the same bucket as the default Codex. The
243 // widening is backward-compatible by construction: prior provider-kind
244 // strings satisfy the `ProviderInstanceId` slug schema, so previously
245 // persisted favorites decode unchanged and continue to point at the
246 // default instance for their kind (because `defaultInstanceIdForDriver(kind)`
247 // uses the same slug). The field name is kept as `provider` for storage
248 // stability; new call sites should treat the value as an instance id.
249 favorites: Schema.Array(
250 Schema.Struct({
251 provider: ProviderInstanceId,
252 model: TrimmedNonEmptyString,
253 }),
254 ).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
255 providerModelPreferences: Schema.Record(
256 ProviderInstanceId,
257 Schema.Struct({
258 hiddenModels: Schema.Array(Schema.String).pipe(
259 Schema.withDecodingDefault(Effect.succeed([])),
260 ),
261 modelOrder: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
262 }),
263 ).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
264 // Legacy plan mode. The composer's Build/Plan toggle was removed from the
265 // default UI; this beta flag restores it (plus the /plan and /default slash
266 // commands) for users who still rely on the old workflow.
267 planModeEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
268 // Legacy context window meter. The composer hides it by default; users who
269 // still want the old usage indicator can restore it from Settings.
270 contextWindowMeterEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
271 showSkillsInSlashMenu: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
272 // Legacy sidebar (the original per-project tree). Deliberately a fresh key
273 // (was `sidebarV2Enabled` + `sidebarV2ConfiguredByUser`): decoding drops the
274 // old keys, so everyone, including prior beta opt-outs, resets to the new
275 // default sidebar.
276 legacySidebarEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
277 sidebarProjectGroupingMode: SidebarProjectGroupingMode.pipe(
278 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE)),
279 ),
280 sidebarProjectGroupingOverrides: Schema.Record(
281 TrimmedNonEmptyString,
282 SidebarProjectGroupingMode,
283 ).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
284 sidebarProjectSortOrder: SidebarProjectSortOrder.pipe(
285 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_SORT_ORDER)),
286 ),
287 sidebarThreadSortOrder: SidebarThreadSortOrder.pipe(
288 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_SORT_ORDER)),
289 ),
290 sidebarThreadPreviewCount: SidebarThreadPreviewCount.pipe(
291 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT)),
292 ),
293 timestampFormat: TimestampFormat.pipe(
294 Schema.withDecodingDefault(Effect.succeed(DEFAULT_TIMESTAMP_FORMAT)),
295 ),
296 wordWrap: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
297});
298export type ClientSettings = typeof ClientSettingsSchema.Type;
299​
300export const DEFAULT_CLIENT_SETTINGS: ClientSettings = Schema.decodeSync(ClientSettingsSchema)({});
301​
302// ── Server Settings (server-authoritative) ────────────────────
303​
304const makeBinaryPathSetting = (fallback: string) =>
305 TrimmedString.pipe(
306 Schema.decodeTo(
307 Schema.String,
308 SchemaTransformation.transformOrFail({
309 decode: (value) => Effect.succeed(value || fallback),
310 encode: (value) => Effect.succeed(value),
311 }),
312 ),
313 Schema.withDecodingDefault(Effect.succeed(fallback)),
314 );
315​
316export type ProviderSettingsFormControl = "text" | "password" | "textarea" | "switch";
317​
318export interface ProviderSettingsFormAnnotation {
319 readonly control?: ProviderSettingsFormControl | undefined;
320 readonly placeholder?: string | undefined;
321 readonly hidden?: boolean | undefined;
322 readonly clearWhenEmpty?: "omit" | "persist" | undefined;
324​
325export interface ProviderSettingsFormSchemaAnnotation {
326 readonly order?: readonly string[] | undefined;
328​
329declare module "effect/Schema" {
330 namespace Annotations {
331 interface Annotations {
332 readonly providerSettingsForm?: ProviderSettingsFormAnnotation | undefined;
333 readonly providerSettingsFormSchema?: ProviderSettingsFormSchemaAnnotation | undefined;
334 }
335 }
337​
338export type ProviderSettingsOrder<Fields extends Schema.Struct.Fields> = readonly Extract<
339 keyof Fields,
340 string
341>[];
342​
343export function makeProviderSettingsSchema<const Fields extends Schema.Struct.Fields>(
344 fields: Fields,
345 options?: {
346 readonly order?: ProviderSettingsOrder<Fields> | undefined;
347 },
348): Schema.Struct<Fields> {
349 return Schema.Struct(fields).pipe(
350 Schema.annotate({
351 providerSettingsFormSchema:
352 options?.order === undefined ? undefined : { order: options.order },
353 }),
354 );
356​
357export const CodexSettings = makeProviderSettingsSchema(
358 {
359 enabled: Schema.Boolean.pipe(
360 Schema.withDecodingDefault(Effect.succeed(true)),
361 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
362 ),
363 binaryPath: makeBinaryPathSetting("codex").pipe(
364 Schema.annotateKey({
365 title: "Binary path",
366 description: "Path to the Codex binary used by this instance.",
367 providerSettingsForm: { placeholder: "codex", clearWhenEmpty: "omit" },
368 }),
369 ),
370 homePath: TrimmedString.pipe(
371 Schema.withDecodingDefault(Effect.succeed("")),
372 Schema.annotateKey({
373 title: "CODEX_HOME path",
374 description: "Custom Codex home and config directory.",
375 providerSettingsForm: {
376 placeholder: "~/.codex",
377 clearWhenEmpty: "omit",
378 },
379 }),
380 ),
381 shadowHomePath: TrimmedString.pipe(
382 Schema.withDecodingDefault(Effect.succeed("")),
383 Schema.annotateKey({
384 title: "Shadow home path",
385 description:
386 "Account-specific Codex home. Keeps auth.json separate while sharing state from CODEX_HOME.",
387 providerSettingsForm: {
388 placeholder: "~/.codex-t3/personal",
389 clearWhenEmpty: "omit",
390 },
391 }),
392 ),
393 launchArgs: TrimmedString.pipe(
394 Schema.withDecodingDefault(Effect.succeed("")),
395 Schema.annotateKey({
396 title: "Launch arguments",
397 description: "Additional CLI arguments passed to codex app-server on session start.",
398 }),
399 ),
400 customModels: Schema.Array(Schema.String).pipe(
401 Schema.withDecodingDefault(Effect.succeed([])),
402 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
403 ),
404 },
405 {
406 order: ["binaryPath", "homePath", "shadowHomePath", "launchArgs"],
407 },
408);
409export type CodexSettings = typeof CodexSettings.Type;
410​
411// Empty, or an integer from 100,000 to 1,000,000. Shared by the full
412// Claude settings schema and its patch so an out-of-range value fails at
413// the update that introduced it.
414const CLAUDE_AUTO_COMPACT_WINDOW_PATTERN = /^(?:|[1-9]\d{5}|1000000)$/;
415​
416export const ClaudeSettings = makeProviderSettingsSchema(
417 {
418 enabled: Schema.Boolean.pipe(
419 Schema.withDecodingDefault(Effect.succeed(true)),
420 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
421 ),
422 binaryPath: makeBinaryPathSetting("claude").pipe(
423 Schema.annotateKey({
424 title: "Binary path",
425 description: "Path to the Claude binary used by this instance.",
426 providerSettingsForm: { placeholder: "claude", clearWhenEmpty: "omit" },
427 }),
428 ),
429 homePath: TrimmedString.pipe(
430 Schema.withDecodingDefault(Effect.succeed("")),
431 Schema.annotateKey({
432 title: "CLAUDE_CONFIG_DIR path",
433 description:
434 "Custom Claude home and config directory. Keeps .claude.json and .claude separate.",
435 providerSettingsForm: { placeholder: "~/.claude", clearWhenEmpty: "omit" },
436 }),
437 ),
438 customModels: Schema.Array(Schema.String).pipe(
439 Schema.withDecodingDefault(Effect.succeed([])),
440 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
441 ),
442 launchArgs: Schema.String.pipe(
443 Schema.withDecodingDefault(Effect.succeed("")),
444 Schema.annotateKey({
445 title: "Launch arguments",
446 description: "Additional CLI arguments passed on session start.",
447 providerSettingsForm: {
448 placeholder: "e.g. --chrome",
449 clearWhenEmpty: "omit",
450 },
451 }),
452 ),
453 autoCompactWindow: TrimmedString.check(
454 Schema.isPattern(CLAUDE_AUTO_COMPACT_WINDOW_PATTERN),
455 ).pipe(
456 Schema.withDecodingDefault(Effect.succeed("")),
457 Schema.annotateKey({
458 title: "Auto-compact after",
459 description:
460 "Compact after 100,000 to 1,000,000 tokens. Leave empty to use Claude's default.",
461 providerSettingsForm: {
462 placeholder: "e.g. 300000",
463 clearWhenEmpty: "omit",
464 },
465 }),
466 ),
467 },
468 {
469 order: ["binaryPath", "homePath", "autoCompactWindow", "launchArgs"],
470 },
471);
472export type ClaudeSettings = typeof ClaudeSettings.Type;
473​
474export const CursorSettings = makeProviderSettingsSchema(
475 {
476 // Off by default like Grok and OpenCode. Users opt in from Settings.
477 enabled: Schema.Boolean.pipe(
478 Schema.withDecodingDefault(Effect.succeed(false)),
479 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
480 ),
481 binaryPath: makeBinaryPathSetting("cursor-agent").pipe(
482 Schema.annotateKey({
483 title: "Binary path",
484 description: "Path to the Cursor agent binary.",
485 providerSettingsForm: { placeholder: "cursor-agent", clearWhenEmpty: "omit" },
486 }),
487 ),
488 apiEndpoint: TrimmedString.pipe(
489 Schema.withDecodingDefault(Effect.succeed("")),
490 Schema.annotateKey({
491 title: "API endpoint",
492 description: "Override the Cursor API endpoint for this instance.",
493 providerSettingsForm: {
494 placeholder: "https://...",
495 clearWhenEmpty: "omit",
496 },
497 }),
498 ),
499 customModels: Schema.Array(Schema.String).pipe(
500 Schema.withDecodingDefault(Effect.succeed([])),
501 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
502 ),
503 },
504 {
505 order: ["binaryPath", "apiEndpoint"],
506 },
507);
508export type CursorSettings = typeof CursorSettings.Type;
509​
510export const GrokSettings = makeProviderSettingsSchema(
511 {
512 // Off by default (like Cursor and OpenCode): the binding is not yet
513 // stable enough to probe on every install. Users opt in from Settings.
514 enabled: Schema.Boolean.pipe(
515 Schema.withDecodingDefault(Effect.succeed(false)),
516 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
517 ),
518 binaryPath: makeBinaryPathSetting("grok").pipe(
519 Schema.annotateKey({
520 title: "Binary path",
521 description: "Path to the Grok CLI binary.",
522 providerSettingsForm: { placeholder: "grok", clearWhenEmpty: "omit" },
523 }),
524 ),
525 customModels: Schema.Array(Schema.String).pipe(
526 Schema.withDecodingDefault(Effect.succeed([])),
527 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
528 ),
529 },
530 {
531 order: ["binaryPath"],
532 },
533);
534export type GrokSettings = typeof GrokSettings.Type;
535​
536export const OpenCodeSettings = makeProviderSettingsSchema(
537 {
538 // Off by default (like Cursor and Grok): the binding is not yet stable
539 // enough to probe on every install. Users opt in from Settings.
540 enabled: Schema.Boolean.pipe(
541 Schema.withDecodingDefault(Effect.succeed(false)),
542 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
543 ),
544 binaryPath: makeBinaryPathSetting("opencode").pipe(
545 Schema.annotateKey({
546 title: "Binary path",
547 description: "Path to the OpenCode binary.",
548 providerSettingsForm: {
549 placeholder: "opencode",
550 clearWhenEmpty: "omit",
551 },
552 }),
553 ),
554 serverUrl: TrimmedString.pipe(
555 Schema.withDecodingDefault(Effect.succeed("")),
556 Schema.annotateKey({
557 title: "Server URL",
558 description: "Leave blank to let T3 Code spawn the server when needed.",
559 providerSettingsForm: {
560 placeholder: "http://127.0.0.1:4096",
561 clearWhenEmpty: "omit",
562 },
563 }),
564 ),
565 serverPassword: TrimmedString.pipe(
566 Schema.withDecodingDefault(Effect.succeed("")),
567 Schema.annotateKey({
568 title: "Server password",
569 description: "Stored in plain text on disk.",
570 providerSettingsForm: {
571 control: "password",
572 placeholder: "Optional",
573 clearWhenEmpty: "omit",
574 },
575 }),
576 ),
577 customModels: Schema.Array(Schema.String).pipe(
578 Schema.withDecodingDefault(Effect.succeed([])),
579 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
580 ),
581 },
582 {
583 order: ["binaryPath", "serverUrl", "serverPassword"],
584 },
585);
586export type OpenCodeSettings = typeof OpenCodeSettings.Type;
587​
588export const ObservabilitySettings = Schema.Struct({
589 otlpTracesUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
590 otlpMetricsUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
591});
592export type ObservabilitySettings = typeof ObservabilitySettings.Type;
593​
594export const SourceControlWritingStyleMode = Schema.Literals([
595 "repo_conventions",
596 "conventional_commits",
597 "custom",
598]);
599export type SourceControlWritingStyleMode = typeof SourceControlWritingStyleMode.Type;
600​
601export const SourceControlWritingStyleSettings = Schema.Struct({
602 mode: SourceControlWritingStyleMode.pipe(
603 Schema.withDecodingDefault(Effect.succeed("repo_conventions" as const)),
604 ),
605 customInstructions: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
606 followChangeRequestTemplates: Schema.Boolean.pipe(
607 Schema.withDecodingDefault(Effect.succeed(true)),
608 ),
609});
610export type SourceControlWritingStyleSettings = typeof SourceControlWritingStyleSettings.Type;
611​
612export const DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL = Duration.seconds(30);
613export const DEFAULT_PROVIDER_HEALTH_REFRESH_INTERVAL = Duration.minutes(5);
614​
615export const BackgroundActivityProfile = Schema.Literals([
616 "balanced",
617 "performance",
618 "battery-saver",
619]);
620export type BackgroundActivityProfile = typeof BackgroundActivityProfile.Type;
621export const DEFAULT_BACKGROUND_ACTIVITY_PROFILE: BackgroundActivityProfile = "balanced";
622​
623export const BackgroundActivityProfileSelection = Schema.Literals([
624 "balanced",
625 "performance",
626 "battery-saver",
627 "custom",
628]);
629export type BackgroundActivityProfileSelection = typeof BackgroundActivityProfileSelection.Type;
630​
631export const BackgroundActivityOverrides = Schema.Struct({
632 automaticGitFetchInterval: Schema.optionalKey(Schema.DurationFromMillis),
633 providerHealthRefreshInterval: Schema.optionalKey(Schema.DurationFromMillis),
634 hostPowerMonitorActiveInterval: Schema.optionalKey(Schema.DurationFromMillis),
635 hostPowerMonitorIdleInterval: Schema.optionalKey(Schema.DurationFromMillis),
636 idleClientTtl: Schema.optionalKey(Schema.DurationFromMillis),
637 pauseWhenHostLocked: Schema.optionalKey(Schema.Boolean),
638 pauseWhenHostLowPower: Schema.optionalKey(Schema.Boolean),
639 pauseWhenClientLowPower: Schema.optionalKey(Schema.Boolean),
640 pauseWhenOnBattery: Schema.optionalKey(Schema.Boolean),
641});
642export type BackgroundActivityOverrides = typeof BackgroundActivityOverrides.Type;
643​
644export const BackgroundActivitySettings = Schema.Struct({
645 schemaVersion: Schema.Literal(1).pipe(Schema.withDecodingDefault(Effect.succeed(1 as const))),
646 profile: BackgroundActivityProfileSelection.pipe(
647 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BACKGROUND_ACTIVITY_PROFILE)),
648 ),
649 baseProfile: Schema.optionalKey(BackgroundActivityProfile),
650 overrides: BackgroundActivityOverrides.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
651}).pipe(Schema.withDecodingDefault(Effect.succeed({})));
652export type BackgroundActivitySettings = typeof BackgroundActivitySettings.Type;
653​
654export const ServerSettings = Schema.Struct({
655 // Legacy token-by-token assistant output. Deliberately a fresh key (was
656 // `enableAssistantStreaming`): decoding drops the old key, so everyone,
657 // including prior opt-ins, resets to the buffered default.
658 enableLegacyTokenStreaming: Schema.Boolean.pipe(
659 Schema.withDecodingDefault(Effect.succeed(false)),
660 ),
661 enableProviderUpdateChecks: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
662 /**
663 * Whether agents may drive the in-app preview browser. Turning this off
664 * withholds the MCP credential, so the `t3-code` server (and with it every
665 * `preview_*` tool) is never attached to a provider session, and the prompt
666 * text describing those tools is dropped along with them. The user's own
667 * browser panel is unaffected — this gates agent access only.
668 *
669 * Server-authoritative rather than client-local: tool injection and prompt
670 * construction both happen on the server, and the answer must not differ
671 * between a desktop window and a phone attached to the same server.
672 */
673 enableAgentBrowserAccess: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
674 sidebarAutoSettleAfterDays: Schema.NullOr(SidebarAutoSettleAfterDays).pipe(
675 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS)),
676 ),
677 sidebarAutoSettleOnMerge: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
678 backgroundActivity: BackgroundActivitySettings,
679 // Legacy flat fields retained for old settings files and old clients. New
680 // consumers should resolve `backgroundActivity` instead.
681 automaticGitFetchInterval: Schema.DurationFromMillis.pipe(
682 Schema.withDecodingDefault(
683 Effect.succeed(Duration.toMillis(DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL)),
684 ),
685 ),
686 providerHealthRefreshInterval: Schema.DurationFromMillis.pipe(
687 Schema.withDecodingDefault(
688 Effect.succeed(Duration.toMillis(DEFAULT_PROVIDER_HEALTH_REFRESH_INTERVAL)),
689 ),
690 ),
691 backgroundActivityProfile: BackgroundActivityProfile.pipe(
692 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BACKGROUND_ACTIVITY_PROFILE)),
693 ),
694 defaultTheme: DefaultThemePreference.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
695 /**
696 * When the environment's theme was last set, so clients can tell a re-set
697 * of the same value from one they already applied: `t3 theme set` must act
698 * even when it names the theme it named before. Empty on environments
699 * provisioned by builds that predate it, where clients fall back to
700 * applying once per value.
701 */
702 defaultThemeSetAt: Schema.String.check(Schema.isMaxLength(64)).pipe(
703 Schema.withDecodingDefault(Effect.succeed("")),
704 ),
705 defaultThreadEnvMode: ThreadEnvMode.pipe(
706 Schema.withDecodingDefault(Effect.succeed("local" as const satisfies ThreadEnvMode)),
707 ),
708 newWorktreesStartFromOrigin: Schema.Boolean.pipe(
709 Schema.withDecodingDefault(Effect.succeed(true)),
710 ),
711 addProjectBaseDirectory: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
712 textGenerationModelSelection: ModelSelection.pipe(
713 Schema.withDecodingDefault(
714 Effect.succeed({
715 instanceId: ProviderInstanceId.make("codex"),
716 model: DEFAULT_TEXT_GENERATION_MODEL,
717 options: [
718 {
719 id: "reasoningEffort",
720 value: DEFAULT_TEXT_GENERATION_REASONING_EFFORT,
721 },
722 ],
723 }),
724 ),
725 ),
726 sourceControlWritingStyle: SourceControlWritingStyleSettings.pipe(
727 Schema.withDecodingDefault(Effect.succeed({})),
728 ),
729 sourceControlWriterModelSelection: Schema.NullOr(ModelSelection).pipe(
730 Schema.withDecodingDefault(Effect.succeed(null)),
731 ),
732​
733 // Legacy single-instance-per-driver settings. Continues to be the source
734 // of truth until `providerInstances` (below) lands per-driver migration
735 // shims and the server starts hydrating instances from it. Driver-specific
736 // schemas live here for the duration of the migration; once each driver
737 // owns its config in its own package, this struct shrinks to nothing and
738 // is removed entirely.
739 providers: Schema.Struct({
740 codex: CodexSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
741 claudeAgent: ClaudeSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
742 cursor: CursorSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
743 grok: GrokSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
744 opencode: OpenCodeSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
745 }).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
746 // New driver-agnostic instance map. Keyed by `ProviderInstanceId`; values
747 // are `ProviderInstanceConfig` envelopes. The driver-specific config blob
748 // is `Schema.Unknown` at this layer so envelopes with unknown drivers
749 // (forks, downgrades, in-flight PR branches) round-trip without loss.
750 // See providerInstance.ts for the forward/backward compatibility invariant.
751 providerInstances: Schema.Record(ProviderInstanceId, ProviderInstanceConfig).pipe(
752 Schema.withDecodingDefault(Effect.succeed({})),
753 ),
754 observability: ObservabilitySettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
755});
756export type ServerSettings = typeof ServerSettings.Type;
757​
758export const DEFAULT_SERVER_SETTINGS: ServerSettings = Schema.decodeSync(ServerSettings)({});
759​
760/**
761 * Read the legacy `enabled` flag embedded in a provider instance config
762 * blob. The envelope-level `ProviderInstanceConfig.enabled` is the single
763 * flag going forward; this reader exists for legacy `providers.<kind>`
764 * blobs and old settings files that still carry the flag in-config.
765 */
766export const providerInstanceConfigEnabledFlag = (config: unknown): boolean | undefined => {
767 if (config === null || typeof config !== "object" || Array.isArray(config)) {
768 return undefined;
769 }
770 const enabled = (config as { readonly enabled?: unknown }).enabled;
771 return typeof enabled === "boolean" ? enabled : undefined;
772};
773​
774/**
775 * Default enabled state for a built-in driver when neither the envelope nor
776 * the config blob carries a flag. Derived from the driver's settings schema
777 * through `DEFAULT_SERVER_SETTINGS`, so the schema's decoding default stays
778 * the single source of truth. Unknown (fork) drivers default to enabled.
779 */
780export const defaultEnabledForDriver = (driver: ProviderDriverKind): boolean => {
781 const legacyDefaults = DEFAULT_SERVER_SETTINGS.providers as Record<
782 string,
783 { readonly enabled?: boolean } | undefined
784 >;
785 return legacyDefaults[driver]?.enabled ?? true;
786};
787​
788/**
789 * Resolve whether a configured provider instance is enabled. An explicit
790 * false on either the envelope or the in-config flag wins (most
791 * restrictive), so a user's disable is never silently undone by the other
792 * flag. Otherwise: envelope, then config, then the driver's default.
793 */
794export const resolveProviderInstanceEnabled = (
795 instance: Pick<ProviderInstanceConfig, "driver" | "enabled" | "config">,
796): boolean => {
797 const configEnabled = providerInstanceConfigEnabledFlag(instance.config);
798 if (instance.enabled === false || configEnabled === false) {
799 return false;
800 }
801 return instance.enabled ?? configEnabled ?? defaultEnabledForDriver(instance.driver);
802};
803​
804export const ServerSettingsOperation = Schema.Literals([
805 "normalize",
806 "check-exists",
807 "read-file",
808 "read-provider-history",
809 "read-secret",
810 "remove-secret",
811 "remove-stale-secret",
812 "write-secret",
813 "write-file",
814 "prepare-directory",
815]);
816export type ServerSettingsOperation = typeof ServerSettingsOperation.Type;
817​
818export class ServerSettingsError extends Schema.TaggedErrorClass<ServerSettingsError>()(
819 "ServerSettingsError",
820 {
821 settingsPath: Schema.String,
822 operation: ServerSettingsOperation,
823 providerInstanceId: Schema.optional(Schema.String),
824 environmentVariable: Schema.optional(Schema.String),
825 cause: Schema.Defect(),
826 },
827) {
828 override get message(): string {
829 const provider =
830 this.providerInstanceId === undefined ? "" : ` for provider ${this.providerInstanceId}`;
831 const variable =
832 this.environmentVariable === undefined
833 ? ""
834 : ` and environment variable ${this.environmentVariable}`;
835 return `Server settings ${this.operation} failed${provider}${variable} at ${this.settingsPath}.`;
836 }
838​
839// ── Unified type ─────────────────────────────────────────────────────
840​
841export type UnifiedSettings = ServerSettings & ClientSettings;
842export const DEFAULT_UNIFIED_SETTINGS: UnifiedSettings = {
843 ...DEFAULT_SERVER_SETTINGS,
844 ...DEFAULT_CLIENT_SETTINGS,
845};
846​
847// ── Server Settings Patch (replace with a Schema.deepPartial if available) ──────────────────────────────────────────
848​
849const ModelSelectionPatch = Schema.Struct({
850 instanceId: Schema.optionalKey(ProviderInstanceId),
851 model: Schema.optionalKey(TrimmedNonEmptyString),
852 options: Schema.optionalKey(ProviderOptionSelections),
853});
854​
855const CodexSettingsPatch = Schema.Struct({
856 enabled: Schema.optionalKey(Schema.Boolean),
857 binaryPath: Schema.optionalKey(TrimmedString),
858 homePath: Schema.optionalKey(TrimmedString),
859 shadowHomePath: Schema.optionalKey(TrimmedString),
860 launchArgs: Schema.optionalKey(TrimmedString),
861 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
862});
863​
864const ClaudeSettingsPatch = Schema.Struct({
865 enabled: Schema.optionalKey(Schema.Boolean),
866 binaryPath: Schema.optionalKey(TrimmedString),
867 homePath: Schema.optionalKey(TrimmedString),
868 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
869 launchArgs: Schema.optionalKey(TrimmedString),
870 // Validated at the patch boundary so a typo fails the one update with a
871 // schema error instead of a generic whole-settings failure.
872 autoCompactWindow: Schema.optionalKey(
873 TrimmedString.check(Schema.isPattern(CLAUDE_AUTO_COMPACT_WINDOW_PATTERN)),
874 ),
875});
876​
877const CursorSettingsPatch = Schema.Struct({
878 enabled: Schema.optionalKey(Schema.Boolean),
879 binaryPath: Schema.optionalKey(TrimmedString),
880 apiEndpoint: Schema.optionalKey(TrimmedString),
881 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
882});
883​
884const GrokSettingsPatch = Schema.Struct({
885 enabled: Schema.optionalKey(Schema.Boolean),
886 binaryPath: Schema.optionalKey(TrimmedString),
887 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
888});
889​
890const OpenCodeSettingsPatch = Schema.Struct({
891 enabled: Schema.optionalKey(Schema.Boolean),
892 binaryPath: Schema.optionalKey(TrimmedString),
893 serverUrl: Schema.optionalKey(TrimmedString),
894 serverPassword: Schema.optionalKey(TrimmedString),
895 customModels: Schema.optionalKey(Schema.Array(Schema.String)),
896});
897​
898export const ServerSettingsPatch = Schema.Struct({
899 // Server settings
900 enableLegacyTokenStreaming: Schema.optionalKey(Schema.Boolean),
901 enableProviderUpdateChecks: Schema.optionalKey(Schema.Boolean),
902 enableAgentBrowserAccess: Schema.optionalKey(Schema.Boolean),
903 sidebarAutoSettleAfterDays: Schema.optionalKey(Schema.NullOr(SidebarAutoSettleAfterDays)),
904 sidebarAutoSettleOnMerge: Schema.optionalKey(Schema.Boolean),
905 backgroundActivity: Schema.optionalKey(
906 Schema.Struct({
907 schemaVersion: Schema.optionalKey(Schema.Literal(1)),
908 profile: Schema.optionalKey(BackgroundActivityProfileSelection),
909 baseProfile: Schema.optionalKey(BackgroundActivityProfile),
910 overrides: Schema.optionalKey(BackgroundActivityOverrides),
911 }),
912 ),
913 automaticGitFetchInterval: Schema.optionalKey(Schema.DurationFromMillis),
914 providerHealthRefreshInterval: Schema.optionalKey(Schema.DurationFromMillis),
915 backgroundActivityProfile: Schema.optionalKey(BackgroundActivityProfile),
916 defaultThreadEnvMode: Schema.optionalKey(ThreadEnvMode),
917 newWorktreesStartFromOrigin: Schema.optionalKey(Schema.Boolean),
918 addProjectBaseDirectory: Schema.optionalKey(TrimmedString),
919 textGenerationModelSelection: Schema.optionalKey(ModelSelectionPatch),
920 sourceControlWritingStyle: Schema.optionalKey(
921 Schema.Struct({
922 mode: Schema.optionalKey(SourceControlWritingStyleMode),
923 customInstructions: Schema.optionalKey(TrimmedString),
924 followChangeRequestTemplates: Schema.optionalKey(Schema.Boolean),
925 }),
926 ),
927 sourceControlWriterModelSelection: Schema.optionalKey(Schema.NullOr(ModelSelection)),
928 observability: Schema.optionalKey(
929 Schema.Struct({
930 otlpTracesUrl: Schema.optionalKey(TrimmedString),
931 otlpMetricsUrl: Schema.optionalKey(TrimmedString),
932 }),
933 ),
934 providers: Schema.optionalKey(
935 Schema.Struct({
936 codex: Schema.optionalKey(CodexSettingsPatch),
937 claudeAgent: Schema.optionalKey(ClaudeSettingsPatch),
938 cursor: Schema.optionalKey(CursorSettingsPatch),
939 grok: Schema.optionalKey(GrokSettingsPatch),
940 opencode: Schema.optionalKey(OpenCodeSettingsPatch),
941 }),
942 ),
943 // Whole-map replacement for the new instance config. Patching individual
944 // entries is intentionally out of scope: the map is small, and partial
945 // patches risk leaving driver-specific config in a half-merged state.
946 // The web UI sends a fully-formed map every time it edits this field.
947 providerInstances: Schema.optionalKey(Schema.Record(ProviderInstanceId, ProviderInstanceConfig)),
948});
949export type ServerSettingsPatch = typeof ServerSettingsPatch.Type;
950​
951export const ClientSettingsPatch = Schema.Struct({
952 appearanceContrast: Schema.optionalKey(AppearanceContrast),
953 browserDefaultViewport: Schema.optionalKey(PreviewViewportSetting),
954 browserDefaultZoomFactor: Schema.optionalKey(PreviewZoomFactor),
955 browserDefaultAppearance: Schema.optionalKey(PreviewAppearancePreference),
956 browserRecordingFrameRate: Schema.optionalKey(BrowserRecordingFrameRate),
957 browserAutoShowFloatingPreview: Schema.optionalKey(Schema.Boolean),
958 confirmQuit: Schema.optionalKey(QuitConfirmationMode),
959 confirmThreadArchive: Schema.optionalKey(Schema.Boolean),
960 confirmThreadDelete: Schema.optionalKey(Schema.Boolean),
961 confirmThreadUnpin: Schema.optionalKey(Schema.Boolean),
962 diffIgnoreWhitespace: Schema.optionalKey(Schema.Boolean),
963 environmentIdentificationMode: Schema.optionalKey(EnvironmentIdentificationMode),
964 glassOpacity: Schema.optionalKey(GlassOpacity),
965 fontSizeInterface: Schema.optionalKey(InterfaceFontSize),
966 fontSizePrompt: Schema.optionalKey(PromptFontSize),
967 fontSizeCode: Schema.optionalKey(CodeFontSize),
968 fontSizeTerminal: Schema.optionalKey(TerminalFontSize),
969 fontFamilyCode: Schema.optionalKey(FontFamilyPreference),
970 fontFamilyComposer: Schema.optionalKey(FontFamilyPreference),
971 fontFamilySans: Schema.optionalKey(FontFamilyPreference),
972 fontFamilyTerminal: Schema.optionalKey(FontFamilyPreference),
973 fontSmoothing: Schema.optionalKey(Schema.Boolean),
974 favorites: Schema.optionalKey(
975 Schema.Array(
976 Schema.Struct({
977 provider: ProviderInstanceId,
978 model: TrimmedNonEmptyString,
979 }),
980 ),
981 ),
982 providerModelPreferences: Schema.optionalKey(
983 Schema.Record(
984 ProviderInstanceId,
985 Schema.Struct({
986 hiddenModels: Schema.Array(Schema.String).pipe(
987 Schema.withDecodingDefault(Effect.succeed([])),
988 ),
989 modelOrder: Schema.Array(Schema.String).pipe(
990 Schema.withDecodingDefault(Effect.succeed([])),
991 ),
992 }),
993 ),
994 ),
995 planModeEnabled: Schema.optionalKey(Schema.Boolean),
996 contextWindowMeterEnabled: Schema.optionalKey(Schema.Boolean),
997 showSkillsInSlashMenu: Schema.optionalKey(Schema.Boolean),
998 legacySidebarEnabled: Schema.optionalKey(Schema.Boolean),
999 sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),
1000 sidebarProjectGroupingOverrides: Schema.optionalKey(
1001 Schema.Record(TrimmedNonEmptyString, SidebarProjectGroupingMode),
1002 ),
1003 sidebarProjectSortOrder: Schema.optionalKey(SidebarProjectSortOrder),
1004 sidebarThreadSortOrder: Schema.optionalKey(SidebarThreadSortOrder),
1005 sidebarThreadPreviewCount: Schema.optionalKey(SidebarThreadPreviewCount),
1006 timestampFormat: Schema.optionalKey(TimestampFormat),
1007 wordWrap: Schema.optionalKey(Schema.Boolean),
1008});
1009export type ClientSettingsPatch = typeof ClientSettingsPatch.Type;