fix: sidebar bug

This commit is contained in:
qixinbo
2026-03-15 17:05:16 +08:00
parent 076eca5d7e
commit eb09129148
2 changed files with 23 additions and 1 deletions
+8 -1
View File
@@ -208,8 +208,15 @@ function SidebarBody() {
navigate(`/?session=${encodeURIComponent(key)}`);
};
const handleNewThread = () => {
const handleNewThread = async () => {
const newSessionId = `api:${Date.now()}`;
try {
await api.post(`/nanobot/sessions/${encodeURIComponent(newSessionId)}/ensure`, {});
await fetchSessions();
window.dispatchEvent(new Event("nanobot:sessions-changed"));
} catch (e) {
console.error("Failed to create session", e);
}
navigate(`/?session=${encodeURIComponent(newSessionId)}`);
};