fix(webui): stabilize empty session history state

This commit is contained in:
Xubin Ren
2026-04-19 13:38:47 +00:00
parent f9e1d92abd
commit b3049f7323
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -1212,7 +1212,7 @@ def test_gateway_health_endpoint_binds_and_serves_expected_responses(
return None
class _FakeChannelManager:
def __init__(self, _config, _bus) -> None:
def __init__(self, _config, _bus, **_kwargs) -> None:
self.enabled_channels = ["telegram", "discord"]
async def start_all(self) -> None:
+4 -2
View File
@@ -11,6 +11,8 @@ import {
import { deriveTitle } from "@/lib/format";
import type { ChatSummary, UIMessage } from "@/lib/types";
const EMPTY_MESSAGES: UIMessage[] = [];
/** Sidebar state: fetches the full session list and exposes create / delete actions. */
export function useSessions(): {
sessions: ChatSummary[];
@@ -163,13 +165,13 @@ export function useSessionHistory(key: string | null): {
}, [key, token]);
if (!key) {
return { messages: [], loading: false, error: null };
return { messages: EMPTY_MESSAGES, loading: false, error: null };
}
// Even before the effect above commits its loading state, never surface the
// previous session's payload for a brand-new key.
if (state.key !== key) {
return { messages: [], loading: true, error: null };
return { messages: EMPTY_MESSAGES, loading: true, error: null };
}
return {