Skip to content

Commit 5138598

Browse files
refactor(shared): host process references live in a HostProcess module
The host references were named exports of a camelCase hostProcess module, imported by name (`HostProcessPlatform`, `HostProcessHomeDirectory`, ...). They are now short exports of `@t3tools/shared/HostProcess`, imported as a namespace like every other service module: `HostProcess.Platform`, `HostProcess.HomeDirectory`, `HostProcess.isWindows`. Reference keys follow the new module path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bad2dd3 commit 5138598

234 files changed

Lines changed: 948 additions & 1145 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/src/app/DesktopApp.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import * as DesktopUpdates from "../updates/DesktopUpdates.ts";
3535
import * as DesktopSnapShot from "../snapShot/DesktopSnapShot.ts";
3636
import * as DesktopWslBackend from "../wsl/DesktopWslBackend.ts";
3737
import * as DesktopRendererHistory from "../telemetry/DesktopRendererHistory.ts";
38-
import { HostProcessHomeDirectory } from "@t3tools/shared/hostProcess";
38+
import * as HostProcess from "@t3tools/shared/HostProcess";
3939

4040
const DEFAULT_DESKTOP_BACKEND_PORT = 3773;
4141
const MAX_TCP_PORT = 65_535;
@@ -286,7 +286,7 @@ const startup = Effect.gen(function* () {
286286
const linuxElectronOptions =
287287
environment.platform === "linux" && !hasCommandLinePasswordStore
288288
? DesktopPreReadyPlatform.resolveEarlyLinuxElectronOptionsFromProcess(
289-
yield* HostProcessHomeDirectory,
289+
yield* HostProcess.HomeDirectory,
290290
)
291291
: preReadyElectronOptions.linux;
292292
if (linuxElectronOptions !== null && !hasCommandLinePasswordStore) {

‎apps/desktop/src/app/DesktopAppActivation.test.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
type DesktopAppActivationResponse,
1212
} from "@t3tools/contracts";
1313
import { resolveDesktopAppControlAddress } from "@t3tools/shared/desktopAppControl";
14-
import { HostProcessPlatform, HostProcessUserId } from "@t3tools/shared/hostProcess";
14+
import * as HostProcess from "@t3tools/shared/HostProcess";
1515
import { it } from "@effect/vitest";
1616
import * as Effect from "effect/Effect";
1717
import { afterEach, describe, expect } from "vite-plus/test";
@@ -83,8 +83,8 @@ function exchange(address: string, payload: DesktopAppActivationRequest) {
8383
describe("desktop app control server", () => {
8484
it.effect("roundtrips a request and removes its socket on shutdown", () =>
8585
Effect.gen(function* () {
86-
const platform = yield* HostProcessPlatform;
87-
const userId = yield* HostProcessUserId;
86+
const platform = yield* HostProcess.Platform;
87+
const userId = yield* HostProcess.UserId;
8888
yield* Effect.promise(async () => {
8989
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-app-control-test-"));
9090
const target = makeTarget(NodePath.join(root, "userdata"), platform, userId);
@@ -123,8 +123,8 @@ describe("desktop app control server", () => {
123123

124124
it.effect("cancels a queued request when the client disconnects", () =>
125125
Effect.gen(function* () {
126-
const platform = yield* HostProcessPlatform;
127-
const userId = yield* HostProcessUserId;
126+
const platform = yield* HostProcess.Platform;
127+
const userId = yield* HostProcess.UserId;
128128
yield* Effect.promise(async () => {
129129
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-app-cancel-test-"));
130130
const target = makeTarget(NodePath.join(root, "userdata"), platform, userId);
@@ -162,8 +162,8 @@ describe("desktop app control server", () => {
162162
// Two desktop apps can share one state dir, such as nightly and a preview build.
163163
it.effect("keeps a newer app's socket when an older app on the same state dir quits", () =>
164164
Effect.gen(function* () {
165-
const platform = yield* HostProcessPlatform;
166-
const userId = yield* HostProcessUserId;
165+
const platform = yield* HostProcess.Platform;
166+
const userId = yield* HostProcess.UserId;
167167
if (platform === "win32") return;
168168
yield* Effect.promise(async () => {
169169
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-app-takeover-test-"));
@@ -183,8 +183,8 @@ describe("desktop app control server", () => {
183183

184184
it.effect("binds its address again after the socket file is removed", () =>
185185
Effect.gen(function* () {
186-
const platform = yield* HostProcessPlatform;
187-
const userId = yield* HostProcessUserId;
186+
const platform = yield* HostProcess.Platform;
187+
const userId = yield* HostProcess.UserId;
188188
if (platform === "win32") return;
189189
yield* Effect.promise(async () => {
190190
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-app-reclaim-test-"));

‎apps/desktop/src/app/DesktopAppActivation.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
type DesktopAppActivationResponse,
1313
} from "@t3tools/contracts";
1414
import { resolveDesktopAppControlAddress } from "@t3tools/shared/desktopAppControl";
15-
import { HostProcessUserId } from "@t3tools/shared/hostProcess";
15+
import * as HostProcess from "@t3tools/shared/HostProcess";
1616
import * as Context from "effect/Context";
1717
import * as Effect from "effect/Effect";
1818
import * as Layer from "effect/Layer";
@@ -315,7 +315,7 @@ export const make = Effect.gen(function* () {
315315
const desktopWindow = yield* DesktopWindow.DesktopWindow;
316316
const electronWindow = yield* ElectronWindow.ElectronWindow;
317317
const path = yield* Path.Path;
318-
const userId = yield* HostProcessUserId;
318+
const userId = yield* HostProcess.UserId;
319319
const runPromise = Effect.runPromiseWith(yield* Effect.context<never>());
320320
const address = resolveDesktopAppControlAddress({
321321
stateDir: path.resolve(desktopEnvironment.stateDir),

‎apps/desktop/src/app/DesktopClerk.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as NodeHttp from "node:http";
33
import * as NodePath from "@effect/platform-node/NodePath";
44
import { codexAuthHandoffUrl, readCodexAuthDelivery } from "@t3tools/shared/codexAuthHandoff";
55
import { EnvironmentId, ProviderInstanceId } from "@t3tools/contracts";
6-
import { HostProcessArguments } from "@t3tools/shared/hostProcess";
6+
import * as HostProcess from "@t3tools/shared/HostProcess";
77
import { assert, describe, it } from "@effect/vitest";
88
import * as Cause from "effect/Cause";
99
import * as Effect from "effect/Effect";
@@ -375,7 +375,7 @@ it.effect.each(["startup", "open-url"] as const)(
375375
assert.strictEqual(delivery?.returnUrl, request.returnUrl);
376376
}).pipe(
377377
Effect.provide(layerDesktopClerk(true, [], "darwin", undefined, shell)),
378-
Effect.provideService(HostProcessArguments, entry === "startup" ? ["t3", link] : ["t3"]),
378+
Effect.provideService(HostProcess.Arguments, entry === "startup" ? ["t3", link] : ["t3"]),
379379
Effect.provideService(ElectronApp.ElectronApp, electronApp),
380380
Effect.provideService(
381381
ElectronWindow.ElectronWindow,

‎apps/desktop/src/app/DesktopClerk.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { codexAuthDeliveryUrl, readCodexAuthHandoff } from "@t3tools/shared/code
1111
import { receiveCodexAuthCallback, CodexAuthCallbackError } from "./CodexAuthCallback.ts";
1212
import * as ElectronShell from "../electron/ElectronShell.ts";
1313
import { providerAuthReturnUrl } from "@t3tools/shared/providerAuthReturnUrl";
14-
import { HostProcessArguments } from "@t3tools/shared/hostProcess";
14+
import * as HostProcess from "@t3tools/shared/HostProcess";
1515
import { clerkFrontendApiHostnameFromPublishableKey } from "@t3tools/shared/relayAuth";
1616
import * as ElectronApp from "../electron/ElectronApp.ts";
1717
import * as ElectronProtocol from "../electron/ElectronProtocol.ts";
@@ -182,7 +182,7 @@ export const make = Effect.gen(function* () {
182182
);
183183
return true;
184184
};
185-
const args = yield* HostProcessArguments;
185+
const args = yield* HostProcess.Arguments;
186186
args.some((value) => startProviderAuthHandoff(value));
187187
yield* electronApp.on("open-url", (event: { preventDefault: () => void }, url: string) => {
188188
if (startProviderAuthHandoff(url) || resumeProviderAuth(url)) event.preventDefault();

‎apps/desktop/src/app/DesktopPreReadyFileSystem.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as NodeServices from "@effect/platform-node/NodeServices";
22
import { assert, it } from "@effect/vitest";
3-
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
3+
import * as HostProcess from "@t3tools/shared/HostProcess";
44
import * as Effect from "effect/Effect";
55
import * as Exit from "effect/Exit";
66
import * as FileSystem from "effect/FileSystem";
@@ -32,7 +32,7 @@ it.layer(NodeServices.layer)("DesktopPreReadyFileSystem", (it) => {
3232
}),
3333
);
3434

35-
it.effect.skipIf(HostProcessPlatform.defaultValue() === "win32" || process.getuid?.() === 0)(
35+
it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32" || process.getuid?.() === 0)(
3636
"fails instead of treating an unreadable profile as missing",
3737
() =>
3838
Effect.gen(function* () {

‎apps/desktop/src/app/DesktopPreReadyPlatform.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assert, describe, it } from "@effect/vitest";
2-
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
2+
import * as HostProcess from "@t3tools/shared/HostProcess";
33
import * as Context from "effect/Context";
44
import * as Effect from "effect/Effect";
55
import * as Layer from "effect/Layer";
@@ -75,7 +75,7 @@ describe("DesktopPreReadyPlatform", () => {
7575
}).pipe(
7676
Effect.provide(
7777
DesktopPreReadyPlatform.layer.pipe(
78-
Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
78+
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
7979
),
8080
),
8181
);
@@ -111,7 +111,7 @@ describe("DesktopPreReadyPlatform", () => {
111111
}));
112112
yield* Layer.build(
113113
DesktopPreReadyPlatform.layer.pipe(
114-
Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
114+
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
115115
),
116116
);
117117
const identity = yield* Effect.promise(() => portalIdentity);
@@ -135,7 +135,7 @@ describe("DesktopPreReadyPlatform", () => {
135135
});
136136

137137
return DesktopPreReadyPlatform.make.pipe(
138-
Effect.provideService(HostProcessPlatform, "linux"),
138+
Effect.provideService(HostProcess.Platform, "linux"),
139139
Effect.asVoid,
140140
);
141141
});
@@ -151,7 +151,7 @@ describe("DesktopPreReadyPlatform", () => {
151151
assert.include(contents, "MimeType=x-scheme-handler/t3code;");
152152
assert.include(contents, "Icon=");
153153
assert.equal(setDesktopNameMock.mock.calls.length, 1);
154-
}).pipe(Effect.provideService(HostProcessPlatform, "linux"));
154+
}).pipe(Effect.provideService(HostProcess.Platform, "linux"));
155155
});
156156

157157
it.effect(
@@ -168,7 +168,7 @@ describe("DesktopPreReadyPlatform", () => {
168168
});
169169

170170
const layerPreReady = DesktopPreReadyPlatform.layer.pipe(
171-
Layer.provide(Layer.succeed(HostProcessPlatform, "darwin")),
171+
Layer.provide(Layer.succeed(HostProcess.Platform, "darwin")),
172172
);
173173

174174
const layerClerkShaped = Layer.effect(

‎apps/desktop/src/app/DesktopPreReadyPlatform.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as Effect from "effect/Effect";
66
import * as Layer from "effect/Layer";
77

88
import * as Electron from "electron";
9-
import { HostProcessHomeDirectory, HostProcessPlatform } from "@t3tools/shared/hostProcess";
9+
import * as HostProcess from "@t3tools/shared/HostProcess";
1010

1111
import * as DesktopEarlyElectronStartup from "./DesktopEarlyElectronStartup.ts";
1212
import { resolveDesktopAppBranding } from "./DesktopEnvironment.ts";
@@ -50,8 +50,8 @@ export class DesktopPreReadyElectronOptions extends Context.Service<
5050

5151
/** @public Service construction is part of the canonical Effect module API. */
5252
export const make = Effect.gen(function* () {
53-
const platform = yield* HostProcessPlatform;
54-
const homeDirectory = yield* HostProcessHomeDirectory;
53+
const platform = yield* HostProcess.Platform;
54+
const homeDirectory = yield* HostProcess.HomeDirectory;
5555
return yield* Effect.sync((): DesktopPreReadyElectronOptions["Service"] => {
5656
const linuxPasswordStoreCommandLine =
5757
platform === "linux"

‎apps/desktop/src/backend/DesktopNetworkInterfaces.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assert, describe, it } from "@effect/vitest";
2-
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
2+
import * as HostProcess from "@t3tools/shared/HostProcess";
33
import * as Cause from "effect/Cause";
44
import * as Effect from "effect/Effect";
55
import * as Layer from "effect/Layer";
@@ -16,7 +16,7 @@ vi.mock("node:os", () => ({
1616
import * as DesktopNetworkInterfaces from "./DesktopNetworkInterfaces.ts";
1717

1818
const layerTest = DesktopNetworkInterfaces.layer.pipe(
19-
Layer.provide(Layer.succeed(HostProcessPlatform, "linux")),
19+
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
2020
);
2121

2222
describe("DesktopNetworkInterfaces", () => {

‎apps/desktop/src/backend/DesktopNetworkInterfaces.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as NodeOS from "node:os";
22

3-
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
3+
import * as HostProcess from "@t3tools/shared/HostProcess";
44
import * as Context from "effect/Context";
55
import * as Effect from "effect/Effect";
66
import * as Layer from "effect/Layer";
@@ -41,7 +41,7 @@ export class DesktopNetworkInterfaces extends Context.Service<
4141

4242
/** @public Service construction is part of the canonical Effect module API. */
4343
export const make = Effect.gen(function* () {
44-
const platform = yield* HostProcessPlatform;
44+
const platform = yield* HostProcess.Platform;
4545
return DesktopNetworkInterfaces.of({
4646
read: Effect.try({
4747
try: () => NodeOS.networkInterfaces(),

0 commit comments

Comments
 (0)