modelSelection.ts ×11

Frontier kind: Code frontier

unlabeled · c_eb59f936dc94

11 tests · 29417 LOC · 143 files · introduces 0 tests · 22 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges22 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2843 ranges29417 lines · 143 files · Browse complete extent
All tests (intent)
11 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: 22 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/modelSelection.ts 22 introduced LOC · 11 ranges

Open complete file

229
230 export function transitionModelSelection(input: IModelSelectionTransitionInput): IModelSelectionTransitionResult {
231 > const { session, models, previous } = input; modelSelection.ts
232 > const sessionKey = session.kind === 'none' ? undefined : session.key;
233 > const chatKey = session.kind === 'none' ? undefined : session.chatKey;
234 > const sessionModelId = session.kind === 'none' ? undefined : session.modelId;
235 > const sessionChanged = sessionKey !== previous.sessionKey;
236 > const currentModel = sessionChanged ? undefined : previous.currentModel;
237 > const currentReason = sessionChanged ? undefined : previous.currentReason;
238 > const sessionModel = sessionModelId ? models.available.find(model => model.identifier === sessionModelId) : undefined;
239 > const fallbackModel = models.available.find(model => model.identifier === models.rememberedModelId) ?? models.fallbackModel;
240 > const newConversation = session.kind === 'untitled' && !sessionChanged && chatKey !== previous.lastPushedChatKey;
241 > const automaticSelection = currentReason === ModelSelectionReason.ConfiguredDefault
242 > || currentReason === ModelSelectionReason.FirstAvailable
243 || currentReason === ModelSelectionReason.Remembered
244 || currentReason === ModelSelectionReason.NewChatRepush;
245 > const configuredModelValue = session.kind === 'untitled' modelSelection.ts
246 && (newConversation
247 || (!newConversation && (!sessionModelId || automaticSelection) && !isAuthoritativeModelSelectionReason(currentReason)))
248 ? models.configuredModel
249 : undefined;
250 > const configuredModel = configuredModelValue modelSelection.ts
251 ? resolveConfiguredModel(models.configuredModel, models.available)
252 : undefined;
253 > if (configuredModel) { modelSelection.ts
254 if (chatKey === previous.lastPushedChatKey && currentReason === ModelSelectionReason.ConfiguredDefault && currentModel?.identifier === configuredModel.identifier) {
255 return { currentModel, currentReason, pendingSelection: undefined, effect: { kind: 'none' }, sessionKey, lastPushedChatKey: previous.lastPushedChatKey };
257 return applyResult(sessionKey, chatKey, configuredModel, ModelSelectionReason.ConfiguredDefault);
258 }
259 > if (session.kind === 'existing' && models.desiredModelResolution.kind === 'pending') { modelSelection.ts
260 return {
261 currentModel: undefined,
267 };
268 }
269 > if (!currentModel && session.kind === 'untitled' && sessionModel) { modelSelection.ts
270 return {
271 currentModel: sessionModel,
278 }
279
280 > if (!currentModel && session.kind === 'untitled') { modelSelection.ts
281 const initial = resolveInitialModelSelection({
282 configuredModel,
322
323 const currentModelAvailable = !!currentModel && models.available.some(model => model.identifier === currentModel.identifier);
324 > if (currentModel && !currentModelAvailable) { modelSelection.ts
325 if (models.desiredModelResolution.kind === 'pending') {
326 return {
346 }
347
348 > if (session.kind === 'untitled' && currentModel && currentReason === ModelSelectionReason.FirstAvailable) { modelSelection.ts
349 const initial = resolveInitialModelSelection({
350 configuredModel,
362 }
363
364 > if (sessionModel && currentModel && sessionModel.identifier !== currentModel.identifier) { modelSelection.ts
365 return { currentModel: sessionModel, currentReason: ModelSelectionReason.SessionRestore, pendingSelection: undefined, effect: { kind: 'none' }, sessionKey, lastPushedChatKey: chatKey };
366 }
367
368 > if (session.kind === 'untitled' && chatKey !== previous.lastPushedChatKey && currentModel && models.available.some(model => model.identifier === currentModel.identifier)) { modelSelection.ts
369 return applyResult(sessionKey, chatKey, currentModel, ModelSelectionReason.NewChatRepush);
370 }