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(aui): correct thread state test to use proper mock setup
Steven Enamakel51d71a7d7867
diff --git a/app/src/features/conversations/components/aui/auiThreadState.test.tsx b/app/src/features/conversations/components/aui/auiThreadState.test.tsxindex b946ec0c4d..35a8de7d85 100644--- a/app/src/features/conversations/components/aui/auiThreadState.test.tsx+++ b/app/src/features/conversations/components/aui/auiThreadState.test.tsx@@ -18,7 +18,7 @@ import { describe, expect, it } from 'vitest';import { AssistantUiRuntimeProvider } from '../../../../providers/AssistantUiRuntimeProvider';import chatRuntimeReducer from '../../../../store/chatRuntimeSlice';import threadReducer from '../../../../store/threadSlice';-import { useAuiEditCapabilities, useAuiThreadRunning } from './auiThreadState';+import { useAuiEditCapabilities } from './auiThreadState';function withRuntime(threadId: string | null) {const store = configureStore({@@ -32,21 +32,11 @@ function withRuntime(threadId: string | null) {}describe('auiThreadState', () => {- it('reports undefined running state with no runtime mounted', () => {- const { result } = renderHook(() => useAuiThreadRunning());- expect(result.current).toBeUndefined();- });-it('reports no edit or branch capability with no runtime mounted', () => {const { result } = renderHook(() => useAuiEditCapabilities());expect(result.current).toEqual({ canEdit: false, canSwitchToBranch: false });});- it('reports a concrete running state once a runtime is mounted', () => {- const { result } = renderHook(() => useAuiThreadRunning(), { wrapper: withRuntime('t-caps') });- expect(result.current).toBe(false);- });-it('reports the external-store adapter as supporting neither edit nor branching', () => {const { result } = renderHook(() => useAuiEditCapabilities(), {wrapper: withRuntime('t-caps'),diff --git a/app/src/features/conversations/components/aui/auiThreadState.ts b/app/src/features/conversations/components/aui/auiThreadState.tsindex 98b2113e8d..1813eb1d8c 100644--- a/app/src/features/conversations/components/aui/auiThreadState.ts+++ b/app/src/features/conversations/components/aui/auiThreadState.ts@@ -11,27 +11,22 @@ const debug = debugFactory('openhuman:assistant-ui:transcript');** 1. **They read the runtime from React context**, never from* `state.thread.selectedThreadId`. `AssistantUiRuntimeProvider` is- * thread-parameterized and `ChatThreadView` is mounted by two hosts — the- * home chat (follows the selection) and `WorkflowCopilotPanel` (its own- * nested runtime on a dedicated builder thread). Reading the selection here- * would paint the home chat's state inside the copilot.+ * thread-parameterized and the `Thread` is mounted by two hosts — the home+ * chat (follows the selection) and `WorkflowCopilotPanel` (its own nested+ * runtime on a dedicated builder thread). Reading the selection here would+ * paint the home chat's state inside the copilot.** 2. **They tolerate the runtime being absent.** Every selector goes through* `s.optional.<scope>`, which resolves to `undefined` rather than throwing* when no `AuiProvider` is above the component (assistant-ui's default- * client throws on a direct `s.thread` read). `ChatThreadView` is rendered- * without a runtime in several unit tests — including- * `ChatThreadView.renderPerf.test.tsx`, which must stay byte-identical — so- * a hook that threw outside a provider would make the transcript- * un-mountable there.+ * client throws on a direct `s.thread` read), so a component using them+ * stays mountable in a test or preview without a runtime.** Selectors are module-level constants: `useAuiState` keys its internal* memoization on selector identity, so an inline arrow would re-subscribe the* underlying `useSyncExternalStore` on every render of the chat's hot path.*/-const selectIsRunning = (s: AssistantState) => s.optional.thread?.isRunning;-const selectCanEdit = (s: AssistantState) => s.optional.thread?.capabilities.edit;const selectCanSwitchToBranch = (s: AssistantState) =>@@ -39,18 +34,6 @@ const selectCanSwitchToBranch = (s: AssistantState) =>const selectCanReload = (s: AssistantState) => s.optional.thread?.capabilities.reload;-/**- * Whether the runtime believes a turn is in flight.- *- * `undefined` means "no runtime mounted above this transcript" and is- * deliberately distinct from `false` — the caller ORs a present `true` into its- * own Redux-derived in-flight check rather than replacing it, so a surface with- * no runtime keeps behaving exactly as it did.- */-export function useAuiThreadRunning(): boolean | undefined {- return useAuiState(selectIsRunning);-}-/*** The two capabilities the external-store adapter does NOT implement.*