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}`)
|
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
||||||
const data = await resp.json()
|
const data = await resp.json()
|
||||||
// Enrich sessions with last query from messages
|
// Enrich sessions with last query from messages
|
||||||
const sessions = data.sessions || []
|
const sessionList = data.sessions || []
|
||||||
for (const s of sessions) {
|
for (const s of sessionList) {
|
||||||
try {
|
try {
|
||||||
const msgResp = await fetch(`${base}/api/v2/search-sessions/${s.id}/messages?limit=1`, {
|
const msgResp = await fetch(`${base}/api/v2/search-sessions/${s.id}/messages?limit=1`, {
|
||||||
headers: getAuthHeaders()
|
headers: getAuthHeaders()
|
||||||
@@ -95,7 +95,7 @@ export function useSearchSession() {
|
|||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
sessions.value = sessions
|
sessions.value = sessionList
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
error.value = e.message || 'Failed to load sessions'
|
error.value = e.message || 'Failed to load sessions'
|
||||||
} finally {
|
} finally {
|
||||||
@@ -117,7 +117,9 @@ export function useSearchSession() {
|
|||||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
||||||
const data = await resp.json()
|
const data = await resp.json()
|
||||||
await loadSessions()
|
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) {
|
} catch (e: any) {
|
||||||
error.value = e.message || 'Failed to create session'
|
error.value = e.message || 'Failed to create session'
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -765,7 +765,9 @@ async function saveCurrentSession() {
|
|||||||
|
|
||||||
// Show rename dialog for session name
|
// Show rename dialog for session name
|
||||||
if (currentSession.value) {
|
if (currentSession.value) {
|
||||||
renamingSession.value = currentSession.value
|
// Ensure we're working with the session from the list
|
||||||
|
const sessionFromList = sessionList.value.find(s => s.id === currentSession.value!.id)
|
||||||
|
renamingSession.value = sessionFromList || currentSession.value
|
||||||
renameValue.value = currentSession.value.title === '未命名' ? '' : currentSession.value.title
|
renameValue.value = currentSession.value.title === '未命名' ? '' : currentSession.value.title
|
||||||
nextTick(() => renameInputEl.value?.focus())
|
nextTick(() => renameInputEl.value?.focus())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user