Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2import * as Schema from "effect/Schema";
3
4import type { CommandId, ProjectId } from "./baseSchemas.ts";
5import { ProviderDriverKind, ProviderInstanceId } from "./providerInstance.ts";
6import {
7 ClientSettingsSchema,
8 ClientSettingsPatch,
9 ClaudeSettings,
10 DEFAULT_SERVER_SETTINGS,
11 requiredScopesForProjectMutation,
12 resolveProjectProviderInstanceEnabled,
13 resolveProviderInstanceEnabled,
14 ServerSettings,
15 ServerSettingsPatch,
16} from "./settings.ts";
17
18const decodeClientSettings = Schema.decodeUnknownSync(ClientSettingsSchema);
19const decodeClientSettingsPatch = Schema.decodeUnknownSync(ClientSettingsPatch);
20const encodeClientSettings = Schema.encodeSync(ClientSettingsSchema);
21const decodeServerSettings = Schema.decodeUnknownSync(ServerSettings);
22const decodeServerSettingsPatch = Schema.decodeUnknownSync(ServerSettingsPatch);
23const encodeServerSettings = Schema.encodeSync(ServerSettings);
24const decodeClaudeSettings = Schema.decodeUnknownSync(ClaudeSettings);
25
26describe("ServerSettings response streaming", () => {
27 it("defaults to paragraph buffering", () => {
28 expect(decodeServerSettings({}).responseStreamingMode).toBe("paragraph");
29 });
30
31 it.each(["turn", "paragraph"])(
32 "round-trips %s as an environment setting and project override",
33 (responseStreamingMode) => {
34 const input = {
35 responseStreamingMode,
36 projectSettingsOverrides: { project: { responseStreamingMode } },
37 };
38 expect(encodeServerSettings(decodeServerSettings(input))).toMatchObject(input);
39 expect(decodeServerSettingsPatch(input)).toEqual(input);
40 },
41 );
42
43 it.each(["token", "unsupported"])("rejects %s in settings snapshots and writes", (mode) => {
44 for (const input of [
45 { responseStreamingMode: mode },
46 { projectSettingsOverrides: { project: { responseStreamingMode: mode } } },
47 ]) {
48 expect(() => decodeServerSettings(input)).toThrow();
49 expect(() => decodeServerSettingsPatch(input)).toThrow();
50 }
51 });
52});
53
54describe("storage cleanup settings", () => {
55 it("keeps cleanup disabled for existing installations", () => {
56 expect(decodeServerSettings({}).worktreeCleanup).toBeNull();
57 expect(decodeServerSettings({}).storageCleanup).toEqual({
58 worktreeAfterDays: null,
59 worktreeOnMerge: false,
60 worktreeOnDelete: false,
61 worktreeUnchanged: false,
62 worktreeKeepWhen: "uncommitted-changes",
63 browserArtifactsAfterDays: null,
64 logsAfterDays: null,
65 });
66 });
67
68 it("accepts eight-day retention and disabling one rule without resetting others", () => {
69 expect(decodeServerSettingsPatch({ storageCleanup: { worktreeAfterDays: 8 } })).toEqual({
70 storageCleanup: { worktreeAfterDays: 8 },
71 });
72 expect(decodeServerSettingsPatch({ storageCleanup: { worktreeAfterDays: null } })).toEqual({
73 storageCleanup: { worktreeAfterDays: null },
74 });
75 });
76
77 it("accepts partial custom patches but requires complete stored project rules", () => {
78 expect(
79 decodeServerSettingsPatch({
80 worktreeCleanup: { mode: "custom", rules: { worktreeAfterDays: 8 } },
81 }),
82 ).toEqual({ worktreeCleanup: { mode: "custom", rules: { worktreeAfterDays: 8 } } });
83 expect(() =>
84 decodeServerSettings({
85 projectSettingsOverrides: {
86 project: { worktreeCleanup: { mode: "custom", rules: { worktreeAfterDays: 8 } } },
87 },
88 }),
89 ).toThrow();
90 });
91
92 it("decodes older custom rules with the default local-file policy", () => {
93 const settings = decodeServerSettings({
94 worktreeCleanup: {
95 mode: "custom",
96 rules: {
97 worktreeAfterDays: 8,
98 worktreeOnMerge: false,
99 worktreeOnDelete: false,
100 worktreeUnchanged: false,
101 },
102 },
103 });
104 expect(settings.worktreeCleanup).toMatchObject({
105 rules: { worktreeKeepWhen: "uncommitted-changes" },
106 });
107 expect(
108 decodeServerSettingsPatch({ storageCleanup: { worktreeKeepWhen: "tracked-changes" } }),
109 ).toEqual({ storageCleanup: { worktreeKeepWhen: "tracked-changes" } });
110 expect(() =>
111 decodeServerSettingsPatch({ storageCleanup: { worktreeKeepWhen: "unknown" } }),
112 ).toThrow();
113 });
114
115 it.each([0, -1, 1.5, 3651])("rejects invalid retention %s", (days) => {
116 expect(() =>
117 decodeServerSettingsPatch({ storageCleanup: { browserArtifactsAfterDays: days } }),
118 ).toThrow();
119 });
120});
121
122describe("ClientSettings rich text composer", () => {
123 it("enables rich text for new and existing settings without a saved preference", () => {
124 expect(decodeClientSettings({}).composerRichTextEnabled).toBe(true);
125 expect(decodeClientSettings({ sendShortcut: "mod-enter" }).composerRichTextEnabled).toBe(true);
126 });
127
128 it("preserves an explicit opt-out through patches and persistence", () => {
129 const preference = { composerRichTextEnabled: false };
130 expect(decodeClientSettingsPatch(preference)).toEqual(preference);
131 expect(encodeClientSettings(decodeClientSettings(preference))).toMatchObject(preference);
132 });
133});
134
135describe("ServerSettings default permissions", () => {
136 it("keeps full access for settings saved before a default was configured", () => {
137 expect(decodeServerSettings({}).defaultRuntimeMode).toBe("full-access");
138 expect(DEFAULT_SERVER_SETTINGS.defaultRuntimeMode).toBe("full-access");
139 });
140
141 it.each(["approval-required", "auto-accept-edits", "auto", "full-access"])(
142 "round-trips %s as an environment default and project override",
143 (defaultRuntimeMode) => {
144 const input = {
145 defaultRuntimeMode,
146 projectSettingsOverrides: { project: { defaultRuntimeMode } },
147 };
148 expect(encodeServerSettings(decodeServerSettings(input))).toMatchObject(input);
149 expect(decodeServerSettingsPatch(input)).toEqual(input);
150 },
151 );
152
153 it("rejects unsupported permission defaults", () => {
154 expect(() => decodeServerSettings({ defaultRuntimeMode: "unsupported" })).toThrow();
155 expect(() => decodeServerSettingsPatch({ defaultRuntimeMode: "unsupported" })).toThrow();
156 expect(() =>
157 decodeServerSettingsPatch({
158 projectSettingsOverrides: { project: { defaultRuntimeMode: "unsupported" } },
159 }),
160 ).toThrow();
161 });
162});
163
164describe("ServerSettings usage price overrides", () => {
165 const prices = { inputCostPerMillionTokens: 2, outputCostPerMillionTokens: 8 };
166
167 it("defaults to automatic pricing and round-trips arbitrary model IDs", () => {
168 expect(decodeServerSettings({}).usagePriceOverrides).toEqual({});
169 const settings = decodeServerSettings({
170 usagePriceOverrides: { " vendor/example-model ": prices },
171 });
172 expect(encodeServerSettings(settings).usagePriceOverrides).toEqual({
173 "vendor/example-model": prices,
174 });
175 });
176
177 it("accepts zero rates, optional cache rates, and per-model deletion", () => {
178 const overrides = {
179 "example-model": {
180 inputCostPerMillionTokens: 0,
181 outputCostPerMillionTokens: 0,
182 cacheReadCostPerMillionTokens: 0.5,
183 cacheWriteCostPerMillionTokens: 3,
184 },
185 "removed-model": null,
186 };
187 expect(
188 decodeServerSettingsPatch({ usagePriceOverrides: overrides }).usagePriceOverrides,
189 ).toEqual(overrides);
190 });
191
192 it.each([
193 "inputCostPerMillionTokens",
194 "outputCostPerMillionTokens",
195 "cacheReadCostPerMillionTokens",
196 "cacheWriteCostPerMillionTokens",
197 ])("rejects invalid %s rates at the settings boundary", (field) => {
198 for (const value of [-1, Number.NaN, Number.POSITIVE_INFINITY, "2"]) {
199 const usagePriceOverrides = { "example-model": { ...prices, [field]: value } };
200 expect(() => decodeServerSettings({ usagePriceOverrides })).toThrow();
201 expect(() => decodeServerSettingsPatch({ usagePriceOverrides })).toThrow();
202 }
203 });
204
205 it("rejects empty model IDs and incomplete input/output pricing", () => {
206 for (const usagePriceOverrides of [
207 { " ": prices },
208 { "example-model": { inputCostPerMillionTokens: 2 } },
209 { "example-model": { outputCostPerMillionTokens: 8 } },
210 ]) {
211 expect(() => decodeServerSettingsPatch({ usagePriceOverrides })).toThrow();
212 }
213 });
214});
215
216describe("custom model settings", () => {
217 const capabilities = {
218 optionDescriptors: [
219 {
220 id: "effort",
221 label: "Reasoning",
222 type: "select",
223 options: [{ id: "high", label: "High", isDefault: true }],
224 },
225 ],
226 };
227
228 it("accepts legacy bare slugs alongside full entries", () => {
229 const decoded = decodeClaudeSettings({
230 customModels: ["bare-slug", { slug: "named", name: "Named", capabilities }],
231 });
232 expect(decoded.customModels).toEqual([
233 "bare-slug",
234 { slug: "named", name: "Named", capabilities },
235 ]);
236 });
237});
238
239describe("ClaudeSettings auto-compaction", () => {
240 it("uses Claude's default threshold when no override is configured", () => {
241 expect(decodeClaudeSettings({}).autoCompactWindow).toBe("");
242 });
243
244 it.each(["100000", "300000", "1000000"])(
245 "accepts a supported auto-compaction threshold: %s",
246 (value) => {
247 expect(decodeClaudeSettings({ autoCompactWindow: value }).autoCompactWindow).toBe(value);
248 },
249 );
250
251 it.each(["99999", "1000001", "300k", "invalid"])(
252 "rejects an unsupported auto-compaction threshold: %s",
253 (value) => {
254 expect(() => decodeClaudeSettings({ autoCompactWindow: value })).toThrow();
255 },
256 );
257});
258
259describe("ClientSettings notifications", () => {
260 it("requires opt-in when existing settings omit notification preferences", () => {
261 expect(decodeClientSettings({}).notificationMode).toBe("off");
262 expect(decodeClientSettings({}).inAppNotificationsEnabled).toBe(false);
263 expect(decodeClientSettingsPatch({})).not.toHaveProperty("inAppNotificationsEnabled");
264 expect(decodeClientSettingsPatch({})).not.toHaveProperty("notificationMode");
265 });
266
267 it.each([true, false])(
268 "round-trips in-app notifications set to %s",
269 (inAppNotificationsEnabled) => {
270 const settings = decodeClientSettings({ inAppNotificationsEnabled });
271 expect(encodeClientSettings(settings).inAppNotificationsEnabled).toBe(
272 inAppNotificationsEnabled,
273 );
274 expect(
275 decodeClientSettingsPatch({ inAppNotificationsEnabled }).inAppNotificationsEnabled,
276 ).toBe(inAppNotificationsEnabled);
277 },
278 );
279
280 it.each(["true", 1, null])(
281 "rejects an invalid in-app notification preference %s",
282 (inAppNotificationsEnabled) => {
283 expect(() => decodeClientSettings({ inAppNotificationsEnabled })).toThrow();
284 expect(() => decodeClientSettingsPatch({ inAppNotificationsEnabled })).toThrow();
285 },
286 );
287
288 it.each(["off", "notifications", "sound", "notifications-and-sound"])(
289 "round-trips the %s mode",
290 (notificationMode) => {
291 const settings = decodeClientSettings({ notificationMode });
292 expect(encodeClientSettings(settings).notificationMode).toBe(notificationMode);
293 expect(decodeClientSettingsPatch({ notificationMode }).notificationMode).toBe(
294 notificationMode,
295 );
296 },
297 );
298
299 it.each(["always", true, null])(
300 "rejects unsupported notification mode %s",
301 (notificationMode) => {
302 expect(() => decodeClientSettings({ notificationMode })).toThrow();
303 expect(() => decodeClientSettingsPatch({ notificationMode })).toThrow();
304 },
305 );
306});
307
308describe("ClientSettings default diff file state", () => {
309 it("keeps files collapsed when existing settings omit the preference", () => {
310 expect(decodeClientSettings({}).diffFilesCollapsed).toBe(true);
311 });
312
313 it.each([true, false])("preserves a saved collapsed preference of %s", (diffFilesCollapsed) => {
314 const settings = decodeClientSettings({ diffFilesCollapsed });
315 expect(encodeClientSettings(settings).diffFilesCollapsed).toBe(diffFilesCollapsed);
316 expect(decodeClientSettingsPatch({ diffFilesCollapsed }).diffFilesCollapsed).toBe(
317 diffFilesCollapsed,
318 );
319 });
320});
321
322describe("ClientSettings diff colors", () => {
323 it("keeps red and green for existing settings without a saved palette", () => {
324 expect(decodeClientSettings({}).diffColorScheme).toBe("red-green");
325 });
326
327 it.each(["red-green", "blue-orange"])("round-trips the %s palette", (diffColorScheme) => {
328 const settings = decodeClientSettings({ diffColorScheme });
329 expect(encodeClientSettings(settings).diffColorScheme).toBe(diffColorScheme);
330 expect(decodeClientSettingsPatch({ diffColorScheme }).diffColorScheme).toBe(diffColorScheme);
331 });
332
333 it("rejects unsupported palettes", () => {
334 expect(() => decodeClientSettings({ diffColorScheme: "purple-yellow" })).toThrow();
335 expect(() => decodeClientSettingsPatch({ diffColorScheme: "purple-yellow" })).toThrow();
336 });
337});
338
339describe("ClientSettings chat width", () => {
340 it("keeps the comfortable width for existing settings without a saved width", () => {
341 expect(decodeClientSettings({}).chatWidth).toBe("comfortable");
342 });
343
344 it.each(["comfortable", "wide", "full"])("round-trips the %s width", (chatWidth) => {
345 const settings = decodeClientSettings({ chatWidth });
346 expect(encodeClientSettings(settings).chatWidth).toBe(chatWidth);
347 expect(decodeClientSettingsPatch({ chatWidth }).chatWidth).toBe(chatWidth);
348 });
349
350 it("rejects unsupported widths", () => {
351 expect(() => decodeClientSettings({ chatWidth: "huge" })).toThrow();
352 expect(() => decodeClientSettingsPatch({ chatWidth: "huge" })).toThrow();
353 });
354});
355
356describe("ClientSettings load balancing", () => {
357 it("requires opt-in when settings are new or omit load balancing", () => {
358 expect(decodeClientSettings({}).loadBalancingEnabled).toBe(false);
359 expect(decodeClientSettings({ loadBalancingWeights: {} }).loadBalancingEnabled).toBe(false);
360 });
361
362 it.each([true, false])("preserves a saved choice of %s", (loadBalancingEnabled) => {
363 const settings = decodeClientSettings({ loadBalancingEnabled });
364 expect(encodeClientSettings(settings).loadBalancingEnabled).toBe(loadBalancingEnabled);
365 expect(decodeClientSettingsPatch({ loadBalancingEnabled }).loadBalancingEnabled).toBe(
366 loadBalancingEnabled,
367 );
368 });
369});
370
371describe("ClientSettings composer context strip", () => {
372 it("defaults to draft-only and accepts a persistent strip preference", () => {
373 expect(decodeClientSettings({}).persistComposerContextStrip).toBe(false);
374 expect(
375 decodeClientSettingsPatch({ persistComposerContextStrip: true }).persistComposerContextStrip,
376 ).toBe(true);
377 });
378});
379
380describe("ClientSettings word wrap", () => {
381 it("defaults word wrap on", () => {
382 expect(decodeClientSettings({}).wordWrap).toBe(true);
383 });
384
385 it("ignores obsolete wrapping preferences", () => {
386 const decoded = decodeClientSettings({
387 chatWordWrap: false,
388 diffWordWrap: false,
389 });
390
391 expect(decoded.wordWrap).toBe(true);
392 expect(decoded).not.toHaveProperty("chatWordWrap");
393 expect(decoded).not.toHaveProperty("diffWordWrap");
394 });
395});
396
397describe("ClientSettings window capture", () => {
398 it("defaults capture off while keeping its feedback enabled", () => {
399 const settings = decodeClientSettings({});
400
401 expect(settings.snapShotEnabled).toBe(false);
402 expect(settings.snapShotIncludeAccessibility).toBe(true);
403 expect(settings.snapShotShortcut).toEqual({ kind: "both-shift-keys" });
404 expect(settings.snapShotPlaySound).toBe(true);
405 expect(settings.snapShotSound).toBe("soft-pop");
406 expect(settings.snapShotFlash).toBe(true);
407 expect(settings.snapShotAnimations).toBe(true);
408 });
409
410 it("accepts capture preference updates", () => {
411 expect(
412 decodeClientSettingsPatch({
413 snapShotEnabled: true,
414 snapShotIncludeAccessibility: false,
415 snapShotShortcut: {
416 key: "w",
417 metaKey: false,
418 ctrlKey: false,
419 shiftKey: true,
420 altKey: true,
421 modKey: false,
422 },
423 snapShotPlaySound: false,
424 snapShotSound: "camera-shutter",
425 snapShotFlash: false,
426 snapShotAnimations: false,
427 }),
428 ).toEqual({
429 snapShotEnabled: true,
430 snapShotIncludeAccessibility: false,
431 snapShotShortcut: {
432 key: "w",
433 metaKey: false,
434 ctrlKey: false,
435 shiftKey: true,
436 altKey: true,
437 modKey: false,
438 },
439 snapShotPlaySound: false,
440 snapShotSound: "camera-shutter",
441 snapShotFlash: false,
442 snapShotAnimations: false,
443 });
444 });
445
446 it("rejects unknown capture sounds", () => {
447 expect(() => decodeClientSettingsPatch({ snapShotSound: "doorbell" })).toThrow();
448 });
449
450 it("accepts modifier pair shortcuts", () => {
451 expect(
452 decodeClientSettingsPatch({
453 snapShotShortcut: { kind: "modifier-pair", modifier: "meta" },
454 }),
455 ).toEqual({
456 snapShotShortcut: { kind: "modifier-pair", modifier: "meta" },
457 });
458 expect(() =>
459 decodeClientSettingsPatch({
460 snapShotShortcut: { kind: "modifier-pair", modifier: "hyper" },
461 }),
462 ).toThrow();
463 });
464
465 it("rejects a capture shortcut with no modifier", () => {
466 expect(() =>
467 decodeClientSettingsPatch({
468 snapShotShortcut: {
469 key: "w",
470 metaKey: false,
471 ctrlKey: false,
472 shiftKey: false,
473 altKey: false,
474 modKey: false,
475 },
476 }),
477 ).toThrow();
478 });
479});
480
481describe("ClientSettings proactive panels", () => {
482 it("is opt-in and accepts client-local updates", () => {
483 expect(decodeClientSettings({}).proactivePanelsEnabled).toBe(false);
484 expect(decodeClientSettingsPatch({ proactivePanelsEnabled: true }).proactivePanelsEnabled).toBe(
485 true,
486 );
487 });
488});
489
490describe("ClientSettings quit confirmation", () => {
491 it("defaults to hold", () => {
492 expect(decodeClientSettings({}).confirmQuit).toBe("hold");
493 });
494
495 it.each(["direct", "hold", "double-click"] as const)("accepts the %s mode", (mode) => {
496 expect(decodeClientSettings({ confirmQuit: mode }).confirmQuit).toBe(mode);
497 expect(decodeClientSettingsPatch({ confirmQuit: mode }).confirmQuit).toBe(mode);
498 });
499
500 it.each([
501 [true, "hold"],
502 [false, "direct"],
503 ] as const)("migrates the legacy %s value to %s", (legacyValue, mode) => {
504 const settings = decodeClientSettings({ confirmQuit: legacyValue });
505
506 expect(settings.confirmQuit).toBe(mode);
507 expect(encodeClientSettings(settings).confirmQuit).toBe(mode);
508 });
509
510 it("rejects legacy booleans at the patch boundary", () => {
511 expect(() => decodeClientSettingsPatch({ confirmQuit: true })).toThrow();
512 });
513});
514
515describe("ClientSettings browser recording frame rate", () => {
516 it("defaults to 30 fps", () => {
517 expect(decodeClientSettings({}).browserRecordingFrameRate).toBe(30);
518 });
519
520 it.each([30, 60])("accepts a supported frame rate: %s", (frameRate) => {
521 expect(
522 decodeClientSettings({ browserRecordingFrameRate: frameRate }).browserRecordingFrameRate,
523 ).toBe(frameRate);
524 expect(
525 decodeClientSettingsPatch({ browserRecordingFrameRate: frameRate }).browserRecordingFrameRate,
526 ).toBe(frameRate);
527 });
528
529 it.each([24, 59, 120])("rejects an unsupported frame rate: %s", (frameRate) => {
530 expect(() => decodeClientSettings({ browserRecordingFrameRate: frameRate })).toThrow();
531 expect(() => decodeClientSettingsPatch({ browserRecordingFrameRate: frameRate })).toThrow();
532 });
533});
534
535describe("ClientSettings recording input overlays", () => {
536 it("defaults both overlays off and accepts independent opt-ins", () => {
537 const settings = decodeClientSettings({});
538 expect(settings.browserRecordingShowKeyPresses).toBe(false);
539 expect(settings.browserRecordingShowMousePresses).toBe(false);
540 expect(
541 decodeClientSettingsPatch({
542 browserRecordingShowKeyPresses: true,
543 browserRecordingShowMousePresses: false,
544 }),
545 ).toMatchObject({
546 browserRecordingShowKeyPresses: true,
547 browserRecordingShowMousePresses: false,
548 });
549 });
550});
551
552describe("ClientSettings glass opacity", () => {
553 it("defaults to a readable translucent surface", () => {
554 expect(decodeClientSettings({}).glassOpacity).toBe(80);
555 });
556
557 it.each([39, 101, 72.5])("rejects an invalid glass opacity: %s", (value) => {
558 expect(() => decodeClientSettings({ glassOpacity: value })).toThrow();
559 expect(() => decodeClientSettingsPatch({ glassOpacity: value })).toThrow();
560 });
561
562 it.each([40, 75, 100])("accepts a glass opacity within the supported range: %s", (value) => {
563 expect(decodeClientSettings({ glassOpacity: value }).glassOpacity).toBe(value);
564 expect(decodeClientSettingsPatch({ glassOpacity: value }).glassOpacity).toBe(value);
565 });
566});
567
568describe("ClientSettings appearance contrast", () => {
569 it("defaults to the theme's original contrast", () => {
570 expect(decodeClientSettings({}).appearanceContrast).toBe(100);
571 });
572
573 it.each([49, 201, 92.5])("rejects an invalid appearance contrast: %s", (value) => {
574 expect(() => decodeClientSettings({ appearanceContrast: value })).toThrow();
575 expect(() => decodeClientSettingsPatch({ appearanceContrast: value })).toThrow();
576 });
577
578 it.each([50, 100, 150, 200])("accepts an appearance contrast in range: %s", (value) => {
579 expect(decodeClientSettings({ appearanceContrast: value }).appearanceContrast).toBe(value);
580 expect(decodeClientSettingsPatch({ appearanceContrast: value }).appearanceContrast).toBe(value);
581 });
582});
583
584describe("ClientSettings panel animations", () => {
585 it("defaults to instant changes", () => {
586 expect(decodeClientSettings({}).panelAnimationDurationMs).toBe(0);
587 });
588
589 it.each([0, 400])("accepts a panel animation duration: %s", (value) => {
590 expect(decodeClientSettingsPatch({ panelAnimationDurationMs: value })).toEqual({
591 panelAnimationDurationMs: value,
592 });
593 });
594
595 it.each([-1, 401, 150.5])("rejects an invalid panel animation duration: %s", (value) => {
596 expect(() => decodeClientSettingsPatch({ panelAnimationDurationMs: value })).toThrow();
597 });
598});
599
600describe("ClientSettings environment identification", () => {
601 it("defaults to artwork and accepts each presentation mode", () => {
602 expect(decodeClientSettings({}).environmentIdentificationMode).toBe("artwork");
603
604 for (const mode of ["artwork", "pill", "none"] as const) {
605 expect(
606 decodeClientSettingsPatch({ environmentIdentificationMode: mode })
607 .environmentIdentificationMode,
608 ).toBe(mode);
609 }
610 });
611
612 it("rejects unsupported presentation modes", () => {
613 expect(() => decodeClientSettings({ environmentIdentificationMode: "badge" })).toThrow();
614 expect(() => decodeClientSettingsPatch({ environmentIdentificationMode: "badge" })).toThrow();
615 });
616});
617
618describe("ClientSettings sidebar", () => {
619 it("defaults to the current sidebar", () => {
620 expect(decodeClientSettings({}).legacySidebarEnabled).toBe(false);
621 });
622
623 it("drops the retired sidebar v2 beta keys, resetting everyone to the default", () => {
624 const decoded = decodeClientSettings({
625 sidebarV2Enabled: false,
626 sidebarV2ConfiguredByUser: true,
627 });
628 expect(decoded.legacySidebarEnabled).toBe(false);
629 expect(decoded).not.toHaveProperty("sidebarV2Enabled");
630 expect(decoded).not.toHaveProperty("sidebarV2ConfiguredByUser");
631 });
632
633 it("drops the retired compact sidebar keys for users who opted in", () => {
634 const stored = { compactSidebarEnabled: true, sidebarCompactThreadRows: true };
635 const decoded = decodeClientSettings(stored);
636 expect(decoded).not.toHaveProperty("compactSidebarEnabled");
637 expect(decoded).not.toHaveProperty("sidebarCompactThreadRows");
638 expect(decodeClientSettingsPatch(stored)).toEqual({});
639 });
640
641 it("preserves an explicit legacy sidebar opt-in", () => {
642 expect(decodeClientSettings({ legacySidebarEnabled: true }).legacySidebarEnabled).toBe(true);
643 expect(decodeClientSettingsPatch({ legacySidebarEnabled: true }).legacySidebarEnabled).toBe(
644 true,
645 );
646 });
647
648 it("keeps unpin confirmation opt-in and patchable", () => {
649 expect(decodeClientSettings({}).confirmThreadUnpin).toBe(false);
650 expect(decodeClientSettingsPatch({ confirmThreadUnpin: true }).confirmThreadUnpin).toBe(true);
651 expect(() => decodeClientSettingsPatch({ confirmThreadUnpin: "yes" })).toThrow();
652 });
653});
654
655describe("ClientSettings context window meter", () => {
656 it("defaults off and preserves an explicit legacy opt-in", () => {
657 expect(decodeClientSettings({}).contextWindowMeterEnabled).toBe(false);
658 expect(
659 decodeClientSettings({ contextWindowMeterEnabled: true }).contextWindowMeterEnabled,
660 ).toBe(true);
661 expect(
662 decodeClientSettingsPatch({ contextWindowMeterEnabled: true }).contextWindowMeterEnabled,
663 ).toBe(true);
664 });
665});
666
667describe("ClientSettings send shortcut", () => {
668 it("defaults to Enter and validates the supported choices", () => {
669 expect(decodeClientSettings({}).sendShortcut).toBe("enter");
670 for (const sendShortcut of ["enter", "mod-enter-multiline", "mod-enter"]) {
671 expect(decodeClientSettings({ sendShortcut }).sendShortcut).toBe(sendShortcut);
672 expect(decodeClientSettingsPatch({ sendShortcut }).sendShortcut).toBe(sendShortcut);
673 }
674 expect(() => decodeClientSettingsPatch({ sendShortcut: "invalid" })).toThrow();
675 });
676});
677
678describe("ClientSettings follow-up behavior", () => {
679 it("defaults to queue and accepts either behavior", () => {
680 expect(decodeClientSettings({}).followUpBehavior).toBe("queue");
681 for (const followUpBehavior of ["queue", "steer"]) {
682 expect(decodeClientSettings({ followUpBehavior }).followUpBehavior).toBe(followUpBehavior);
683 expect(decodeClientSettingsPatch({ followUpBehavior }).followUpBehavior).toBe(
684 followUpBehavior,
685 );
686 }
687 expect(() => decodeClientSettingsPatch({ followUpBehavior: "invalid" })).toThrow();
688 });
689});
690
691describe("ClientSettings composer collapse", () => {
692 it("collapses on scroll by default and accepts opting out", () => {
693 expect(decodeClientSettings({}).composerCollapseOnScroll).toBe(true);
694 expect(
695 decodeClientSettingsPatch({ composerCollapseOnScroll: false }).composerCollapseOnScroll,
696 ).toBe(false);
697 });
698
699 it("drops the retired blur trigger key", () => {
700 const decoded = decodeClientSettings({ composerCollapseOnBlur: false });
701 expect(decoded.composerCollapseOnScroll).toBe(true);
702 expect(decoded).not.toHaveProperty("composerCollapseOnBlur");
703 });
704});
705
706describe("ServerSettings thread settlement", () => {
707 it("defaults merge settlement on and inactivity settlement to three days", () => {
708 const settings = decodeServerSettings({});
709 expect(settings.sidebarAutoSettleAfterDays).toBe(3);
710 expect(settings.sidebarAutoSettleOnMerge).toBe(true);
711 });
712
713 it("allows both automatic rules to be disabled", () => {
714 expect(
715 decodeServerSettings({
716 sidebarAutoSettleAfterDays: null,
717 sidebarAutoSettleOnMerge: false,
718 }),
719 ).toMatchObject({ sidebarAutoSettleAfterDays: null, sidebarAutoSettleOnMerge: false });
720 expect(
721 decodeServerSettingsPatch({
722 sidebarAutoSettleAfterDays: null,
723 sidebarAutoSettleOnMerge: false,
724 }),
725 ).toMatchObject({ sidebarAutoSettleAfterDays: null, sidebarAutoSettleOnMerge: false });
726 });
727
728 it.each([-1, 0, 91])("rejects an auto-settle threshold outside 1..90: %s", (value) => {
729 expect(() => decodeServerSettings({ sidebarAutoSettleAfterDays: value })).toThrow();
730 expect(() => decodeServerSettingsPatch({ sidebarAutoSettleAfterDays: value })).toThrow();
731 });
732});
733
734describe("ClientSettings pull request merge methods", () => {
735 it("defaults to no project overrides and accepts supported methods", () => {
736 expect(decodeClientSettings({}).pullRequestMergeMethodOverrides).toEqual({});
737 expect(
738 decodeClientSettingsPatch({
739 pullRequestMergeMethodOverrides: { project: "squash" },
740 }).pullRequestMergeMethodOverrides,
741 ).toEqual({ project: "squash" });
742 });
743
744 it("rejects unsupported project merge methods", () => {
745 expect(() =>
746 decodeClientSettingsPatch({
747 pullRequestMergeMethodOverrides: { project: "fast-forward" },
748 }),
749 ).toThrow();
750 });
751});
752
753describe("ServerSettings.providerInstances (slice-2 invariant)", () => {
754 it("defaults to an empty record so legacy configs without the key still decode", () => {
755 expect(DEFAULT_SERVER_SETTINGS.providerInstances).toEqual({});
756 });
757
758 it("decodes a fully empty config (legacy on-disk shape) without complaint", () => {
759 const decoded = decodeServerSettings({});
760 expect(decoded.providerInstances).toEqual({});
761 });
762
763 it("decodes a multi-instance map mixing first-party and fork drivers", () => {
764 const decoded = decodeServerSettings({
765 providerInstances: {
766 codex_personal: {
767 driver: "codex",
768 displayName: "Codex (personal)",
769 config: { homePath: "~/.codex_personal" },
770 },
771 codex_work: {
772 driver: "codex",
773 config: { homePath: "~/.codex_work" },
774 },
775 ollama_local: {
776 driver: "ollama",
777 displayName: "Ollama (local)",
778 config: { endpoint: "http://localhost:11434" },
779 },
780 },
781 });
782 const personalId = ProviderInstanceId.make("codex_personal");
783 const workId = ProviderInstanceId.make("codex_work");
784 const ollamaId = ProviderInstanceId.make("ollama_local");
785
786 expect(decoded.providerInstances[personalId]?.driver).toBe("codex");
787 expect(decoded.providerInstances[workId]?.config).toEqual({ homePath: "~/.codex_work" });
788 // Critical: a config naming a driver this build does not know about
789 // (`ollama` is not in `ProviderDriverKind`) must round-trip without loss.
790 // The runtime handles "driver not installed" — the schema must not.
791 expect(decoded.providerInstances[ollamaId]?.driver).toBe("ollama");
792 expect(decoded.providerInstances[ollamaId]?.config).toEqual({
793 endpoint: "http://localhost:11434",
794 });
795 });
796
797 it("rejects instance keys that violate the slug pattern", () => {
798 expect(() =>
799 decodeServerSettings({
800 providerInstances: { "1bad": { driver: "codex" } },
801 }),
802 ).toThrow();
803 });
804});
805
806describe("provider enabled defaults", () => {
807 it("keeps Muse disabled until a configured instance opts in", () => {
808 const muse = ProviderDriverKind.make("muse");
809 expect(resolveProviderInstanceEnabled({ driver: muse, config: {} })).toBe(false);
810 expect(resolveProviderInstanceEnabled({ driver: muse, enabled: true, config: {} })).toBe(true);
811 expect(
812 resolveProviderInstanceEnabled({ driver: muse, enabled: true, config: { enabled: false } }),
813 ).toBe(false);
814 });
815
816 it("enables only the stable bindings by default", () => {
817 const enabledByDefault = (driver: string) =>
818 resolveProviderInstanceEnabled({ driver: ProviderDriverKind.make(driver), config: {} });
819 expect(enabledByDefault("codex")).toBe(true);
820 expect(enabledByDefault("claudeAgent")).toBe(true);
821 for (const driver of ["cursor", "grok", "muse", "pi", "opencode", "antigravity"]) {
822 expect(enabledByDefault(driver)).toBe(false);
823 }
824 });
825
826 it("resolves instance enabled state with explicit false winning", () => {
827 const grok = ProviderDriverKind.make("grok");
828 const codex = ProviderDriverKind.make("codex");
829 // No flags anywhere: driver default applies.
830 expect(resolveProviderInstanceEnabled({ driver: grok, config: {} })).toBe(false);
831 expect(resolveProviderInstanceEnabled({ driver: codex, config: {} })).toBe(true);
832 // Unknown fork drivers stay enabled.
833 expect(
834 resolveProviderInstanceEnabled({ driver: ProviderDriverKind.make("ollama"), config: {} }),
835 ).toBe(true);
836 // Envelope flag wins over the driver default.
837 expect(resolveProviderInstanceEnabled({ driver: grok, enabled: true, config: {} })).toBe(true);
838 expect(resolveProviderInstanceEnabled({ driver: codex, enabled: false, config: {} })).toBe(
839 false,
840 );
841 // Legacy in-config flag fills in when the envelope is silent.
842 expect(resolveProviderInstanceEnabled({ driver: grok, config: { enabled: true } })).toBe(true);
843 // Conflicting flags: the explicit false wins, whichever side it is on.
844 expect(
845 resolveProviderInstanceEnabled({ driver: grok, enabled: true, config: { enabled: false } }),
846 ).toBe(false);
847 expect(
848 resolveProviderInstanceEnabled({ driver: codex, enabled: false, config: { enabled: true } }),
849 ).toBe(false);
850 });
851});
852
853describe("ServerSettings worktree defaults", () => {
854 it("defaults the thread env mode to inherit and keeps stored values", () => {
855 expect(decodeServerSettings({}).defaultThreadEnvMode).toBeNull();
856 expect(decodeServerSettings({ defaultThreadEnvMode: "worktree" }).defaultThreadEnvMode).toBe(
857 "worktree",
858 );
859 expect(
860 decodeServerSettings({ defaultThreadEnvMode: "remote" }).defaultThreadEnvMode,
861 ).toBeNull();
862 expect(
863 decodeServerSettingsPatch({ defaultThreadEnvMode: null }).defaultThreadEnvMode,
864 ).toBeNull();
865 });
866
867 it("keeps an inherited thread env mode off the wire for older clients", () => {
868 const encode = Schema.encodeSync(ServerSettings);
869 expect("defaultThreadEnvMode" in encode(decodeServerSettings({}))).toBe(false);
870 expect(
871 encode(decodeServerSettings({ defaultThreadEnvMode: "worktree" })).defaultThreadEnvMode,
872 ).toBe("worktree");
873 });
874
875 it("defaults start-from-origin on for legacy configs", () => {
876 expect(decodeServerSettings({}).newWorktreesStartFromOrigin).toBe(true);
877 });
878
879 it("accepts start-from-origin updates", () => {
880 expect(
881 decodeServerSettingsPatch({ newWorktreesStartFromOrigin: false }).newWorktreesStartFromOrigin,
882 ).toBe(false);
883 });
884
885 it("defaults worktree submodules to inherit and tolerates unknown modes", () => {
886 expect(decodeServerSettings({}).worktreeSubmodules).toBeNull();
887 expect(decodeServerSettings({ worktreeSubmodules: "top-level" }).worktreeSubmodules).toBe(
888 "top-level",
889 );
890 expect(decodeServerSettings({ worktreeSubmodules: "shallow" }).worktreeSubmodules).toBeNull();
891 expect(decodeServerSettingsPatch({ worktreeSubmodules: null }).worktreeSubmodules).toBeNull();
892 });
893});
894
895describe("ServerSettings.sourceControlWritingStyle", () => {
896 it("defaults all style settings for legacy configs", () => {
897 const settings = decodeServerSettings({});
898
899 expect(settings.sourceControlWritingStyle).toEqual({
900 mode: "repo_conventions",
901 customInstructions: "",
902 followChangeRequestTemplates: true,
903 });
904 expect(settings.sourceControlWriterModelSelection).toBeNull();
905 });
906
907 it("trims partial style updates", () => {
908 const patch = decodeServerSettingsPatch({
909 sourceControlWritingStyle: {
910 mode: "custom",
911 customInstructions: " Prefer concise wording. ",
912 },
913 });
914
915 expect(patch.sourceControlWritingStyle).toEqual({
916 mode: "custom",
917 customInstructions: "Prefer concise wording.",
918 });
919 });
920});
921
922describe("ServerSettingsPatch.providerInstances", () => {
923 it("treats providerInstances as an optional whole-map replacement", () => {
924 const patch = decodeServerSettingsPatch({});
925 expect(patch.providerInstances).toBeUndefined();
926
927 const replacement = decodeServerSettingsPatch({
928 providerInstances: {
929 codex_personal: { driver: "codex", config: { homePath: "~/.codex" } },
930 },
931 });
932 expect(replacement.providerInstances).toBeDefined();
933 expect(replacement.providerInstances?.[ProviderInstanceId.make("codex_personal")]?.driver).toBe(
934 "codex",
935 );
936 });
937
938 it("preserves a fork-defined driver entry through patch decoding", () => {
939 const patch = decodeServerSettingsPatch({
940 providerInstances: {
941 ollama_local: {
942 driver: "ollama",
943 config: { endpoint: "http://localhost:11434" },
944 },
945 },
946 });
947 const ollamaId = ProviderInstanceId.make("ollama_local");
948 expect(patch.providerInstances?.[ollamaId]?.driver).toBe("ollama");
949 });
950});
951
952describe("ServerSettingsPatch string normalization", () => {
953 it("trims string settings while decoding patches", () => {
954 const patch = decodeServerSettingsPatch({
955 addProjectBaseDirectory: " ~/Development ",
956 textGenerationModelSelection: { model: " gpt-5.4-mini " },
957 observability: {
958 otlpTracesUrl: " http://localhost:4318/v1/traces ",
959 },
960 providerInstances: {
961 codex_personal: {
962 driver: " codex ",
963 displayName: " Codex Personal ",
964 config: { homePath: " ~/.codex-personal " },
965 },
966 },
967 });
968
969 expect(patch.addProjectBaseDirectory).toBe("~/Development");
970 expect(patch.textGenerationModelSelection?.model).toBe("gpt-5.4-mini");
971 expect(patch.observability?.otlpTracesUrl).toBe("http://localhost:4318/v1/traces");
972 expect(patch.providerInstances?.[ProviderInstanceId.make("codex_personal")]?.driver).toBe(
973 "codex",
974 );
975 expect(patch.providerInstances?.[ProviderInstanceId.make("codex_personal")]?.displayName).toBe(
976 "Codex Personal",
977 );
978 expect(patch.providerInstances?.[ProviderInstanceId.make("codex_personal")]?.config).toEqual({
979 homePath: " ~/.codex-personal ",
980 });
981 });
982
983 it("trims encoded server settings values before validation", () => {
984 const defaultSettings = decodeServerSettings({});
985 const encoded = encodeServerSettings({
986 ...defaultSettings,
987 addProjectBaseDirectory: " ~/Development ",
988 });
989
990 expect(encoded.addProjectBaseDirectory).toBe("~/Development");
991 });
992});
993
994describe("ServerSettings environment icon", () => {
995 it("defaults to null", () => {
996 expect(decodeServerSettings({}).environmentIcon).toBeNull();
997 });
998
999 it("keeps a kind this build knows", () => {
1000 expect(decodeServerSettings({ environmentIcon: "mac-mini" }).environmentIcon).toBe("mac-mini");
1001 expect(decodeServerSettings({ environmentIcon: "linux" }).environmentIcon).toBe("linux");
1002 });
1003
1004 it("decodes a kind from a newer server as null instead of failing the snapshot", () => {
1005 expect(decodeServerSettings({ environmentIcon: "toaster" }).environmentIcon).toBeNull();
1006 });
1007
1008 it("round-trips through encode", () => {
1009 const settings = decodeServerSettings({ environmentIcon: "laptop" });
1010 expect(encodeServerSettings(settings).environmentIcon).toBe("laptop");
1011
1012 const linuxSettings = decodeServerSettings({ environmentIcon: "linux" });
1013 expect(encodeServerSettings(linuxSettings).environmentIcon).toBe("linux");
1014 });
1015});
1016
1017const decodeDeviceHostSettings = Schema.decodeSync(ServerSettings);
1018
1019it("validates remote device hosts and rejects ambiguous host ids", () => {
1020 const host = { id: "mini", label: "Mac mini", target: "user@mini", port: 2222 };
1021 expect(decodeDeviceHostSettings({ deviceHosts: [host] }).deviceHosts).toEqual([host]);
1022 expect(() => decodeDeviceHostSettings({ deviceHosts: [host, host] })).toThrow();
1023 expect(() => decodeDeviceHostSettings({ deviceHosts: [{ ...host, id: "local" }] })).toThrow();
1024 expect(() =>
1025 decodeDeviceHostSettings({ deviceHosts: [{ ...host, target: "-oProxyCommand=bad" }] }),
1026 ).toThrow();
1027 expect(() => decodeDeviceHostSettings({ deviceHosts: [{ ...host, port: 0 }] })).toThrow();
1028});
1029
1030describe("branch naming settings", () => {
1031 it("defaults existing settings to the t3 static prefix", () => {
1032 expect(decodeServerSettings({})).toMatchObject({
1033 branchNamingMode: "static",
1034 branchNamePrefix: "t3",
1035 branchNameInstructions: "",
1036 });
1037 });
1038 it.each(["static", "semantic", "custom"])(
1039 "round-trips %s and project overrides",
1040 (branchNamingMode) => {
1041 const naming = {
1042 branchNamingMode,
1043 branchNamePrefix: "team/",
1044 branchNameInstructions: "Include the issue ID.",
1045 };
1046 const input = { ...naming, projectSettingsOverrides: { project: naming } };
1047 expect(encodeServerSettings(decodeServerSettings(input))).toMatchObject(input);
1048 expect(decodeServerSettingsPatch(input)).toEqual(input);
1049 },
1050 );
1051});
1052
1053describe("ServerSettings.removeAgentCreditsOnMerge", () => {
1054 it("keeps agent credits by default and accepts opt-in patches", () => {
1055 expect(decodeServerSettings({}).removeAgentCreditsOnMerge).toBe(false);
1056 expect(
1057 decodeServerSettingsPatch({ removeAgentCreditsOnMerge: true }).removeAgentCreditsOnMerge,
1058 ).toBe(true);
1059 expect(
1060 decodeServerSettings({
1061 projectSettingsOverrides: { project: { removeAgentCreditsOnMerge: true } },
1062 }).projectSettingsOverrides["project" as ProjectId]?.removeAgentCreditsOnMerge,
1063 ).toBe(true);
1064 });
1065});
1066
1067describe("resolveProjectProviderInstanceEnabled", () => {
1068 const projectId = "project-a" as ProjectId;
1069 const instanceId = ProviderInstanceId.make("codex_work");
1070
1071 it("inherits the machine value when the project has no override", () => {
1072 const settings: ServerSettings = {
1073 ...DEFAULT_SERVER_SETTINGS,
1074 providerInstances: {
1075 [instanceId]: { driver: ProviderDriverKind.make("codex"), enabled: false },
1076 },
1077 };
1078 expect(resolveProjectProviderInstanceEnabled(settings, projectId, instanceId)).toBe(false);
1079 });
1080
1081 it("lets a project enable an instance the machine disabled", () => {
1082 const settings: ServerSettings = {
1083 ...DEFAULT_SERVER_SETTINGS,
1084 providerInstances: {
1085 [instanceId]: { driver: ProviderDriverKind.make("codex"), enabled: false },
1086 },
1087 projectSettingsOverrides: {
1088 [projectId]: { providerInstances: { [instanceId]: { enabled: true } } },
1089 },
1090 };
1091 expect(resolveProjectProviderInstanceEnabled(settings, projectId, instanceId)).toBe(true);
1092 });
1093
1094 it("lets a project disable an instance the machine enabled", () => {
1095 const settings: ServerSettings = {
1096 ...DEFAULT_SERVER_SETTINGS,
1097 providerInstances: {
1098 [instanceId]: { driver: ProviderDriverKind.make("codex"), enabled: true },
1099 },
1100 projectSettingsOverrides: {
1101 [projectId]: { providerInstances: { [instanceId]: { enabled: false } } },
1102 },
1103 };
1104 expect(resolveProjectProviderInstanceEnabled(settings, projectId, instanceId)).toBe(false);
1105 });
1106
1107 it("always resolves to the machine value when no project is in scope", () => {
1108 const settings: ServerSettings = {
1109 ...DEFAULT_SERVER_SETTINGS,
1110 providerInstances: {
1111 [instanceId]: { driver: ProviderDriverKind.make("codex"), enabled: true },
1112 },
1113 projectSettingsOverrides: {
1114 [projectId]: { providerInstances: { [instanceId]: { enabled: false } } },
1115 },
1116 };
1117 expect(resolveProjectProviderInstanceEnabled(settings, null, instanceId)).toBe(true);
1118 });
1119
1120 it("falls back to the unconfigured default when the instance has no settings entry", () => {
1121 const settings: ServerSettings = { ...DEFAULT_SERVER_SETTINGS, providerInstances: {} };
1122 // `codex_work` has no entry in `providerInstances`, so with no project
1123 // override either, this is the same unconfigured-default fallback a
1124 // machine-wide (no project) lookup would use.
1125 expect(resolveProjectProviderInstanceEnabled(settings, projectId, instanceId)).toBe(
1126 resolveProjectProviderInstanceEnabled(settings, null, instanceId),
1127 );
1128
1129 const overridden = {
1130 ...settings,
1131 projectSettingsOverrides: {
1132 [projectId]: { providerInstances: { [instanceId]: { enabled: true } } },
1133 },
1134 };
1135 expect(resolveProjectProviderInstanceEnabled(overridden, projectId, instanceId)).toBe(true);
1136 });
1137});
1138
1139describe("requiredScopesForProjectMutation", () => {
1140 it("adds the settings scope only when a mutation carries scripts", () => {
1141 const projectId = "project-1" as ProjectId;
1142 const commandId = "command-1" as CommandId;
1143 expect(
1144 requiredScopesForProjectMutation({ type: "project.update", commandId, projectId }),
1145 ).toEqual(["orchestration:operate"]);
1146 expect(
1147 requiredScopesForProjectMutation({
1148 type: "project.update",
1149 commandId,
1150 projectId,
1151 scripts: [],
1152 }),
1153 ).toEqual(["orchestration:operate", "settings:write"]);
1154 });
1155});
1156
1157describe("server model preferences", () => {
1158 it("decodes a visibility update scoped to a provider instance and model", () => {
1159 const patch = { setModelsHidden: [{ provider: "codex_work", model: "sol", hidden: false }] };
1160 expect(decodeServerSettingsPatch(patch)).toEqual(patch);
1161 expect(() =>
1162 decodeServerSettingsPatch({ setModelsHidden: [{ provider: "codex_work", model: "sol" }] }),
1163 ).toThrow();
1164 });
1165 it("distinguishes unmigrated lists from deliberately cleared lists", () => {
1166 expect(decodeServerSettings({})).toMatchObject({
1167 favorites: null,
1168 providerModelPreferences: null,
1169 });
1170 const input = { favorites: [], providerModelPreferences: {} };
1171 expect(encodeServerSettings(decodeServerSettings(input))).toMatchObject(input);
1172 expect(decodeServerSettingsPatch(input)).toEqual(input);
1173 });
1174
1175 it("round trips favorites and hidden models keyed by provider instance", () => {
1176 const input = {
1177 favorites: [{ provider: "codex_work", model: "sol" }],
1178 providerModelPreferences: { codex_work: { hiddenModels: ["astra"], modelOrder: ["sol"] } },
1179 };
1180 expect(encodeServerSettings(decodeServerSettings(input))).toMatchObject(input);
1181 expect(decodeServerSettingsPatch(input)).toEqual(input);
1182 expect(decodeServerSettingsPatch({ migrateModelPreferences: input })).toEqual({
1183 migrateModelPreferences: input,
1184 });
1185 });
1186});