chatServiceImpl.ts ×11

Frontier kind: Code frontier

unlabeled · c_4cc8b5e1156f

30 tests · 71007 LOC · 309 files · introduces 0 tests · 64 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges64 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5905 ranges71007 lines · 309 files · Browse complete extent
All tests (intent)
30 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.

3 files ranked by introduced lines: 64 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts 45 introduced LOC · 11 ranges

Open complete file

70 * persisted on dispose so the draft survives switching sessions.
71 */
72 > function hasDraftInput(model: ChatModel): boolean { chatServiceImpl.ts
73 > const state = model.inputModel.state.get();
74 > if (!state) {
75 return false;
76 }
675 return undefined;
676 }
678 > const providedSession = await this.chatSessionService.getOrCreateChatSession(sessionResource, token);
679 >
680 > // Make sure we haven't created this in the meantime
681 > {
682 > const existingRef = this.acquireExistingSession(sessionResource, debugOwner);
683 > if (existingRef) {
684 return existingRef;
685 }
686 }
687 > const chatSessionType = getChatSessionType(sessionResource); chatServiceImpl.ts
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;
690 const storedMetadata = this._chatSessionStore.getMetadataForSessionSync(sessionResource);
747 };
748 }
750 > // Contributed sessions do not use UI tools.
751 > // Prefer (in order): a transferred draft, the persisted draft from metadata,
752 > // otherwise let the constructor fall back to initialData.value.inputState.
753 > // When restoring the persisted draft we keep the unsent text/selections/mode but
754 > // deliberately drop its persisted selectedModel identifier (it can be stale or belong
755 > // to a different model pool) in favour of the model derived from the session's request
756 > // history. The user's per-model configuration (thinking effort, context window) is
757 > // carried over onto that history-derived model above when the ids match. When no
758 > // history model is available the model is left undefined so the input part resolves
759 > // it via its own selection logic.
760 > const restoredDraft: ISerializableChatModelInputState | undefined = storedInputState
761 ? { ...storedInputState, selectedModel: historyDerivedModel }
762 > : undefined; chatServiceImpl.ts
763 // At cold restore the agent-host transferred draft can drop the user's per-session picker
764 // selections (model/mode); restore them from the session's own saved `storedInputState`
769 const stateToApply = transferredInputState
770 ? backfillTransferredModel(transferredInputState, historyDerivedModel)
771 > : restoredDraft; chatServiceImpl.ts
772 const inputState = backfillRestoredPickerState(stateToApply, storedInputState, ChatMode.Agent.id);
773 const modelRef = this._sessionModels.acquireOrCreate({
788 modelRef.object.inputModel.setState({ permissionLevel: storedPermissionLevel });
789 }
791 > if (providedSession.title) {
792 modelRef.object.setCustomTitle(providedSession.title);
793 }
795 > const model = modelRef.object;
796 > const disposables = new DisposableStore();
797 > disposables.add(modelRef.object.onDidDispose(() => {
798 > disposables.dispose();
799 > providedSession.dispose();
800 > }));
801 >
802 > const isAgentHostSession = isAgentHostTarget(chatSessionType);
803 const requestParser = isAgentHostSession ? this.instantiationService.createInstance(ChatRequestParser) : undefined;
804 const parseAgentHostHistoryPrompt = (text: string, agent: IChatAgentData | undefined): IParsedChatRequest => {
897 }
898 }
900 > // Set up progress streaming and cancellation for contributed sessions.
901 > // This handles both the initial in-flight response (from session load)
902 > // and any subsequent server-initiated turns (e.g. consumed queued messages).
903 > const hasProgressStreaming = providedSession.progressObs && providedSession.interruptActiveResponseCallback;
904 if (hasProgressStreaming) {
905 let lastProgressLength = 0;
1040 }
1041 }));
1042 > } else { chatServiceImpl.ts
1043 if (providedSession.isCompleteObs?.get()) {
1044 completeLastResponse();
src/vs/workbench/contrib/chat/test/common/mockChatSessionsService.ts 13 introduced LOC · 3 ranges

Open complete file

152
153 registerChatSessionContentProvider(chatSessionType: string, provider: IChatSessionContentProvider): IDisposable {
154 > this.contentProviders.set(chatSessionType, provider); mockChatSessionsService.ts
155 > this._onDidChangeContentProviderSchemes.fire({ added: [chatSessionType], removed: [] });
156 > return {
157 > dispose: () => {
158 > this.contentProviders.delete(chatSessionType);
159 > }
160 > };
161 > }
162
163 async canResolveContentProvider(chatSessionType: string): Promise<boolean> {
166
167 async getOrCreateChatSession(sessionResource: URI, token: CancellationToken): Promise<IChatSession> {
168 > const sessionType = getChatSessionType(sessionResource); mockChatSessionsService.ts
169 > const provider = this.contentProviders.get(sessionType);
170 > if (!provider) {
171 throw new Error(`No content provider for ${sessionType}`);
172 }
173 > return provider.provideChatSessionContent(sessionResource, token); mockChatSessionsService.ts
174 > }
175
176 async canResolveChatSession(sessionType: string): Promise<boolean> {
src/vs/workbench/contrib/chat/common/model/chatSessionStore.ts 6 introduced LOC · 2 ranges

Open complete file

588
589 getMetadataForSessionSync(sessionResource: URI): IChatSessionEntryMetadata | undefined {
590 > const index = this.internalGetIndex(); chatSessionStore.ts
591 > return index.entries[this.getIndexKey(sessionResource)];
592 > }
593
594 private getIndexKey(sessionResource: URI): string {
595 > const sessionId = LocalChatSessionUri.parseLocalSessionId(sessionResource); chatSessionStore.ts
596 > return sessionId ?? sessionResource.toString();
597 > }
598
599 logIndex(): void {