mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-19 17:50:37 -07:00
fix(cli): allow sub-agent confirmation requests in UI while preventing background flicker (#20722)
This commit is contained in:
@@ -115,11 +115,42 @@ export function useToolScheduler(
|
||||
|
||||
useEffect(() => {
|
||||
const handler = (event: ToolCallsUpdateMessage) => {
|
||||
// Only process updates for the root scheduler.
|
||||
// Subagent internal tools should not be displayed in the main tool list.
|
||||
if (event.schedulerId !== ROOT_SCHEDULER_ID) {
|
||||
return;
|
||||
}
|
||||
const isRoot = event.schedulerId === ROOT_SCHEDULER_ID;
|
||||
|
||||
setToolCallsMap((prev) => {
|
||||
const prevCalls = prev[event.schedulerId] ?? [];
|
||||
const prevCallIds = new Set(prevCalls.map((tc) => tc.request.callId));
|
||||
|
||||
// For non-root schedulers, we only show tool calls that:
|
||||
// 1. Are currently awaiting approval.
|
||||
// 2. Were previously shown (e.g., they are now executing or completed).
|
||||
// This prevents "thinking" tools (reads/searches) from flickering in the UI
|
||||
// unless they specifically required user interaction.
|
||||
const filteredToolCalls = isRoot
|
||||
? event.toolCalls
|
||||
: event.toolCalls.filter(
|
||||
(tc) =>
|
||||
tc.status === CoreToolCallStatus.AwaitingApproval ||
|
||||
prevCallIds.has(tc.request.callId),
|
||||
);
|
||||
|
||||
// If this is a subagent and we have no tools to show and weren't showing any,
|
||||
// we can skip the update entirely to avoid unnecessary re-renders.
|
||||
if (
|
||||
!isRoot &&
|
||||
filteredToolCalls.length === 0 &&
|
||||
prevCalls.length === 0
|
||||
) {
|
||||
return prev;
|
||||
}
|
||||
|
||||
const adapted = internalAdaptToolCalls(filteredToolCalls, prevCalls);
|
||||
|
||||
return {
|
||||
...prev,
|
||||
[event.schedulerId]: adapted,
|
||||
};
|
||||
});
|
||||
|
||||
// Update output timer for UI spinners (Side Effect)
|
||||
const hasExecuting = event.toolCalls.some(
|
||||
@@ -134,18 +165,6 @@ export function useToolScheduler(
|
||||
if (hasExecuting) {
|
||||
setLastToolOutputTime(Date.now());
|
||||
}
|
||||
|
||||
setToolCallsMap((prev) => {
|
||||
const adapted = internalAdaptToolCalls(
|
||||
event.toolCalls,
|
||||
prev[event.schedulerId] ?? [],
|
||||
);
|
||||
|
||||
return {
|
||||
...prev,
|
||||
[event.schedulerId]: adapted,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
messageBus.subscribe(MessageBusType.TOOL_CALLS_UPDATE, handler);
|
||||
|
||||
Reference in New Issue
Block a user