fix(regression): preserve CLI bindings across session reset

This commit is contained in:
Tak Hoffman
2026-03-27 15:46:49 -05:00
parent 9446ee8ea3
commit fa56682b3c
2 changed files with 50 additions and 4 deletions

View File

@@ -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<string, string>;
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<string, string>;
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",

View File

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