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

settings.ts

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