Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(conversations): remember a widget tool decision for the rest of the view

oxoxDevc6bb0bc1ad39
diff --git a/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx b/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx
index 37a1564ea1..4918e8cdf6 100644
--- a/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx
+++ b/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx
@@ -19,7 +19,7 @@ const DEFAULT_HEIGHT = 360;
interface PendingCall {
name: string;
args: Record<string, unknown>;
- resolve: (value: unknown) => void;
+ resolve: () => void;
reject: (error: Error) => void;
}
@@ -39,6 +39,7 @@ export function McpAppFrame({ presentation }: { presentation: McpUiPresentation
const [height, setHeight] = useState(DEFAULT_HEIGHT);
const [pending, setPending] = useState<PendingCall | null>(null);
const [handoffUrl, setHandoffUrl] = useState<string | null>(null);
+ const decisionsRef = useRef(new Map<string, Promise<void>>());
const serverId = presentation.server_id;
useEffect(() => {
@@ -80,9 +81,15 @@ export function McpAppFrame({ presentation }: { presentation: McpUiPresentation
if (!serverId) throw new Error('No server for this view');
const first = await mcpUiApi.toolCall(serverId, name, args, false);
if (!first.requires_confirmation) return first.result;
- await new Promise<unknown>((resolve, reject) =>
- setPending({ name, args, resolve, reject })
- );
+ let decision = decisionsRef.current.get(name);
+ if (!decision) {
+ decision = new Promise<void>((resolve, reject) =>
+ setPending({ name, args, resolve, reject })
+ );
+ decision.catch(() => undefined);
+ decisionsRef.current.set(name, decision);
+ }
+ await decision;
const confirmed = await mcpUiApi.toolCall(serverId, name, args, true);
return confirmed.result;
},
@@ -154,7 +161,7 @@ export function McpAppFrame({ presentation }: { presentation: McpUiPresentation
cancelLabel={t('conversations.mcpUi.confirmDeny')}
testId="mcp-ui-confirm"
onConfirm={() => {
- pending.resolve(undefined);
+ pending.resolve();
setPending(null);
}}
onCancel={() => {