The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(chat): handle missing thread todos gracefully
Steven Enamakel408be861f0a7
diff --git a/app/src/features/conversations/aui/useThreadTodos.test.tsx b/app/src/features/conversations/aui/useThreadTodos.test.tsxnew file mode 100644index 0000000000..7241724aeb--- /dev/null+++ b/app/src/features/conversations/aui/useThreadTodos.test.tsx@@ -0,0 +1,67 @@+import { combineReducers, configureStore } from '@reduxjs/toolkit';+import { renderHook, waitFor } from '@testing-library/react';+import type { ReactNode } from 'react';+import { Provider } from 'react-redux';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { threadApi } from '../../../services/api/threadApi';+import threadTodosReducer from '../../../store/threadTodosSlice';+import { useLoadThreadTodos, useThreadTodos } from './useThreadTodos';++vi.mock('../../../services/api/threadApi', () => ({+ threadApi: { getTodos: vi.fn() },+}));++function setup() {+ const store = configureStore({ reducer: combineReducers({ threadTodos: threadTodosReducer }) });+ const wrapper = ({ children }: { children: ReactNode }) => (+ <Provider store={store}>{children}</Provider>+ );+ return { store, wrapper };+}++describe('useThreadTodos', () => {+ beforeEach(() => vi.mocked(threadApi.getTodos).mockReset());++ it('returns null for a thread with no live entry', () => {+ const { wrapper } = setup();+ const { result } = renderHook(() => useThreadTodos('t1'), { wrapper });+ expect(result.current).toBeNull();+ });++ it('returns null when threadId is null', () => {+ const { wrapper } = setup();+ const { result } = renderHook(() => useThreadTodos(null), { wrapper });+ expect(result.current).toBeNull();+ });+});++describe('useLoadThreadTodos', () => {+ beforeEach(() => vi.mocked(threadApi.getTodos).mockReset());++ it('primes the slice from the RPC on thread open', async () => {+ vi.mocked(threadApi.getTodos).mockResolvedValue([{ content: 'Write tests', status: 'pending' }]);+ const { store, wrapper } = setup();+ renderHook(() => useLoadThreadTodos('t1'), { wrapper });++ await waitFor(() => expect(store.getState().threadTodos.byThread.t1).toBeDefined());+ expect(store.getState().threadTodos.byThread.t1).toEqual([+ { content: 'Write tests', status: 'pending' },+ ]);+ });++ it('leaves the slice untouched when the RPC fails (older core)', async () => {+ vi.mocked(threadApi.getTodos).mockRejectedValue(new Error('no such method'));+ const { store, wrapper } = setup();+ renderHook(() => useLoadThreadTodos('t1'), { wrapper });++ await waitFor(() => expect(threadApi.getTodos).toHaveBeenCalled());+ expect(store.getState().threadTodos.byThread.t1).toBeUndefined();+ });++ it('does nothing for a null threadId', () => {+ const { wrapper } = setup();+ renderHook(() => useLoadThreadTodos(null), { wrapper });+ expect(threadApi.getTodos).not.toHaveBeenCalled();+ });+});diff --git a/app/src/providers/ChatRuntimeProvider.tsx b/app/src/providers/ChatRuntimeProvider.tsxindex cc5f23a58d..6d649ca518 100644--- a/app/src/providers/ChatRuntimeProvider.tsx+++ b/app/src/providers/ChatRuntimeProvider.tsx@@ -1651,6 +1651,7 @@ const ChatRuntimeProvider = ({ children }: { children: React.ReactNode }) => {content: errorContent,threadId: event.thread_id,messageId: errorMessageId,+ extraMetadata: chatErrorExtraMetadata(event),}));}diff --git a/crates/openhuman-core/src/agent/artifacts/ops.rs b/crates/openhuman-core/src/agent/artifacts/ops.rsindex d8887d4bb3..7734c59ef9 100644--- a/crates/openhuman-core/src/agent/artifacts/ops.rs+++ b/crates/openhuman-core/src/agent/artifacts/ops.rs@@ -213,6 +213,9 @@ async fn regenerate_presentation(let chat_ctx = ApprovalChatContext {thread_id: thread_id.to_string(),client_id: client_id.to_string(),+ // No turn request_id in scope on this path (artifact regeneration is+ // not itself a chat turn).+ request_id: None,};let result = store::REGENERATE_TARGET_ID