diff --git a/ui/host/src/rail.test.tsx b/ui/host/src/rail.test.tsx index 01993aad1..258196c61 100644 --- a/ui/host/src/rail.test.tsx +++ b/ui/host/src/rail.test.tsx @@ -74,6 +74,27 @@ describe("Rail", () => { document.body.innerHTML = ""; }); + it("says when the collapsed rail's chats and dashboards could not load", async () => { + fetchMock.mockImplementation(async (input, init) => { + const path = new URL(String(input), "http://localhost").pathname; + if (path === "/api/agent/threads" || path === "/api/dashboards") return json({ code: "unavailable", message: "down" }, 503); + return respond(input, init); + }); + const { root, render } = mount({ collapsed: true }); + await act(async () => render()); + const items = async (label: string) => { + await act(async () => document.querySelector(`button[aria-label="${label}"]`)!.click()); + await vi.waitFor(() => expect(document.querySelector('[role="menu"]')).not.toBeNull()); + return () => [...document.querySelectorAll('[role="menuitem"]')].map(node => node.textContent); + }; + const chats = await items("Chats"); + await vi.waitFor(() => expect(chats()).toContain("Chats could not be loaded. Retry")); + expect(chats()).not.toContain("No chats yet"); + const boards = await items("Dashboards"); + await vi.waitFor(() => expect(boards()).toContain("Dashboards could not be loaded. Retry")); + await act(async () => root.unmount()); + }); + it("reaches existing chats and dashboards from the collapsed rail", async () => { const { root, handlers, render } = mount({ collapsed: true }); await act(async () => render()); diff --git a/ui/host/src/rail.tsx b/ui/host/src/rail.tsx index 2889a18b0..3ad277b1b 100644 --- a/ui/host/src/rail.tsx +++ b/ui/host/src/rail.tsx @@ -135,7 +135,9 @@ export default function Rail({ collapsed = false, agentAvailable, activeThreadID Recent chats - {threads.length === 0 && No chats yet} + {history.isPending ? Loading chats… + : history.isError ? void history.refetch()}>Chats could not be loaded. Retry + : threads.length === 0 && No chats yet} {threads.slice(0, 10).map(thread => onSelectThread(thread.id)}>{thread.title || "Untitled chat"})}