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

settings.ts

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