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