2159
2160
dispatchAction(channel: string, action: SessionAction | ChatAction | TerminalAction | ClientChangesetAction | ClientAnnotationsAction | IRootConfigChangedAction, clientId: string, clientSeq: number): void {
2161
>
this._logService.trace(`[AgentService] dispatchAction: type=${action.type}, clientId=${clientId}, clientSeq=${clientSeq}`, action);
agentService.ts
2162
>
2163
>
// Clients dispatch chat (chat) actions against a chat channel
2164
>
// URI. Keep that chat channel for the optimistic state apply and for
2165
>
// per-chat routing in side effects, while deriving the owning session
2166
>
// URI for all session-scoped work (attachment snapshotting, agent
2167
>
// lookup, telemetry, permissions — all keyed by session).
2168
>
const chatChannel = isAhpChatChannel(channel) ? channel : undefined;
2169
>
const sessionChannel = chatChannel ? parseRequiredSessionUriFromChatUri(chatChannel) : channel;
2170
>
2171
>
const pending = this._clientDispatchQueues.get(clientId);
2172
>
if (!pending && !this._needsAsyncRewrite(sessionChannel, action)) {
2173
this._dispatchActionNow(channel, sessionChannel, action, clientId, clientSeq);
2174
return;
2175
}
2176
>
const next = (pending ?? Promise.resolve()).then(async () => {
agentService.ts
2177
const rewritten: SessionAction | ChatAction | TerminalAction | ClientChangesetAction | ClientAnnotationsAction | IRootConfigChangedAction = this._needsAsyncRewrite(sessionChannel, action)
2178
? await this._rewriteUserMessageAttachments(sessionChannel, action, clientId)