mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-24 20:14:44 -07:00
Co-authored-by: Aashir Javed <Aaxhirrr@users.noreply.github.com> Co-authored-by: Dev Randalpura <devrandalpura@google.com>
This commit is contained in:
@@ -247,15 +247,8 @@ export const useGeminiStream = (
|
||||
const previousApprovalModeRef = useRef<ApprovalMode>(
|
||||
config.getApprovalMode(),
|
||||
);
|
||||
const [isResponding, setIsRespondingState] = useState<boolean>(false);
|
||||
const isRespondingRef = useRef<boolean>(false);
|
||||
const setIsResponding = useCallback(
|
||||
(value: boolean) => {
|
||||
setIsRespondingState(value);
|
||||
isRespondingRef.current = value;
|
||||
},
|
||||
[setIsRespondingState],
|
||||
);
|
||||
const [isResponding, isRespondingRef, setIsResponding] =
|
||||
useStateAndRef<boolean>(false);
|
||||
const [thought, thoughtRef, setThought] =
|
||||
useStateAndRef<ThoughtSummary | null>(null);
|
||||
const [pendingHistoryItem, pendingHistoryItemRef, setPendingHistoryItem] =
|
||||
@@ -280,13 +273,16 @@ export const useGeminiStream = (
|
||||
|
||||
useEffect(() => {
|
||||
const handleRetryAttempt = (payload: RetryAttemptPayload) => {
|
||||
if (turnCancelledRef.current || !isRespondingRef.current) {
|
||||
return;
|
||||
}
|
||||
setRetryStatus(payload);
|
||||
};
|
||||
coreEvents.on(CoreEvent.RetryAttempt, handleRetryAttempt);
|
||||
return () => {
|
||||
coreEvents.off(CoreEvent.RetryAttempt, handleRetryAttempt);
|
||||
};
|
||||
}, []);
|
||||
}, [isRespondingRef]);
|
||||
|
||||
const [
|
||||
toolCalls,
|
||||
@@ -839,6 +835,7 @@ export const useGeminiStream = (
|
||||
return;
|
||||
}
|
||||
turnCancelledRef.current = true;
|
||||
setRetryStatus(null);
|
||||
|
||||
// A full cancellation means no tools have produced a final result yet.
|
||||
// This determines if we show a generic "Request cancelled" message.
|
||||
@@ -1765,6 +1762,7 @@ export const useGeminiStream = (
|
||||
setThought,
|
||||
maybeAddSuppressedToolErrorNote,
|
||||
maybeAddLowVerbosityFailureNote,
|
||||
isRespondingRef,
|
||||
settings.merged.billing?.overageStrategy,
|
||||
setIsResponding,
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user