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

DesktopAppSettings.ts

607 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 { retryWindowsFileSystemOperation } from "@t3tools/shared/windowsFileRetry";
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 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;
53​
54export interface DesktopSettingsChange {
55 readonly settings: DesktopSettings;
56 readonly changed: boolean;
58​
59export const 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 linuxPasswordStore: DEFAULT_LINUX_PASSWORD_STORE,
78 mainWindowBounds: null,
79 mainWindowMaximized: false,
80 serverExposureMode: "local-only",
81 tailscaleServeEnabled: false,
82 tailscaleServePort: DEFAULT_TAILSCALE_SERVE_PORT,
83 updateChannel: "latest",
84 updateChannelConfiguredByUser: false,
85 wslBackendEnabled: false,
86 wslDistro: null,
87 wslOnly: false,
88};
89​
90const DesktopWindowBoundsDocument = Schema.Struct({
91 x: Schema.Number,
92 y: Schema.Number,
93 width: Schema.Number,
94 height: Schema.Number,
95});
96​
97const DesktopSettingsDocument = Schema.Struct({
98 linuxPasswordStore: Schema.optionalKey(Schema.Unknown),
99 mainWindowBounds: Schema.optionalKey(Schema.NullOr(DesktopWindowBoundsDocument)),
100 mainWindowMaximized: Schema.optionalKey(Schema.Boolean),
101 serverExposureMode: Schema.optionalKey(DesktopServerExposureModeSchema),
102 tailscaleServeEnabled: Schema.optionalKey(Schema.Boolean),
103 tailscaleServePort: Schema.optionalKey(Schema.Number),
104 updateChannel: Schema.optionalKey(DesktopUpdateChannelSchema),
105 updateChannelConfiguredByUser: Schema.optionalKey(Schema.Boolean),
106 // Newer form of the WSL toggle. `wslMode` is still accepted on load so
107 // existing on-disk settings keep working; on the next persist we write the
108 // new boolean and the legacy key drops out.
109 wslBackendEnabled: Schema.optionalKey(Schema.Boolean),
110 wslMode: Schema.optionalKey(Schema.Literals(["local", "wsl"])),
111 wslDistro: Schema.optionalKey(Schema.NullOr(Schema.String)),
112 wslOnly: Schema.optionalKey(Schema.Boolean),
113});
114​
115type DesktopSettingsDocument = typeof DesktopSettingsDocument.Type;
116type Mutable<T> = { -readonly [K in keyof T]: T[K] };
117​
118const DesktopSettingsJson = fromLenientJson(DesktopSettingsDocument);
119const decodeDesktopSettingsJson = Schema.decodeEffect(DesktopSettingsJson);
120const encodeDesktopSettingsJson = Schema.encodeEffect(DesktopSettingsJson);
121const decodeDesktopWindowBounds = Schema.decodeUnknownOption(DesktopWindowBoundsSchema);
122const desktopWindowBoundsEquivalence = Schema.toEquivalence(DesktopWindowBoundsSchema);
123​
124const settingsChange = (settings: DesktopSettings, changed: boolean): DesktopSettingsChange => ({
125 settings,
126 changed,
127});
128​
129const DesktopSettingsWriteOperation = Schema.Literals([
130 "create-temporary-file-name",
131 "encode-document",
132 "create-directory",
133 "write-temporary-file",
134 "replace-settings-file",
135]);
136type DesktopSettingsWriteOperation = typeof DesktopSettingsWriteOperation.Type;
137​
138export class DesktopSettingsWriteError extends Schema.TaggedErrorClass<DesktopSettingsWriteError>()(
139 "DesktopSettingsWriteError",
140 {
141 operation: DesktopSettingsWriteOperation,
142 path: Schema.String,
143 cause: Schema.Defect(),
144 },
145) {
146 override get message(): string {
147 return `Desktop settings write failed during ${this.operation} at ${this.path}.`;
148 }
150​
151export class DesktopAppSettings extends Context.Service<
152 DesktopAppSettings,
153 {
154 readonly load: Effect.Effect<DesktopSettings>;
155 readonly get: Effect.Effect<DesktopSettings>;
156 readonly setMainWindowBounds: (
157 bounds: DesktopWindowBounds,
158 isMaximized: boolean,
159 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
160 readonly setServerExposureMode: (
161 mode: DesktopServerExposureMode,
162 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
163 readonly setTailscaleServe: (input: {
164 readonly enabled: boolean;
165 readonly port: Option.Option<number>;
166 }) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
167 readonly setUpdateChannel: (
168 channel: DesktopUpdateChannel,
169 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
170 readonly setWslBackendEnabled: (
171 enabled: boolean,
172 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
173 readonly setWslDistro: (
174 distro: string | null,
175 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
176 readonly setWslOnly: (
177 enabled: boolean,
178 ) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
179 readonly applyWslWindowsFallback: Effect.Effect<
180 DesktopSettingsChange,
181 DesktopSettingsWriteError
182 >;
183 readonly applyWslWindowsFallbackInMemory: Effect.Effect<DesktopSettingsChange>;
184 }
185>()("@t3tools/desktop/settings/DesktopAppSettings") {}
186​
187export function resolveDefaultDesktopSettings(appVersion: string): DesktopSettings {
188 return {
189 ...DEFAULT_DESKTOP_SETTINGS,
190 updateChannel: resolveDefaultDesktopUpdateChannel(appVersion),
191 };
193​
194function normalizeTailscaleServePort(value: unknown): number {
195 return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 65_535
196 ? value
197 : DEFAULT_TAILSCALE_SERVE_PORT;
199​
200function normalizeWslDistro(value: unknown): string | null {
201 return typeof value === "string" && isValidDistroName(value) ? value : null;
203​
204export function normalizeMainWindowBounds(value: unknown): DesktopWindowBounds | null {
205 return Option.getOrNull(decodeDesktopWindowBounds(value));
207​
208function normalizeDesktopSettingsDocument(
209 parsed: DesktopSettingsDocument,
210 appVersion: string,
211): DesktopSettings {
212 const defaultSettings = resolveDefaultDesktopSettings(appVersion);
213 const mainWindowBounds = normalizeMainWindowBounds(parsed.mainWindowBounds);
214 const parsedUpdateChannel = Option.fromNullishOr(parsed.updateChannel);
215 const isLegacySettings = parsed.updateChannelConfiguredByUser === undefined;
216 const updateChannelConfiguredByUser =
217 parsed.updateChannelConfiguredByUser === true ||
218 (isLegacySettings && Option.contains(parsedUpdateChannel, "nightly"));
219​
220 // Newer form wins when both are present; otherwise fall back to the legacy
221 // `wslMode === "wsl"` signal so users coming off the swap-mode build keep
222 // their WSL backend enabled.
223 const wslBackendEnabled =
224 parsed.wslBackendEnabled === true ||
225 (parsed.wslBackendEnabled === undefined && parsed.wslMode === "wsl");
226​
227 return {
228 linuxPasswordStore: normalizeLinuxPasswordStorePreference(parsed.linuxPasswordStore),
229 mainWindowBounds,
230 mainWindowMaximized: mainWindowBounds !== null && parsed.mainWindowMaximized === true,
231 serverExposureMode:
232 parsed.serverExposureMode === "network-accessible" ? "network-accessible" : "local-only",
233 tailscaleServeEnabled: parsed.tailscaleServeEnabled === true,
234 tailscaleServePort: normalizeTailscaleServePort(parsed.tailscaleServePort),
235 updateChannel: updateChannelConfiguredByUser
236 ? Option.getOrElse(parsedUpdateChannel, () => defaultSettings.updateChannel)
237 : defaultSettings.updateChannel,
238 updateChannelConfiguredByUser,
239 wslBackendEnabled,
240 wslDistro: normalizeWslDistro(parsed.wslDistro),
241 wslOnly: parsed.wslOnly === true,
242 };
244​
245function toDesktopSettingsDocument(
246 settings: DesktopSettings,
247 defaults: DesktopSettings,
248): DesktopSettingsDocument {
249 const document: Mutable<DesktopSettingsDocument> = {};
250​
251 if (settings.linuxPasswordStore !== defaults.linuxPasswordStore) {
252 document.linuxPasswordStore = settings.linuxPasswordStore;
253 }
254 if (settings.mainWindowBounds !== null) {
255 document.mainWindowBounds = settings.mainWindowBounds;
256 }
257 if (settings.mainWindowMaximized) {
258 document.mainWindowMaximized = true;
259 }
260 if (settings.serverExposureMode !== defaults.serverExposureMode) {
261 document.serverExposureMode = settings.serverExposureMode;
262 }
263 if (settings.tailscaleServeEnabled !== defaults.tailscaleServeEnabled) {
264 document.tailscaleServeEnabled = settings.tailscaleServeEnabled;
265 }
266 if (settings.tailscaleServePort !== defaults.tailscaleServePort) {
267 document.tailscaleServePort = settings.tailscaleServePort;
268 }
269 if (settings.updateChannel !== defaults.updateChannel) {
270 document.updateChannel = settings.updateChannel;
271 }
272 if (settings.updateChannelConfiguredByUser !== defaults.updateChannelConfiguredByUser) {
273 document.updateChannelConfiguredByUser = settings.updateChannelConfiguredByUser;
274 }
275 if (settings.wslBackendEnabled !== defaults.wslBackendEnabled) {
276 document.wslBackendEnabled = settings.wslBackendEnabled;
277 }
278 if (settings.wslDistro !== defaults.wslDistro) {
279 document.wslDistro = settings.wslDistro;
280 }
281 if (settings.wslOnly !== defaults.wslOnly) {
282 document.wslOnly = settings.wslOnly;
283 }
284​
285 return document;
287​
288function setServerExposureMode(
289 settings: DesktopSettings,
290 requestedMode: DesktopServerExposureMode,
291): DesktopSettings {
292 return settings.serverExposureMode === requestedMode
293 ? settings
294 : {
295 ...settings,
296 serverExposureMode: requestedMode,
297 };
299​
300function setMainWindowBounds(
301 settings: DesktopSettings,
302 bounds: DesktopWindowBounds,
303 isMaximized: boolean,
304): DesktopSettings {
305 return settings.mainWindowBounds !== null &&
306 desktopWindowBoundsEquivalence(settings.mainWindowBounds, bounds) &&
307 settings.mainWindowMaximized === isMaximized
308 ? settings
309 : {
310 ...settings,
311 mainWindowBounds: bounds,
312 mainWindowMaximized: isMaximized,
313 };
315​
316function setTailscaleServe(
317 settings: DesktopSettings,
318 input: { readonly enabled: boolean; readonly port: Option.Option<number> },
319): DesktopSettings {
320 const port = Option.match(input.port, {
321 onNone: () => settings.tailscaleServePort,
322 onSome: normalizeTailscaleServePort,
323 });
324 return settings.tailscaleServeEnabled === input.enabled && settings.tailscaleServePort === port
325 ? settings
326 : {
327 ...settings,
328 tailscaleServeEnabled: input.enabled,
329 tailscaleServePort: port,
330 };
332​
333function setUpdateChannel(
334 settings: DesktopSettings,
335 requestedChannel: DesktopUpdateChannel,
336): DesktopSettings {
337 return settings.updateChannel === requestedChannel
338 ? settings
339 : {
340 ...settings,
341 updateChannel: requestedChannel,
342 updateChannelConfiguredByUser: true,
343 };
345​
346function setWslBackendEnabled(settings: DesktopSettings, enabled: boolean): DesktopSettings {
347 return settings.wslBackendEnabled === enabled
348 ? settings
349 : {
350 ...settings,
351 wslBackendEnabled: enabled,
352 };
354​
355function setWslDistro(settings: DesktopSettings, distro: string | null): DesktopSettings {
356 const normalized = normalizeWslDistro(distro);
357 return settings.wslDistro === normalized
358 ? settings
359 : {
360 ...settings,
361 wslDistro: normalized,
362 };
364​
365function setWslOnly(settings: DesktopSettings, enabled: boolean): DesktopSettings {
366 return settings.wslOnly === enabled
367 ? settings
368 : {
369 ...settings,
370 wslOnly: enabled,
371 };
373​
374function applyWslWindowsFallback(settings: DesktopSettings): DesktopSettings {
375 return setWslOnly(setWslBackendEnabled(settings, false), false);
377​
378function readSettings(
379 fileSystem: FileSystem.FileSystem,
380 settingsPath: string,
381 appVersion: string,
382): Effect.Effect<DesktopSettings> {
383 const defaultSettings = resolveDefaultDesktopSettings(appVersion);
384​
385 return fileSystem.readFileString(settingsPath).pipe(
386 Effect.option,
387 Effect.flatMap(
388 Option.match({
389 onNone: () => Effect.succeed(defaultSettings),
390 onSome: (raw) =>
391 decodeDesktopSettingsJson(raw).pipe(
392 Effect.map((parsed) => normalizeDesktopSettingsDocument(parsed, appVersion)),
393 Effect.orElseSucceed(() => defaultSettings),
394 ),
395 }),
396 ),
397 );
399​
400const writeSettings = Effect.fn("desktop.settings.writeSettings")(function* (input: {
401 readonly fileSystem: FileSystem.FileSystem;
402 readonly path: Path.Path;
403 readonly settingsPath: string;
404 readonly settings: DesktopSettings;
405 readonly defaultSettings: DesktopSettings;
406 readonly suffix: string;
407}): Effect.fn.Return<void, DesktopSettingsWriteError> {
408 const directory = input.path.dirname(input.settingsPath);
409 const tempPath = `${input.settingsPath}.${process.pid}.${input.suffix}.tmp`;
410 const encoded = yield* encodeDesktopSettingsJson(
411 toDesktopSettingsDocument(input.settings, input.defaultSettings),
412 ).pipe(
413 Effect.mapError(
414 (cause) =>
415 new DesktopSettingsWriteError({
416 operation: "encode-document",
417 path: input.settingsPath,
418 cause,
419 }),
420 ),
421 );
422 yield* retryWindowsFileSystemOperation(
423 input.fileSystem.makeDirectory(directory, { recursive: true }),
424 ).pipe(
425 Effect.mapError(
426 (cause) =>
427 new DesktopSettingsWriteError({
428 operation: "create-directory",
429 path: directory,
430 cause,
431 }),
432 ),
433 );
434 yield* Effect.gen(function* () {
435 yield* retryWindowsFileSystemOperation(
436 input.fileSystem.writeFileString(tempPath, `${encoded}\n`),
437 ).pipe(
438 Effect.mapError(
439 (cause) =>
440 new DesktopSettingsWriteError({
441 operation: "write-temporary-file",
442 path: tempPath,
443 cause,
444 }),
445 ),
446 );
447 yield* retryWindowsFileSystemOperation(
448 input.fileSystem.rename(tempPath, input.settingsPath),
449 ).pipe(
450 Effect.mapError(
451 (cause) =>
452 new DesktopSettingsWriteError({
453 operation: "replace-settings-file",
454 path: input.settingsPath,
455 cause,
456 }),
457 ),
458 );
459 }).pipe(
460 Effect.ensuring(
461 retryWindowsFileSystemOperation(
462 input.fileSystem.remove(tempPath, { force: true }),
463 ).pipe(Effect.ignore),
464 ),
465 );
466});
467​
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 applyWslWindowsFallback: persist(applyWslWindowsFallback).pipe(
563 Effect.withSpan("desktop.settings.applyWslWindowsFallback"),
564 ),
565 applyWslWindowsFallbackInMemory: updateInMemory(applyWslWindowsFallback).pipe(
566 Effect.withSpan("desktop.settings.applyWslWindowsFallbackInMemory"),
567 ),
568 });
569});
570​
571export const layer = Layer.effect(DesktopAppSettings, make);
572​
573export const layerTest = (initialSettings: DesktopSettings = DEFAULT_DESKTOP_SETTINGS) =>
574 Layer.effect(
575 DesktopAppSettings,
576 Effect.gen(function* () {
577 const settingsRef = yield* SynchronizedRef.make(initialSettings);
578 const update = (f: (settings: DesktopSettings) => DesktopSettings) =>
579 SynchronizedRef.modify(settingsRef, (settings) => {
580 const nextSettings = f(settings);
581 return [
582 {
583 settings: nextSettings,
584 changed: nextSettings !== settings,
585 },
586 nextSettings,
587 ] as const;
588 });
589​
590 return DesktopAppSettings.of({
591 get: SynchronizedRef.get(settingsRef),
592 load: SynchronizedRef.get(settingsRef),
593 setMainWindowBounds: (bounds, isMaximized) =>
594 update((settings) => setMainWindowBounds(settings, bounds, isMaximized)),
595 setServerExposureMode: (mode) =>
596 update((settings) => setServerExposureMode(settings, mode)),
597 setTailscaleServe: (input) => update((settings) => setTailscaleServe(settings, input)),
598 setUpdateChannel: (channel) => update((settings) => setUpdateChannel(settings, channel)),
599 setWslBackendEnabled: (enabled) =>
600 update((settings) => setWslBackendEnabled(settings, enabled)),
601 setWslDistro: (distro) => update((settings) => setWslDistro(settings, distro)),
602 setWslOnly: (enabled) => update((settings) => setWslOnly(settings, enabled)),
603 applyWslWindowsFallback: update(applyWslWindowsFallback),
604 applyWslWindowsFallbackInMemory: update(applyWslWindowsFallback),
605 });
606 }),
607 );