From b3049f732310a49155cd83b5c4a315ddc113110e Mon Sep 17 00:00:00 2001 From: Xubin Ren Date: Sun, 19 Apr 2026 13:38:47 +0000 Subject: [PATCH] fix(webui): stabilize empty session history state --- tests/cli/test_commands.py | 2 +- webui/src/hooks/useSessions.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/cli/test_commands.py b/tests/cli/test_commands.py index 5966d5200..b970d9201 100644 --- a/tests/cli/test_commands.py +++ b/tests/cli/test_commands.py @@ -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: diff --git a/webui/src/hooks/useSessions.ts b/webui/src/hooks/useSessions.ts index 9e3901bdf..b627f8607 100644 --- a/webui/src/hooks/useSessions.ts +++ b/webui/src/hooks/useSessions.ts @@ -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 {