From fa56682b3cedde5e46b3239e8c8cbe4186e40301 Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Fri, 27 Mar 2026 15:46:49 -0500 Subject: [PATCH] fix(regression): preserve CLI bindings across session reset --- ...sessions.gateway-server-sessions-a.test.ts | 51 +++++++++++++++++-- src/gateway/session-reset-service.ts | 3 ++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/gateway/server.sessions.gateway-server-sessions-a.test.ts b/src/gateway/server.sessions.gateway-server-sessions-a.test.ts index 796890a29d2..e2f5360693d 100644 --- a/src/gateway/server.sessions.gateway-server-sessions-a.test.ts +++ b/src/gateway/server.sessions.gateway-server-sessions-a.test.ts @@ -1163,6 +1163,13 @@ describe("gateway server sessions", () => { cliSessionIds: { "claude-cli": "cli-session-123", }, + cliSessionBindings: { + "claude-cli": { + sessionId: "cli-session-123", + authProfileId: "anthropic:work", + extraSystemPromptHash: "prompt-hash", + }, + }, claudeCliSessionId: "cli-session-123", deliveryContext: { channel: "discord", @@ -1213,6 +1220,15 @@ describe("gateway server sessions", () => { execAsk?: string; execNode?: string; displayName?: string; + cliSessionBindings?: Record< + string, + { + sessionId?: string; + authProfileId?: string; + extraSystemPromptHash?: string; + mcpConfigHash?: string; + } + >; cliSessionIds?: Record; claudeCliSessionId?: string; deliveryContext?: { @@ -1259,8 +1275,17 @@ describe("gateway server sessions", () => { expect(reset.payload?.entry.execAsk).toBe("on-miss"); expect(reset.payload?.entry.execNode).toBe("mac-mini"); expect(reset.payload?.entry.displayName).toBe("Ops Child"); - expect(reset.payload?.entry.cliSessionIds).toBeUndefined(); - expect(reset.payload?.entry.claudeCliSessionId).toBeUndefined(); + expect(reset.payload?.entry.cliSessionBindings).toEqual({ + "claude-cli": { + sessionId: "cli-session-123", + authProfileId: "anthropic:work", + extraSystemPromptHash: "prompt-hash", + }, + }); + expect(reset.payload?.entry.cliSessionIds).toEqual({ + "claude-cli": "cli-session-123", + }); + expect(reset.payload?.entry.claudeCliSessionId).toBe("cli-session-123"); expect(reset.payload?.entry.deliveryContext).toEqual({ channel: "discord", to: "discord:child", @@ -1305,6 +1330,15 @@ describe("gateway server sessions", () => { execAsk?: string; execNode?: string; displayName?: string; + cliSessionBindings?: Record< + string, + { + sessionId?: string; + authProfileId?: string; + extraSystemPromptHash?: string; + mcpConfigHash?: string; + } + >; cliSessionIds?: Record; claudeCliSessionId?: string; deliveryContext?: { @@ -1349,8 +1383,17 @@ describe("gateway server sessions", () => { expect(store["agent:main:subagent:child"]?.execAsk).toBe("on-miss"); expect(store["agent:main:subagent:child"]?.execNode).toBe("mac-mini"); expect(store["agent:main:subagent:child"]?.displayName).toBe("Ops Child"); - expect(store["agent:main:subagent:child"]?.cliSessionIds).toBeUndefined(); - expect(store["agent:main:subagent:child"]?.claudeCliSessionId).toBeUndefined(); + expect(store["agent:main:subagent:child"]?.cliSessionBindings).toEqual({ + "claude-cli": { + sessionId: "cli-session-123", + authProfileId: "anthropic:work", + extraSystemPromptHash: "prompt-hash", + }, + }); + expect(store["agent:main:subagent:child"]?.cliSessionIds).toEqual({ + "claude-cli": "cli-session-123", + }); + expect(store["agent:main:subagent:child"]?.claudeCliSessionId).toBe("cli-session-123"); expect(store["agent:main:subagent:child"]?.deliveryContext).toEqual({ channel: "discord", to: "discord:child", diff --git a/src/gateway/session-reset-service.ts b/src/gateway/session-reset-service.ts index 1409aa9f91d..b8af8bcaf65 100644 --- a/src/gateway/session-reset-service.ts +++ b/src/gateway/session-reset-service.ts @@ -368,6 +368,9 @@ export async function performGatewaySessionReset(params: { space: currentEntry?.space, origin: snapshotSessionOrigin(currentEntry), deliveryContext: currentEntry?.deliveryContext, + cliSessionBindings: currentEntry?.cliSessionBindings, + cliSessionIds: currentEntry?.cliSessionIds, + claudeCliSessionId: currentEntry?.claudeCliSessionId, lastChannel: currentEntry?.lastChannel, lastTo: currentEntry?.lastTo, lastAccountId: currentEntry?.lastAccountId,