Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2import * as Schema from "effect/Schema";
3
4import { ProviderDriverKind, ProviderInstanceId } from "./providerInstance.ts";
5import {
6 ClientSettingsSchema,
7 ClientSettingsPatch,
8 ClaudeSettings,
9 DEFAULT_SERVER_SETTINGS,
10 resolveProviderInstanceEnabled,
11 ServerSettings,
12 ServerSettingsPatch,
13} from "./settings.ts";
14
15const decodeClientSettings = Schema.decodeUnknownSync(ClientSettingsSchema);
16const decodeClientSettingsPatch = Schema.decodeUnknownSync(ClientSettingsPatch);
17const encodeClientSettings = Schema.encodeSync(ClientSettingsSchema);
18const decodeServerSettings = Schema.decodeUnknownSync(ServerSettings);
19const decodeServerSettingsPatch = Schema.decodeUnknownSync(ServerSettingsPatch);
20const encodeServerSettings = Schema.encodeSync(ServerSettings);
21const decodeClaudeSettings = Schema.decodeUnknownSync(ClaudeSettings);
22
23describe("ServerSettings usage price overrides", () => {
24 const prices = { inputCostPerMillionTokens: 2, outputCostPerMillionTokens: 8 };
25
26 it("defaults to automatic pricing and round-trips arbitrary model IDs", () => {
27 expect(decodeServerSettings({}).usagePriceOverrides).toEqual({});
28 const settings = decodeServerSettings({
29 usagePriceOverrides: { " vendor/example-model ": prices },
30 });
31 expect(encodeServerSettings(settings).usagePriceOverrides).toEqual({
32 "vendor/example-model": prices,
33 });
34 });
35
36 it("accepts zero rates, optional cache rates, and per-model deletion", () => {
37 const overrides = {
38 "example-model": {
39 inputCostPerMillionTokens: 0,
40 outputCostPerMillionTokens: 0,
41 cacheReadCostPerMillionTokens: 0.5,
42 cacheWriteCostPerMillionTokens: 3,
43 },
44 "removed-model": null,
45 };
46 expect(
47 decodeServerSettingsPatch({ usagePriceOverrides: overrides }).usagePriceOverrides,
48 ).toEqual(overrides);
49 });
50
51 it.each([
52 "inputCostPerMillionTokens",
53 "outputCostPerMillionTokens",
54 "cacheReadCostPerMillionTokens",
55 "cacheWriteCostPerMillionTokens",
56 ])("rejects invalid %s rates at the settings boundary", (field) => {
57 for (const value of [-1, Number.NaN, Number.POSITIVE_INFINITY, "2"]) {
58 const usagePriceOverrides = { "example-model": { ...prices, [field]: value } };
59 expect(() => decodeServerSettings({ usagePriceOverrides })).toThrow();
60 expect(() => decodeServerSettingsPatch({ usagePriceOverrides })).toThrow();
61 }
62 });
63
64 it("rejects empty model IDs and incomplete input/output pricing", () => {
65 for (const usagePriceOverrides of [
66 { " ": prices },
67 { "example-model": { inputCostPerMillionTokens: 2 } },
68 { "example-model": { outputCostPerMillionTokens: 8 } },
69 ]) {
70 expect(() => decodeServerSettingsPatch({ usagePriceOverrides })).toThrow();
71 }
72 });
73});
74
75describe("custom model settings", () => {
76 const capabilities = {
77 optionDescriptors: [
78 {
79 id: "effort",
80 label: "Reasoning",
81 type: "select",
82 options: [{ id: "high", label: "High", isDefault: true }],
83 },
84 ],
85 };
86
87 it("accepts legacy bare slugs alongside full entries", () => {
88 const decoded = decodeClaudeSettings({
89 customModels: ["bare-slug", { slug: "named", name: "Named", capabilities }],
90 });
91 expect(decoded.customModels).toEqual([
92 "bare-slug",
93 { slug: "named", name: "Named", capabilities },
94 ]);
95 });
96
97 it("accepts entries at the settings patch boundary", () => {
98 expect(
99 decodeServerSettingsPatch({
100 providers: { codex: { customModels: [{ slug: "x", capabilities }] } },
101 }).providers?.codex?.customModels,
102 ).toEqual([{ slug: "x", capabilities }]);
103 expect(() =>
104 decodeServerSettingsPatch({ providers: { codex: { customModels: [{ name: "no slug" }] } } }),
105 ).toThrow();
106 });
107});
108
109describe("ClaudeSettings auto-compaction", () => {
110 it("uses Claude's default threshold when no override is configured", () => {
111 expect(decodeClaudeSettings({}).autoCompactWindow).toBe("");
112 });
113
114 it.each(["100000", "300000", "1000000"])(
115 "accepts a supported auto-compaction threshold: %s",
116 (value) => {
117 expect(decodeClaudeSettings({ autoCompactWindow: value }).autoCompactWindow).toBe(value);
118 },
119 );
120
121 it.each(["99999", "1000001", "300k", "invalid"])(
122 "rejects an unsupported auto-compaction threshold: %s",
123 (value) => {
124 expect(() => decodeClaudeSettings({ autoCompactWindow: value })).toThrow();
125 },
126 );
127
128 it("rejects an unsupported threshold at the settings patch boundary", () => {
129 expect(() =>
130 decodeServerSettingsPatch({ providers: { claudeAgent: { autoCompactWindow: "300k" } } }),
131 ).toThrow();
132 expect(
133 decodeServerSettingsPatch({ providers: { claudeAgent: { autoCompactWindow: "300000" } } }),
134 ).toBeDefined();
135 });
136});
137
138describe("ClientSettings word wrap", () => {
139 it("defaults word wrap on", () => {
140 expect(decodeClientSettings({}).wordWrap).toBe(true);
141 });
142
143 it("ignores obsolete wrapping preferences", () => {
144 const decoded = decodeClientSettings({
145 chatWordWrap: false,
146 diffWordWrap: false,
147 });
148
149 expect(decoded.wordWrap).toBe(true);
150 expect(decoded).not.toHaveProperty("chatWordWrap");
151 expect(decoded).not.toHaveProperty("diffWordWrap");
152 });
153});
154
155describe("ClientSettings proactive panels", () => {
156 it("is opt-in and accepts client-local updates", () => {
157 expect(decodeClientSettings({}).proactivePanelsEnabled).toBe(false);
158 expect(decodeClientSettingsPatch({ proactivePanelsEnabled: true }).proactivePanelsEnabled).toBe(
159 true,
160 );
161 });
162});
163
164describe("ClientSettings quit confirmation", () => {
165 it("defaults to hold", () => {
166 expect(decodeClientSettings({}).confirmQuit).toBe("hold");
167 });
168
169 it.each(["direct", "hold", "double-click"] as const)("accepts the %s mode", (mode) => {
170 expect(decodeClientSettings({ confirmQuit: mode }).confirmQuit).toBe(mode);
171 expect(decodeClientSettingsPatch({ confirmQuit: mode }).confirmQuit).toBe(mode);
172 });
173
174 it.each([
175 [true, "hold"],
176 [false, "direct"],
177 ] as const)("migrates the legacy %s value to %s", (legacyValue, mode) => {
178 const settings = decodeClientSettings({ confirmQuit: legacyValue });
179
180 expect(settings.confirmQuit).toBe(mode);
181 expect(encodeClientSettings(settings).confirmQuit).toBe(mode);
182 });
183
184 it("rejects legacy booleans at the patch boundary", () => {
185 expect(() => decodeClientSettingsPatch({ confirmQuit: true })).toThrow();
186 });
187});
188
189describe("ClientSettings browser recording frame rate", () => {
190 it("defaults to 30 fps", () => {
191 expect(decodeClientSettings({}).browserRecordingFrameRate).toBe(30);
192 });
193
194 it.each([30, 60])("accepts a supported frame rate: %s", (frameRate) => {
195 expect(
196 decodeClientSettings({ browserRecordingFrameRate: frameRate }).browserRecordingFrameRate,
197 ).toBe(frameRate);
198 expect(
199 decodeClientSettingsPatch({ browserRecordingFrameRate: frameRate }).browserRecordingFrameRate,
200 ).toBe(frameRate);
201 });
202
203 it.each([24, 59, 120])("rejects an unsupported frame rate: %s", (frameRate) => {
204 expect(() => decodeClientSettings({ browserRecordingFrameRate: frameRate })).toThrow();
205 expect(() => decodeClientSettingsPatch({ browserRecordingFrameRate: frameRate })).toThrow();
206 });
207});
208
209describe("ClientSettings glass opacity", () => {
210 it("defaults to a readable translucent surface", () => {
211 expect(decodeClientSettings({}).glassOpacity).toBe(80);
212 });
213
214 it.each([39, 101, 72.5])("rejects an invalid glass opacity: %s", (value) => {
215 expect(() => decodeClientSettings({ glassOpacity: value })).toThrow();
216 expect(() => decodeClientSettingsPatch({ glassOpacity: value })).toThrow();
217 });
218
219 it.each([40, 75, 100])("accepts a glass opacity within the supported range: %s", (value) => {
220 expect(decodeClientSettings({ glassOpacity: value }).glassOpacity).toBe(value);
221 expect(decodeClientSettingsPatch({ glassOpacity: value }).glassOpacity).toBe(value);
222 });
223});
224
225describe("ClientSettings appearance contrast", () => {
226 it("defaults to the theme's original contrast", () => {
227 expect(decodeClientSettings({}).appearanceContrast).toBe(100);
228 });
229
230 it.each([49, 201, 92.5])("rejects an invalid appearance contrast: %s", (value) => {
231 expect(() => decodeClientSettings({ appearanceContrast: value })).toThrow();
232 expect(() => decodeClientSettingsPatch({ appearanceContrast: value })).toThrow();
233 });
234
235 it.each([50, 100, 150, 200])("accepts an appearance contrast in range: %s", (value) => {
236 expect(decodeClientSettings({ appearanceContrast: value }).appearanceContrast).toBe(value);
237 expect(decodeClientSettingsPatch({ appearanceContrast: value }).appearanceContrast).toBe(value);
238 });
239});
240
241describe("ClientSettings panel animations", () => {
242 it("defaults to instant changes", () => {
243 expect(decodeClientSettings({}).panelAnimationDurationMs).toBe(0);
244 });
245
246 it.each([0, 400])("accepts a panel animation duration: %s", (value) => {
247 expect(decodeClientSettingsPatch({ panelAnimationDurationMs: value })).toEqual({
248 panelAnimationDurationMs: value,
249 });
250 });
251
252 it.each([-1, 401, 150.5])("rejects an invalid panel animation duration: %s", (value) => {
253 expect(() => decodeClientSettingsPatch({ panelAnimationDurationMs: value })).toThrow();
254 });
255});
256
257describe("ClientSettings environment identification", () => {
258 it("defaults to artwork and accepts each presentation mode", () => {
259 expect(decodeClientSettings({}).environmentIdentificationMode).toBe("artwork");
260
261 for (const mode of ["artwork", "pill", "none"] as const) {
262 expect(
263 decodeClientSettingsPatch({ environmentIdentificationMode: mode })
264 .environmentIdentificationMode,
265 ).toBe(mode);
266 }
267 });
268
269 it("rejects unsupported presentation modes", () => {
270 expect(() => decodeClientSettings({ environmentIdentificationMode: "badge" })).toThrow();
271 expect(() => decodeClientSettingsPatch({ environmentIdentificationMode: "badge" })).toThrow();
272 });
273});
274
275describe("ClientSettings sidebar", () => {
276 it("defaults to the current sidebar", () => {
277 expect(decodeClientSettings({}).legacySidebarEnabled).toBe(false);
278 });
279
280 it("drops the retired sidebar v2 beta keys, resetting everyone to the default", () => {
281 const decoded = decodeClientSettings({
282 sidebarV2Enabled: false,
283 sidebarV2ConfiguredByUser: true,
284 });
285 expect(decoded.legacySidebarEnabled).toBe(false);
286 expect(decoded).not.toHaveProperty("sidebarV2Enabled");
287 expect(decoded).not.toHaveProperty("sidebarV2ConfiguredByUser");
288 });
289
290 it("preserves an explicit legacy sidebar opt-in", () => {
291 expect(decodeClientSettings({ legacySidebarEnabled: true }).legacySidebarEnabled).toBe(true);
292 expect(decodeClientSettingsPatch({ legacySidebarEnabled: true }).legacySidebarEnabled).toBe(
293 true,
294 );
295 });
296
297 it("keeps unpin confirmation opt-in and patchable", () => {
298 expect(decodeClientSettings({}).confirmThreadUnpin).toBe(false);
299 expect(decodeClientSettingsPatch({ confirmThreadUnpin: true }).confirmThreadUnpin).toBe(true);
300 expect(() => decodeClientSettingsPatch({ confirmThreadUnpin: "yes" })).toThrow();
301 });
302});
303
304describe("ClientSettings context window meter", () => {
305 it("defaults off and preserves an explicit legacy opt-in", () => {
306 expect(decodeClientSettings({}).contextWindowMeterEnabled).toBe(false);
307 expect(
308 decodeClientSettings({ contextWindowMeterEnabled: true }).contextWindowMeterEnabled,
309 ).toBe(true);
310 expect(
311 decodeClientSettingsPatch({ contextWindowMeterEnabled: true }).contextWindowMeterEnabled,
312 ).toBe(true);
313 });
314});
315
316describe("ClientSettings composer collapse", () => {
317 it("collapses on blur and scroll by default and accepts opting out of each", () => {
318 const defaults = decodeClientSettings({});
319 expect(defaults.composerCollapseOnBlur).toBe(true);
320 expect(defaults.composerCollapseOnScroll).toBe(true);
321
322 const blurOff = decodeClientSettings({ composerCollapseOnBlur: false });
323 expect(blurOff.composerCollapseOnBlur).toBe(false);
324 expect(blurOff.composerCollapseOnScroll).toBe(true);
325
326 expect(
327 decodeClientSettingsPatch({ composerCollapseOnScroll: false }).composerCollapseOnScroll,
328 ).toBe(false);
329 });
330});
331
332describe("ServerSettings thread settlement", () => {
333 it("defaults merge settlement on and inactivity settlement to three days", () => {
334 const settings = decodeServerSettings({});
335 expect(settings.sidebarAutoSettleAfterDays).toBe(3);
336 expect(settings.sidebarAutoSettleOnMerge).toBe(true);
337 });
338
339 it("allows both automatic rules to be disabled", () => {
340 expect(
341 decodeServerSettings({
342 sidebarAutoSettleAfterDays: null,
343 sidebarAutoSettleOnMerge: false,
344 }),
345 ).toMatchObject({ sidebarAutoSettleAfterDays: null, sidebarAutoSettleOnMerge: false });
346 expect(
347 decodeServerSettingsPatch({
348 sidebarAutoSettleAfterDays: null,
349 sidebarAutoSettleOnMerge: false,
350 }),
351 ).toMatchObject({ sidebarAutoSettleAfterDays: null, sidebarAutoSettleOnMerge: false });
352 });
353
354 it.each([-1, 0, 91])("rejects an auto-settle threshold outside 1..90: %s", (value) => {
355 expect(() => decodeServerSettings({ sidebarAutoSettleAfterDays: value })).toThrow();
356 expect(() => decodeServerSettingsPatch({ sidebarAutoSettleAfterDays: value })).toThrow();
357 });
358});
359
360describe("ServerSettings.providerInstances (slice-2 invariant)", () => {
361 it("defaults text generation to Luna at low reasoning effort", () => {
362 expect(DEFAULT_SERVER_SETTINGS.textGenerationModelSelection).toEqual({
363 instanceId: ProviderInstanceId.make("codex"),
364 model: "gpt-5.6-luna",
365 options: [{ id: "reasoningEffort", value: "low" }],
366 });
367 });
368
369 it("defaults to an empty record so legacy configs without the key still decode", () => {
370 expect(DEFAULT_SERVER_SETTINGS.providerInstances).toEqual({});
371 });
372
373 it("decodes a fully empty config (legacy on-disk shape) without complaint", () => {
374 const decoded = decodeServerSettings({});
375 expect(decoded.providerInstances).toEqual({});
376 // Legacy `providers` struct is still hydrated with its per-driver defaults
377 // so existing call sites keep working through the migration.
378 expect(decoded.providers.codex.enabled).toBe(true);
379 });
380
381 it("decodes a multi-instance map mixing first-party and fork drivers", () => {
382 const decoded = decodeServerSettings({
383 providerInstances: {
384 codex_personal: {
385 driver: "codex",
386 displayName: "Codex (personal)",
387 config: { homePath: "~/.codex_personal" },
388 },
389 codex_work: {
390 driver: "codex",
391 config: { homePath: "~/.codex_work" },
392 },
393 ollama_local: {
394 driver: "ollama",
395 displayName: "Ollama (local)",
396 config: { endpoint: "http://localhost:11434" },
397 },
398 },
399 });
400 const personalId = ProviderInstanceId.make("codex_personal");
401 const workId = ProviderInstanceId.make("codex_work");
402 const ollamaId = ProviderInstanceId.make("ollama_local");
403
404 expect(decoded.providerInstances[personalId]?.driver).toBe("codex");
405 expect(decoded.providerInstances[workId]?.config).toEqual({ homePath: "~/.codex_work" });
406 // Critical: a config naming a driver this build does not know about
407 // (`ollama` is not in `ProviderDriverKind`) must round-trip without loss.
408 // The runtime handles "driver not installed" — the schema must not.
409 expect(decoded.providerInstances[ollamaId]?.driver).toBe("ollama");
410 expect(decoded.providerInstances[ollamaId]?.config).toEqual({
411 endpoint: "http://localhost:11434",
412 });
413 });
414
415 it("rejects instance keys that violate the slug pattern", () => {
416 expect(() =>
417 decodeServerSettings({
418 providerInstances: { "1bad": { driver: "codex" } },
419 }),
420 ).toThrow();
421 });
422});
423
424describe("provider enabled defaults", () => {
425 it("enables only the stable bindings by default", () => {
426 const decoded = decodeServerSettings({});
427 expect(decoded.providers.codex.enabled).toBe(true);
428 expect(decoded.providers.claudeAgent.enabled).toBe(true);
429 expect(decoded.providers.cursor.enabled).toBe(false);
430 expect(decoded.providers.grok.enabled).toBe(false);
431 expect(decoded.providers.opencode.enabled).toBe(false);
432 });
433
434 it("keeps Cursor enabled when an existing user explicitly opted in", () => {
435 const cursor = ProviderDriverKind.make("cursor");
436 const cursorId = ProviderInstanceId.make("cursor");
437 const decoded = decodeServerSettings({
438 providers: { cursor: { enabled: true } },
439 providerInstances: {
440 [cursorId]: { driver: cursor, enabled: true, config: {} },
441 },
442 });
443
444 expect(decoded.providers.cursor.enabled).toBe(true);
445 expect(resolveProviderInstanceEnabled(decoded.providerInstances[cursorId]!)).toBe(true);
446 });
447
448 it("resolves instance enabled state with explicit false winning", () => {
449 const grok = ProviderDriverKind.make("grok");
450 const codex = ProviderDriverKind.make("codex");
451 // No flags anywhere: driver default applies.
452 expect(resolveProviderInstanceEnabled({ driver: grok, config: {} })).toBe(false);
453 expect(resolveProviderInstanceEnabled({ driver: codex, config: {} })).toBe(true);
454 // Unknown fork drivers stay enabled.
455 expect(
456 resolveProviderInstanceEnabled({ driver: ProviderDriverKind.make("ollama"), config: {} }),
457 ).toBe(true);
458 // Envelope flag wins over the driver default.
459 expect(resolveProviderInstanceEnabled({ driver: grok, enabled: true, config: {} })).toBe(true);
460 expect(resolveProviderInstanceEnabled({ driver: codex, enabled: false, config: {} })).toBe(
461 false,
462 );
463 // Legacy in-config flag fills in when the envelope is silent.
464 expect(resolveProviderInstanceEnabled({ driver: grok, config: { enabled: true } })).toBe(true);
465 // Conflicting flags: the explicit false wins, whichever side it is on.
466 expect(
467 resolveProviderInstanceEnabled({ driver: grok, enabled: true, config: { enabled: false } }),
468 ).toBe(false);
469 expect(
470 resolveProviderInstanceEnabled({ driver: codex, enabled: false, config: { enabled: true } }),
471 ).toBe(false);
472 });
473});
474
475describe("ServerSettings worktree defaults", () => {
476 it("defaults start-from-origin on for legacy configs", () => {
477 expect(decodeServerSettings({}).newWorktreesStartFromOrigin).toBe(true);
478 });
479
480 it("accepts start-from-origin updates", () => {
481 expect(
482 decodeServerSettingsPatch({ newWorktreesStartFromOrigin: false }).newWorktreesStartFromOrigin,
483 ).toBe(false);
484 });
485});
486
487describe("ServerSettings.sourceControlWritingStyle", () => {
488 it("defaults all style settings for legacy configs", () => {
489 const settings = decodeServerSettings({});
490
491 expect(settings.sourceControlWritingStyle).toEqual({
492 mode: "repo_conventions",
493 customInstructions: "",
494 followChangeRequestTemplates: true,
495 });
496 expect(settings.sourceControlWriterModelSelection).toBeNull();
497 });
498
499 it("trims partial style updates", () => {
500 const patch = decodeServerSettingsPatch({
501 sourceControlWritingStyle: {
502 mode: "custom",
503 customInstructions: " Prefer concise wording. ",
504 },
505 });
506
507 expect(patch.sourceControlWritingStyle).toEqual({
508 mode: "custom",
509 customInstructions: "Prefer concise wording.",
510 });
511 });
512});
513
514describe("ServerSettingsPatch.providerInstances", () => {
515 it("treats providerInstances as an optional whole-map replacement", () => {
516 const patch = decodeServerSettingsPatch({});
517 expect(patch.providerInstances).toBeUndefined();
518
519 const replacement = decodeServerSettingsPatch({
520 providerInstances: {
521 codex_personal: { driver: "codex", config: { homePath: "~/.codex" } },
522 },
523 });
524 expect(replacement.providerInstances).toBeDefined();
525 expect(replacement.providerInstances?.[ProviderInstanceId.make("codex_personal")]?.driver).toBe(
526 "codex",
527 );
528 });
529
530 it("preserves a fork-defined driver entry through patch decoding", () => {
531 const patch = decodeServerSettingsPatch({
532 providerInstances: {
533 ollama_local: {
534 driver: "ollama",
535 config: { endpoint: "http://localhost:11434" },
536 },
537 },
538 });
539 const ollamaId = ProviderInstanceId.make("ollama_local");
540 expect(patch.providerInstances?.[ollamaId]?.driver).toBe("ollama");
541 });
542});
543
544describe("ServerSettingsPatch string normalization", () => {
545 it("trims string settings while decoding patches", () => {
546 const patch = decodeServerSettingsPatch({
547 addProjectBaseDirectory: " ~/Development ",
548 textGenerationModelSelection: { model: " gpt-5.4-mini " },
549 observability: {
550 otlpTracesUrl: " http://localhost:4318/v1/traces ",
551 },
552 providers: {
553 codex: {
554 binaryPath: " /opt/homebrew/bin/codex ",
555 homePath: " ~/.codex ",
556 launchArgs: " --strict-config --enable foo ",
557 },
558 },
559 providerInstances: {
560 codex_personal: {
561 driver: " codex ",
562 displayName: " Codex Personal ",
563 config: { homePath: " ~/.codex-personal " },
564 },
565 },
566 });
567
568 expect(patch.addProjectBaseDirectory).toBe("~/Development");
569 expect(patch.textGenerationModelSelection?.model).toBe("gpt-5.4-mini");
570 expect(patch.observability?.otlpTracesUrl).toBe("http://localhost:4318/v1/traces");
571 expect(patch.providers?.codex?.binaryPath).toBe("/opt/homebrew/bin/codex");
572 expect(patch.providers?.codex?.homePath).toBe("~/.codex");
573 expect(patch.providers?.codex?.launchArgs).toBe("--strict-config --enable foo");
574 expect(patch.providerInstances?.[ProviderInstanceId.make("codex_personal")]?.driver).toBe(
575 "codex",
576 );
577 expect(patch.providerInstances?.[ProviderInstanceId.make("codex_personal")]?.displayName).toBe(
578 "Codex Personal",
579 );
580 expect(patch.providerInstances?.[ProviderInstanceId.make("codex_personal")]?.config).toEqual({
581 homePath: " ~/.codex-personal ",
582 });
583 });
584
585 it("trims encoded server settings values before validation", () => {
586 const defaultSettings = decodeServerSettings({});
587 const encoded = encodeServerSettings({
588 ...defaultSettings,
589 addProjectBaseDirectory: " ~/Development ",
590 providers: {
591 ...defaultSettings.providers,
592 codex: {
593 ...defaultSettings.providers.codex,
594 binaryPath: " /opt/homebrew/bin/codex ",
595 launchArgs: " --strict-config ",
596 },
597 },
598 });
599
600 expect(encoded.addProjectBaseDirectory).toBe("~/Development");
601 expect(encoded.providers?.codex?.binaryPath).toBe("/opt/homebrew/bin/codex");
602 expect(encoded.providers?.codex?.launchArgs).toBe("--strict-config");
603 });
604});
605
606describe("ServerSettings environment icon", () => {
607 it("defaults to null", () => {
608 expect(decodeServerSettings({}).environmentIcon).toBeNull();
609 });
610
611 it("keeps a kind this build knows", () => {
612 expect(decodeServerSettings({ environmentIcon: "mac-mini" }).environmentIcon).toBe("mac-mini");
613 });
614
615 it("decodes a kind from a newer server as null instead of failing the snapshot", () => {
616 expect(decodeServerSettings({ environmentIcon: "toaster" }).environmentIcon).toBeNull();
617 });
618
619 it("round-trips through encode", () => {
620 const settings = decodeServerSettings({ environmentIcon: "laptop" });
621 expect(encodeServerSettings(settings).environmentIcon).toBe("laptop");
622 });
623});