Skip to content

Commit 4fd208f

Browse files
authored
fix(sessions): preserve conversation preferences on reset (#126575)
1 parent 7646223 commit 4fd208f

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

‎src/gateway/server.sessions.reset-cleanup.test.ts‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,27 +1045,32 @@ test("sessions.reset directly unbinds thread bindings when hooks are unavailable
10451045
});
10461046
});
10471047

1048-
test("sessions.reset preserves explicit responseUsage preference across session rollover", async () => {
1049-
// Regression: a full session reset must carry the user's display preference forward
1050-
// so the usage footer mode survives rollovers. Only /usage reset clears the override.
1051-
const { dir } = await createSessionStoreDir();
1048+
test("sessions.reset preserves explicit session preferences across session rollover", async () => {
1049+
// Reset clears conversation state without discarding operator-owned session preferences.
1050+
const { dir, storePath } = await createSessionStoreDir();
10521051
await writeSingleLineSession(dir, "sess-main", "hello");
1052+
const preferences = {
1053+
responseUsage: "tokens",
1054+
pinnedAt: 123,
1055+
label: "Operator session",
1056+
category: "Operator group",
1057+
icon: "🦞",
1058+
boardFace: "dashboard",
1059+
visibility: "draft",
1060+
} satisfies Partial<InternalSessionEntry>;
10531061
await writeSessionStore({
10541062
entries: {
1055-
main: sessionStoreEntry("sess-main", {
1056-
responseUsage: "tokens",
1057-
pinnedAt: 123,
1058-
}),
1063+
main: sessionStoreEntry("sess-main", preferences),
10591064
},
10601065
});
10611066

10621067
const reset = await directSessionReq<{
10631068
ok: true;
10641069
key: string;
1065-
entry: { sessionId: string; responseUsage?: string; pinnedAt?: number };
1070+
entry: InternalSessionEntry;
10661071
}>("sessions.reset", { key: "main" });
10671072

10681073
expect(reset.ok).toBe(true);
1069-
expect(reset.payload?.entry.responseUsage).toBe("tokens");
1070-
expect(reset.payload?.entry.pinnedAt).toBe(123);
1074+
expect(reset.payload?.entry).toMatchObject(preferences);
1075+
expect(loadSessionEntry({ sessionKey: "agent:main:main", storePath })).toMatchObject(preferences);
10711076
});

‎src/gateway/session-reset-service.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,10 @@ export async function performGatewaySessionReset(params: {
15781578
subagentRole: currentEntry?.subagentRole,
15791579
subagentControlScope: currentEntry?.subagentControlScope,
15801580
label: currentEntry?.label,
1581+
icon: currentEntry?.icon,
1582+
category: currentEntry?.category,
1583+
boardFace: currentEntry?.boardFace,
1584+
visibility: currentEntry?.visibility,
15811585
displayName: currentEntry?.displayName,
15821586
delivery: currentEntry?.delivery,
15831587
pendingDeliveryNotice: currentEntry?.pendingDeliveryNotice,

0 commit comments

Comments
 (0)