Ver código fonte

fix: 选择会话不改动最近活动排序

samien 2 meses atrás
pai
commit
0d2206b936
1 arquivos alterados com 5 adições e 5 exclusões
  1. 5 5
      src/client/stores/chat.ts

+ 5 - 5
src/client/stores/chat.ts

@@ -109,7 +109,7 @@ export const useChatStore = defineStore('chat', () => {
       const shouldResume = hasConnectedOnce
       hasConnectedOnce = true
       const active = activeRouteState.value
-      if (shouldResume && active && !active.runtimeSessionId && !reconnectResumePromise) {
+      if (shouldResume && active?.isStreaming && !active.runtimeSessionId && !reconnectResumePromise) {
         reconnectResumePromise = ensureRuntime(active)
           .catch(cause => { active.error = errorMessage(cause) })
           .finally(() => { reconnectResumePromise = undefined })
@@ -332,10 +332,10 @@ export const useChatStore = defineStore('chat', () => {
     activeSessionId.value = sessionId
     activeProfileName.value = selectedProfile
     const state = ensureRoute(selectedProfile, sessionId)
-    await Promise.allSettled([connect(), state.historySynced ? Promise.resolve() : loadHistory(state)])
-    if (connectionState.value === 'connected' || connectionState.value === 'ready') {
-      try { await ensureRuntime(state) } catch (cause) { state.error = errorMessage(cause) }
-    }
+    // Reading an old session must not rewrite the server's last_active field.
+    // The runtime is attached lazily by send/interrupt/usage, or when a known
+    // in-flight turn reconnects. REST history remains authoritative here.
+    if (!state.historySynced) await loadHistory(state)
   }
 
   async function loadOlder(): Promise<void> {