fix(cli): clear static error message when starting new query

Previously, only countdown-based errors were cleared when user starts
a new query. Static errors (like "Press Ctrl+Y to retry") remained
visible. Now both types of errors are properly cleared.
This commit is contained in:
yiliang114 2026-03-05 16:00:58 +08:00
parent 991ae9febc
commit 8ad4a2d205
2 changed files with 81 additions and 3 deletions

View file

@ -1080,8 +1080,13 @@ export const useGeminiStream = (
if (!options?.isContinuation) {
setModelSwitchedFromQuotaError(false);
// Commit any pending retry error to history (without hint) since the
// user is starting a new conversation turn
if (pendingRetryCountdownItemRef.current) {
// user is starting a new conversation turn.
// Clear both countdown-based errors AND static errors (those without
// an active countdown timer, e.g. "Press Ctrl+Y to retry").
if (
pendingRetryCountdownItemRef.current ||
pendingRetryErrorItemRef.current
) {
clearRetryCountdown();
}
}
@ -1176,7 +1181,8 @@ export const useGeminiStream = (
}
// Only clear auto-retry countdown errors (those with an active timer).
// Do NOT clear static error+hint from handleErrorEvent — those should
// remain visible until the user presses Ctrl+Y to retry.
// remain visible until the user presses Ctrl+Y to retry or starts
// a new conversation turn (cleared in submitQuery).
if (retryCountdownTimerRef.current) {
clearRetryCountdown();
}
@ -1223,6 +1229,7 @@ export const useGeminiStream = (
handleLoopDetectedEvent,
clearRetryCountdown,
pendingRetryCountdownItemRef,
pendingRetryErrorItemRef,
setPendingRetryErrorItem,
],
);