diff --git a/ui/litellm-dashboard/src/components/lens/traces/detail/conversation/TraceConversation.integration.test.tsx b/ui/litellm-dashboard/src/components/lens/traces/detail/conversation/TraceConversation.integration.test.tsx index 3f5a76b62bb..52250d3adfa 100644 --- a/ui/litellm-dashboard/src/components/lens/traces/detail/conversation/TraceConversation.integration.test.tsx +++ b/ui/litellm-dashboard/src/components/lens/traces/detail/conversation/TraceConversation.integration.test.tsx @@ -56,6 +56,27 @@ describe("TraceConversation", () => { .mockImplementation(async (_token, _trace, id) => (id === "root" ? rootDetail : { ...toolDetail, span_id: id })); }); + it.each([false, true])("refreshes unchanged spans without hiding loaded content on failure (%s)", async (failed) => { + const user = userEvent.setup(); + renderWithProviders( + , + ); + await user.click(await screen.findByRole("tab", { name: "Conversation" })); + expect(await screen.findByText("The release is ready")).toBeVisible(); + vi.mocked(agentTraceSpanCall).mockImplementation(async (_token, _trace, id) => { + if (failed) throw new Error("content refresh failed"); + return id === "root" ? { ...rootDetail, output: "Updated final answer" } : toolDetail; + }); + await user.click(screen.getByRole("button", { name: "Refresh run" })); + if (failed) { + expect(await screen.findByRole("button", { name: "Retry batch" })).toBeVisible(); + expect(screen.getByText("The release is ready")).toBeVisible(); + } else { + expect(await screen.findByText("Updated final answer")).toBeVisible(); + expect(screen.queryByText("The release is ready")).not.toBeInTheDocument(); + } + }); + it("switches to a readable transcript and opens the exact tool step from it", async () => { const user = userEvent.setup(); renderWithProviders( diff --git a/ui/litellm-dashboard/src/components/lens/traces/detail/run/RunView.tsx b/ui/litellm-dashboard/src/components/lens/traces/detail/run/RunView.tsx index 46377b44ed1..d5d383ec6f3 100644 --- a/ui/litellm-dashboard/src/components/lens/traces/detail/run/RunView.tsx +++ b/ui/litellm-dashboard/src/components/lens/traces/detail/run/RunView.tsx @@ -114,7 +114,18 @@ function LoadedRun({ setManualRead(true); void read().finally(() => setManualRead(false)); }; - const refreshRun = () => readManually(() => traceQuery.refetch()); + const refreshRun = () => + readManually(async () => { + await traceQuery.refetch(); + await Promise.all( + ["agentTraceSpan", "agentTraceContents"].map((kind) => + queryClient.invalidateQueries({ + queryKey: [kind, traceId, traceRef], + predicate: (query) => query.queryKey.at(-1) === accessToken, + }), + ), + ); + }); const toggleLive = () => { if (live && !manualRead && !traceQuery.isFetchingNextPage) { void queryClient.cancelQueries({ queryKey, exact: true });