Skip to content

Commit 0b86d22

Browse files
committed
fix(site/src/pages/AgentsPage/components/ChatConversation): retry only a failed store load
A retry after a chat detail failure refetched a loaded store and replaced it, which dropped its pending actions.
1 parent 5a7f502 commit 0b86d22

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎site/src/pages/AgentsPage/components/ChatConversation/chatStore.test.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,6 +2934,11 @@ describe("useChatStore", () => {
29342934
expect(watchChat).toHaveBeenCalledWith(chatID, 3);
29352935
});
29362936
expect(result.current.loadState).toEqual({ status: "loaded" });
2937+
2938+
act(() => {
2939+
result.current.retryLoad();
2940+
});
2941+
expect(API.experimental.getChatMessages).toHaveBeenCalledTimes(2);
29372942
});
29382943

29392944
it("does not use one chat's snapshot version for another chat", async () => {

‎site/src/pages/AgentsPage/components/ChatConversation/useChatStore.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,11 @@ export const useChatStore = (
506506
return {
507507
store,
508508
loadState,
509+
// A refetch replaces a loaded store, so only a failed load retries.
509510
retryLoad: () => {
510-
void storeQuery.refetch();
511+
if (storeQuery.isError) {
512+
void storeQuery.refetch();
513+
}
511514
},
512515
clearClientError: () => {
513516
store.clearClientError();

0 commit comments

Comments
 (0)