authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-09-07 15:00:36-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-09-07 15:00:36-07:00
log5b8a69c7b90b751507d0ab762dd77aaa2048408b
tree45353c30f4ee1a0ebf7464bd121ffbf1be745000
parent3bf74eb6dce3e1372cfafc2ca84825f4b13bae6a
signature Signed by PGP key B5690EEEBB952194

refactor(desktop): classify backend exports (#10265)


10 files changed, 14 insertions(+), 59 deletions(-)

apps/desktop/scripts/electron-launcher.mjs+3-3
......@@ -15,8 +15,8 @@ const repoRoot = NodePath.resolve(desktopDir, "..", "..");
1515const devBundleIdSuffix = NodePath.basename(repoRoot)
1616 .toLowerCase()
1717 .replaceAll(/[^a-z0-9]+/g, "");
18export const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
19export const APP_BUNDLE_ID = isDevelopment
18const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
19const APP_BUNDLE_ID = isDevelopment
2020 ? `com.t3tools.t3code.dev.${devBundleIdSuffix || "local"}`
2121 : "com.t3tools.t3code";
2222const APP_PROTOCOL_SCHEMES = isDevelopment ? ["t3code-dev"] : ["t3code"];
......@@ -387,7 +387,7 @@ function resolveLinuxSandboxArgs(electronBinaryPath) {
387387 return ["--no-sandbox"];
388388}
389389
390export function resolveElectronPath() {
390function resolveElectronPath() {
391391 const electronBinaryPath = resolveElectronBinaryPath();
392392
393393 if (hostPlatform !== "darwin") {
apps/desktop/src/backend/DesktopBackendConfiguration.ts+1
......@@ -737,6 +737,7 @@ const resolveWslStartConfig = Effect.fn("desktop.backendConfiguration.resolveWsl
737737 } satisfies DesktopBackendManager.DesktopBackendStartConfig;
738738});
739739
740/** @public Service construction is part of the canonical Effect module API. */
740741export const make = Effect.gen(function* () {
741742 const environment = yield* DesktopEnvironment.DesktopEnvironment;
742743 const fileSystem = yield* FileSystem.FileSystem;
apps/desktop/src/backend/DesktopLocalEnvironmentAuth.ts+1
......@@ -42,6 +42,7 @@ export class DesktopLocalEnvironmentAuth extends Context.Service<
4242 }
4343>()("@t3tools/desktop/backend/DesktopLocalEnvironmentAuth") {}
4444
45/** @public Service construction is part of the canonical Effect module API. */
4546export const make = Effect.gen(function* () {
4647 const pool = yield* DesktopBackendPool.DesktopBackendPool;
4748 const httpClient = yield* HttpClient.HttpClient;
apps/desktop/src/backend/DesktopNetworkInterfaces.ts+1
......@@ -39,6 +39,7 @@ export class DesktopNetworkInterfaces extends Context.Service<
3939 }
4040>()("@t3tools/desktop/backend/DesktopNetworkInterfaces") {}
4141
42/** @public Service construction is part of the canonical Effect module API. */
4243export const make = Effect.gen(function* () {
4344 const platform = yield* HostProcessPlatform;
4445 return DesktopNetworkInterfaces.of({
apps/desktop/src/backend/DesktopServerExposure.ts+2-1
......@@ -27,7 +27,7 @@ import { resolveTailscaleAdvertisedEndpoints } from "./tailscaleEndpointProvider
2727
2828const TAILSCALE_STATUS_CACHE_TTL = Duration.seconds(60);
2929
30export const DESKTOP_LOOPBACK_HOST = "127.0.0.1";
30const DESKTOP_LOOPBACK_HOST = "127.0.0.1";
3131const DESKTOP_LAN_BIND_HOST = "0.0.0.0";
3232
3333interface ResolvedDesktopServerExposure {
......@@ -411,6 +411,7 @@ const requiresBackendRelaunch = (previous: RuntimeState, next: RuntimeState): bo
411411 previous.bindHost !== next.bindHost ||
412412 previous.localHttpUrl !== next.localHttpUrl;
413413
414/** @public Service construction is part of the canonical Effect module API. */
414415export const make = Effect.gen(function* () {
415416 const config = yield* DesktopConfig.DesktopConfig;
416417 const networkInterfaces = yield* DesktopNetworkInterfaces.DesktopNetworkInterfaces;
apps/desktop/src/backend/tailscaleEndpointProvider.ts+1-1
......@@ -14,7 +14,7 @@ import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawne
1414
1515import type { NetworkInterfaces } from "./DesktopNetworkInterfaces.ts";
1616
17export { isTailscaleIpv4Address, parseTailscaleMagicDnsName } from "@t3tools/tailscale";
17export { parseTailscaleMagicDnsName } from "@t3tools/tailscale";
1818
1919const TAILSCALE_ENDPOINT_PROVIDER: AdvertisedEndpointProvider = {
2020 id: "tailscale",
apps/desktop/src/settings/DesktopAppSettings.ts+2-1
......@@ -55,7 +55,7 @@ export interface DesktopSettingsChange {
5555 readonly changed: boolean;
5656}
5757
58export const DEFAULT_TAILSCALE_SERVE_PORT = 443;
58const DEFAULT_TAILSCALE_SERVE_PORT = 443;
5959const MIN_MAIN_WINDOW_SIZE = {
6060 width: 840,
6161 height: 620,
......@@ -450,6 +450,7 @@ const writeSettings = Effect.fn("desktop.settings.writeSettings")(function* (inp
450450 );
451451});
452452
453/** @public Service construction is part of the canonical Effect module API. */
453454export const make = Effect.gen(function* () {
454455 const environment = yield* DesktopEnvironment.DesktopEnvironment;
455456 const fileSystem = yield* FileSystem.FileSystem;
apps/desktop/src/settings/DesktopSavedEnvironments.ts+1-53
......@@ -9,7 +9,6 @@ import * as Layer from "effect/Layer";
99import * as Option from "effect/Option";
1010import * as Path from "effect/Path";
1111import * as Schema from "effect/Schema";
12import * as Ref from "effect/Ref";
1312
1413import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
1514import * as ElectronSafeStorage from "../electron/ElectronSafeStorage.ts";
......@@ -365,6 +364,7 @@ function decodeSecretBytes(
365364 );
366365}
367366
367/** @public Service construction is part of the canonical Effect module API. */
368368export const make = Effect.gen(function* () {
369369 const environment = yield* DesktopEnvironment.DesktopEnvironment;
370370 const fileSystem = yield* FileSystem.FileSystem;
......@@ -555,55 +555,3 @@ export const make = Effect.gen(function* () {
555555});
556556
557557export const layer = Layer.effect(DesktopSavedEnvironments, make);
558
559export const layerTest = (input?: {
560 readonly records?: readonly PersistedSavedEnvironmentRecord[];
561 readonly secrets?: ReadonlyMap<string, string>;
562}) =>
563 Layer.effect(
564 DesktopSavedEnvironments,
565 Effect.gen(function* () {
566 const recordsRef = yield* Ref.make(input?.records ?? []);
567 const secretsRef = yield* Ref.make(new Map(input?.secrets ?? []));
568
569 return DesktopSavedEnvironments.of({
570 getRegistry: Ref.get(recordsRef),
571 setRegistry: (records) => Ref.set(recordsRef, records),
572 removeEnvironment: (environmentId) =>
573 Ref.update(recordsRef, (records) =>
574 records.filter((record) => record.environmentId !== environmentId),
575 ).pipe(
576 Effect.andThen(
577 Ref.update(secretsRef, (secrets) => {
578 const nextSecrets = new Map(secrets);
579 nextSecrets.delete(environmentId);
580 return nextSecrets;
581 }),
582 ),
583 ),
584 getSecret: (environmentId) =>
585 Ref.get(secretsRef).pipe(
586 Effect.map((secrets) => Option.fromNullishOr(secrets.get(environmentId))),
587 ),
588 setSecret: ({ environmentId, secret }) =>
589 Ref.get(recordsRef).pipe(
590 Effect.flatMap((records) => {
591 if (!records.some((record) => record.environmentId === environmentId)) {
592 return Effect.succeed(false);
593 }
594 return Ref.update(secretsRef, (secrets) => {
595 const nextSecrets = new Map(secrets);
596 nextSecrets.set(environmentId, secret);
597 return nextSecrets;
598 }).pipe(Effect.as(true));
599 }),
600 ),
601 removeSecret: (environmentId) =>
602 Ref.update(secretsRef, (secrets) => {
603 const nextSecrets = new Map(secrets);
604 nextSecrets.delete(environmentId);
605 return nextSecrets;
606 }),
607 });
608 }),
609 );
apps/desktop/src/telemetry/DesktopTelemetryPublisher.ts+1
......@@ -145,6 +145,7 @@ function sampleInterval(
145145 return LIVE_SAMPLE_INTERVAL;
146146}
147147
148/** @public Service construction is part of the canonical Effect module API. */
148149export const make = Effect.fn("desktop.telemetryPublisher.make")(function* () {
149150 const electronApp = yield* ElectronApp.ElectronApp;
150151 const powerMonitor = yield* ElectronPowerMonitor.ElectronPowerMonitor;
apps/desktop/src/wsl/DesktopWslServerTree.ts+1
......@@ -116,6 +116,7 @@ const copyTree = (
116116 }),
117117 );
118118
119/** @public Service construction is part of the canonical Effect module API. */
119120export const make = Effect.gen(function* () {
120121 const environment = yield* DesktopEnvironment.DesktopEnvironment;
121122 const fs = yield* FileSystem.FileSystem;