570
return true;
571
}
572
>
const tokenChanged = this._githubToken !== token;
claudeAgent.ts
573
if (!tokenChanged && this._proxyHandle) {
574
this._logService.info('[Claude] Auth token unchanged');
575
return true;
576
}
577
>
// Acquire the new handle BEFORE committing the token or disposing
claudeAgent.ts
578
>
// the old one. If `start()` throws, leave `_githubToken` and
579
>
// `_proxyHandle` untouched so the next `authenticate()` call still
580
>
// sees the token as new and retries — otherwise a transient proxy
581
>
// startup failure would leave us in a "token recorded, no proxy
582
>
// running" state and the retry path would short-circuit as
583
>
// "unchanged" and falsely return true.
584
>
//
585
>
// The proxy server's refcount stays >= 1 throughout this swap
586
>
// because the new handle is acquired before the old one is
587
>
// disposed; {@link IClaudeProxyService} applies most-recent-token-
588
>
// wins on subsequent `start()` calls.
589
>
const newHandle = await this._claudeProxyService.start(token);
590
>
const oldHandle = this._proxyHandle;
591
>
this._proxyHandle = newHandle;
592
>
this._githubToken = token;
593
>
this._logService.info('[Claude] Auth token updated');
594
oldHandle?.dispose();
595
if (tokenChanged) {