fix: ESC key not interrupting during Working... state

Three related fixes:

1. google-gemini-cli: Handle abort signal in stream reading loop
   - Add abort event listener to cancel reader immediately when signal fires
   - Fix AbortError detection in retry catch block (fetch throws AbortError,
     not our custom message)
   - Swallow reader.cancel() rejection to avoid unhandled promise

2. agent-session: Fix retry attempt counter showing 0 on cancel
   - abortRetry() was resetting _retryAttempt before the catch block could
     read it for the error message

3. interactive-mode: Restore main escape handler on agent_start
   - When auto-retry starts, onEscape is replaced with retry-specific handler
   - auto_retry_end (which restores it) fires on turn_end, after streaming begins
   - Now restore immediately on agent_start if retry handler is still active

Amended: suppress reader.cancel() rejection on abort.
This commit is contained in:
Thomas Mustier 2026-01-08 09:35:53 +00:00
parent cfa63c255d
commit a65da1c14b
3 changed files with 161 additions and 133 deletions

View file

@ -1567,7 +1567,7 @@ export class AgentSession {
*/
abortRetry(): void {
this._retryAbortController?.abort();
this._retryAttempt = 0;
// Note: _retryAttempt is reset in the catch block of _autoRetry
this._resolveRetry();
}