diff --git a/src/tests/websocket/listen-client-protocol.test.ts b/src/tests/websocket/listen-client-protocol.test.ts index 348c6c1..e7d4f9b 100644 --- a/src/tests/websocket/listen-client-protocol.test.ts +++ b/src/tests/websocket/listen-client-protocol.test.ts @@ -247,6 +247,14 @@ describe("listen-client state_response control protocol", () => { const snapshot = __listenClientTestUtils.buildStateResponse(runtime, 1); expect(snapshot.control_response_capable).toBe(true); }); + + test("includes the effective working directory", () => { + const runtime = __listenClientTestUtils.createRuntime(); + const snapshot = __listenClientTestUtils.buildStateResponse(runtime, 1); + + expect(typeof snapshot.cwd).toBe("string"); + expect(snapshot.cwd.length).toBeGreaterThan(0); + }); }); describe("listen-client state_response pending interrupt snapshot", () => { diff --git a/src/websocket/listen-client.ts b/src/websocket/listen-client.ts index 69ed17f..487dfa7 100644 --- a/src/websocket/listen-client.ts +++ b/src/websocket/listen-client.ts @@ -187,6 +187,7 @@ interface StateResponseMessage { snapshot_id: string; generated_at: string; state_seq: number; + cwd: string; mode: "default" | "acceptEdits" | "plan" | "bypassPermissions"; is_processing: boolean; last_stop_reason: string | null; @@ -723,6 +724,7 @@ function buildStateResponse( generated_at: new Date().toISOString(), state_seq: stateSeq, event_seq: stateSeq, + cwd: process.env.USER_CWD || process.cwd(), mode: permissionMode.getMode(), is_processing: runtime.isProcessing, last_stop_reason: runtime.lastStopReason,