refactor(chat): modify newSession logic to avoid resetting old sessio… (#185)
This commit is contained in:
@@ -1010,19 +1010,10 @@ export const useChatStore = create<ChatState>((set, get) => ({
|
|||||||
// ── New session ──
|
// ── New session ──
|
||||||
|
|
||||||
newSession: () => {
|
newSession: () => {
|
||||||
const { currentSessionKey } = get();
|
// Generate a new unique session key and switch to it.
|
||||||
|
// NOTE: We intentionally do NOT call sessions.reset on the old session.
|
||||||
// Notify the gateway that the old session is ending so the session-memory
|
// sessions.reset archives (renames) the session JSONL file, making old
|
||||||
// hook can persist conversation memories to memory/YYYY-MM-DD-<slug>.md.
|
// conversation history inaccessible when the user switches back to it.
|
||||||
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
|
|
||||||
const prefix = getCanonicalPrefixFromSessions(get().sessions) ?? DEFAULT_CANONICAL_PREFIX;
|
const prefix = getCanonicalPrefixFromSessions(get().sessions) ?? DEFAULT_CANONICAL_PREFIX;
|
||||||
const newKey = `${prefix}:session-${Date.now()}`;
|
const newKey = `${prefix}:session-${Date.now()}`;
|
||||||
const newSessionEntry: ChatSession = { key: newKey, displayName: newKey };
|
const newSessionEntry: ChatSession = { key: newKey, displayName: newKey };
|
||||||
|
|||||||
Reference in New Issue
Block a user