mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 04:30:48 +00:00
Merge pull request #2420 from huww98/fix/ctrl-y-retry-rate-limit
feat: allow Ctrl+Y to skip rate-limit retry delay immediately
This commit is contained in:
commit
0776627e0f
5 changed files with 234 additions and 15 deletions
|
|
@ -9,6 +9,7 @@ import type {
|
|||
Config,
|
||||
EditorType,
|
||||
GeminiClient,
|
||||
RetryInfo,
|
||||
ServerGeminiChatCompressedEvent,
|
||||
ServerGeminiContentEvent as ContentEvent,
|
||||
ServerGeminiFinishedEvent,
|
||||
|
|
@ -272,6 +273,7 @@ export const useGeminiStream = (
|
|||
*/
|
||||
const clearRetryCountdown = useCallback(() => {
|
||||
stopRetryCountdownTimer();
|
||||
skipRetryDelayRef.current = null;
|
||||
setPendingRetryErrorItem(null);
|
||||
setPendingRetryCountdownItem(null);
|
||||
}, [
|
||||
|
|
@ -280,14 +282,14 @@ export const useGeminiStream = (
|
|||
stopRetryCountdownTimer,
|
||||
]);
|
||||
|
||||
// Holds the skipDelay callback from the current rate-limit RetryInfo.
|
||||
// Managed symmetrically: set in startRetryCountdown, cleared in clearRetryCountdown.
|
||||
const skipRetryDelayRef = useRef<(() => void) | null>(null);
|
||||
|
||||
const startRetryCountdown = useCallback(
|
||||
(retryInfo: {
|
||||
message?: string;
|
||||
attempt: number;
|
||||
maxRetries: number;
|
||||
delayMs: number;
|
||||
}) => {
|
||||
(retryInfo: RetryInfo) => {
|
||||
stopRetryCountdownTimer();
|
||||
skipRetryDelayRef.current = retryInfo.skipDelay;
|
||||
const startTime = Date.now();
|
||||
const { message, attempt, maxRetries, delayMs } = retryInfo;
|
||||
const retryReasonText =
|
||||
|
|
@ -1391,6 +1393,15 @@ export const useGeminiStream = (
|
|||
* when the user presses Ctrl+Y (bound to Command.RETRY_LAST in keyBindings.ts).
|
||||
*/
|
||||
const retryLastPrompt = useCallback(async () => {
|
||||
// During a rate-limit retry countdown, skip the delay so the generator
|
||||
// retries immediately — no abort/re-submit needed.
|
||||
if (skipRetryDelayRef.current) {
|
||||
skipRetryDelayRef.current();
|
||||
skipRetryDelayRef.current = null;
|
||||
clearRetryCountdown();
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
streamingState === StreamingState.Responding ||
|
||||
streamingState === StreamingState.WaitingForConfirmation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue