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

settings.ts

1,483 lines63.8 KB

1import { SshDeviceHostConfigs } from "./device.ts";
2import * as Effect from "effect/Effect";
3import * as Duration from "effect/Duration";
4import * as Schema from "effect/Schema";
5import * as SchemaTransformation from "effect/SchemaTransformation";
6import {
7 ForwardCompatibleNullable,
8 ProjectId,
9 TrimmedNonEmptyString,
10 TrimmedString,
11} from "./baseSchemas.ts";
12import { UsageLimitSourceId } from "./usageLimitSourceId.ts";
13import { EnvironmentMachineKind, ThreadEnvMode } from "./environment.ts";
14import { KeybindingShortcut } from "./keybindings.ts";
15import {
16 CustomModelSetting,
17 DEFAULT_TEXT_GENERATION_MODEL,
18 DEFAULT_TEXT_GENERATION_REASONING_EFFORT,
19 ProviderOptionSelections,
20} from "./model.ts";
21import { ModelSelection } from "./modelSelection.ts";
22import { ProjectScript } from "./project.ts";
23import { BrowserProfile, BrowserProfileId, DEFAULT_BROWSER_PROFILE_ID } from "./browserProfile.ts";
24import {
25 DEFAULT_PREVIEW_APPEARANCE,
26 DEFAULT_PREVIEW_ZOOM_FACTOR,
27 FILL_PREVIEW_VIEWPORT,
28 PreviewAppearancePreference,
29 PreviewViewportSetting,
30 PreviewZoomFactor,
31} from "./preview.ts";
32import {
33 ProviderInstanceConfig,
34 ProviderInstanceId,
35 type ProviderDriverKind,
36} from "./providerInstance.ts";
37import { PullRequestMergeMethod } from "./pullRequest.ts";
38​
39// ── Client Settings (local-only) ───────────────────────────────
40​
41export const TimestampFormat = Schema.Literals(["locale", "12-hour", "24-hour"]);
42export type TimestampFormat = typeof TimestampFormat.Type;
43const DEFAULT_TIMESTAMP_FORMAT: TimestampFormat = "locale";
44​
45export const DiffLayout = Schema.Literals(["stacked", "split"]);
46export type DiffLayout = typeof DiffLayout.Type;
47const DEFAULT_DIFF_LAYOUT: DiffLayout = "stacked";
48​
49export const SidebarProjectSortOrder = Schema.Literals(["updated_at", "created_at", "manual"]);
50export type SidebarProjectSortOrder = typeof SidebarProjectSortOrder.Type;
51export const DEFAULT_SIDEBAR_PROJECT_SORT_ORDER: SidebarProjectSortOrder = "updated_at";
52​
53export const SidebarThreadSortOrder = Schema.Literals(["updated_at", "created_at"]);
54export type SidebarThreadSortOrder = typeof SidebarThreadSortOrder.Type;
55export const DEFAULT_SIDEBAR_THREAD_SORT_ORDER: SidebarThreadSortOrder = "updated_at";
56​
57export const SidebarProjectGroupingMode = Schema.Literals([
58 "repository",
59 "repository_path",
60 "separate",
61]);
62export type SidebarProjectGroupingMode = typeof SidebarProjectGroupingMode.Type;
63const DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE: SidebarProjectGroupingMode = "repository";
64export const MIN_SIDEBAR_THREAD_PREVIEW_COUNT = 1;
65export const MAX_SIDEBAR_THREAD_PREVIEW_COUNT = 15;
66export const SidebarThreadPreviewCount = Schema.Int.check(
67 Schema.isBetween({
68 minimum: MIN_SIDEBAR_THREAD_PREVIEW_COUNT,
69 maximum: MAX_SIDEBAR_THREAD_PREVIEW_COUNT,
70 }),
71);
72export type SidebarThreadPreviewCount = typeof SidebarThreadPreviewCount.Type;
73const DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT: SidebarThreadPreviewCount = 6;
74export const MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS = 1;
75export const MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS = 90;
76export const SidebarAutoSettleAfterDays = Schema.Number.check(
77 Schema.isBetween({
78 minimum: MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
79 maximum: MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
80 }),
81);
82export type SidebarAutoSettleAfterDays = typeof SidebarAutoSettleAfterDays.Type;
83const DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS: SidebarAutoSettleAfterDays = 3;
84export const MIN_GLASS_OPACITY = 40;
85export const MAX_GLASS_OPACITY = 100;
86export const GlassOpacity = Schema.Int.check(
87 Schema.isBetween({
88 minimum: MIN_GLASS_OPACITY,
89 maximum: MAX_GLASS_OPACITY,
90 }),
91);
92export type GlassOpacity = typeof GlassOpacity.Type;
93const DEFAULT_GLASS_OPACITY: GlassOpacity = 80;
94​
95export const MIN_APPEARANCE_CONTRAST = 50;
96export const MAX_APPEARANCE_CONTRAST = 200;
97export const AppearanceContrast = Schema.Int.check(
98 Schema.isBetween({ minimum: MIN_APPEARANCE_CONTRAST, maximum: MAX_APPEARANCE_CONTRAST }),
99);
100export type AppearanceContrast = typeof AppearanceContrast.Type;
101const DEFAULT_APPEARANCE_CONTRAST: AppearanceContrast = 100;
102export const MIN_PANEL_ANIMATION_DURATION_MS = 0;
103export const MAX_PANEL_ANIMATION_DURATION_MS = 400;
104export const PanelAnimationDurationMs = Schema.Int.check(
105 Schema.isBetween({
106 minimum: MIN_PANEL_ANIMATION_DURATION_MS,
107 maximum: MAX_PANEL_ANIMATION_DURATION_MS,
108 }),
109);
110export type PanelAnimationDurationMs = typeof PanelAnimationDurationMs.Type;
111const DEFAULT_PANEL_ANIMATION_DURATION_MS: PanelAnimationDurationMs = 0;
112/**
113 * Font size preferences, in CSS pixels. The ranges are deliberately narrow:
114 * the interface size scales every rem-based dimension in the app, so the
115 * bounds keep layouts intact rather than offering unusable extremes.
116 */
117export const MIN_INTERFACE_FONT_SIZE = 12;
118export const MAX_INTERFACE_FONT_SIZE = 20;
119export const InterfaceFontSize = Schema.Int.check(
120 Schema.isBetween({ minimum: MIN_INTERFACE_FONT_SIZE, maximum: MAX_INTERFACE_FONT_SIZE }),
121);
122export type InterfaceFontSize = typeof InterfaceFontSize.Type;
123export const DEFAULT_INTERFACE_FONT_SIZE: InterfaceFontSize = 16;
124​
125export const MIN_PROMPT_FONT_SIZE = 12;
126export const MAX_PROMPT_FONT_SIZE = 20;
127export const PromptFontSize = Schema.Int.check(
128 Schema.isBetween({ minimum: MIN_PROMPT_FONT_SIZE, maximum: MAX_PROMPT_FONT_SIZE }),
129);
130export type PromptFontSize = typeof PromptFontSize.Type;
131export const DEFAULT_PROMPT_FONT_SIZE: PromptFontSize = 14;
132​
133export const MIN_CODE_FONT_SIZE = 10;
134export const MAX_CODE_FONT_SIZE = 18;
135export const CodeFontSize = Schema.Int.check(
136 Schema.isBetween({ minimum: MIN_CODE_FONT_SIZE, maximum: MAX_CODE_FONT_SIZE }),
137);
138export type CodeFontSize = typeof CodeFontSize.Type;
139export const DEFAULT_CODE_FONT_SIZE: CodeFontSize = 13;
140​
141export const MIN_TERMINAL_FONT_SIZE = 8;
142export const MAX_TERMINAL_FONT_SIZE = 20;
143export const TerminalFontSize = Schema.Int.check(
144 Schema.isBetween({ minimum: MIN_TERMINAL_FONT_SIZE, maximum: MAX_TERMINAL_FONT_SIZE }),
145);
146export type TerminalFontSize = typeof TerminalFontSize.Type;
147const DEFAULT_TERMINAL_FONT_SIZE: TerminalFontSize = 12;
148​
149export const EnvironmentIdentificationMode = Schema.Literals(["artwork", "pill", "none"]);
150export type EnvironmentIdentificationMode = typeof EnvironmentIdentificationMode.Type;
151export const DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE: EnvironmentIdentificationMode = "artwork";
152​
153export const SnapShotKeyChord = KeybindingShortcut.check(
154 Schema.makeFilter(
155 (shortcut) =>
156 shortcut.metaKey ||
157 shortcut.ctrlKey ||
158 shortcut.shiftKey ||
159 shortcut.altKey ||
160 shortcut.modKey ||
161 "Snapshot shortcut requires a modifier.",
162 ),
163);
164export type SnapShotKeyChord = typeof SnapShotKeyChord.Type;
165export const SNAP_SHOT_MODIFIERS = ["shift", "meta", "control", "alt"] as const;
166export const SnapShotModifier = Schema.Literals(SNAP_SHOT_MODIFIERS);
167export type SnapShotModifier = typeof SnapShotModifier.Type;
168export const SnapShotShortcut = Schema.Union([
169 Schema.Struct({ kind: Schema.Literal("both-shift-keys") }),
170 Schema.Struct({ kind: Schema.Literal("modifier-pair"), modifier: SnapShotModifier }),
171 SnapShotKeyChord,
172]);
173export type SnapShotShortcut = typeof SnapShotShortcut.Type;
174export const SnapShotSound = Schema.Literals(["soft-pop", "camera-shutter"]);
175export type SnapShotSound = typeof SnapShotSound.Type;
176const DEFAULT_SNAP_SHOT_SOUND: SnapShotSound = "soft-pop";
177​
178export type SnapShotModifierPairShortcut = Extract<SnapShotShortcut, { readonly kind: string }>;
179​
180export function isModifierPairShortcut(
181 shortcut: SnapShotShortcut,
182): shortcut is SnapShotModifierPairShortcut {
183 return "kind" in shortcut;
185​
186export function snapShotShortcutModifierPair(
187 shortcut: SnapShotModifierPairShortcut,
188): SnapShotModifier {
189 return shortcut.kind === "both-shift-keys" ? "shift" : shortcut.modifier;
191​
192const APPLE_MODIFIER_LABELS: Record<SnapShotModifier, string> = {
193 shift: "Shift",
194 meta: "Command",
195 control: "Control",
196 alt: "Option",
197};
198const OTHER_MODIFIER_LABELS: Record<SnapShotModifier, string> = {
199 shift: "Shift",
200 meta: "Super",
201 control: "Ctrl",
202 alt: "Alt",
203};
204​
205export function snapShotModifierPairLabel(modifier: SnapShotModifier, apple: boolean): string {
206 const label = (apple ? APPLE_MODIFIER_LABELS : OTHER_MODIFIER_LABELS)[modifier];
207 return `${label} + ${label}`;
209const DEFAULT_SNAP_SHOT_SHORTCUT: SnapShotShortcut = {
210 kind: "both-shift-keys",
211};
212​
213export const QuitConfirmationMode = Schema.Literals(["direct", "hold", "double-click"]);
214export type QuitConfirmationMode = typeof QuitConfirmationMode.Type;
215const DEFAULT_QUIT_CONFIRMATION_MODE: QuitConfirmationMode = "hold";
216​
217const LegacyConfirmQuit = Schema.Boolean.pipe(
218 Schema.decodeTo(
219 QuitConfirmationMode,
220 SchemaTransformation.transform({
221 decode: (confirmQuit): QuitConfirmationMode => (confirmQuit ? "hold" : "direct"),
222 encode: (mode) => mode === "hold",
223 }),
224 ),
225);
226​
227const QuitConfirmationModeSetting = Schema.Union([QuitConfirmationMode, LegacyConfirmQuit]);
228​
229/**
230 * A user-chosen font family (a single name or a comma-separated list). Empty
231 * means "use the app default"; clients compose their own fallback stacks.
232 */
233export const FontFamilyPreference = Schema.String.check(Schema.isMaxLength(200));
234export type FontFamilyPreference = typeof FontFamilyPreference.Type;
235​
236/**
237 * The environment's theme, set with `t3 theme set <id>`. Each client applies
238 * it once per value — live when connected, on its next connect otherwise — so
239 * setting it switches every client, while a theme a user picks in Settings
240 * afterwards sticks until the next set. Empty means "no environment theme",
241 * which is also how it is cleared.
242 */
243export const DefaultThemePreference = Schema.String.check(Schema.isMaxLength(64));
244// Deliberately absent from ServerSettingsPatch: `t3 theme set` checks that an
245// id is syntactically valid and actually resolvable, and a generic RPC patch
246// would let a client write a theme no client can resolve, bypassing both.
247export type DefaultThemePreference = typeof DefaultThemePreference.Type;
248​
249/**
250 * Defaults for the in-app preview browser, applied whenever a tab is opened
251 * without an explicit viewport/zoom/appearance — by the user opening a browser
252 * tab, or by an agent calling `preview_open` with no size. Recording quality is
253 * client-local for the same reason: the Chromium guest being captured belongs
254 * to the desktop app.
255 */
256export const DEFAULT_BROWSER_VIEWPORT: PreviewViewportSetting = FILL_PREVIEW_VIEWPORT;
257export const DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW = true;
258export const BROWSER_RECORDING_FRAME_RATES = [30, 60] as const;
259export const BrowserRecordingFrameRate = Schema.Literals(BROWSER_RECORDING_FRAME_RATES);
260export type BrowserRecordingFrameRate = typeof BrowserRecordingFrameRate.Type;
261export const DEFAULT_BROWSER_RECORDING_FRAME_RATE: BrowserRecordingFrameRate = 30;
262/**
263 * Where a clicked link goes: the OS default browser, or a tab in the in-app
264 * browser beside the thread. "system" is the default because that is what
265 * every link did before the setting existed.
266 */
267export const BrowserLinkTarget = Schema.Literals(["system", "app"]);
268export type BrowserLinkTarget = typeof BrowserLinkTarget.Type;
269export const DEFAULT_BROWSER_LINK_TARGET: BrowserLinkTarget = "system";
270​
271export const LoadBalancingWeights = Schema.Record(
272 TrimmedNonEmptyString,
273 Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 100 })),
274);
275​
276export const DiffColorScheme = Schema.Literals(["red-green", "blue-orange"]);
277​
278export const ClientSettingsSchema = Schema.Struct({
279 diffColorScheme: DiffColorScheme.pipe(
280 Schema.withDecodingDefault(Effect.succeed("red-green" as const)),
281 ),
282 loadBalancingEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
283 loadBalancingWeights: LoadBalancingWeights.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
284 appearanceContrast: AppearanceContrast.pipe(
285 Schema.withDecodingDefault(Effect.succeed(DEFAULT_APPEARANCE_CONTRAST)),
286 ),
287 // Panel motion defaults to zero because width and height transitions cause
288 // layout work on every frame, which is noticeable on lower-power clients.
289 panelAnimationDurationMs: PanelAnimationDurationMs.pipe(
290 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PANEL_ANIMATION_DURATION_MS)),
291 ),
292 browserDefaultViewport: PreviewViewportSetting.pipe(
293 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BROWSER_VIEWPORT)),
294 ),
295 browserDefaultZoomFactor: PreviewZoomFactor.pipe(
296 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PREVIEW_ZOOM_FACTOR)),
297 ),
298 browserDefaultAppearance: PreviewAppearancePreference.pipe(
299 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PREVIEW_APPEARANCE)),
300 ),
301 browserRecordingFrameRate: BrowserRecordingFrameRate.pipe(
302 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BROWSER_RECORDING_FRAME_RATE)),
303 ),
304 /**
305 * Where links clicked in a thread (chat markdown, terminal output) open.
306 * Only the desktop app has an in-app browser, so other clients ignore "app".
307 */
308 browserLinkTarget: BrowserLinkTarget.pipe(
309 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BROWSER_LINK_TARGET)),
310 ),
311 /**
312 * Whether an agent using a preview pops the floating mini player into
313 * view. Only applies when the agent didn't ask either way — an explicit
314 * `open`/`show` on `preview_open` still wins, since that is the agent
315 * deliberately showing or hiding its work.
316 */
317 browserAutoShowFloatingPreview: Schema.Boolean.pipe(
318 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BROWSER_AUTO_SHOW_FLOATING_PREVIEW)),
319 ),
320 /**
321 * User-created browser profiles. The built-in Default and Incognito profiles
322 * are synthesized by `resolveBrowserProfiles`, not stored here, so they
323 * cannot be renamed away or deleted.
324 */
325 browserProfiles: Schema.Array(BrowserProfile).pipe(
326 Schema.withDecodingDefault(Effect.succeed([])),
327 ),
328 /** Profile new tabs open under. Falls back to Default if it no longer exists. */
329 browserDefaultProfileId: BrowserProfileId.pipe(
330 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BROWSER_PROFILE_ID)),
331 ),
332 // Desktop-only. Boolean values from older settings files decode to their
333 // equivalent mode and encode back as the canonical string value.
334 confirmQuit: QuitConfirmationModeSetting.pipe(
335 Schema.withDecodingDefault(Effect.succeed(DEFAULT_QUIT_CONFIRMATION_MODE)),
336 ),
337 confirmThreadArchive: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
338 confirmThreadDelete: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
339 confirmThreadUnpin: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
340 dismissedProviderUpdateNotificationKeys: Schema.Array(TrimmedNonEmptyString).pipe(
341 Schema.withDecodingDefault(Effect.succeed([])),
342 ),
343 diffIgnoreWhitespace: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
344 diffLayout: DiffLayout.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_DIFF_LAYOUT))),
345 environmentIdentificationMode: EnvironmentIdentificationMode.pipe(
346 Schema.withDecodingDefault(Effect.succeed(DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE)),
347 ),
348 glassOpacity: GlassOpacity.pipe(
349 Schema.withDecodingDefault(Effect.succeed(DEFAULT_GLASS_OPACITY)),
350 ),
351 fontSizeInterface: InterfaceFontSize.pipe(
352 Schema.withDecodingDefault(Effect.succeed(DEFAULT_INTERFACE_FONT_SIZE)),
353 ),
354 fontSizePrompt: PromptFontSize.pipe(
355 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PROMPT_FONT_SIZE)),
356 ),
357 fontSizeCode: CodeFontSize.pipe(
358 Schema.withDecodingDefault(Effect.succeed(DEFAULT_CODE_FONT_SIZE)),
359 ),
360 fontSizeTerminal: TerminalFontSize.pipe(
361 Schema.withDecodingDefault(Effect.succeed(DEFAULT_TERMINAL_FONT_SIZE)),
362 ),
363 fontFamilyCode: FontFamilyPreference.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
364 fontFamilyComposer: FontFamilyPreference.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
365 fontFamilySans: FontFamilyPreference.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
366 fontFamilyTerminal: FontFamilyPreference.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
367 // Grayscale `-webkit-font-smoothing: antialiased` (thinner strokes);
368 // disabling restores the platform's heavier default. No effect off macOS.
369 fontSmoothing: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
370 // When the first-run welcome wizard finished (or was skipped), as an ISO
371 // timestamp. `null` alone does not mean "show the wizard" — every install
372 // that predates this field decodes to `null` — so the gate also requires an
373 // empty workspace before it treats the client as a fresh install.
374 onboardingCompletedAt: Schema.NullOr(Schema.String).pipe(
375 Schema.withDecodingDefault(Effect.succeed(null)),
376 ),
377 persistComposerContextStrip: Schema.Boolean.pipe(
378 Schema.withDecodingDefault(Effect.succeed(false)),
379 ),
380 // Model favorites. Historically keyed by provider kind, now
381 // widened to `ProviderInstanceId` so users can favorite a specific model
382 // on a custom provider instance (e.g. "Codex Personal · gpt-5") without
383 // the UI collapsing it into the same bucket as the default Codex. The
384 // widening is backward-compatible by construction: prior provider-kind
385 // strings satisfy the `ProviderInstanceId` slug schema, so previously
386 // persisted favorites decode unchanged and continue to point at the
387 // default instance for their kind (because `defaultInstanceIdForDriver(kind)`
388 // uses the same slug). The field name is kept as `provider` for storage
389 // stability; new call sites should treat the value as an instance id.
390 favorites: Schema.Array(
391 Schema.Struct({
392 provider: ProviderInstanceId,
393 model: TrimmedNonEmptyString,
394 }),
395 ).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
396 providerModelPreferences: Schema.Record(
397 ProviderInstanceId,
398 Schema.Struct({
399 hiddenModels: Schema.Array(Schema.String).pipe(
400 Schema.withDecodingDefault(Effect.succeed([])),
401 ),
402 modelOrder: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
403 }),
404 ).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
405 pullRequestMergeMethodOverrides: Schema.Record(
406 TrimmedNonEmptyString,
407 PullRequestMergeMethod,
408 ).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
409 // Legacy plan mode. The composer's Build/Plan toggle was removed from the
410 // default UI; this beta flag restores it (plus the /plan and /default slash
411 // commands) for users who still rely on the old workflow.
412 planModeEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
413 // Legacy context window meter. The composer hides it by default; users who
414 // still want the old usage indicator can restore it from Settings.
415 contextWindowMeterEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
416 // Desktop resting composer: scrolling an existing thread's conversation
417 // settles the composer into its single-line layout. Losing focus never does.
418 composerCollapseOnScroll: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
419 proactivePanelsEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
420 showSkillsInSlashMenu: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
421 // Legacy sidebar (the original per-project tree). Deliberately a fresh key
422 // (was `sidebarV2Enabled` + `sidebarV2ConfiguredByUser`): decoding drops the
423 // old keys, so everyone, including prior beta opt-outs, resets to the new
424 // default sidebar.
425 legacySidebarEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
426 sidebarProjectGroupingMode: SidebarProjectGroupingMode.pipe(
427 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE)),
428 ),
429 sidebarProjectGroupingOverrides: Schema.Record(
430 TrimmedNonEmptyString,
431 SidebarProjectGroupingMode,
432 ).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
433 sidebarProjectSortOrder: SidebarProjectSortOrder.pipe(
434 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_SORT_ORDER)),
435 ),
436 sidebarThreadSortOrder: SidebarThreadSortOrder.pipe(
437 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_SORT_ORDER)),
438 ),
439 sidebarThreadPreviewCount: SidebarThreadPreviewCount.pipe(
440 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT)),
441 ),
442 timestampFormat: TimestampFormat.pipe(
443 Schema.withDecodingDefault(Effect.succeed(DEFAULT_TIMESTAMP_FORMAT)),
444 ),
445 snapShotEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
446 snapShotIncludeAccessibility: Schema.Boolean.pipe(
447 Schema.withDecodingDefault(Effect.succeed(true)),
448 ),
449 snapShotShortcut: SnapShotShortcut.pipe(
450 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SNAP_SHOT_SHORTCUT)),
451 ),
452 snapShotPlaySound: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
453 snapShotSound: SnapShotSound.pipe(
454 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SNAP_SHOT_SOUND)),
455 ),
456 snapShotFlash: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
457 snapShotAnimations: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
458 wordWrap: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
459});
460export type ClientSettings = typeof ClientSettingsSchema.Type;
461​
462export const DEFAULT_CLIENT_SETTINGS: ClientSettings = Schema.decodeSync(ClientSettingsSchema)({});
463​
464// ── Server Settings (server-authoritative) ────────────────────
465​
466const UsageModelTokenPrice = Schema.Number.check(
467 Schema.isFinite(),
468 Schema.isGreaterThanOrEqualTo(0),
469);
470​
471/** USD per million tokens. Omitted cache rates use the input rate. */
472export const UsageModelPriceOverride = Schema.Struct({
473 inputCostPerMillionTokens: UsageModelTokenPrice,
474 outputCostPerMillionTokens: UsageModelTokenPrice,
475 cacheReadCostPerMillionTokens: Schema.optionalKey(UsageModelTokenPrice),
476 cacheWriteCostPerMillionTokens: Schema.optionalKey(UsageModelTokenPrice),
477});
478export type UsageModelPriceOverride = typeof UsageModelPriceOverride.Type;
479​
480const makeBinaryPathSetting = (fallback: string) =>
481 TrimmedString.pipe(
482 Schema.decodeTo(
483 Schema.String,
484 SchemaTransformation.transformOrFail({
485 decode: (value) => Effect.succeed(value || fallback),
486 encode: (value) => Effect.succeed(value),
487 }),
488 ),
489 Schema.withDecodingDefault(Effect.succeed(fallback)),
490 );
491​
492export type ProviderSettingsFormControl = "text" | "password" | "textarea" | "switch" | "select";
493​
494export interface ProviderSettingsFormOption {
495 readonly value: string;
496 readonly label: string;
498​
499export interface ProviderSettingsFormAnnotation {
500 readonly control?: ProviderSettingsFormControl | undefined;
501 readonly placeholder?: string | undefined;
502 readonly hidden?: boolean | undefined;
503 readonly clearWhenEmpty?: "omit" | "persist" | undefined;
504 /** Choices for a `select` control. The first entry is the default. */
505 readonly options?: ReadonlyArray<ProviderSettingsFormOption> | undefined;
507​
508export interface ProviderSettingsFormSchemaAnnotation {
509 readonly order?: readonly string[] | undefined;
511​
512declare module "effect/Schema" {
513 namespace Annotations {
514 interface Annotations {
515 readonly providerSettingsForm?: ProviderSettingsFormAnnotation | undefined;
516 readonly providerSettingsFormSchema?: ProviderSettingsFormSchemaAnnotation | undefined;
517 }
518 }
520​
521export type ProviderSettingsOrder<Fields extends Schema.Struct.Fields> = readonly Extract<
522 keyof Fields,
523 string
524>[];
525​
526function makeProviderSettingsSchema<const Fields extends Schema.Struct.Fields>(
527 fields: Fields,
528 options?: {
529 readonly order?: ProviderSettingsOrder<Fields> | undefined;
530 },
531): Schema.Struct<Fields> {
532 return Schema.Struct(fields).pipe(
533 Schema.annotate({
534 providerSettingsFormSchema:
535 options?.order === undefined ? undefined : { order: options.order },
536 }),
537 );
539​
540export const CodexSettings = makeProviderSettingsSchema(
541 {
542 enabled: Schema.Boolean.pipe(
543 Schema.withDecodingDefault(Effect.succeed(true)),
544 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
545 ),
546 binaryPath: makeBinaryPathSetting("codex").pipe(
547 Schema.annotateKey({
548 title: "Binary path",
549 description: "Path to the Codex binary used by this instance.",
550 providerSettingsForm: { placeholder: "codex", clearWhenEmpty: "omit" },
551 }),
552 ),
553 homePath: TrimmedString.pipe(
554 Schema.withDecodingDefault(Effect.succeed("")),
555 Schema.annotateKey({
556 title: "CODEX_HOME path",
557 description: "Custom Codex home and config directory.",
558 providerSettingsForm: {
559 placeholder: "~/.codex",
560 clearWhenEmpty: "omit",
561 },
562 }),
563 ),
564 shadowHomePath: TrimmedString.pipe(
565 Schema.withDecodingDefault(Effect.succeed("")),
566 Schema.annotateKey({
567 title: "Shadow home path",
568 description:
569 "Account-specific Codex home. Keeps auth.json separate while sharing state from CODEX_HOME.",
570 providerSettingsForm: {
571 placeholder: "~/.codex-t3/personal",
572 clearWhenEmpty: "omit",
573 },
574 }),
575 ),
576 launchArgs: TrimmedString.pipe(
577 Schema.withDecodingDefault(Effect.succeed("")),
578 Schema.annotateKey({
579 title: "Launch arguments",
580 description: "Additional CLI arguments passed to codex app-server on session start.",
581 }),
582 ),
583 customModels: Schema.Array(CustomModelSetting).pipe(
584 Schema.withDecodingDefault(Effect.succeed([])),
585 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
586 ),
587 },
588 {
589 order: ["binaryPath", "homePath", "shadowHomePath", "launchArgs"],
590 },
591);
592export type CodexSettings = typeof CodexSettings.Type;
593​
594// Empty, or an integer from 100,000 to 1,000,000. Shared by the full
595// Claude settings schema and its patch so an out-of-range value fails at
596// the update that introduced it.
597const CLAUDE_AUTO_COMPACT_WINDOW_PATTERN = /^(?:|[1-9]\d{5}|1000000)$/;
598​
599export const ClaudeSettings = makeProviderSettingsSchema(
600 {
601 enabled: Schema.Boolean.pipe(
602 Schema.withDecodingDefault(Effect.succeed(true)),
603 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
604 ),
605 binaryPath: makeBinaryPathSetting("claude").pipe(
606 Schema.annotateKey({
607 title: "Binary path",
608 description: "Path to the Claude binary used by this instance.",
609 providerSettingsForm: { placeholder: "claude", clearWhenEmpty: "omit" },
610 }),
611 ),
612 homePath: TrimmedString.pipe(
613 Schema.withDecodingDefault(Effect.succeed("")),
614 Schema.annotateKey({
615 title: "CLAUDE_CONFIG_DIR path",
616 description:
617 "Custom Claude home and config directory. Keeps .claude.json and .claude separate.",
618 providerSettingsForm: { placeholder: "~/.claude", clearWhenEmpty: "omit" },
619 }),
620 ),
621 customModels: Schema.Array(CustomModelSetting).pipe(
622 Schema.withDecodingDefault(Effect.succeed([])),
623 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
624 ),
625 launchArgs: Schema.String.pipe(
626 Schema.withDecodingDefault(Effect.succeed("")),
627 Schema.annotateKey({
628 title: "Launch arguments",
629 description: "Additional CLI arguments passed on session start.",
630 providerSettingsForm: {
631 placeholder: "e.g. --chrome",
632 clearWhenEmpty: "omit",
633 },
634 }),
635 ),
636 autoCompactWindow: TrimmedString.check(
637 Schema.isPattern(CLAUDE_AUTO_COMPACT_WINDOW_PATTERN),
638 ).pipe(
639 Schema.withDecodingDefault(Effect.succeed("")),
640 Schema.annotateKey({
641 title: "Auto-compact after",
642 description:
643 "Compact after 100,000 to 1,000,000 tokens. Leave empty to use Claude's default.",
644 providerSettingsForm: {
645 placeholder: "e.g. 300000",
646 clearWhenEmpty: "omit",
647 },
648 }),
649 ),
650 },
651 {
652 order: ["binaryPath", "homePath", "autoCompactWindow", "launchArgs"],
653 },
654);
655export type ClaudeSettings = typeof ClaudeSettings.Type;
656​
657export const CursorSettings = makeProviderSettingsSchema(
658 {
659 // Off by default like Grok and OpenCode. Users opt in from Settings.
660 enabled: Schema.Boolean.pipe(
661 Schema.withDecodingDefault(Effect.succeed(false)),
662 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
663 ),
664 customModels: Schema.Array(CustomModelSetting).pipe(
665 Schema.withDecodingDefault(Effect.succeed([])),
666 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
667 ),
668 },
669 {
670 order: [],
671 },
672);
673export type CursorSettings = typeof CursorSettings.Type;
674​
675export const GrokSettings = makeProviderSettingsSchema(
676 {
677 // Off by default (like Cursor and OpenCode): the binding is not yet
678 // stable enough to probe on every install. Users opt in from Settings.
679 enabled: Schema.Boolean.pipe(
680 Schema.withDecodingDefault(Effect.succeed(false)),
681 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
682 ),
683 binaryPath: makeBinaryPathSetting("grok").pipe(
684 Schema.annotateKey({
685 title: "Binary path",
686 description: "Path to the Grok CLI binary.",
687 providerSettingsForm: { placeholder: "grok", clearWhenEmpty: "omit" },
688 }),
689 ),
690 customModels: Schema.Array(CustomModelSetting).pipe(
691 Schema.withDecodingDefault(Effect.succeed([])),
692 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
693 ),
694 },
695 {
696 order: ["binaryPath"],
697 },
698);
699export type GrokSettings = typeof GrokSettings.Type;
700​
701/**
702 * Antigravity ACP auth methods. Personal and Enterprise open a Google sign-in
703 * in the browser. The API key and Agent Platform methods take credentials from
704 * the instance config and never open a browser.
705 */
706export const ANTIGRAVITY_AUTH_METHODS = [
707 { value: "oauth-personal", label: "Google account" },
708 { value: "oauth-business", label: "Gemini Enterprise" },
709 { value: "gemini-api-key", label: "Gemini API key" },
710 { value: "agent-platform", label: "Agent Platform (Vertex AI)" },
711] as const satisfies ReadonlyArray<ProviderSettingsFormOption>;
712export const AntigravityAuthMethod = Schema.Literals(
713 ANTIGRAVITY_AUTH_METHODS.map((method) => method.value),
714);
715export type AntigravityAuthMethod = typeof AntigravityAuthMethod.Type;
716​
717export const AntigravitySettings = makeProviderSettingsSchema(
718 {
719 enabled: Schema.Boolean.pipe(
720 Schema.withDecodingDefault(Effect.succeed(false)),
721 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
722 ),
723 authMethod: AntigravityAuthMethod.pipe(
724 Schema.withDecodingDefault(Effect.succeed("oauth-personal" as const)),
725 Schema.annotateKey({
726 title: "Sign-in method",
727 description:
728 "Google account uses your Antigravity subscription. Gemini Enterprise needs a GCP project and location. API key and Agent Platform bill the credential you enter.",
729 providerSettingsForm: {
730 control: "select",
731 options: ANTIGRAVITY_AUTH_METHODS,
732 clearWhenEmpty: "omit",
733 },
734 }),
735 ),
736 apiKey: TrimmedString.pipe(
737 Schema.withDecodingDefault(Effect.succeed("")),
738 Schema.annotateKey({
739 title: "API key",
740 description:
741 "Gemini API key, or a Vertex AI express key for Agent Platform. Stored in plain text on this environment.",
742 providerSettingsForm: {
743 control: "password",
744 placeholder: "Optional",
745 clearWhenEmpty: "omit",
746 },
747 }),
748 ),
749 gcpProject: TrimmedString.pipe(
750 Schema.withDecodingDefault(Effect.succeed("")),
751 Schema.annotateKey({
752 title: "GCP project",
753 description:
754 "Required for Gemini Enterprise. Agent Platform uses it when no API key is set.",
755 providerSettingsForm: { placeholder: "my-project-id", clearWhenEmpty: "omit" },
756 }),
757 ),
758 gcpLocation: TrimmedString.pipe(
759 Schema.withDecodingDefault(Effect.succeed("")),
760 Schema.annotateKey({
761 title: "GCP location",
762 description: "Region for Gemini Enterprise or Agent Platform, such as us-central1.",
763 providerSettingsForm: { placeholder: "us-central1", clearWhenEmpty: "omit" },
764 }),
765 ),
766 binaryPath: TrimmedString.pipe(
767 Schema.withDecodingDefault(Effect.succeed("")),
768 Schema.annotateKey({
769 title: "Binary path",
770 description:
771 "Optional path to the official Antigravity ACP executable. Leave empty for automatic selection.",
772 providerSettingsForm: { placeholder: "Automatic", clearWhenEmpty: "persist" },
773 }),
774 ),
775 customModels: Schema.Array(CustomModelSetting).pipe(
776 Schema.withDecodingDefault(Effect.succeed([])),
777 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
778 ),
779 },
780 { order: ["authMethod", "apiKey", "gcpProject", "gcpLocation", "binaryPath"] },
781);
782export type AntigravitySettings = typeof AntigravitySettings.Type;
783​
784export const PiSettings = makeProviderSettingsSchema(
785 {
786 // Disabled by default while Pi support is Early Access.
787 enabled: Schema.Boolean.pipe(
788 Schema.withDecodingDefault(Effect.succeed(false)),
789 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
790 ),
791 binaryPath: makeBinaryPathSetting("pi").pipe(
792 Schema.annotateKey({
793 title: "Binary path",
794 description: "Path to the Pi coding agent binary.",
795 providerSettingsForm: { placeholder: "pi", clearWhenEmpty: "omit" },
796 }),
797 ),
798 launchArgs: TrimmedString.pipe(
799 Schema.withDecodingDefault(Effect.succeed("")),
800 Schema.annotateKey({
801 title: "Launch arguments",
802 description: "Additional CLI arguments passed to pi --mode rpc on session start.",
803 providerSettingsForm: { clearWhenEmpty: "omit" },
804 }),
805 ),
806 customModels: Schema.Array(CustomModelSetting).pipe(
807 Schema.withDecodingDefault(Effect.succeed([])),
808 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
809 ),
810 },
811 {
812 order: ["binaryPath", "launchArgs"],
813 },
814);
815export type PiSettings = typeof PiSettings.Type;
816​
817export const AcpRegistryDistributionPreference = Schema.Literals(["auto", "binary", "npx", "uvx"]);
818export type AcpRegistryDistributionPreference = typeof AcpRegistryDistributionPreference.Type;
819​
820export const AcpRegistrySettings = makeProviderSettingsSchema(
821 {
822 enabled: Schema.Boolean.pipe(
823 Schema.withDecodingDefault(Effect.succeed(true)),
824 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
825 ),
826 agentId: TrimmedString.pipe(
827 Schema.withDecodingDefault(Effect.succeed("")),
828 Schema.annotateKey({
829 title: "Registry agent ID",
830 description: "Agent identifier from the official ACP Registry, for example 'devin'.",
831 providerSettingsForm: { placeholder: "devin", clearWhenEmpty: "persist" },
832 }),
833 ),
834 commandPath: TrimmedString.pipe(
835 Schema.withDecodingDefault(Effect.succeed("")),
836 Schema.annotateKey({
837 title: "Executable override",
838 description:
839 "Optional local executable to use instead of installing the registry distribution. Registry arguments and environment are still applied.",
840 providerSettingsForm: { placeholder: "Registry default", clearWhenEmpty: "omit" },
841 }),
842 ),
843 authMethodId: TrimmedString.pipe(
844 Schema.withDecodingDefault(Effect.succeed("")),
845 Schema.annotateKey({
846 title: "Authentication method",
847 description:
848 "Optional ACP authentication method ID. By default, the first agent-managed method is selected.",
849 providerSettingsForm: { placeholder: "auto", clearWhenEmpty: "omit" },
850 }),
851 ),
852 distribution: AcpRegistryDistributionPreference.pipe(
853 Schema.withDecodingDefault(Effect.succeed("auto")),
854 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
855 ),
856 customModels: Schema.Array(Schema.String).pipe(
857 Schema.withDecodingDefault(Effect.succeed([])),
858 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
859 ),
860 },
861 {
862 order: ["agentId", "commandPath", "authMethodId"],
863 },
864);
865export type AcpRegistrySettings = typeof AcpRegistrySettings.Type;
866​
867export const OpenCodeSettings = makeProviderSettingsSchema(
868 {
869 // Off by default (like Cursor and Grok): the binding is not yet stable
870 // enough to probe on every install. Users opt in from Settings.
871 enabled: Schema.Boolean.pipe(
872 Schema.withDecodingDefault(Effect.succeed(false)),
873 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
874 ),
875 binaryPath: makeBinaryPathSetting("opencode").pipe(
876 Schema.annotateKey({
877 title: "Binary path",
878 description: "Path to the OpenCode binary.",
879 providerSettingsForm: {
880 placeholder: "opencode",
881 clearWhenEmpty: "omit",
882 },
883 }),
884 ),
885 serverUrl: TrimmedString.pipe(
886 Schema.withDecodingDefault(Effect.succeed("")),
887 Schema.annotateKey({
888 title: "Server URL",
889 description: "Leave blank to let T3 Code spawn the server when needed.",
890 providerSettingsForm: {
891 placeholder: "http://127.0.0.1:4096",
892 clearWhenEmpty: "omit",
893 },
894 }),
895 ),
896 serverPassword: TrimmedString.pipe(
897 Schema.withDecodingDefault(Effect.succeed("")),
898 Schema.annotateKey({
899 title: "Server password",
900 description: "Stored in plain text on disk.",
901 providerSettingsForm: {
902 control: "password",
903 placeholder: "Optional",
904 clearWhenEmpty: "omit",
905 },
906 }),
907 ),
908 customModels: Schema.Array(CustomModelSetting).pipe(
909 Schema.withDecodingDefault(Effect.succeed([])),
910 Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
911 ),
912 },
913 {
914 order: ["binaryPath", "serverUrl", "serverPassword"],
915 },
916);
917export type OpenCodeSettings = typeof OpenCodeSettings.Type;
918​
919/**
920 * A read-only quota source outside this environment's provider CLIs. The
921 * only kind today is a CLIProxyAPI hub, whose management API reports the
922 * windows of every pooled account. The key travels in settings for now, like
923 * provider environment secrets; it is redacted before reaching a client.
924 */
925export const UsageLimitSourceConfig = Schema.Struct({
926 kind: Schema.Literal("cliproxy"),
927 label: Schema.optional(TrimmedNonEmptyString),
928 url: TrimmedNonEmptyString,
929 managementKey: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
930 enabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
931});
932export type UsageLimitSourceConfig = typeof UsageLimitSourceConfig.Type;
933​
934export const ObservabilitySettings = Schema.Struct({
935 otlpTracesUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
936 otlpMetricsUrl: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
937});
938export type ObservabilitySettings = typeof ObservabilitySettings.Type;
939​
940export const SourceControlWritingStyleMode = Schema.Literals([
941 "repo_conventions",
942 "conventional_commits",
943 "custom",
944]);
945export type SourceControlWritingStyleMode = typeof SourceControlWritingStyleMode.Type;
946​
947export const SourceControlWritingStyleSettings = Schema.Struct({
948 mode: SourceControlWritingStyleMode.pipe(
949 Schema.withDecodingDefault(Effect.succeed("repo_conventions" as const)),
950 ),
951 customInstructions: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
952 followChangeRequestTemplates: Schema.Boolean.pipe(
953 Schema.withDecodingDefault(Effect.succeed(true)),
954 ),
955});
956export type SourceControlWritingStyleSettings = typeof SourceControlWritingStyleSettings.Type;
957​
958export const DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL = Duration.seconds(30);
959export const DEFAULT_PROVIDER_HEALTH_REFRESH_INTERVAL = Duration.minutes(5);
960​
961export const BackgroundActivityProfile = Schema.Literals([
962 "balanced",
963 "performance",
964 "battery-saver",
965]);
966export type BackgroundActivityProfile = typeof BackgroundActivityProfile.Type;
967export const DEFAULT_BACKGROUND_ACTIVITY_PROFILE: BackgroundActivityProfile = "balanced";
968​
969export const BackgroundActivityProfileSelection = Schema.Literals([
970 "balanced",
971 "performance",
972 "battery-saver",
973 "custom",
974]);
975export type BackgroundActivityProfileSelection = typeof BackgroundActivityProfileSelection.Type;
976​
977export const BackgroundActivityOverrides = Schema.Struct({
978 automaticGitFetchInterval: Schema.optionalKey(Schema.DurationFromMillis),
979 providerHealthRefreshInterval: Schema.optionalKey(Schema.DurationFromMillis),
980 hostPowerMonitorActiveInterval: Schema.optionalKey(Schema.DurationFromMillis),
981 hostPowerMonitorIdleInterval: Schema.optionalKey(Schema.DurationFromMillis),
982 idleClientTtl: Schema.optionalKey(Schema.DurationFromMillis),
983 pauseWhenHostLocked: Schema.optionalKey(Schema.Boolean),
984 pauseWhenHostLowPower: Schema.optionalKey(Schema.Boolean),
985 pauseWhenClientLowPower: Schema.optionalKey(Schema.Boolean),
986 pauseWhenOnBattery: Schema.optionalKey(Schema.Boolean),
987});
988export type BackgroundActivityOverrides = typeof BackgroundActivityOverrides.Type;
989​
990export const BackgroundActivitySettings = Schema.Struct({
991 schemaVersion: Schema.Literal(1).pipe(Schema.withDecodingDefault(Effect.succeed(1 as const))),
992 profile: BackgroundActivityProfileSelection.pipe(
993 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BACKGROUND_ACTIVITY_PROFILE)),
994 ),
995 baseProfile: Schema.optionalKey(BackgroundActivityProfile),
996 overrides: BackgroundActivityOverrides.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
997}).pipe(Schema.withDecodingDefault(Effect.succeed({})));
998export type BackgroundActivitySettings = typeof BackgroundActivitySettings.Type;
999​
1000export const ServerSettings = Schema.Struct({
1001 // Legacy token-by-token assistant output. Deliberately a fresh key (was
1002 // `enableAssistantStreaming`): decoding drops the old key, so everyone,
1003 // including prior opt-ins, resets to the buffered default.
1004 enableLegacyTokenStreaming: Schema.Boolean.pipe(
1005 Schema.withDecodingDefault(Effect.succeed(false)),
1006 ),
1007 enableProviderUpdateChecks: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
1008 // Retain the update-era key; recovery now needs an environment-owned opt-in.
1009 continueThreadsAfterServerUpdate: Schema.Boolean.pipe(
1010 Schema.withDecodingDefault(Effect.succeed(false)),
1011 ),
1012 /**
1013 * Whether agents may drive the in-app preview browser. Turning this off
1014 * withholds the MCP credential, so the `t3-code` server (and with it every
1015 * `preview_*` tool) is never attached to a provider session, and the prompt
1016 * text describing those tools is dropped along with them. The user's own
1017 * browser panel is unaffected — this gates agent access only.
1019 * Server-authoritative rather than client-local: tool injection and prompt
1020 * construction both happen on the server, and the answer must not differ
1021 * between a desktop window and a phone attached to the same server.
1022 */
1023 enableAgentBrowserAccess: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
1024 projectAgentBrowserAccessOverrides: Schema.Record(ProjectId, Schema.Boolean).pipe(
1025 Schema.withDecodingDefault(Effect.succeed({})),
1026 ),
1027 defaultAutoPull: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
1028 defaultProjectScripts: Schema.Array(ProjectScript).pipe(
1029 Schema.withDecodingDefault(Effect.succeed([])),
1030 ),
1031 projectScriptOverrides: Schema.Record(ProjectId, Schema.NullOr(Schema.Array(ProjectScript))).pipe(
1032 Schema.withDecodingDefault(Effect.succeed({})),
1033 ),
1034 projectAutoPullOverrides: Schema.Record(ProjectId, Schema.Boolean).pipe(
1035 Schema.withDecodingDefault(Effect.succeed({})),
1036 ),
1037 defaultModelSelection: Schema.NullOr(ModelSelection).pipe(
1038 Schema.withDecodingDefault(Effect.succeed(null)),
1039 ),
1040 /**
1041 * Whether agents may drive simulators and emulators. Gates the `device_*`
1042 * MCP tools and the preconfigured `agent-device` CLI the same way
1043 * `enableAgentBrowserAccess` gates the browser: server-authoritative, applied
1044 * when the provider session is prepared. The user's own Device panel is
1045 * unaffected.
1046 */
1047 enableAgentDeviceAccess: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
1048 /**
1049 * Whether this server may install and run T3's device helper processes.
1050 * Kept separate from agent access so enabling the user's Device panel does
1051 * not also grant providers control of simulators and emulators.
1052 */
1053 enableDeviceSupport: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
1054 /** Whether the server-local Device panel setup flow has been completed. */
1055 deviceOnboardingCompleted: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
1056 deviceHosts: SshDeviceHostConfigs.pipe(Schema.withDecodingDefault(Effect.succeed([]))),
1057 sidebarAutoSettleAfterDays: Schema.NullOr(SidebarAutoSettleAfterDays).pipe(
1058 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS)),
1059 ),
1060 sidebarAutoSettleOnMerge: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
1061 backgroundActivity: BackgroundActivitySettings,
1062 // Legacy flat fields retained for old settings files and old clients. New
1063 // consumers should resolve `backgroundActivity` instead.
1064 automaticGitFetchInterval: Schema.DurationFromMillis.pipe(
1065 Schema.withDecodingDefault(
1066 Effect.succeed(Duration.toMillis(DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL)),
1067 ),
1068 ),
1069 providerHealthRefreshInterval: Schema.DurationFromMillis.pipe(
1070 Schema.withDecodingDefault(
1071 Effect.succeed(Duration.toMillis(DEFAULT_PROVIDER_HEALTH_REFRESH_INTERVAL)),
1072 ),
1073 ),
1074 backgroundActivityProfile: BackgroundActivityProfile.pipe(
1075 Schema.withDecodingDefault(Effect.succeed(DEFAULT_BACKGROUND_ACTIVITY_PROFILE)),
1076 ),
1077 defaultTheme: DefaultThemePreference.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
1078 /**
1079 * When the environment's theme was last set, so clients can tell a re-set
1080 * of the same value from one they already applied: `t3 theme set` must act
1081 * even when it names the theme it named before. Empty on environments
1082 * provisioned by builds that predate it, where clients fall back to
1083 * applying once per value.
1084 */
1085 defaultThemeSetAt: Schema.String.check(Schema.isMaxLength(64)).pipe(
1086 Schema.withDecodingDefault(Effect.succeed("")),
1087 ),
1088 /**
1089 * The icon clients draw for this environment. Null means "use what the
1090 * server detected" (`environment.platform.machine`), falling back to a
1091 * generic server. Lives on the server, not the client, so every device
1092 * sees the same machine. A kind picked on a newer server decodes as null
1093 * here rather than failing the whole settings snapshot for an older client.
1094 */
1095 environmentIcon: ForwardCompatibleNullable(EnvironmentMachineKind).pipe(
1096 Schema.withDecodingDefault(Effect.succeed(null)),
1097 ),
1098 defaultThreadEnvMode: ThreadEnvMode.pipe(
1099 Schema.withDecodingDefault(Effect.succeed("local" as const satisfies ThreadEnvMode)),
1100 ),
1101 newWorktreesStartFromOrigin: Schema.Boolean.pipe(
1102 Schema.withDecodingDefault(Effect.succeed(true)),
1103 ),
1104 addProjectBaseDirectory: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
1105 textGenerationModelSelection: ModelSelection.pipe(
1106 Schema.withDecodingDefault(
1107 Effect.succeed({
1108 instanceId: ProviderInstanceId.make("codex"),
1109 model: DEFAULT_TEXT_GENERATION_MODEL,
1110 options: [
1112 id: "reasoningEffort",
1113 value: DEFAULT_TEXT_GENERATION_REASONING_EFFORT,
1114 },
1115 ],
1116 }),
1117 ),
1118 ),
1119 sourceControlWritingStyle: SourceControlWritingStyleSettings.pipe(
1120 Schema.withDecodingDefault(Effect.succeed({})),
1121 ),
1122 sourceControlWriterModelSelection: Schema.NullOr(ModelSelection).pipe(
1123 Schema.withDecodingDefault(Effect.succeed(null)),
1124 ),
1125​
1126 // Legacy single-instance-per-driver settings. Continues to be the source
1127 // of truth until `providerInstances` (below) lands per-driver migration
1128 // shims and the server starts hydrating instances from it. Driver-specific
1129 // schemas live here for the duration of the migration; once each driver
1130 // owns its config in its own package, this struct shrinks to nothing and
1131 // is removed entirely.
1132 providers: Schema.Struct({
1133 codex: CodexSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
1134 claudeAgent: ClaudeSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
1135 cursor: CursorSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
1136 grok: GrokSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
1137 pi: PiSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
1138 opencode: OpenCodeSettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
1139 antigravity: AntigravitySettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
1140 }).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
1141 // New driver-agnostic instance map. Keyed by `ProviderInstanceId`; values
1142 // are `ProviderInstanceConfig` envelopes. The driver-specific config blob
1143 // is `Schema.Unknown` at this layer so envelopes with unknown drivers
1144 // (forks, downgrades, in-flight PR branches) round-trip without loss.
1145 // See providerInstance.ts for the forward/backward compatibility invariant.
1146 providerInstances: Schema.Record(ProviderInstanceId, ProviderInstanceConfig).pipe(
1147 Schema.withDecodingDefault(Effect.succeed({})),
1148 ),
1149 observability: ObservabilitySettings.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
1150 // Keyed by a user-chosen id so a source keeps its rows across edits. Entries
1151 // this build cannot decode round-trip untouched, as provider instances do.
1152 usageLimitSources: Schema.Record(UsageLimitSourceId, UsageLimitSourceConfig).pipe(
1153 Schema.withDecodingDefault(Effect.succeed({})),
1154 ),
1155 /** Exact model IDs, applied to past and future usage on this environment. */
1156 usagePriceOverrides: Schema.Record(TrimmedNonEmptyString, UsageModelPriceOverride).pipe(
1157 Schema.withDecodingDefault(Effect.succeed({})),
1158 ),
1159});
1160export type ServerSettings = typeof ServerSettings.Type;
1161​
1162export const DEFAULT_SERVER_SETTINGS: ServerSettings = Schema.decodeSync(ServerSettings)({});
1163​
1164/**
1165 * Read the legacy `enabled` flag embedded in a provider instance config
1166 * blob. The envelope-level `ProviderInstanceConfig.enabled` is the single
1167 * flag going forward; this reader exists for legacy `providers.<kind>`
1168 * blobs and old settings files that still carry the flag in-config.
1169 */
1170export const providerInstanceConfigEnabledFlag = (config: unknown): boolean | undefined => {
1171 if (config === null || typeof config !== "object" || Array.isArray(config)) {
1172 return undefined;
1174 const enabled = (config as { readonly enabled?: unknown }).enabled;
1175 return typeof enabled === "boolean" ? enabled : undefined;
1177​
1178/**
1179 * Default enabled state for a built-in driver when neither the envelope nor
1180 * the config blob carries a flag. Derived from the driver's settings schema
1181 * through `DEFAULT_SERVER_SETTINGS`, so the schema's decoding default stays
1182 * the single source of truth. Unknown (fork) drivers default to enabled.
1183 */
1184const defaultEnabledForDriver = (driver: ProviderDriverKind): boolean => {
1185 const legacyDefaults = DEFAULT_SERVER_SETTINGS.providers as Record<
1186 string,
1187 { readonly enabled?: boolean } | undefined
1188 >;
1189 return legacyDefaults[driver]?.enabled ?? true;
1191​
1192/**
1193 * Resolve whether a configured provider instance is enabled. An explicit
1194 * false on either the envelope or the in-config flag wins (most
1195 * restrictive), so a user's disable is never silently undone by the other
1196 * flag. Otherwise: envelope, then config, then the driver's default.
1197 */
1198export const resolveProviderInstanceEnabled = (
1199 instance: Pick<ProviderInstanceConfig, "driver" | "enabled" | "config">,
1200): boolean => {
1201 const configEnabled = providerInstanceConfigEnabledFlag(instance.config);
1202 if (instance.enabled === false || configEnabled === false) {
1203 return false;
1205 return instance.enabled ?? configEnabled ?? defaultEnabledForDriver(instance.driver);
1207​
1208export const ServerSettingsOperation = Schema.Literals([
1209 "normalize",
1210 "check-exists",
1211 "create-provider-instance",
1212 "read-file",
1213 "read-provider-history",
1214 "read-secret",
1215 "remove-secret",
1216 "remove-stale-secret",
1217 "write-secret",
1218 "write-file",
1219 "prepare-directory",
1220]);
1221export type ServerSettingsOperation = typeof ServerSettingsOperation.Type;
1222​
1223export class ServerSettingsError extends Schema.TaggedError<ServerSettingsError>()(
1224 "ServerSettingsError",
1226 settingsPath: Schema.String,
1227 operation: ServerSettingsOperation,
1228 providerInstanceId: Schema.optional(Schema.String),
1229 environmentVariable: Schema.optional(Schema.String),
1230 // Validation failures (e.g. a create colliding with an existing
1231 // instance) originate without an upstream defect.
1232 cause: Schema.optional(Schema.Defect()),
1233 },
1234) {
1235 override get message(): string {
1236 const provider =
1237 this.providerInstanceId === undefined ? "" : ` for provider ${this.providerInstanceId}`;
1238 const variable =
1239 this.environmentVariable === undefined
1240 ? ""
1241 : ` and environment variable ${this.environmentVariable}`;
1242 return `Server settings ${this.operation} failed${provider}${variable} at ${this.settingsPath}.`;
1245​
1246// ── Unified type ─────────────────────────────────────────────────────
1247​
1248export type UnifiedSettings = ServerSettings & ClientSettings;
1249export const DEFAULT_UNIFIED_SETTINGS: UnifiedSettings = {
1250 ...DEFAULT_SERVER_SETTINGS,
1251 ...DEFAULT_CLIENT_SETTINGS,
1253​
1254// ── Server Settings Patch (replace with a Schema.deepPartial if available) ──────────────────────────────────────────
1255​
1256const ModelSelectionPatch = Schema.Struct({
1257 instanceId: Schema.optionalKey(ProviderInstanceId),
1258 model: Schema.optionalKey(TrimmedNonEmptyString),
1259 options: Schema.optionalKey(ProviderOptionSelections),
1260});
1261​
1262const CodexSettingsPatch = Schema.Struct({
1263 enabled: Schema.optionalKey(Schema.Boolean),
1264 binaryPath: Schema.optionalKey(TrimmedString),
1265 homePath: Schema.optionalKey(TrimmedString),
1266 shadowHomePath: Schema.optionalKey(TrimmedString),
1267 launchArgs: Schema.optionalKey(TrimmedString),
1268 customModels: Schema.optionalKey(Schema.Array(CustomModelSetting)),
1269});
1270​
1271const ClaudeSettingsPatch = Schema.Struct({
1272 enabled: Schema.optionalKey(Schema.Boolean),
1273 binaryPath: Schema.optionalKey(TrimmedString),
1274 homePath: Schema.optionalKey(TrimmedString),
1275 customModels: Schema.optionalKey(Schema.Array(CustomModelSetting)),
1276 launchArgs: Schema.optionalKey(TrimmedString),
1277 // Validated at the patch boundary so a typo fails the one update with a
1278 // schema error instead of a generic whole-settings failure.
1279 autoCompactWindow: Schema.optionalKey(
1280 TrimmedString.check(Schema.isPattern(CLAUDE_AUTO_COMPACT_WINDOW_PATTERN)),
1281 ),
1282});
1283​
1284const CursorSettingsPatch = Schema.Struct({
1285 enabled: Schema.optionalKey(Schema.Boolean),
1286 customModels: Schema.optionalKey(Schema.Array(CustomModelSetting)),
1287});
1288​
1289const GrokSettingsPatch = Schema.Struct({
1290 enabled: Schema.optionalKey(Schema.Boolean),
1291 binaryPath: Schema.optionalKey(TrimmedString),
1292 customModels: Schema.optionalKey(Schema.Array(CustomModelSetting)),
1293});
1294​
1295const AntigravitySettingsPatch = Schema.Struct({
1296 enabled: Schema.optionalKey(Schema.Boolean),
1297 authMethod: Schema.optionalKey(AntigravityAuthMethod),
1298 apiKey: Schema.optionalKey(TrimmedString),
1299 gcpProject: Schema.optionalKey(TrimmedString),
1300 gcpLocation: Schema.optionalKey(TrimmedString),
1301 binaryPath: Schema.optionalKey(TrimmedString),
1302 customModels: Schema.optionalKey(Schema.Array(CustomModelSetting)),
1303});
1304​
1305const PiSettingsPatch = Schema.Struct({
1306 enabled: Schema.optionalKey(Schema.Boolean),
1307 binaryPath: Schema.optionalKey(TrimmedString),
1308 launchArgs: Schema.optionalKey(TrimmedString),
1309 customModels: Schema.optionalKey(Schema.Array(CustomModelSetting)),
1310});
1311​
1312const OpenCodeSettingsPatch = Schema.Struct({
1313 enabled: Schema.optionalKey(Schema.Boolean),
1314 binaryPath: Schema.optionalKey(TrimmedString),
1315 serverUrl: Schema.optionalKey(TrimmedString),
1316 serverPassword: Schema.optionalKey(TrimmedString),
1317 customModels: Schema.optionalKey(Schema.Array(CustomModelSetting)),
1318});
1319​
1320export const ServerSettingsPatch = Schema.Struct({
1321 // Server settings
1322 enableLegacyTokenStreaming: Schema.optionalKey(Schema.Boolean),
1323 enableProviderUpdateChecks: Schema.optionalKey(Schema.Boolean),
1324 continueThreadsAfterServerUpdate: Schema.optionalKey(Schema.Boolean),
1325 enableAgentBrowserAccess: Schema.optionalKey(Schema.Boolean),
1326 projectAgentBrowserAccessOverrides: Schema.optionalKey(
1327 Schema.Record(ProjectId, Schema.NullOr(Schema.Boolean)),
1328 ),
1329 defaultAutoPull: Schema.optionalKey(Schema.Boolean),
1330 defaultProjectScripts: Schema.optionalKey(Schema.Array(ProjectScript)),
1331 projectScriptOverrides: Schema.optionalKey(
1332 Schema.Record(ProjectId, Schema.NullOr(Schema.Array(ProjectScript))),
1333 ),
1334 projectAutoPullOverrides: Schema.optionalKey(
1335 Schema.Record(ProjectId, Schema.NullOr(Schema.Boolean)),
1336 ),
1337 defaultModelSelection: Schema.optionalKey(Schema.NullOr(ModelSelection)),
1338 enableAgentDeviceAccess: Schema.optionalKey(Schema.Boolean),
1339 enableDeviceSupport: Schema.optionalKey(Schema.Boolean),
1340 deviceOnboardingCompleted: Schema.optionalKey(Schema.Boolean),
1341 deviceHosts: Schema.optionalKey(SshDeviceHostConfigs),
1342 sidebarAutoSettleAfterDays: Schema.optionalKey(Schema.NullOr(SidebarAutoSettleAfterDays)),
1343 sidebarAutoSettleOnMerge: Schema.optionalKey(Schema.Boolean),
1344 backgroundActivity: Schema.optionalKey(
1345 Schema.Struct({
1346 schemaVersion: Schema.optionalKey(Schema.Literal(1)),
1347 profile: Schema.optionalKey(BackgroundActivityProfileSelection),
1348 baseProfile: Schema.optionalKey(BackgroundActivityProfile),
1349 overrides: Schema.optionalKey(BackgroundActivityOverrides),
1350 }),
1351 ),
1352 automaticGitFetchInterval: Schema.optionalKey(Schema.DurationFromMillis),
1353 providerHealthRefreshInterval: Schema.optionalKey(Schema.DurationFromMillis),
1354 backgroundActivityProfile: Schema.optionalKey(BackgroundActivityProfile),
1355 environmentIcon: Schema.optionalKey(Schema.NullOr(EnvironmentMachineKind)),
1356 defaultThreadEnvMode: Schema.optionalKey(ThreadEnvMode),
1357 newWorktreesStartFromOrigin: Schema.optionalKey(Schema.Boolean),
1358 addProjectBaseDirectory: Schema.optionalKey(TrimmedString),
1359 textGenerationModelSelection: Schema.optionalKey(ModelSelectionPatch),
1360 sourceControlWritingStyle: Schema.optionalKey(
1361 Schema.Struct({
1362 mode: Schema.optionalKey(SourceControlWritingStyleMode),
1363 customInstructions: Schema.optionalKey(TrimmedString),
1364 followChangeRequestTemplates: Schema.optionalKey(Schema.Boolean),
1365 }),
1366 ),
1367 sourceControlWriterModelSelection: Schema.optionalKey(Schema.NullOr(ModelSelection)),
1368 observability: Schema.optionalKey(
1369 Schema.Struct({
1370 otlpTracesUrl: Schema.optionalKey(TrimmedString),
1371 otlpMetricsUrl: Schema.optionalKey(TrimmedString),
1372 }),
1373 ),
1374 providers: Schema.optionalKey(
1375 Schema.Struct({
1376 codex: Schema.optionalKey(CodexSettingsPatch),
1377 claudeAgent: Schema.optionalKey(ClaudeSettingsPatch),
1378 cursor: Schema.optionalKey(CursorSettingsPatch),
1379 grok: Schema.optionalKey(GrokSettingsPatch),
1380 pi: Schema.optionalKey(PiSettingsPatch),
1381 opencode: Schema.optionalKey(OpenCodeSettingsPatch),
1382 antigravity: Schema.optionalKey(AntigravitySettingsPatch),
1383 }),
1384 ),
1385 // Whole-map replacement for the new instance config. Patching individual
1386 // entries is intentionally out of scope: the map is small, and partial
1387 // patches risk leaving driver-specific config in a half-merged state.
1388 // The web UI sends a fully-formed map every time it edits this field.
1389 providerInstances: Schema.optionalKey(Schema.Record(ProviderInstanceId, ProviderInstanceConfig)),
1390 // Per-entry, unlike `providerInstances`: a client only ever adds or removes
1391 // one source, and sending the whole map races another edit that has not
1392 // echoed back yet. `null` removes; the server merges into its current map.
1393 usageLimitSources: Schema.optionalKey(
1394 Schema.Record(UsageLimitSourceId, Schema.NullOr(UsageLimitSourceConfig)),
1395 ),
1396 /** Each entry replaces one model's rates; `null` restores automatic pricing. */
1397 usagePriceOverrides: Schema.optionalKey(
1398 Schema.Record(TrimmedNonEmptyString, Schema.NullOr(UsageModelPriceOverride)),
1399 ),
1400});
1401export type ServerSettingsPatch = typeof ServerSettingsPatch.Type;
1402​
1403export const ClientSettingsPatch = Schema.Struct({
1404 diffColorScheme: Schema.optionalKey(DiffColorScheme),
1405 loadBalancingEnabled: Schema.optionalKey(Schema.Boolean),
1406 loadBalancingWeights: Schema.optionalKey(LoadBalancingWeights),
1407 appearanceContrast: Schema.optionalKey(AppearanceContrast),
1408 panelAnimationDurationMs: Schema.optionalKey(PanelAnimationDurationMs),
1409 browserDefaultViewport: Schema.optionalKey(PreviewViewportSetting),
1410 browserDefaultZoomFactor: Schema.optionalKey(PreviewZoomFactor),
1411 browserDefaultAppearance: Schema.optionalKey(PreviewAppearancePreference),
1412 browserRecordingFrameRate: Schema.optionalKey(BrowserRecordingFrameRate),
1413 browserLinkTarget: Schema.optionalKey(BrowserLinkTarget),
1414 browserAutoShowFloatingPreview: Schema.optionalKey(Schema.Boolean),
1415 browserProfiles: Schema.optionalKey(Schema.Array(BrowserProfile)),
1416 browserDefaultProfileId: Schema.optionalKey(BrowserProfileId),
1417 confirmQuit: Schema.optionalKey(QuitConfirmationMode),
1418 confirmThreadArchive: Schema.optionalKey(Schema.Boolean),
1419 confirmThreadDelete: Schema.optionalKey(Schema.Boolean),
1420 confirmThreadUnpin: Schema.optionalKey(Schema.Boolean),
1421 diffIgnoreWhitespace: Schema.optionalKey(Schema.Boolean),
1422 diffLayout: Schema.optionalKey(DiffLayout),
1423 environmentIdentificationMode: Schema.optionalKey(EnvironmentIdentificationMode),
1424 glassOpacity: Schema.optionalKey(GlassOpacity),
1425 onboardingCompletedAt: Schema.optionalKey(Schema.NullOr(Schema.String)),
1426 fontSizeInterface: Schema.optionalKey(InterfaceFontSize),
1427 fontSizePrompt: Schema.optionalKey(PromptFontSize),
1428 fontSizeCode: Schema.optionalKey(CodeFontSize),
1429 fontSizeTerminal: Schema.optionalKey(TerminalFontSize),
1430 fontFamilyCode: Schema.optionalKey(FontFamilyPreference),
1431 fontFamilyComposer: Schema.optionalKey(FontFamilyPreference),
1432 fontFamilySans: Schema.optionalKey(FontFamilyPreference),
1433 fontFamilyTerminal: Schema.optionalKey(FontFamilyPreference),
1434 fontSmoothing: Schema.optionalKey(Schema.Boolean),
1435 persistComposerContextStrip: Schema.optionalKey(Schema.Boolean),
1436 favorites: Schema.optionalKey(
1437 Schema.Array(
1438 Schema.Struct({
1439 provider: ProviderInstanceId,
1440 model: TrimmedNonEmptyString,
1441 }),
1442 ),
1443 ),
1444 providerModelPreferences: Schema.optionalKey(
1445 Schema.Record(
1446 ProviderInstanceId,
1447 Schema.Struct({
1448 hiddenModels: Schema.Array(Schema.String).pipe(
1449 Schema.withDecodingDefault(Effect.succeed([])),
1450 ),
1451 modelOrder: Schema.Array(Schema.String).pipe(
1452 Schema.withDecodingDefault(Effect.succeed([])),
1453 ),
1454 }),
1455 ),
1456 ),
1457 pullRequestMergeMethodOverrides: Schema.optionalKey(
1458 Schema.Record(TrimmedNonEmptyString, PullRequestMergeMethod),
1459 ),
1460 planModeEnabled: Schema.optionalKey(Schema.Boolean),
1461 contextWindowMeterEnabled: Schema.optionalKey(Schema.Boolean),
1462 composerCollapseOnScroll: Schema.optionalKey(Schema.Boolean),
1463 proactivePanelsEnabled: Schema.optionalKey(Schema.Boolean),
1464 showSkillsInSlashMenu: Schema.optionalKey(Schema.Boolean),
1465 legacySidebarEnabled: Schema.optionalKey(Schema.Boolean),
1466 sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),
1467 sidebarProjectGroupingOverrides: Schema.optionalKey(
1468 Schema.Record(TrimmedNonEmptyString, SidebarProjectGroupingMode),
1469 ),
1470 sidebarProjectSortOrder: Schema.optionalKey(SidebarProjectSortOrder),
1471 sidebarThreadSortOrder: Schema.optionalKey(SidebarThreadSortOrder),
1472 sidebarThreadPreviewCount: Schema.optionalKey(SidebarThreadPreviewCount),
1473 timestampFormat: Schema.optionalKey(TimestampFormat),
1474 snapShotEnabled: Schema.optionalKey(Schema.Boolean),
1475 snapShotIncludeAccessibility: Schema.optionalKey(Schema.Boolean),
1476 snapShotShortcut: Schema.optionalKey(SnapShotShortcut),
1477 snapShotPlaySound: Schema.optionalKey(Schema.Boolean),
1478 snapShotSound: Schema.optionalKey(SnapShotSound),
1479 snapShotFlash: Schema.optionalKey(Schema.Boolean),
1480 snapShotAnimations: Schema.optionalKey(Schema.Boolean),
1481 wordWrap: Schema.optionalKey(Schema.Boolean),
1482});
1483export type ClientSettingsPatch = typeof ClientSettingsPatch.Type;