diff options
| author | akbash <akbash@herdr.dev> | 2026-09-10 13:19:25 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-10 13:19:25 +0300 |
| commit | 6fe8f818b91a2565f3546f9dc6b3b18f8a55b065 (patch) | |
| tree | d2a2d5f42ab7b0a740efde889131340d38de8620 | |
| parent | 120c682008a85dc17d7a13cc619a2fd5d25f3924 (diff) | |
fix(pi): support Windows session paths (#3729)
refs #3726
Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
| -rw-r--r-- | src/integration/assets/herdr-agent-state.test.ts | 29 | ||||
| -rw-r--r-- | src/integration/assets/pi/herdr-agent-state.ts | 8 | ||||
| -rw-r--r-- | src/integration/mod.rs | 2 | ||||
| -rw-r--r-- | tests/cli/sessions.rs | 2 |
4 files changed, 37 insertions, 4 deletions
diff --git a/src/integration/assets/herdr-agent-state.test.ts b/src/integration/assets/herdr-agent-state.test.ts index 7720e088..48cc8708 100644 --- a/src/integration/assets/herdr-agent-state.test.ts +++ b/src/integration/assets/herdr-agent-state.test.ts @@ -240,6 +240,28 @@ test("OMP accepts POSIX and Windows session paths", async () => { expect(isAbsoluteSessionPath("relative/omp-session.jsonl")).toBe(false); }); +test("Pi reports a Windows session path", async () => { + const requests = await startRecordingServer("pi-windows-session-path"); + const { handlers, pi } = createExtensionHarness(); + const { default: install } = await importFresh("./pi/herdr-agent-state.ts"); + install(pi); + + const sessionPath = "C:\\Users\\User\\.pi\\agent\\sessions\\pi-session.jsonl"; + await handlers.get("session_start")?.( + { reason: "startup" }, + { + ...piContext(() => true), + sessionManager: { + getSessionFile: () => sessionPath, + getSessionId: () => "pi-session", + }, + }, + ); + await waitFor(() => requests.length === 2); + + expect(requests.map(requestSessionPath)).toEqual([sessionPath, sessionPath]); +}); + test("Pi reports idle only after the agent settles", async () => { const requests = await startRecordingServer("pi-settled"); const { handlers, pi } = createExtensionHarness(); @@ -617,6 +639,13 @@ function requestState(request: unknown): unknown { return request.params.state; } +function requestSessionPath(request: unknown): unknown { + if (!isRecord(request) || !isRecord(request.params)) { + return undefined; + } + return request.params.agent_session_path; +} + function isRecord(value: unknown): value is Record<string, unknown> { return typeof value === "object" && value !== null; } diff --git a/src/integration/assets/pi/herdr-agent-state.ts b/src/integration/assets/pi/herdr-agent-state.ts index 67bc4188..276c964d 100644 --- a/src/integration/assets/pi/herdr-agent-state.ts +++ b/src/integration/assets/pi/herdr-agent-state.ts @@ -2,10 +2,11 @@ // managed by herdr; reinstalling or updating the integration overwrites this file. // add custom hooks/plugins beside this file instead of editing it. // HERDR_INTEGRATION_ID=pi -// HERDR_INTEGRATION_VERSION=8 +// HERDR_INTEGRATION_VERSION=9 // @ts-nocheck import net from "node:net"; +import path from "node:path"; const HERDR_ENV = process.env.HERDR_ENV; const socketPath = process.env.HERDR_SOCKET_PATH; @@ -74,7 +75,10 @@ function updateSessionRef(ctx: any): void { try { const file = ctx?.sessionManager?.getSessionFile?.(); currentAgentSessionPath = - typeof file === "string" && file.startsWith("/") ? file : undefined; + typeof file === "string" && + (path.posix.isAbsolute(file) || path.win32.isAbsolute(file)) + ? file + : undefined; } catch { currentAgentSessionPath = undefined; } diff --git a/src/integration/mod.rs b/src/integration/mod.rs index 3f7176b3..3bb8485c 100644 --- a/src/integration/mod.rs +++ b/src/integration/mod.rs @@ -24,7 +24,7 @@ pub(crate) use types::{IntegrationRecommendation, IntegrationStatus, Integration const PI_EXTENSION_INSTALL_NAME: &str = "herdr-agent-state.ts"; const PI_EXTENSION_ASSET: &str = include_str!("assets/pi/herdr-agent-state.ts"); -const PI_INTEGRATION_VERSION: u32 = 8; +const PI_INTEGRATION_VERSION: u32 = 9; const OMP_EXTENSION_INSTALL_NAME: &str = "herdr-omp-agent-state.ts"; const OMP_EXTENSION_ASSET: &str = include_str!("assets/omp/herdr-agent-state.ts"); const OMP_INTEGRATION_VERSION: u32 = 9; diff --git a/tests/cli/sessions.rs b/tests/cli/sessions.rs index 8e5fc48f..5d87f73b 100644 --- a/tests/cli/sessions.rs +++ b/tests/cli/sessions.rs @@ -293,7 +293,7 @@ fn integration_commands_run_locally_when_server_is_missing() { .unwrap(); assert_eq!(integration_status.status.code(), Some(0)); let status_stdout = String::from_utf8_lossy(&integration_status.stdout); - assert!(status_stdout.contains("pi: current (v8)")); + assert!(status_stdout.contains("pi: current (v9)")); assert!(status_stdout.contains("claude: not installed")); let integration_uninstall = Command::new(env!("CARGO_BIN_EXE_herdr")) |
