fix(session): preserve overrides on /new reset

Co-authored-by: Yurii Chukhlib <yuri.v.chu@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-16 23:51:01 +00:00
parent 6bba84b043
commit 13e2dd97a7

View File

@@ -278,10 +278,13 @@ export async function initSessionState(params: {
ctx.MessageThreadId,
);
}
// Fresh start for new sessions - don't inherit old state like compactionCount
sessionStore[sessionKey] = isNewSession
? sessionEntry
: { ...sessionStore[sessionKey], ...sessionEntry };
if (isNewSession) {
sessionEntry.compactionCount = 0;
sessionEntry.memoryFlushCompactionCount = undefined;
sessionEntry.memoryFlushAt = undefined;
}
// Preserve per-session overrides while resetting compaction state on /new.
sessionStore[sessionKey] = { ...sessionStore[sessionKey], ...sessionEntry };
await updateSessionStore(storePath, (store) => {
if (groupResolution?.legacyKey && groupResolution.legacyKey !== sessionKey) {
if (store[groupResolution.legacyKey] && !store[sessionKey]) {
@@ -289,10 +292,8 @@ export async function initSessionState(params: {
}
delete store[groupResolution.legacyKey];
}
// Fresh start for new sessions - don't inherit old state like compactionCount
store[sessionKey] = isNewSession
? sessionEntry
: { ...store[sessionKey], ...sessionEntry };
// Preserve per-session overrides while resetting compaction state on /new.
store[sessionKey] = { ...store[sessionKey], ...sessionEntry };
});
const sessionCtx: TemplateContext = {