sessionState.ts ×12

Frontier kind: Joint frontier

unlabeled · c_f857caf31152

1 test · 43955 LOC · 243 files · introduces 1 test · 71 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges71 lines · 2 files
Tests
1 test

Contains — complete concept membership

All code (extent)
4052 ranges43955 lines · 243 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

1 test introduced at this concept.

Introduced code

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

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

src/vs/platform/agentHost/common/state/sessionState.ts 48 introduced LOC · 12 ranges

Open complete file

198 */
199 export function readUsageInfoMeta(usage: UsageInfo | undefined): UsageInfoMeta {
200 > const meta = usage?._meta; sessionState.ts
201 > if (!meta) {
202 return {};
203 }
204 > const result: Mutable<UsageInfoMeta> = {}; sessionState.ts
205 > if (typeof meta['cost'] === 'number') { result.cost = meta['cost']; }
206 > const autoModeResolved = readAutoModeResolvedInfo(meta['autoModeResolved']);
207 > if (autoModeResolved) { result.autoModeResolved = autoModeResolved; }
208 > const copilotUsage = meta['copilotUsage'];
209 > if (copilotUsage && typeof copilotUsage === 'object' && !Array.isArray(copilotUsage)) {
210 const rawUsage = copilotUsage as Record<string, unknown>;
211 const usage: Mutable<NonNullable<UsageInfoMeta['copilotUsage']>> = {};
213 result.copilotUsage = usage;
214 }
215 > const quotaSnapshots = meta['quotaSnapshots']; sessionState.ts
216 > if (quotaSnapshots && typeof quotaSnapshots === 'object' && !Array.isArray(quotaSnapshots)) {
217 const snapshots: Mutable<NonNullable<UsageInfoMeta['quotaSnapshots']>> = {};
218 for (const [quotaType, value] of Object.entries(quotaSnapshots as Record<string, unknown>)) {
221 result.quotaSnapshots = snapshots;
222 }
223 > const contextAttribution = readContextAttribution(meta['contextAttribution']); sessionState.ts
224 > if (contextAttribution) {
225 result.contextAttribution = contextAttribution;
226 }
227 > return result; sessionState.ts
228 > }
229
230 > function readAutoModeResolvedInfo(value: unknown): IAutoModeResolvedInfo | undefined { sessionState.ts
231 > if (!value || typeof value !== 'object' || Array.isArray(value)) {
232 return undefined;
233 }
234 > const raw = value as Record<string, unknown>; sessionState.ts
235 > if (typeof raw['chosenModel'] !== 'string') {
236 return undefined;
237 }
238 > const result: Mutable<IAutoModeResolvedInfo> = { chosenModel: raw['chosenModel'] }; sessionState.ts
239 > const reasoningBucket = raw['reasoningBucket'];
240 > if (reasoningBucket === 'low' || reasoningBucket === 'medium' || reasoningBucket === 'high') {
241 > result.reasoningBucket = reasoningBucket;
242 > }
243 > const categoryScores = raw['categoryScores'];
244 > if (categoryScores && typeof categoryScores === 'object' && !Array.isArray(categoryScores)) {
245 > const scores: Record<string, number> = {};
246 > for (const [category, score] of Object.entries(categoryScores as Record<string, unknown>)) {
247 > if (typeof score === 'number') {
248 > scores[category] = score;
249 > }
250 > }
251 > result.categoryScores = scores;
252 > }
253 > if (typeof raw['predictedLabel'] === 'string') { result.predictedLabel = raw['predictedLabel']; }
254 > if (typeof raw['confidence'] === 'number') { result.confidence = raw['confidence']; }
255 > if (Array.isArray(raw['candidateModels']) && raw['candidateModels'].every(candidate => typeof candidate === 'string')) {
256 > result.candidateModels = raw['candidateModels'];
257 > }
258 > return result;
259 > }
260
261 > function readContextAttribution(value: unknown): IContextAttributionData | undefined { sessionState.ts
262 > if (!value || typeof value !== 'object' || Array.isArray(value)) {
263 > return undefined;
264 > }
265 const raw = value as Record<string, unknown>;
266 > if (typeof raw['totalTokens'] !== 'number' || !Array.isArray(raw['entries'])) { sessionState.ts
267 return undefined;
268 }
289 }
290 const compactionsRaw = raw['compactions'];
291 > const compactions = compactionsRaw && typeof compactionsRaw === 'object' && !Array.isArray(compactionsRaw) sessionState.ts
292 && typeof (compactionsRaw as Record<string, unknown>)['count'] === 'number'
293 ? { count: (compactionsRaw as Record<string, unknown>)['count'] as number }
294 : { count: 0 };
295 > return { totalTokens: raw['totalTokens'] as number, entries, compactions }; sessionState.ts
296 > }
297
298 function filterStringAttributes(raw: Record<string, unknown>): Record<string, string | undefined> {
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts 23 introduced LOC · 3 ranges

Open complete file

3614
3615 this._register(wrapper.onAutoModeResolved(e => {
3616 > this._lastSeenModelId = e.data.chosenModel; copilotAgentSession.ts
3617 > const turnId = this._turnId;
3618 > this._logService.info(`[Copilot:${sessionId}] Auto mode resolved to ${e.data.chosenModel}${e.data.reasoningBucket ? ` (${e.data.reasoningBucket})` : ''}`);
3619 > if (!turnId) {
3620 return;
3621 }
3622 > autoModeResolved = { turnId, data: e.data }; copilotAgentSession.ts
3623 > const priorUsage = lastParentUsageTurnId === turnId ? lastParentUsage : undefined;
3624 > const usage: UsageInfo = {
3625 > ...priorUsage,
3626 > model: e.data.chosenModel,
3627 > _meta: {
3628 > ...(priorUsage?._meta ?? {}),
3629 > autoModeResolved: e.data,
3630 > },
3631 > };
3632 > lastParentUsage = usage;
3633 > lastParentUsageTurnId = turnId;
3634 > this._emitAction({
3635 > type: ActionType.ChatUsage,
3636 > turnId,
3637 > usage,
3638 > });
3639 }));
3640
3690 }
3691 if (scope === '' && autoModeResolved?.turnId === this._turnId) {
3692 > metadata.autoModeResolved = autoModeResolved.data; copilotAgentSession.ts
3693 > }
3694 if (turn && typeof copilotUsage?.totalNanoAiu === 'number') {
3695 const scopedTotal = (turn.copilotUsageTotalNanoAiuByScope.get(scope) ?? 0) + copilotUsage.totalNanoAiu;