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 run queue events gracefully
Steven Enamakela644072fbb12
diff --git a/app/src/features/conversations/aui/useRunQueueEvents.test.tsx b/app/src/features/conversations/aui/useRunQueueEvents.test.tsxnew file mode 100644index 0000000000..5f5cfba82b--- /dev/null+++ b/app/src/features/conversations/aui/useRunQueueEvents.test.tsx@@ -0,0 +1,85 @@+import { combineReducers, configureStore } from '@reduxjs/toolkit';+import { act, renderHook } from '@testing-library/react';+import type { ReactNode } from 'react';+import { Provider } from 'react-redux';+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { type QueueEventListeners, subscribeQueueEvents } from '../../../services/chatService';+import chatRuntimeReducer from '../../../store/chatRuntimeSlice';+import queueReducer, { pendingFollowupAdded } from '../../../store/queueSlice';+import { useRunQueueEvents } from './useRunQueueEvents';++// The socket is the one external boundary here; capture what the hook registers.+vi.mock('../../../services/chatService', () => ({ subscribeQueueEvents: vi.fn() }));++function setup() {+ const store = configureStore({+ reducer: combineReducers({ chatRuntime: chatRuntimeReducer, queue: queueReducer }),+ });+ let listeners: QueueEventListeners = {};+ const unsubscribe = vi.fn();+ vi.mocked(subscribeQueueEvents).mockImplementation(l => {+ listeners = l;+ return unsubscribe;+ });+ const wrapper = ({ children }: { children: ReactNode }) => (+ <Provider store={store}>{children}</Provider>+ );+ const hook = renderHook(({ enabled }) => useRunQueueEvents(enabled), {+ wrapper,+ initialProps: { enabled: true },+ });+ return { store, listeners: () => listeners, unsubscribe, hook };+}++const event = (id: string, text: string) => ({+ thread_id: 't1',+ queue_item: { id, text_preview: text },+});++describe('useRunQueueEvents', () => {+ beforeEach(() => vi.mocked(subscribeQueueEvents).mockReset());++ it('mirrors queued and delivered events into the queue slice', () => {+ const { store, listeners } = setup();++ act(() => listeners().onQueued?.(event('q1', 'one')));+ act(() => listeners().onQueued?.(event('q2', 'two')));+ expect(store.getState().queue.itemsByThread.t1.map(i => i.id)).toEqual(['q1', 'q2']);++ act(() => listeners().onDelivered?.(event('q1', 'one')));+ expect(store.getState().queue.itemsByThread.t1.map(i => i.id)).toEqual(['q2']);+ });++ it('a core-side removal also drops the matching pending follow-up', () => {+ const { store, listeners } = setup();+ store.dispatch(+ pendingFollowupAdded({+ threadId: 't1',+ text: 'gone',+ message: {+ id: 'm1',+ content: 'gone',+ type: 'text',+ extraMetadata: {},+ sender: 'user',+ createdAt: '2026-01-01T00:00:00.000Z',+ },+ })+ );+ act(() => listeners().onQueued?.(event('q1', 'gone')));+ act(() => listeners().onRemoved?.(event('q1', 'gone')));++ expect(store.getState().queue.itemsByThread.t1).toBeUndefined();+ expect(store.getState().queue.pendingFollowupsByThread.t1).toBeUndefined();+ });++ it('does not subscribe while disabled and unsubscribes when disabled', () => {+ const { hook, unsubscribe } = setup();+ expect(subscribeQueueEvents).toHaveBeenCalledTimes(1);++ hook.rerender({ enabled: false });+ expect(unsubscribe).toHaveBeenCalledTimes(1);+ expect(subscribeQueueEvents).toHaveBeenCalledTimes(1);+ });+});diff --git a/app/src/features/conversations/aui/useRunQueueEvents.ts b/app/src/features/conversations/aui/useRunQueueEvents.tsnew file mode 100644index 0000000000..011bf77aec--- /dev/null+++ b/app/src/features/conversations/aui/useRunQueueEvents.ts@@ -0,0 +1 @@+export function useRunQueueEvents(_enabled: boolean): void {}diff --git a/app/src/features/conversations/components/ChatToolParts.tsx b/app/src/features/conversations/components/ChatToolParts.tsxindex bb1a649325..d869a61e8e 100644--- a/app/src/features/conversations/components/ChatToolParts.tsx+++ b/app/src/features/conversations/components/ChatToolParts.tsx@@ -142,18 +142,21 @@ const ComposioConnectCall: ToolCallMessagePartComponent = props => {const gate = useGatedApproval(props.approval);if (!gate) return <OpenHumanToolCall {...props} />;return (- <div data-testid="assistant-ui-integration-connect">- {/* Keyed by request id so a second parked connect remounts the card with- fresh phase / field / poll state, matching the legacy placement. */}- <IntegrationConnectCard- key={gate.request.requestId}- threadId={gate.threadId}- approval={gate.request}- />- </div>+ // Keyed by request id so a second parked connect remounts the card with+ // fresh phase / field / poll state, matching the legacy placement.+ <PermissionGrantAdapter+ key={gate.request.requestId}+ threadId={gate.threadId}+ approval={gate.request}+ />);};+/** Redacted args the gate extracted for display, as the approval card's command. */+function commandFromApproval(approval: PendingApproval): string {+ return approval.command ?? '';+}+/*** A parked tool call, with the decision attached to the call it gates.*diff --git a/app/src/providers/ChatRuntimeProvider.tsx b/app/src/providers/ChatRuntimeProvider.tsxindex fd29b08e1b..716ff38ee5 100644--- a/app/src/providers/ChatRuntimeProvider.tsx+++ b/app/src/providers/ChatRuntimeProvider.tsx@@ -87,6 +87,7 @@ import {loadThreadMessages,setActiveThread,setSelectedThread,+ TIMING_METADATA_KEY,} from '../store/threadSlice';import { reportUserError } from '../store/userErrorsSlice';import { IS_PROD } from '../utils/config';