Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

DesktopAppSettings.ts

613 lines21.8 KB

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 // Requires restart because the pool chooses its primary spec at layer initialization.
41 readonly wslOnly: boolean;
43​
44export interface DesktopSettingsChange {
45 readonly settings: DesktopSettings;
46 readonly changed: boolean;
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 }
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: resolveDefaultDesktopUpdateChannel(appVersion),
184 };
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;
192​
193function normalizeWslDistro(value: unknown): string | null {
194 return typeof value === "string" && isValidDistroName(value) ? value : null;
196​
197export function normalizeMainWindowBounds(value: unknown): DesktopWindowBounds | null {
198 return Option.getOrNull(decodeDesktopWindowBounds(value));
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 };
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;
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 };
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 };
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 };
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 };
340​
341function setWslBackendEnabled(settings: DesktopSettings, enabled: boolean): DesktopSettings {
342 return settings.wslBackendEnabled === enabled
343 ? settings
344 : {
345 ...settings,
346 wslBackendEnabled: enabled,
347 };
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 };
359​
360function setWslOnly(settings: DesktopSettings, enabled: boolean): DesktopSettings {
361 return settings.wslOnly === enabled
362 ? settings
363 : {
364 ...settings,
365 wslOnly: enabled,
366 };
368​
369function setLocalEnvironmentEnabled(settings: DesktopSettings, enabled: boolean): DesktopSettings {
370 return settings.localEnvironmentEnabled === enabled
371 ? settings
372 : { ...settings, localEnvironmentEnabled: enabled };
374​
375function applyWslWindowsFallback(settings: DesktopSettings): DesktopSettings {
376 return setWslOnly(setWslBackendEnabled(settings, false), false);
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 );
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 crypto = yield* Crypto.Crypto;
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 crypto.randomUUIDv4().pipe(
491 Effect.map((uuid) => uuid.replace(/-/g, "")),
492 Effect.mapError(
493 (cause) =>
494 new DesktopSettingsWriteError({
495 operation: "create-temporary-file-name",
496 path: environment.desktopSettingsPath,
497 cause,
498 }),
499 ),
500 Effect.flatMap((suffix) =>
501 writeSettings({
502 fileSystem,
503 path,
504 settingsPath: environment.desktopSettingsPath,
505 settings: nextSettings,
506 defaultSettings: environment.defaultDesktopSettings,
507 suffix,
508 }),
509 ),
510 Effect.as([settingsChange(nextSettings, true), nextSettings] as const),
511 );
512 });
513​
514 return DesktopAppSettings.of({
515 get: SynchronizedRef.get(settingsRef),
516 load: Effect.gen(function* () {
517 const settings = yield* readSettings(
518 fileSystem,
519 environment.desktopSettingsPath,
520 environment.appVersion,
521 );
522 return yield* SynchronizedRef.setAndGet(settingsRef, settings);
523 }).pipe(Effect.withSpan("desktop.settings.load")),
524 setMainWindowBounds: (bounds, isMaximized) =>
525 persist((settings) => setMainWindowBounds(settings, bounds, isMaximized)).pipe(
526 Effect.withSpan("desktop.settings.setMainWindowBounds", {
527 attributes: {
528 x: bounds.x,
529 y: bounds.y,
530 width: bounds.width,
531 height: bounds.height,
532 isMaximized,
533 },
534 }),
535 ),
536 setServerExposureMode: (mode) =>
537 persist((settings) => setServerExposureMode(settings, mode)).pipe(
538 Effect.withSpan("desktop.settings.setServerExposureMode", { attributes: { mode } }),
539 ),
540 setTailscaleServe: (input) =>
541 persist((settings) => setTailscaleServe(settings, input)).pipe(
542 Effect.withSpan("desktop.settings.setTailscaleServe", { attributes: input }),
543 ),
544 setUpdateChannel: (channel) =>
545 persist((settings) => setUpdateChannel(settings, channel)).pipe(
546 Effect.withSpan("desktop.settings.setUpdateChannel", { attributes: { channel } }),
547 ),
548 setWslBackendEnabled: (enabled) =>
549 persist((settings) => setWslBackendEnabled(settings, enabled)).pipe(
550 Effect.withSpan("desktop.settings.setWslBackendEnabled", { attributes: { enabled } }),
551 ),
552 setWslDistro: (distro) =>
553 persist((settings) => setWslDistro(settings, distro)).pipe(
554 Effect.withSpan("desktop.settings.setWslDistro", {
555 attributes: { distro: distro ?? null },
556 }),
557 ),
558 setWslOnly: (enabled) =>
559 persist((settings) => setWslOnly(settings, enabled)).pipe(
560 Effect.withSpan("desktop.settings.setWslOnly", { attributes: { enabled } }),
561 ),
562 setLocalEnvironmentEnabled: (enabled) =>
563 persist((settings) => setLocalEnvironmentEnabled(settings, enabled)).pipe(
564 Effect.withSpan("desktop.settings.setLocalEnvironmentEnabled", { attributes: { enabled } }),
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: (bounds, isMaximized) =>
598 update((settings) => setMainWindowBounds(settings, bounds, isMaximized)),
599 setServerExposureMode: (mode) =>
600 update((settings) => setServerExposureMode(settings, mode)),
601 setTailscaleServe: (input) => update((settings) => setTailscaleServe(settings, input)),
602 setUpdateChannel: (channel) => update((settings) => setUpdateChannel(settings, channel)),
603 setWslBackendEnabled: (enabled) =>
604 update((settings) => setWslBackendEnabled(settings, enabled)),
605 setWslDistro: (distro) => update((settings) => setWslDistro(settings, distro)),
606 setWslOnly: (enabled) => update((settings) => setWslOnly(settings, enabled)),
607 setLocalEnvironmentEnabled: (enabled) =>
608 update((settings) => setLocalEnvironmentEnabled(settings, enabled)),
609 applyWslWindowsFallback: update(applyWslWindowsFallback),
610 applyWslWindowsFallbackInMemory: update(applyWslWindowsFallback),
611 });
612 }),
613 );