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

settings.ts

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