Skip to content

Commit 702ae3f

Browse files
refactor(desktop): acquire DesktopEnvironment from context in resolveUserDataPath
Follow the Effect service convention: the shared helper reads DesktopEnvironment and FileSystem from the environment instead of taking the service instance as a parameter, and DesktopAppIdentity provides its captured context only at the service boundary. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 81fe1ad commit 702ae3f

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ const normalizeCommitHash = (value: string): Option.Option<string> => {
4545
: Option.none();
4646
};
4747

48-
export const resolveUserDataPath = Effect.fn("desktop.appIdentity.resolveUserDataPath")(function* (
49-
environment: DesktopEnvironment.DesktopEnvironment["Service"],
50-
) {
48+
export const resolveUserDataPath = Effect.gen(function* () {
49+
const environment = yield* DesktopEnvironment.DesktopEnvironment;
5150
const fileSystem = yield* FileSystem.FileSystem;
5251
const legacyPath = environment.path.join(
5352
environment.appDataDirectory,
@@ -65,7 +64,7 @@ export const resolveUserDataPath = Effect.fn("desktop.appIdentity.resolveUserDat
6564
return legacyPathExists
6665
? legacyPath
6766
: environment.path.join(environment.appDataDirectory, environment.userDataDirName);
68-
});
67+
}).pipe(Effect.withSpan("desktop.appIdentity.resolveUserDataPath"));
6968

7069
export const make = Effect.gen(function* () {
7170
const assets = yield* DesktopAssets.DesktopAssets;
@@ -112,8 +111,10 @@ export const make = Effect.gen(function* () {
112111
return commitHash;
113112
});
114113

115-
const userDataPath = resolveUserDataPath(environment).pipe(
116-
Effect.provideService(FileSystem.FileSystem, fileSystem),
114+
const userDataPath = resolveUserDataPath.pipe(
115+
Effect.provide(
116+
yield* Effect.context<DesktopEnvironment.DesktopEnvironment | FileSystem.FileSystem>(),
117+
),
117118
);
118119

119120
const configure = Effect.gen(function* () {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const make = Effect.gen(function* () {
9393
// directory here — under the default productName-derived path, acquiring
9494
// the lock would create "T3 Code (Alpha)" and make the legacy-install
9595
// detection in resolveUserDataPath match on fresh installs.
96-
const userDataPath = yield* DesktopAppIdentity.resolveUserDataPath(environment);
96+
const userDataPath = yield* DesktopAppIdentity.resolveUserDataPath;
9797
yield* electronApp.setPath("userData", userDataPath);
9898

9999
const bridge = yield* Effect.acquireRelease(

0 commit comments

Comments
 (0)