fix: clear localStorage when creating new session

- Added localStorage.removeItem(SESSION_STORAGE_KEY) to handleNewSession
- Prevents old messages from reappearing after page refresh
- New session now starts completely clean
This commit is contained in:
2026-10-27 16:41:51 +08:00
parent c5b8069af4
commit ab7281dbf4

View File

@@ -826,6 +826,9 @@ async function handleNewSession() {
console.log('[handleNewSession] No current session or no messages to save') console.log('[handleNewSession] No current session or no messages to save')
} }
// Clear localStorage so old messages don't reappear on refresh
localStorage.removeItem(SESSION_STORAGE_KEY)
// Create new session // Create new session
const now = new Date() const now = new Date()
const timeStr = `${now.getFullYear()}/${(now.getMonth()+1).toString().padStart(2,'0')}/${now.getDate().toString().padStart(2,'0')} ${now.getHours().toString().padStart(2,'0')}:${now.getMinutes().toString().padStart(2,'0')}` const timeStr = `${now.getFullYear()}/${(now.getMonth()+1).toString().padStart(2,'0')}/${now.getDate().toString().padStart(2,'0')} ${now.getHours().toString().padStart(2,'0')}:${now.getMinutes().toString().padStart(2,'0')}`