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(approvals): keep an answered chat approval out of the background deck
M3gA-Mind0b9606c256a4
diff --git a/app/src/hooks/__tests__/useUnroutedApprovals.test.tsx b/app/src/hooks/__tests__/useUnroutedApprovals.test.tsxindex f49daac7f2..ed8ea09e6e 100644--- a/app/src/hooks/__tests__/useUnroutedApprovals.test.tsx+++ b/app/src/hooks/__tests__/useUnroutedApprovals.test.tsx@@ -12,7 +12,7 @@* that showed nothing would be the bug it is fixing.*/import { configureStore } from '@reduxjs/toolkit';-import { renderHook, waitFor } from '@testing-library/react';+import { act, renderHook, waitFor } from '@testing-library/react';import type { ReactNode } from 'react';import { Provider } from 'react-redux';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';@@ -22,7 +22,10 @@ import {fetchPendingApprovals,type PendingApproval,} from '../../services/api/approvalApi';-import chatRuntimeReducer, { setPendingApprovalForThread } from '../../store/chatRuntimeSlice';+import chatRuntimeReducer, {+ clearPendingApprovalForThread,+ setPendingApprovalForThread,+} from '../../store/chatRuntimeSlice';import threadReducer from '../../store/threadSlice';import { resetFlowPendingApprovalsStoreForTests } from '../flowPendingApprovalsStore';import { useUnroutedApprovals } from '../useUnroutedApprovals';@@ -51,7 +54,7 @@ function mount(seed?: (store: ReturnType<typeof buildStore>) => void) {const wrapper = ({ children }: { children: ReactNode }) => (<Provider store={store}>{children}</Provider>);- return renderHook(() => useUnroutedApprovals(), { wrapper });+ return { store, ...renderHook(() => useUnroutedApprovals(), { wrapper }) };}function buildStore() {@@ -113,6 +116,34 @@ describe('useUnroutedApprovals', () => {await waitFor(() => expect(result.current.approvals).toEqual([]));});+ it('does not resurface a chat approval once its transcript card clears', async () => {+ // The poll caught the park while the chat card owned it. Deciding from the+ // chat card clears the card locally, but the polled list still holds the+ // row until the next poll — it must not reappear here as a second card+ // whose Deny then fails with "already decided".+ vi.mocked(fetchPendingApprovals).mockResolvedValue([row({ request_id: 'req-chat' })]);+ const { result, store } = mount(store => {+ store.dispatch(+ setPendingApprovalForThread({+ threadId: 't1',+ approval: {+ requestId: 'req-chat',+ toolName: 'GOOGLECALENDAR_CREATE_EVENT',+ message: 'm',+ },+ })+ );+ });+ await waitFor(() => expect(vi.mocked(fetchPendingApprovals)).toHaveBeenCalled());+ await waitFor(() => expect(result.current.approvals).toEqual([]));++ act(() => {+ store.dispatch(clearPendingApprovalForThread({ threadId: 't1' }));+ });++ expect(result.current.approvals).toEqual([]);+ });+it('shows a background park raised alongside an unrelated chat approval', async () => {// The discriminator must exclude by request_id, not "is any chat approval// open" — otherwise one chat gate hides every background one behind it.diff --git a/app/src/hooks/useUnroutedApprovals.ts b/app/src/hooks/useUnroutedApprovals.tsindex 9837c1e07e..2eef4a3ee5 100644--- a/app/src/hooks/useUnroutedApprovals.ts+++ b/app/src/hooks/useUnroutedApprovals.ts@@ -86,12 +86,18 @@ export function useUnroutedApprovals(enabled = true): UseUnroutedApprovalsResultstate => state.chatRuntime.pendingApprovalByThread);+ // Every request id a chat card has ever shown, not only the ones it shows+ // now. Deciding from the chat card clears its entry at once, while the+ // polled rows keep that park until the next poll (up to 15 s); matching on+ // "shown right now" would put the answered park back here as a second card+ // whose decide then fails with "already decided". A chat-owned park is+ // never unrouted, so once seen it stays excluded.+ const everChatRoutedIds = useRef(new Set<string>());const chatRoutedIds = useMemo(() => {- const ids = new Set<string>();for (const approval of Object.values(pendingApprovalByThread ?? {})) {- if (approval?.requestId) ids.add(approval.requestId);+ if (approval?.requestId) everChatRoutedIds.current.add(approval.requestId);}- return ids;+ return new Set(everChatRoutedIds.current);}, [pendingApprovalByThread]);const approvals = useMemo(