Open History to see the last commit
1import {
2 DesktopServerExposureModeSchema,
3 DesktopUpdateChannelSchema,
4 type DesktopServerExposureMode,
5 type DesktopUpdateChannel,
6} from "@t3tools/contracts";
7import { fromLenientJson } from "@t3tools/shared/schemaJson";
8import * as Context from "effect/Context";
9import * as Crypto from "effect/Crypto";
10import * as Effect from "effect/Effect";
11import * as FileSystem from "effect/FileSystem";
12import * as Layer from "effect/Layer";
13import * as Option from "effect/Option";
14import * as Path from "effect/Path";
15import * as Schema from "effect/Schema";
16import * as SynchronizedRef from "effect/SynchronizedRef";
17
18import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
19import {
20 DEFAULT_LINUX_PASSWORD_STORE,
21 normalizeLinuxPasswordStorePreference,
22 type LinuxPasswordStorePreference,
23} from "../linuxSecretStorage.ts";
24import { resolveDefaultDesktopUpdateChannel } from "../updates/updateChannels.ts";
25import { isValidDistroName } from "../wsl/wslPathParsing.ts";
26
27export interface DesktopSettings {
28 readonly localEnvironmentEnabled: boolean;
29 readonly linuxPasswordStore: LinuxPasswordStorePreference;
30 readonly mainWindowBounds: DesktopWindowBounds | null;
31 readonly mainWindowMaximized: boolean;
32 readonly serverExposureMode: DesktopServerExposureMode;
33 readonly tailscaleServeEnabled: boolean;
34 readonly tailscaleServePort: number;
35 readonly updateChannel: DesktopUpdateChannel;
36 readonly updateChannelConfiguredByUser: boolean;
37 // Was a "local" | "wsl" swap mode in an earlier iteration of the WSL
38 // integration. We now run Windows and WSL backends side by side, so the
39 // setting is just whether the WSL backend should be running alongside the
40 // primary. Persisted documents that still carry the legacy `wslMode: "wsl"`
41 // value are migrated to `wslBackendEnabled: true` on load.
42 readonly wslBackendEnabled: boolean;
43 readonly wslDistro: string | null;
44 // When true (and wslBackendEnabled is also true) the desktop runs only
45 // the WSL backend as the primary, and the Windows-side Node backend is
46 // not started. Designed for users who develop entirely inside WSL and
47 // don't want a second backend process running. Defaults to false so
48 // existing setups stay on the parallel-backends behavior. Changing
49 // this requires a desktop restart because the pool's primary spec is
50 // chosen once at layer init.
51 readonly wslOnly: boolean;
52}
53
54export interface DesktopSettingsChange {
55 readonly settings: DesktopSettings;
56 readonly changed: boolean;
57}
58
59const DEFAULT_TAILSCALE_SERVE_PORT = 443;
60const MIN_MAIN_WINDOW_SIZE = {
61 width: 840,
62 height: 620,
63} as const;
64export const DesktopWindowBoundsSchema = Schema.Struct({
65 x: Schema.Int,
66 y: Schema.Int,
67 width: Schema.Int.check(Schema.isGreaterThanOrEqualTo(MIN_MAIN_WINDOW_SIZE.width)),
68 height: Schema.Int.check(Schema.isGreaterThanOrEqualTo(MIN_MAIN_WINDOW_SIZE.height)),
69});
70export type DesktopWindowBounds = typeof DesktopWindowBoundsSchema.Type;
71export const DEFAULT_MAIN_WINDOW_SIZE = {
72 width: 1100,
73 height: 780,
74} as const;
75
76export const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = {
77 localEnvironmentEnabled: true,
78 linuxPasswordStore: DEFAULT_LINUX_PASSWORD_STORE,
79 mainWindowBounds: null,
80 mainWindowMaximized: false,
81 serverExposureMode: "local-only",
82 tailscaleServeEnabled: false,
83 tailscaleServePort: DEFAULT_TAILSCALE_SERVE_PORT,
84 updateChannel: "latest",
85 updateChannelConfiguredByUser: false,
86 wslBackendEnabled: false,
87 wslDistro: null,
88 wslOnly: false,
89};
90
91const DesktopWindowBoundsDocument = Schema.Struct({
92 x: Schema.Number,
93 y: Schema.Number,
94 width: Schema.Number,
95 height: Schema.Number,
96});
97
98const DesktopSettingsDocument = Schema.Struct({
99 localEnvironmentEnabled: Schema.optionalKey(Schema.Boolean),
100 linuxPasswordStore: Schema.optionalKey(Schema.Unknown),
101 mainWindowBounds: Schema.optionalKey(Schema.NullOr(DesktopWindowBoundsDocument)),
102 mainWindowMaximized: Schema.optionalKey(Schema.Boolean),
103 serverExposureMode: Schema.optionalKey(DesktopServerExposureModeSchema),
104 tailscaleServeEnabled: Schema.optionalKey(Schema.Boolean),
105 tailscaleServePort: Schema.optionalKey(Schema.Number),
106 updateChannel: Schema.optionalKey(DesktopUpdateChannelSchema),
107 updateChannelConfiguredByUser: Schema.optionalKey(Schema.Boolean),
108 // Newer form of the WSL toggle. `wslMode` is still accepted on load so
109 // existing on-disk settings keep working; on the next persist we write the
110 // new boolean and the legacy key drops out.
111 wslBackendEnabled: Schema.optionalKey(Schema.Boolean),
112 wslMode: Schema.optionalKey(Schema.Literals(["local", "wsl"])),
113 wslDistro: Schema.optionalKey(Schema.NullOr(Schema.String)),
114 wslOnly: Schema.optionalKey(Schema.Boolean),
115});
116
117type DesktopSettingsDocument = typeof DesktopSettingsDocument.Type;
118type Mutable<T> = { -readonly [K in keyof T]: T[K] };
119
120const DesktopSettingsJson = fromLenientJson(DesktopSettingsDocument);
121const decodeDesktopSettingsJson = Schema.decodeEffect(DesktopSettingsJson);
122const encodeDesktopSettingsJson = Schema.encodeEffect(DesktopSettingsJson);
123const decodeDesktopWindowBounds = Schema.decodeUnknownOption(DesktopWindowBoundsSchema);
124const desktopWindowBoundsEquivalence = Schema.toEquivalence(DesktopWindowBoundsSchema);
125
126const settingsChange = (settings: DesktopSettings, changed: boolean): DesktopSettingsChange => ({
127 settings,
128 changed,
129});
130
131const DesktopSettingsWriteOperation = Schema.Literals([
132 "create-temporary-file-name",
133 "encode-document",
134 "create-directory",
135 "write-temporary-file",
136 "replace-settings-file",
137]);
138type DesktopSettingsWriteOperation = typeof DesktopSettingsWriteOperation.Type;
139
140export class DesktopSettingsWriteError extends Schema.TaggedError<DesktopSettingsWriteError>()(
141 "DesktopSettingsWriteError",
142 {
143 operation: DesktopSettingsWriteOperation,
144 path: Schema.String,
145 cause: Schema.Defect(),
146 },
147) {
148 override get message(): string {
149 return `Desktop settings write failed during ${this.operation} at ${this.path}.`;
150 }
151}
152
153export class DesktopAppSettings extends Context.Service<
154 DesktopAppSettings,
155 {
156 readonly load: Effect.Effect<DesktopSettings>;
157 readonly get: Effect.Effect<DesktopSettings>;
158 readonly setLocalEnvironmentEnabled: (
159 enabled: boolean,
160 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
161 readonly setMainWindowBounds: (
162 bounds: DesktopWindowBounds,
163 isMaximized: boolean,
164 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
165 readonly setServerExposureMode: (
166 mode: DesktopServerExposureMode,
167 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
168 readonly setTailscaleServe: (input: {
169 readonly enabled: boolean;
170 readonly port: Option.Option<number>;
171 }) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
172 readonly setUpdateChannel: (
173 channel: DesktopUpdateChannel,
174 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
175 readonly setWslBackendEnabled: (
176 enabled: boolean,
177 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
178 readonly setWslDistro: (
179 distro: string | null,
180 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
181 readonly setWslOnly: (
182 enabled: boolean,
183 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
184 readonly applyWslWindowsFallback: Effect.Effect<
185 DesktopSettingsChange,
186 DesktopSettingsWriteError
187 >;
188 readonly applyWslWindowsFallbackInMemory: Effect.Effect<DesktopSettingsChange>;
189 }
190>()("@t3tools/desktop/settings/DesktopAppSettings") {}
191
192export function resolveDefaultDesktopSettings(appVersion: string): DesktopSettings {
193 return {
194 ...DEFAULT_DESKTOP_SETTINGS,
195 updateChannel: resolveDefaultDesktopUpdateChannel(appVersion),
196 };
197}
198
199function normalizeTailscaleServePort(value: unknown): number {
200 return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 65_535
201 ? value
202 : DEFAULT_TAILSCALE_SERVE_PORT;
203}
204
205function normalizeWslDistro(value: unknown): string | null {
206 return typeof value === "string" && isValidDistroName(value) ? value : null;
207}
208
209export function normalizeMainWindowBounds(value: unknown): DesktopWindowBounds | null {
210 return Option.getOrNull(decodeDesktopWindowBounds(value));
211}
212
213function normalizeDesktopSettingsDocument(
214 parsed: DesktopSettingsDocument,
215 appVersion: string,
216): DesktopSettings {
217 const defaultSettings = resolveDefaultDesktopSettings(appVersion);
218 const mainWindowBounds = normalizeMainWindowBounds(parsed.mainWindowBounds);
219 const parsedUpdateChannel = Option.fromNullishOr(parsed.updateChannel);
220 const isLegacySettings = parsed.updateChannelConfiguredByUser === undefined;
221 const updateChannelConfiguredByUser =
222 parsed.updateChannelConfiguredByUser === true ||
223 (isLegacySettings && Option.contains(parsedUpdateChannel, "nightly"));
224
225 // Newer form wins when both are present; otherwise fall back to the legacy
226 // `wslMode === "wsl"` signal so users coming off the swap-mode build keep
227 // their WSL backend enabled.
228 const wslBackendEnabled =
229 parsed.wslBackendEnabled === true ||
230 (parsed.wslBackendEnabled === undefined && parsed.wslMode === "wsl");
231
232 return {
233 localEnvironmentEnabled: parsed.localEnvironmentEnabled !== false,
234 linuxPasswordStore: normalizeLinuxPasswordStorePreference(parsed.linuxPasswordStore),
235 mainWindowBounds,
236 mainWindowMaximized: mainWindowBounds !== null && parsed.mainWindowMaximized === true,
237 serverExposureMode:
238 parsed.serverExposureMode === "network-accessible" ? "network-accessible" : "local-only",
239 tailscaleServeEnabled: parsed.tailscaleServeEnabled === true,
240 tailscaleServePort: normalizeTailscaleServePort(parsed.tailscaleServePort),
241 updateChannel: updateChannelConfiguredByUser
242 ? Option.getOrElse(parsedUpdateChannel, () => defaultSettings.updateChannel)
243 : defaultSettings.updateChannel,
244 updateChannelConfiguredByUser,
245 wslBackendEnabled,
246 wslDistro: normalizeWslDistro(parsed.wslDistro),
247 wslOnly: parsed.wslOnly === true,
248 };
249}
250
251function toDesktopSettingsDocument(
252 settings: DesktopSettings,
253 defaults: DesktopSettings,
254): DesktopSettingsDocument {
255 const document: Mutable<DesktopSettingsDocument> = {};
256
257 if (settings.localEnvironmentEnabled !== defaults.localEnvironmentEnabled) {
258 document.localEnvironmentEnabled = settings.localEnvironmentEnabled;
259 }
260
261 if (settings.linuxPasswordStore !== defaults.linuxPasswordStore) {
262 document.linuxPasswordStore = settings.linuxPasswordStore;
263 }
264 if (settings.mainWindowBounds !== null) {
265 document.mainWindowBounds = settings.mainWindowBounds;
266 }
267 if (settings.mainWindowMaximized) {
268 document.mainWindowMaximized = true;
269 }
270 if (settings.serverExposureMode !== defaults.serverExposureMode) {
271 document.serverExposureMode = settings.serverExposureMode;
272 }
273 if (settings.tailscaleServeEnabled !== defaults.tailscaleServeEnabled) {
274 document.tailscaleServeEnabled = settings.tailscaleServeEnabled;
275 }
276 if (settings.tailscaleServePort !== defaults.tailscaleServePort) {
277 document.tailscaleServePort = settings.tailscaleServePort;
278 }
279 if (settings.updateChannel !== defaults.updateChannel) {
280 document.updateChannel = settings.updateChannel;
281 }
282 if (settings.updateChannelConfiguredByUser !== defaults.updateChannelConfiguredByUser) {
283 document.updateChannelConfiguredByUser = settings.updateChannelConfiguredByUser;
284 }
285 if (settings.wslBackendEnabled !== defaults.wslBackendEnabled) {
286 document.wslBackendEnabled = settings.wslBackendEnabled;
287 }
288 if (settings.wslDistro !== defaults.wslDistro) {
289 document.wslDistro = settings.wslDistro;
290 }
291 if (settings.wslOnly !== defaults.wslOnly) {
292 document.wslOnly = settings.wslOnly;
293 }
294
295 return document;
296}
297
298function setServerExposureMode(
299 settings: DesktopSettings,
300 requestedMode: DesktopServerExposureMode,
301): DesktopSettings {
302 return settings.serverExposureMode === requestedMode
303 ? settings
304 : {
305 ...settings,
306 serverExposureMode: requestedMode,
307 };
308}
309
310function setMainWindowBounds(
311 settings: DesktopSettings,
312 bounds: DesktopWindowBounds,
313 isMaximized: boolean,
314): DesktopSettings {
315 return settings.mainWindowBounds !== null &&
316 desktopWindowBoundsEquivalence(settings.mainWindowBounds, bounds) &&
317 settings.mainWindowMaximized === isMaximized
318 ? settings
319 : {
320 ...settings,
321 mainWindowBounds: bounds,
322 mainWindowMaximized: isMaximized,
323 };
324}
325
326function setTailscaleServe(
327 settings: DesktopSettings,
328 input: { readonly enabled: boolean; readonly port: Option.Option<number> },
329): DesktopSettings {
330 const port = Option.match(input.port, {
331 onNone: () => settings.tailscaleServePort,
332 onSome: normalizeTailscaleServePort,
333 });
334 return settings.tailscaleServeEnabled === input.enabled && settings.tailscaleServePort === port
335 ? settings
336 : {
337 ...settings,
338 tailscaleServeEnabled: input.enabled,
339 tailscaleServePort: port,
340 };
341}
342
343function setUpdateChannel(
344 settings: DesktopSettings,
345 requestedChannel: DesktopUpdateChannel,
346): DesktopSettings {
347 return settings.updateChannel === requestedChannel
348 ? settings
349 : {
350 ...settings,
351 updateChannel: requestedChannel,
352 updateChannelConfiguredByUser: true,
353 };
354}
355
356function setWslBackendEnabled(settings: DesktopSettings, enabled: boolean): DesktopSettings {
357 return settings.wslBackendEnabled === enabled
358 ? settings
359 : {
360 ...settings,
361 wslBackendEnabled: enabled,
362 };
363}
364
365function setWslDistro(settings: DesktopSettings, distro: string | null): DesktopSettings {
366 const normalized = normalizeWslDistro(distro);
367 return settings.wslDistro === normalized
368 ? settings
369 : {
370 ...settings,
371 wslDistro: normalized,
372 };
373}
374
375function setWslOnly(settings: DesktopSettings, enabled: boolean): DesktopSettings {
376 return settings.wslOnly === enabled
377 ? settings
378 : {
379 ...settings,
380 wslOnly: enabled,
381 };
382}
383
384function setLocalEnvironmentEnabled(settings: DesktopSettings, enabled: boolean): DesktopSettings {
385 return settings.localEnvironmentEnabled === enabled
386 ? settings
387 : { ...settings, localEnvironmentEnabled: enabled };
388}
389
390function applyWslWindowsFallback(settings: DesktopSettings): DesktopSettings {
391 return setWslOnly(setWslBackendEnabled(settings, false), false);
392}
393
394function readSettings(
395 fileSystem: FileSystem.FileSystem,
396 settingsPath: string,
397 appVersion: string,
398): Effect.Effect<DesktopSettings> {
399 const defaultSettings = resolveDefaultDesktopSettings(appVersion);
400
401 return fileSystem.readFileString(settingsPath).pipe(
402 Effect.option,
403 Effect.flatMap(
404 Option.match({
405 onNone: () => Effect.succeed(defaultSettings),
406 onSome: (raw) =>
407 decodeDesktopSettingsJson(raw).pipe(
408 Effect.map((parsed) => normalizeDesktopSettingsDocument(parsed, appVersion)),
409 Effect.orElseSucceed(() => defaultSettings),
410 ),
411 }),
412 ),
413 );
414}
415
416const writeSettings = Effect.fn("desktop.settings.writeSettings")(function* (input: {
417 readonly fileSystem: FileSystem.FileSystem;
418 readonly path: Path.Path;
419 readonly settingsPath: string;
420 readonly settings: DesktopSettings;
421 readonly defaultSettings: DesktopSettings;
422 readonly suffix: string;
423}): Effect.fn.Return<void, DesktopSettingsWriteError> {
424 const directory = input.path.dirname(input.settingsPath);
425 const tempPath = `${input.settingsPath}.${process.pid}.${input.suffix}.tmp`;
426 const encoded = yield* encodeDesktopSettingsJson(
427 toDesktopSettingsDocument(input.settings, input.defaultSettings),
428 ).pipe(
429 Effect.mapError(
430 (cause) =>
431 new DesktopSettingsWriteError({
432 operation: "encode-document",
433 path: input.settingsPath,
434 cause,
435 }),
436 ),
437 );
438 yield* input.fileSystem.makeDirectory(directory, { recursive: true }).pipe(
439 Effect.mapError(
440 (cause) =>
441 new DesktopSettingsWriteError({
442 operation: "create-directory",
443 path: directory,
444 cause,
445 }),
446 ),
447 );
448 yield* input.fileSystem.writeFileString(tempPath, `${encoded}\n`).pipe(
449 Effect.mapError(
450 (cause) =>
451 new DesktopSettingsWriteError({
452 operation: "write-temporary-file",
453 path: tempPath,
454 cause,
455 }),
456 ),
457 );
458 yield* input.fileSystem.rename(tempPath, input.settingsPath).pipe(
459 Effect.mapError(
460 (cause) =>
461 new DesktopSettingsWriteError({
462 operation: "replace-settings-file",
463 path: input.settingsPath,
464 cause,
465 }),
466 ),
467 );
468});
469
470/** @public Service construction is part of the canonical Effect module API. */
471export const make = Effect.gen(function* () {
472 const environment = yield* DesktopEnvironment.DesktopEnvironment;
473 const fileSystem = yield* FileSystem.FileSystem;
474 const path = yield* Path.Path;
475 const crypto = yield* Crypto.Crypto;
476 const settingsRef = yield* SynchronizedRef.make(environment.defaultDesktopSettings);
477
478 const updateInMemory = (update: (settings: DesktopSettings) => DesktopSettings) =>
479 SynchronizedRef.modify(settingsRef, (settings) => {
480 const nextSettings = update(settings);
481 return [settingsChange(nextSettings, nextSettings !== settings), nextSettings] as const;
482 });
483
484 const persist = (
485 update: (settings: DesktopSettings) => DesktopSettings,
486 ): Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError> =>
487 SynchronizedRef.modifyEffect(settingsRef, (settings) => {
488 const nextSettings = update(settings);
489 if (nextSettings === settings) {
490 return Effect.succeed([settingsChange(settings, false), settings] as const);
491 }
492
493 return crypto.randomUUIDv4.pipe(
494 Effect.map((uuid) => uuid.replace(/-/g, "")),
495 Effect.mapError(
496 (cause) =>
497 new DesktopSettingsWriteError({
498 operation: "create-temporary-file-name",
499 path: environment.desktopSettingsPath,
500 cause,
501 }),
502 ),
503 Effect.flatMap((suffix) =>
504 writeSettings({
505 fileSystem,
506 path,
507 settingsPath: environment.desktopSettingsPath,
508 settings: nextSettings,
509 defaultSettings: environment.defaultDesktopSettings,
510 suffix,
511 }),
512 ),
513 Effect.as([settingsChange(nextSettings, true), nextSettings] as const),
514 );
515 });
516
517 return DesktopAppSettings.of({
518 get: SynchronizedRef.get(settingsRef),
519 load: Effect.gen(function* () {
520 const settings = yield* readSettings(
521 fileSystem,
522 environment.desktopSettingsPath,
523 environment.appVersion,
524 );
525 return yield* SynchronizedRef.setAndGet(settingsRef, settings);
526 }).pipe(Effect.withSpan("desktop.settings.load")),
527 setMainWindowBounds: (bounds, isMaximized) =>
528 persist((settings) => setMainWindowBounds(settings, bounds, isMaximized)).pipe(
529 Effect.withSpan("desktop.settings.setMainWindowBounds", {
530 attributes: {
531 x: bounds.x,
532 y: bounds.y,
533 width: bounds.width,
534 height: bounds.height,
535 isMaximized,
536 },
537 }),
538 ),
539 setServerExposureMode: (mode) =>
540 persist((settings) => setServerExposureMode(settings, mode)).pipe(
541 Effect.withSpan("desktop.settings.setServerExposureMode", { attributes: { mode } }),
542 ),
543 setTailscaleServe: (input) =>
544 persist((settings) => setTailscaleServe(settings, input)).pipe(
545 Effect.withSpan("desktop.settings.setTailscaleServe", { attributes: input }),
546 ),
547 setUpdateChannel: (channel) =>
548 persist((settings) => setUpdateChannel(settings, channel)).pipe(
549 Effect.withSpan("desktop.settings.setUpdateChannel", { attributes: { channel } }),
550 ),
551 setWslBackendEnabled: (enabled) =>
552 persist((settings) => setWslBackendEnabled(settings, enabled)).pipe(
553 Effect.withSpan("desktop.settings.setWslBackendEnabled", { attributes: { enabled } }),
554 ),
555 setWslDistro: (distro) =>
556 persist((settings) => setWslDistro(settings, distro)).pipe(
557 Effect.withSpan("desktop.settings.setWslDistro", {
558 attributes: { distro: distro ?? null },
559 }),
560 ),
561 setWslOnly: (enabled) =>
562 persist((settings) => setWslOnly(settings, enabled)).pipe(
563 Effect.withSpan("desktop.settings.setWslOnly", { attributes: { enabled } }),
564 ),
565 setLocalEnvironmentEnabled: (enabled) =>
566 persist((settings) => setLocalEnvironmentEnabled(settings, enabled)).pipe(
567 Effect.withSpan("desktop.settings.setLocalEnvironmentEnabled", { attributes: { enabled } }),
568 ),
569 applyWslWindowsFallback: persist(applyWslWindowsFallback).pipe(
570 Effect.withSpan("desktop.settings.applyWslWindowsFallback"),
571 ),
572 applyWslWindowsFallbackInMemory: updateInMemory(applyWslWindowsFallback).pipe(
573 Effect.withSpan("desktop.settings.applyWslWindowsFallbackInMemory"),
574 ),
575 });
576});
577
578export const layer = Layer.effect(DesktopAppSettings, make);
579
580export const layerTest = (initialSettings: DesktopSettings = DEFAULT_DESKTOP_SETTINGS) =>
581 Layer.effect(
582 DesktopAppSettings,
583 Effect.gen(function* () {
584 const settingsRef = yield* SynchronizedRef.make(initialSettings);
585 const update = (f: (settings: DesktopSettings) => DesktopSettings) =>
586 SynchronizedRef.modify(settingsRef, (settings) => {
587 const nextSettings = f(settings);
588 return [
589 {
590 settings: nextSettings,
591 changed: nextSettings !== settings,
592 },
593 nextSettings,
594 ] as const;
595 });
596
597 return DesktopAppSettings.of({
598 get: SynchronizedRef.get(settingsRef),
599 load: SynchronizedRef.get(settingsRef),
600 setMainWindowBounds: (bounds, isMaximized) =>
601 update((settings) => setMainWindowBounds(settings, bounds, isMaximized)),
602 setServerExposureMode: (mode) =>
603 update((settings) => setServerExposureMode(settings, mode)),
604 setTailscaleServe: (input) => update((settings) => setTailscaleServe(settings, input)),
605 setUpdateChannel: (channel) => update((settings) => setUpdateChannel(settings, channel)),
606 setWslBackendEnabled: (enabled) =>
607 update((settings) => setWslBackendEnabled(settings, enabled)),
608 setWslDistro: (distro) => update((settings) => setWslDistro(settings, distro)),
609 setWslOnly: (enabled) => update((settings) => setWslOnly(settings, enabled)),
610 setLocalEnvironmentEnabled: (enabled) =>
611 update((settings) => setLocalEnvironmentEnabled(settings, enabled)),
612 applyWslWindowsFallback: update(applyWslWindowsFallback),
613 applyWslWindowsFallbackInMemory: update(applyWslWindowsFallback),
614 });
615 }),
616 );