fix(session): preserve overrides on /new reset
Co-authored-by: Yurii Chukhlib <yuri.v.chu@gmail.com>
This commit is contained in:
@@ -278,10 +278,13 @@ export async function initSessionState(params: {
|
|||||||
ctx.MessageThreadId,
|
ctx.MessageThreadId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Fresh start for new sessions - don't inherit old state like compactionCount
|
if (isNewSession) {
|
||||||
sessionStore[sessionKey] = isNewSession
|
sessionEntry.compactionCount = 0;
|
||||||
? sessionEntry
|
sessionEntry.memoryFlushCompactionCount = undefined;
|
||||||
: { ...sessionStore[sessionKey], ...sessionEntry };
|
sessionEntry.memoryFlushAt = undefined;
|
||||||
|
}
|
||||||
|
// Preserve per-session overrides while resetting compaction state on /new.
|
||||||
|
sessionStore[sessionKey] = { ...sessionStore[sessionKey], ...sessionEntry };
|
||||||
await updateSessionStore(storePath, (store) => {
|
await updateSessionStore(storePath, (store) => {
|
||||||
if (groupResolution?.legacyKey && groupResolution.legacyKey !== sessionKey) {
|
if (groupResolution?.legacyKey && groupResolution.legacyKey !== sessionKey) {
|
||||||
if (store[groupResolution.legacyKey] && !store[sessionKey]) {
|
if (store[groupResolution.legacyKey] && !store[sessionKey]) {
|
||||||
@@ -289,10 +292,8 @@ export async function initSessionState(params: {
|
|||||||
}
|
}
|
||||||
delete store[groupResolution.legacyKey];
|
delete store[groupResolution.legacyKey];
|
||||||
}
|
}
|
||||||
// Fresh start for new sessions - don't inherit old state like compactionCount
|
// Preserve per-session overrides while resetting compaction state on /new.
|
||||||
store[sessionKey] = isNewSession
|
store[sessionKey] = { ...store[sessionKey], ...sessionEntry };
|
||||||
? sessionEntry
|
|
||||||
: { ...store[sessionKey], ...sessionEntry };
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const sessionCtx: TemplateContext = {
|
const sessionCtx: TemplateContext = {
|
||||||
|
|||||||
Reference in New Issue
Block a user