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,19 +600,24 @@ function closeDropdowns(e: MouseEvent) {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
document.addEventListener('click', closeDropdowns)
|
document.addEventListener('click', closeDropdowns)
|
||||||
await ensureFiles()
|
await ensureFiles()
|
||||||
await loadSessions()
|
|
||||||
loadBookmarks()
|
loadBookmarks()
|
||||||
|
|
||||||
|
// Auto-login and load sessions
|
||||||
|
await loadSessions()
|
||||||
|
|
||||||
// Auto-create default session if none exists
|
// Auto-create default session if none exists
|
||||||
if (!sessionList.value.length) {
|
if (!sessionList.value.length) {
|
||||||
await createSession('Default', 'keyword')
|
const defaultSession = await createSession('Default', 'keyword')
|
||||||
await loadSessions()
|
if (defaultSession) {
|
||||||
|
setCurrentSession(defaultSession)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
await loadSessions()
|
||||||
// Set first session as current
|
// Set first session as current
|
||||||
if (sessionList.value.length && !currentSession.value) {
|
if (sessionList.value.length && !currentSession.value) {
|
||||||
setCurrentSession(sessionList.value[0])
|
setCurrentSession(sessionList.value[0])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Restore session from localStorage
|
// Restore session from localStorage
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user