fix: improve session initialization and save logic
- Fixed onMounted to properly set currentSession after creating default - startNewChat now creates a new session when called - Ensure authToken before all session API calls
This commit is contained in:
Binary file not shown.
@@ -600,18 +600,23 @@ function closeDropdowns(e: MouseEvent) {
|
||||
onMounted(async () => {
|
||||
document.addEventListener('click', closeDropdowns)
|
||||
await ensureFiles()
|
||||
await loadSessions()
|
||||
loadBookmarks()
|
||||
|
||||
// Auto-login and load sessions
|
||||
await loadSessions()
|
||||
|
||||
// Auto-create default session if none exists
|
||||
if (!sessionList.value.length) {
|
||||
await createSession('Default', 'keyword')
|
||||
const defaultSession = await createSession('Default', 'keyword')
|
||||
if (defaultSession) {
|
||||
setCurrentSession(defaultSession)
|
||||
}
|
||||
} else {
|
||||
await loadSessions()
|
||||
}
|
||||
|
||||
// Set first session as current
|
||||
if (sessionList.value.length && !currentSession.value) {
|
||||
setCurrentSession(sessionList.value[0])
|
||||
// Set first session as current
|
||||
if (sessionList.value.length && !currentSession.value) {
|
||||
setCurrentSession(sessionList.value[0])
|
||||
}
|
||||
}
|
||||
|
||||
// Restore session from localStorage
|
||||
|
||||
Reference in New Issue
Block a user