1864
return;
1865
}
1867
>
this.trace('processNextPendingRequest', `Processing ${allRequests.length} queued request(s) for session ${model.sessionResource}`);
1868
>
1869
>
// Collect and remove all deferreds
1870
>
const deferreds: DeferredPromise<ChatSendResult>[] = [];
1871
>
for (const req of allRequests) {
1872
>
const deferred = this._queuedRequestDeferreds.get(req.request.id);
1873
>
this._queuedRequestDeferreds.delete(req.request.id);
1874
>
if (deferred) {
1875
>
deferreds.push(deferred);
1876
>
}
1877
>
}
1878
>
1879
>
// Build send options from the first request, combining attachments from all
1880
>
const firstRequest = allRequests[0];
1881
>
1882
>
// Preserve terminal correlation only when all merged requests agree on the
1883
>
// same terminal. With subagents, multiple terminals can queue steering
1884
>
// requests simultaneously — picking one arbitrarily would misattribute the
1885
>
// notification, so we drop the ID when they conflict.
1886
>
const terminalIds = new Set(allRequests.map(req => req.sendOptions.terminalExecutionId).filter((id): id is string => !!id));
1887
>
if (terminalIds.size > 1) {
1888
this.info('processNextPendingRequest', `Dropping terminalExecutionId: ${terminalIds.size} conflicting terminal IDs (${[...terminalIds].join(', ')})`);
1889
}