feat: expose cwd in listener state snapshots (#1315)

This commit is contained in:
Charles Packer
2026-03-09 18:14:59 -07:00
committed by GitHub
parent f148beee5d
commit 963274bb75
2 changed files with 10 additions and 0 deletions

View File

@@ -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", () => {

View File

@@ -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,