Skip to content

Commit 22d1f80

Browse files
committed
fix(pi): match platform home selection for usage
1 parent 95455f1 commit 22d1f80

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎apps/server/src/usage/UsageService.test.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ describe("UsageService", () => {
12691269
it.live("discovers Pi history in its default home and directory overrides", () =>
12701270
Effect.gen(function* () {
12711271
const { home, settings } = yield* setup;
1272-
for (const [agentDir, sessionDir, relativeDir, launchArgs, instanceHome] of [
1272+
for (const [agentDir, sessionDir, relativeDir, launchArgs, instanceHome, platform] of [
12731273
[undefined, undefined, ".pi/agent/sessions", undefined],
12741274
["~/custom-pi", undefined, "custom-pi/sessions", undefined],
12751275
["~/ignored-pi", "~/custom-sessions", "custom-sessions", undefined],
@@ -1282,6 +1282,14 @@ describe("UsageService", () => {
12821282
"--session-dir ~/launch-sessions",
12831283
"instance-home ",
12841284
],
1285+
[
1286+
"~/ignored-pi",
1287+
undefined,
1288+
"windows-profile/launch-sessions",
1289+
"--session-dir ~/launch-sessions",
1290+
"windows-profile",
1291+
"win32",
1292+
],
12851293
] as const) {
12861294
const dir = NodePath.join(home, relativeDir);
12871295
yield* Effect.promise(async () => {
@@ -1335,7 +1343,7 @@ describe("UsageService", () => {
13351343
? []
13361344
: [
13371345
{
1338-
name: "HOME",
1346+
name: platform === "win32" ? "USERPROFILE" : "HOME",
13391347
value: NodePath.join(home, instanceHome),
13401348
sensitive: false,
13411349
},
@@ -1347,6 +1355,7 @@ describe("UsageService", () => {
13471355
PI_CODING_AGENT_DIR: agentDir,
13481356
PI_CODING_AGENT_SESSION_DIR: sessionDir,
13491357
},
1358+
platform: platform ?? "linux",
13501359
}),
13511360
),
13521361
Effect.provideService(HostProcess.HomeDirectory, home),

‎packages/provider-pi/src/server/usage.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ export const piUsageReader: ProviderUsageReader<PiSettings, Path.Path> = {
132132
directories: Effect.fn("piUsageReader.directories")(function* ({ config, environment }) {
133133
const path = yield* Path.Path;
134134
const home = yield* HostProcess.HomeDirectory;
135+
const platform = yield* HostProcess.Platform;
136+
const launchHome = (platform === "win32" ? environment.USERPROFILE : environment.HOME) || home;
135137
const sessionDirArg = config === undefined ? undefined : piLaunchSessionDir(config.launchArgs);
136138
const launchDir =
137-
sessionDirArg === undefined
138-
? undefined
139-
: expandHomePath(sessionDirArg, environment.HOME || home);
139+
sessionDirArg === undefined ? undefined : expandHomePath(sessionDirArg, launchHome);
140140
// --session-dir moves only T3-launched sessions; terminal sessions stay in Pi's own directory.
141141
return [
142142
...(launchDir !== undefined && path.isAbsolute(launchDir)

0 commit comments

Comments
 (0)