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