agentService.ts ×9

Frontier kind: Code frontier

unlabeled · c_4152f3d087cb

33 tests · 50785 LOC · 304 files · introduces 0 tests · 27 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges27 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5179 ranges50785 lines · 304 files · Browse complete extent
All tests (intent)
33 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 27 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentService.ts 27 introduced LOC · 9 ranges

Open complete file

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)
2187 }
2188 this._dispatchActionNow(channel, sessionChannel, rewritten, clientId, clientSeq);
2189 > }).catch(err => { agentService.ts
2190 this._logService.error(`[AgentService] async dispatchAction failed: ${toErrorMessage(err)}`);
2191 > }); agentService.ts
2192 >
2193 > this._clientDispatchQueues.set(clientId, next.finally(() => {
2194 if (this._clientDispatchQueues.get(clientId) === next) {
2195 this._clientDispatchQueues.delete(clientId);
2196 }
2197 > })); agentService.ts
2198 > }
2199
2200 private _dispatchActionNow(channel: string, sessionChannel: string, action: SessionAction | ChatAction | TerminalAction | ClientChangesetAction | ClientAnnotationsAction | IRootConfigChangedAction, clientId: string, clientSeq: number): void {
2201 > const origin = { clientId, clientSeq }; agentService.ts
2202 > this._stateManager.dispatchClientAction(channel, action, origin);
2203 > if (action.type === ActionType.RootConfigChanged) {
2204 this._configurationService.persistRootConfig();
2205 }
2206 > this._sideEffects.handleAction(channel, action, clientId); agentService.ts
2207 > }
2208
2209 private _needsAsyncRewrite(channel: string, action: SessionAction | ChatAction | TerminalAction | ClientChangesetAction | ClientAnnotationsAction | IRootConfigChangedAction): action is ChatTurnStartedAction | ChatPendingMessageSetAction {
2210 > if (action.type !== ActionType.ChatTurnStarted && action.type !== ActionType.ChatPendingMessageSet) { agentService.ts
2211 return false;
2212 }
2213 const attachmentsRootStr = this._attachmentsRoot(channel).toString();
2214 > return !!action.message.attachments?.some(a => this._isRewritableAttachment(a, attachmentsRootStr)); agentService.ts
2215 > }
2216 private _isRewritableAttachment(attachment: MessageAttachment, attachmentsRootStr: string): boolean {
2217 if (attachment.type === MessageAttachmentKind.EmbeddedResource) {