817
private _handleClientDisconnected(clientId: string): void {
818
for (const session of this._stateManager.getSessionUris()) {
820
>
const isActive = state ? this._isActiveClient(state, clientId) : false;
821
>
const ownsPendingToolCall = state ? this._hasPendingClientToolCall(state, clientId) : false;
822
>
// Keep the client marked active during the grace window so a quick
823
>
// reconnect that resubscribes can retain its slot. The disconnect
824
>
// timeout removes the active client (and fails its pending tool
825
>
// calls) if it never returns; an explicit unsubscribe or a
826
>
// reconnect without resubscription removes it sooner.
827
>
if (isActive || ownsPendingToolCall) {
828
for (const chat of state?.chats ?? []) {
829
this._startClientToolCallDisconnectTimeout(clientId, session, chat.resource);
830
}
831
}
833
}
834
835
/** Whether `clientId` is one of the session's active clients. */
836
private _isActiveClient(state: SessionState, clientId: string): boolean {
838
>
}
839
840
/**