Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): retry failed activity counter reads
Josué97904bde1885
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useActivityController.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useActivityController.test.tsxindex c8835c9ce..1c537bb83 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/useActivityController.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/useActivityController.test.tsx@@ -148,6 +148,57 @@ describe('useActivityController', () => {)})+ it('keeps failed counter reads retryable instead of persisting zero aggregates', async () => {+ const messages = [+ { id: 'm1', role: 'assistant', content: 'failed', timestamp: 1, isError: true },+ ]+ const loadMessages = vi+ .fn()+ .mockRejectedValueOnce(new Error('temporary read failure'))+ .mockResolvedValue(messages)+ const backfillCounters = vi.fn().mockResolvedValue(undefined)+ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ chat: {+ getIndex: vi.fn(async () => ({ chats: [] })),+ loadMessages,+ backfillCounters,+ },+ },+ })+ const localChat = {+ id: 'legacy-chat',+ title: 'Legacy',+ createdAt: '2026-07-22T00:00:00.000Z',+ updatedAt: '2026-07-22T00:00:00.000Z',+ messageCount: 1,+ }+ const initialProps = { chatList: [localChat] }+ const { result, rerender } = renderHook(+ ({ chatList }: typeof initialProps) =>+ useActivityController({+ selectedAgent: 'agent-a',+ isAuthenticated: true,+ loadMenuData: true,+ chatList,+ progressByAgentMessage: EMPTY_PROGRESS,+ agentNames: AGENT_A,+ }),+ { initialProps }+ )++ await waitFor(() => expect(loadMessages).toHaveBeenCalledTimes(1))+ expect(backfillCounters).not.toHaveBeenCalled()++ rerender({ chatList: [{ ...localChat, remote: true }] })+ rerender({ chatList: [localChat] })++ await waitFor(() => expect(loadMessages).toHaveBeenCalledTimes(2))+ await waitFor(() => expect(result.current.selectedAgentActivitySummary.errors).toBe(1))+ expect(backfillCounters).toHaveBeenCalledWith('agent-a', 'legacy-chat', messages)+ })+it('does not download transcripts for server-only catalog entries', async () => {const getIndex = vi.fn(async () => ({version: 3,diff --git a/desktop-app/ui/src/hooks/domain/useActivityController.ts b/desktop-app/ui/src/hooks/domain/useActivityController.tsindex af01c00d0..8c023b423 100644--- a/desktop-app/ui/src/hooks/domain/useActivityController.ts+++ b/desktop-app/ui/src/hooks/domain/useActivityController.ts@@ -118,9 +118,18 @@ export function useActivityController({let cancelled = falsevoid Promise.all(chatIds.map(async chatId => {- const messages = await chatStore- .loadMessages(selectedAgent, chatId, ACTIVITY_SUMMARY_MESSAGE_SCAN_LIMIT)- .catch(() => [])+ let messages: Awaited<ReturnType<typeof chatStore.loadMessages>>+ try {+ messages = await chatStore.loadMessages(+ selectedAgent,+ chatId,+ ACTIVITY_SUMMARY_MESSAGE_SCAN_LIMIT+ )+ } catch {+ // A failed read is unknown, not an empty transcript. Leave this chat+ // unmarked so a later catalog refresh can retry the backfill.+ return null+ }try {await chatStore.backfillCounters(selectedAgent, chatId, messages)} catch {@@ -140,9 +149,10 @@ export function useActivityController({})).then(entries => {if (!cancelled) {+ const successfulEntries = entries.filter(entry => entry !== null)setBackfilledCountersByChat(previous => ({...previous,- ...Object.fromEntries(entries),+ ...Object.fromEntries(successfulEntries),}))}})