fix(lens): serialize conversation paging with refresh

This commit is contained in:
moe-berri 2026-10-06 14:09:19 -07:00
parent 8ad9606e00
commit 4a679ecde7
2 changed files with 28 additions and 1 deletions

View file

@ -70,6 +70,33 @@ describe("TraceConversation", () => {
expect(screen.getByRole("heading", { name: "read_file" })).toBeVisible();
});
it("waits for an in-flight refresh before requesting another conversation page", async () => {
const user = userEvent.setup();
const first = { ...trace, spans: [root], next_cursor: "old-page" };
const refreshed = { ...first, next_cursor: "fresh-page" };
const second = { ...trace, spans: [tool], next_cursor: null };
const pending = Promise.withResolvers<Trace>();
vi.mocked(agentTraceCall)
.mockResolvedValueOnce(first)
.mockReturnValueOnce(pending.promise)
.mockResolvedValue(second);
renderWithProviders(
<RoutedRunView traceId={trace.summary.trace_id} accessToken="test" onBack={vi.fn()} embedded />,
);
await user.click(await screen.findByRole("tab", { name: "Conversation" }));
expect(await screen.findByText("Read the release notes")).toBeVisible();
await user.click(screen.getByRole("button", { name: "Refresh run" }));
const more = screen.getByRole("button", { name: "Load next 20 entries" });
expect(more).toBeDisabled();
await user.click(more);
expect(agentTraceCall).toHaveBeenCalledTimes(2);
await act(async () => pending.resolve(refreshed));
await waitFor(() => expect(more).toBeEnabled());
await user.click(more);
expect(await screen.findByRole("button", { name: "Expand read_file tool call" })).toBeVisible();
expect(vi.mocked(agentTraceCall).mock.calls.map((call) => call[3])).toEqual([null, null, "fresh-page"]);
});
it("can load the next conversation page after a refresh fails", async () => {
const user = userEvent.setup();
const first = { ...trace, spans: [root], next_cursor: "next-page" };

View file

@ -186,7 +186,7 @@ function LoadedRun({
embedded={embedded}
stale={switching}
conversationPaging={{
loading: traceQuery.isFetchingNextPage,
loading: traceQuery.isFetching,
failed: isFetchNextPageError,
loadMore: fetchNextPage,
}}