chatServiceImpl.ts ×12

Frontier kind: Code frontier

unlabeled · c_197d3d2b21c0

31 tests · 70205 LOC · 309 files · introduces 0 tests · 53 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges53 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5708 ranges70205 lines · 309 files · Browse complete extent
All tests (intent)
31 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.

2 files ranked by introduced lines: 53 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts 51 introduced LOC · 12 ranges

Open complete file

658 return this.acquireOrRestoreLocalSession(sessionResource, debugOwner);
659 } else {
660 > return this.loadRemoteSession(sessionResource, location, token, debugOwner); chatServiceImpl.ts
661 > }
662 }
663
664 private async loadRemoteSession(sessionResource: URI, location: ChatAgentLocation, token: CancellationToken, debugOwner?: string): Promise<IChatModelReference | undefined> {
665 > // Check if session already exists before resolving the provider, chatServiceImpl.ts
666 > // so we can return a cached model even if the provider was unregistered.
667 > {
668 > const existingRef = this.acquireExistingSession(sessionResource, debugOwner);
669 > if (existingRef) {
670 return existingRef;
671 }
673 >
674 > if (!await raceCancellationError(this.chatSessionService.canResolveChatSession(getChatSessionType(sessionResource)), token)) {
675 return undefined;
676 }
684 return existingRef;
685 }
687 const chatSessionType = getChatSessionType(sessionResource);
688 const modelId = findLast(providedSession.history.filter(m => m.type === 'request'), req => req.modelId)?.modelId;
689 > const agentUri = findLast(providedSession.history.filter(m => m.type === 'request'), req => req.modeInstructions?.uri)?.modeInstructions?.uri; chatServiceImpl.ts
690 > const storedMetadata = this._chatSessionStore.getMetadataForSessionSync(sessionResource);
691 > const storedPermissionLevel = storedMetadata?.permissionLevel;
692 > const storedInputState = storedMetadata?.inputState;
693 > let initialData: ISerializedChatDataReference | undefined = undefined;
694 > let historySelectedModel: string | undefined = undefined;
695 > let historyDerivedModel: ISerializableChatModelInputState['selectedModel'] = undefined;
696 > if ((modelId || agentUri)) {
697 const mode: ISerializableChatModelInputState['mode'] = agentUri ? { kind: ChatModeKind.Agent, id: agentUri.toString() } : { kind: ChatModeKind.Agent, id: ChatMode.Agent.id };
698 const modelMetadata = modelId ? this.languageModelsService.lookupLanguageModel(modelId) : undefined;
761 ? { ...storedInputState, selectedModel: historyDerivedModel }
762 : undefined;
763 > // At cold restore the agent-host transferred draft can drop the user's per-session picker chatServiceImpl.ts
764 > // selections (model/mode); restore them from the session's own saved `storedInputState`
765 > // (mode, via {@link backfillRestoredPickerState}) and from the history-derived model
766 > // (via {@link backfillTransferredModel}). The persisted draft already contains
767 > // `historyDerivedModel`, so only a transferred draft needs this backfill.
768 > const transferredInputState = providedSession.transferredState?.inputState;
769 > const stateToApply = transferredInputState
770 ? backfillTransferredModel(transferredInputState, historyDerivedModel)
771 : restoredDraft;
772 > const inputState = backfillRestoredPickerState(stateToApply, storedInputState, ChatMode.Agent.id); chatServiceImpl.ts
773 > const modelRef = this._sessionModels.acquireOrCreate({
774 > initialData,
775 > location,
776 > sessionResource: sessionResource,
777 > canUseTools: false,
778 > transferEditingSession: providedSession.transferredState?.editingSession,
779 > inputState,
780 > isReadOnly: providedSession.isReadOnly,
781 > }, debugOwner ?? 'ChatService#loadRemoteSession');
782 >
783 > logChangesToStateModel(modelRef.object.inputModel, `loadRemoteSession inputState source: session=${sessionResource.toString()}, chatSessionType=${chatSessionType}, historyModelId=${modelId}, agentUri=${agentUri?.toString()}, historySelectedModel=${historySelectedModel}, transferredSelectedModel=${providedSession.transferredState?.inputState?.selectedModel?.identifier}, storedSelectedModel=${storedInputState?.selectedModel?.identifier}, finalSelectedModel=${modelRef.object.inputModel.state.get()?.selectedModel?.identifier}, hasTransferredInputState=${!!providedSession.transferredState?.inputState}, hasStoredInputState=${!!storedInputState}, hasInitialData=${!!initialData}`, modelRef.object.inputModel.state.get(), undefined, this.logService);
784 >
785 > // Restore permission level from metadata even when initialData was not constructed
786 > // and no inputState carried it through.
787 > if (storedPermissionLevel && !initialData && !storedInputState) {
788 modelRef.object.inputModel.setState({ permissionLevel: storedPermissionLevel });
789 }
801
802 const isAgentHostSession = isAgentHostTarget(chatSessionType);
803 > const requestParser = isAgentHostSession ? this.instantiationService.createInstance(ChatRequestParser) : undefined; chatServiceImpl.ts
804 > const parseAgentHostHistoryPrompt = (text: string, agent: IChatAgentData | undefined): IParsedChatRequest => {
805 if (requestParser) {
806 try {
829 };
830 };
832 > let lastRequest: ChatRequestModel | undefined;
833 > let lastResponseCompletedAt: number | undefined;
834 > const completeLastResponse = () => {
835 if (Number.isFinite(lastResponseCompletedAt)) {
836 lastRequest?.response?.complete(lastResponseCompletedAt);
840 lastResponseCompletedAt = undefined;
841 };
842 > for (const message of providedSession.history) { chatServiceImpl.ts
843 if (message.type === 'request') {
844 if (lastRequest) {
902 // and any subsequent server-initiated turns (e.g. consumed queued messages).
903 const hasProgressStreaming = providedSession.progressObs && providedSession.interruptActiveResponseCallback;
904 > if (hasProgressStreaming) { chatServiceImpl.ts
905 let lastProgressLength = 0;
906
1054
1055 return modelRef;
1057
1058 async resendRequest(request: IChatRequestModel, options?: IChatSendRequestOptions): Promise<void> {
src/vs/workbench/contrib/chat/test/common/mockChatSessionsService.ts 2 introduced LOC · 1 range

Open complete file

175
176 async canResolveChatSession(sessionType: string): Promise<boolean> {
177 > return this.contentProviders.has(sessionType); mockChatSessionsService.ts
178 > }
179
180 async provideChatInputCompletions(sessionResource: URI, params: IChatInputCompletionsParams, token: CancellationToken): Promise<IChatInputCompletionsResult | undefined> {