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