fix: loadSessions variable shadowing bug
- Local variable 'sessions' was shadowing the ref 'sessions' - sessions.value = sessions was not updating the ref - Renamed local variable to 'sessionList' and properly assign to sessions.value - This fixes sessions not appearing in history list after save
This commit is contained in:
@@ -80,8 +80,8 @@ export function useSearchSession() {
|
||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
||||
const data = await resp.json()
|
||||
// Enrich sessions with last query from messages
|
||||
const sessions = data.sessions || []
|
||||
for (const s of sessions) {
|
||||
const sessionList = data.sessions || []
|
||||
for (const s of sessionList) {
|
||||
try {
|
||||
const msgResp = await fetch(`${base}/api/v2/search-sessions/${s.id}/messages?limit=1`, {
|
||||
headers: getAuthHeaders()
|
||||
@@ -95,7 +95,7 @@ export function useSearchSession() {
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
sessions.value = sessions
|
||||
sessions.value = sessionList
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to load sessions'
|
||||
} finally {
|
||||
@@ -117,7 +117,9 @@ export function useSearchSession() {
|
||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
||||
const data = await resp.json()
|
||||
await loadSessions()
|
||||
return data.session
|
||||
// Return the newly created session from the sessions list
|
||||
const newSession = sessions.value.find(s => s.id === data.session?.id)
|
||||
return newSession || data.session
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to create session'
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user