fix(chat):建立连接前进行 token 有效性验证

This commit is contained in:
2026-06-05 13:06:20 +08:00
parent 57369772c7
commit 709b029c4e
3 changed files with 109 additions and 6 deletions
@@ -683,6 +683,10 @@ export const useAgentChatSession = ({
async (targetSessionId: string) => {
if (isHydrating || isStreaming) return;
setChatSessions((prev) =>
prev.filter((session) => session.id !== targetSessionId),
);
try {
const nextActiveSessionId = await deleteChatSession(
targetSessionId,
@@ -732,6 +736,11 @@ export const useAgentChatSession = ({
setChatSessions(sessionsAfterDelete);
} catch (error) {
console.error("[GlobalChatbox] Failed to delete chat session:", error);
try {
setChatSessions(await listChatSessions());
} catch (refreshError) {
console.error("[GlobalChatbox] Failed to refresh chat sessions:", refreshError);
}
} finally {
setIsHydrating(false);
}