chatModel.ts ×13

Frontier kind: Code frontier

unlabeled · c_1418565daef4

84 tests · 45243 LOC · 194 files · introduces 0 tests · 121 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
27 ranges121 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4260 ranges45243 lines · 194 files · Browse complete extent
All tests (intent)
84 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: 121 introduced LOC across 27 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/model/chatModel.ts 75 introduced LOC · 13 ranges

Open complete file

816
817 clear(): void {
818 > this.finalizeReasoningDuration(); chatModel.ts
819 > this._responseParts = [];
820 > this._contentChanged(true);
821 > }
822
823 clearToPreviousToolInvocation(message?: string): void {
1170
1171 public get shouldBeRemovedOnSend() {
1172 > return this._shouldBeRemovedOnSend; chatModel.ts
1173 > }
1174
1175 public get isComplete(): boolean {
1335
1336 constructor(params: IChatResponseModelParameters) {
1337 > super(); chatModel.ts
1338 >
1339 > this._session = params.session;
1340 > this._agent = params.agent;
1341 > this._slashCommand = params.slashCommand;
1342 > this.requestId = params.requestId;
1343 > this._timestamp = params.timestamp || Date.now();
1344 > if (params.modelState) {
1345 this._modelState.set(params.modelState, undefined);
1346 }
1347 > this._completionTimestamp = params.completionTimestamp === null chatModel.ts
1348 ? undefined
1349 > : params.completionTimestamp ?? (params.modelState && 'completedAt' in params.modelState ? params.modelState.completedAt : undefined); chatModel.ts
1350 > this._timeSpentWaitingAccumulator = params.timeSpentWaiting || 0;
1351 > this._elapsedMs = params.elapsedMs;
1352 > this._vote = params.vote;
1353 > this._result = params.result;
1354 > this._followups = params.followups ? [...params.followups] : undefined;
1355 > this.isCompleteAddedRequest = params.isCompleteAddedRequest ?? false;
1356 > this._shouldBeRemovedOnSend = params.shouldBeRemovedOnSend;
1357 > this._shouldBeBlocked.set(params.shouldBeBlocked ?? false, undefined);
1358 >
1359 > // If we are creating a response with some existing content, consider it stale
1360 > this._isStale = Array.isArray(params.responseContent) && (params.responseContent.length !== 0 || isMarkdownString(params.responseContent) && params.responseContent.value.length !== 0);
1361 >
1362 > this._response = this._register(new Response(params.responseContent));
1363 > this._codeBlockInfos = params.codeBlockInfos ? [...params.codeBlockInfos] : undefined;
1364 >
1365 > const signal = observableSignalFromEvent(this, this.onDidChange);
1366 >
1367 > const _pendingInfo = signal.map((_value, r): string | undefined => {
1368 > signal.read(r);
1369 >
1370 > for (const part of this._response.value) {
1371 if (part.kind === 'toolInvocation') {
1372 const state = part.state.read(r);
1396 }
1397 }
1398 > chatModel.ts
1399 > return undefined;
1400 > });
1401 >
1402 > const _startedWaitingAt = _pendingInfo.map(p => !!p).map(p => p ? Date.now() : undefined);
1403 > this.isPendingConfirmation = _startedWaitingAt.map((waiting, r) => waiting ? { startedWaitingAt: waiting, detail: _pendingInfo.read(r) } : undefined);
1404 >
1405 > this.isInProgress = signal.map((_value, r) => {
1406 >
1407 > signal.read(r);
1408 >
1409 > return !_pendingInfo.read(r)
1410 > && !this.shouldBeRemovedOnSend
1411 > && (this._modelState.read(r).value === ResponseModelState.Pending || this._modelState.read(r).value === ResponseModelState.NeedsInput);
1412 > });
1413 >
1414 > this.isIncomplete = this._modelState.map(state => {
1415 return state.value === ResponseModelState.Pending || state.value === ResponseModelState.NeedsInput;
1416 > }); chatModel.ts
1417 >
1418 > this._register(this._response.onDidChangeValue(() => this._onDidChange.fire(defaultChatResponseModelChangeReason)));
1419 > this.id = params.restoredId ?? 'response_' + generateUuid();
1420 >
1421 > let lastStartedWaitingAt: number | undefined = undefined;
1422 > this.confirmationAdjustedTimestamp = derived(reader => {
1423 > const pending = this.isPendingConfirmation.read(reader);
1424 > if (pending) {
1425 this._modelState.set({ value: ResponseModelState.NeedsInput }, undefined);
1426 if (!lastStartedWaitingAt) {
1427 lastStartedWaitingAt = pending.startedWaitingAt;
1428 }
1429 > } else if (lastStartedWaitingAt) { chatModel.ts
1430 // Restore state to Pending if it was set to NeedsInput by this observable
1431 if (this._modelState.read(reader).value === ResponseModelState.NeedsInput) {
1435 lastStartedWaitingAt = undefined;
1436 }
1437 > chatModel.ts
1438 > return this._timestamp + this._timeSpentWaitingAccumulator;
1439 > }).recomputeInitiallyAndOnChange(this._store);
1440 > }
1441
1442 initializeCodeBlockInfos(codeBlockInfo: ICodeBlockInfo[]): void {
1644
1645 override dispose(): void {
1646 > super.dispose(); chatModel.ts
1647 > this._response.clear();
1648 > if (this._codeBlockInfos) {
1649 this._codeBlockInfos.length = 0;
1650 }
1651 > } chatModel.ts
1652
1653 toJSON(): Omit<ISerializableChatResponseData, 'timestamp'> {
2620 return;
2621 }
2622 > chatModel.ts
2623 > reader.store.add(request.response.onDidChange(async ev => {
2624 if (!this._editingSession || ev.reason !== 'completedRequest') {
2625 return;
2627
2628 this._onDidChange.fire({ kind: 'completedRequest', request });
2629 > })); chatModel.ts
2630 }));
2631
src/vs/base/common/observableInternal/debugName.ts 25 introduced LOC · 8 ranges

Open complete file

94
95 if (data.owner !== undefined) {
96 > const key = findKey(data.owner, self); debugName.ts
97 > if (key !== undefined) {
98 return ownerStr + key;
99 }
100 > } debugName.ts
101 return undefined;
102 }
103
104 > function findKey(obj: object, value: object): string | undefined { debugName.ts
105 > for (const key in obj) {
106 > if ((obj as Record<string, unknown>)[key] === value) {
107 return key;
108 }
109 > } debugName.ts
110 > return undefined;
111 > }
112
113 const countPerClassName = new Map<string, number>();
114 const ownerId = new WeakMap<object, string>();
115
116 > function formatOwner(owner: object): string { debugName.ts
117 > const id = ownerId.get(owner);
118 > if (id) {
119 return id;
120 }
121 > const className = getClassName(owner) ?? 'Object'; debugName.ts
122 > let count = countPerClassName.get(className) ?? 0;
123 > count++;
124 > countPerClassName.set(className, count);
125 > const result = count === 1 ? className : `${className}#${count}`;
126 > ownerId.set(owner, result);
127 > return result;
128 > }
129
130 export function getClassName(obj: object): string | undefined {
131 > const ctor = obj.constructor; debugName.ts
132 > if (ctor) {
133 > if (ctor.name === 'Object') {
134 return undefined;
135 }
136 > return ctor.name; debugName.ts
137 > }
138 return undefined;
139 }
src/vs/base/common/observableInternal/observables/observableSignalFromEvent.ts 21 introduced LOC · 6 ranges

Open complete file

12
13 export function observableSignalFromEvent(
14 > owner: DebugOwner | string, observableSignalFromEvent.ts
15 > event: Event<any>,
16 > debugLocation = DebugLocation.ofCaller()
17 > ): IObservable<void> {
18 > return new FromEventObservableSignal(typeof owner === 'string' ? owner : new DebugNameData(owner, undefined, undefined), event, debugLocation);
19 > }
20
21 class FromEventObservableSignal extends BaseObservable<void> {
24 public readonly debugName: string;
25 constructor(
26 > debugNameDataOrName: DebugNameData | string, observableSignalFromEvent.ts
27 > private readonly event: Event<any>,
28 > debugLocation: DebugLocation
29 > ) {
30 > super(debugLocation);
31 > this.debugName = typeof debugNameDataOrName === 'string'
32 ? debugNameDataOrName
33 > : debugNameDataOrName.getDebugName(this) ?? 'Observable Signal From Event'; observableSignalFromEvent.ts
34 > }
35
36 protected override onFirstObserverAdded(): void {
37 > this.subscription = this.event(this.handleEvent); observableSignalFromEvent.ts
38 > }
39
40 private readonly handleEvent = () => {