From 45932a95c326336fafaa58cf05552bc745fa58fd Mon Sep 17 00:00:00 2001 From: Haze <709547807@qq.com> Date: Thu, 26 Feb 2026 15:23:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor(chat):=20modify=20newSession=20logic?= =?UTF-8?q?=20to=20avoid=20resetting=20old=20sessio=E2=80=A6=20(#185)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/chat.ts | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/stores/chat.ts b/src/stores/chat.ts index cc000ea24..2928ffe94 100644 --- a/src/stores/chat.ts +++ b/src/stores/chat.ts @@ -1010,19 +1010,10 @@ export const useChatStore = create((set, get) => ({ // ── New session ── newSession: () => { - const { currentSessionKey } = get(); - - // Notify the gateway that the old session is ending so the session-memory - // hook can persist conversation memories to memory/YYYY-MM-DD-.md. - if (currentSessionKey) { - void window.electron.ipcRenderer.invoke( - 'gateway:rpc', - 'sessions.reset', - { key: currentSessionKey, reason: 'new' }, - ).catch(() => { /* fire-and-forget */ }); - } - - // Generate a new unique session key and switch to it + // Generate a new unique session key and switch to it. + // NOTE: We intentionally do NOT call sessions.reset on the old session. + // sessions.reset archives (renames) the session JSONL file, making old + // conversation history inaccessible when the user switches back to it. const prefix = getCanonicalPrefixFromSessions(get().sessions) ?? DEFAULT_CANONICAL_PREFIX; const newKey = `${prefix}:session-${Date.now()}`; const newSessionEntry: ChatSession = { key: newKey, displayName: newKey };