fix: bridge 创建的聊天不立即显示在 ChatList

Bridge 在服务端通过 createSession() 创建会话,无法触发浏览器端的
session-created 事件,导致 ChatListPanel 不知道有新聊天。

添加 5 秒轮询刷新,查本地 SQLite 开销可忽略,bridge 新建的会话
最多 5 秒即可出现在聊天列表。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
7418andClaude Opus 4.6 committed 2026-03-01 00:49:30 +08:00
1 parent 6ad821d3af
commit 65fdeb6dac
1 file changed
+8
+8
View File
@@ -259,6 +259,14 @@ export function ChatListPanel({ open, width }: ChatListPanelProps) {
};
}, [debouncedFetchSessions]);
// Periodic poll to catch sessions created server-side (e.g. bridge)
useEffect(() => {
const interval = setInterval(() => {
fetchSessions();
}, 5000);
return () => clearInterval(interval);
}, [fetchSessions]);
const handleDeleteSession = async (
e: React.MouseEvent,
sessionId: string