Skip to content

Commit 3140ee0

Browse files
authored
Merge pull request microsoft#300562 from mjbvz/dev/mjbvz/tragic-tyrannosaurus
Log when `untitled` sessions cross the ext host boundary
2 parents 6097683 + f6a8182 commit 3140ee0

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/vs/workbench/api/browser/mainThreadChatSessions.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { IChatContentInlineReference, IChatProgress, IChatService, ResponseModel
2727
import { ChatSessionStatus, IChatSession, IChatSessionContentProvider, IChatSessionHistoryItem, IChatSessionItem, IChatSessionItemController, IChatSessionProviderOptionItem, IChatSessionsService } from '../../contrib/chat/common/chatSessionsService.js';
2828
import { ChatAgentLocation } from '../../contrib/chat/common/constants.js';
2929
import { IChatModel } from '../../contrib/chat/common/model/chatModel.js';
30+
import { isUntitledChatSession } from '../../contrib/chat/common/model/chatUri.js';
3031
import { IChatAgentRequest } from '../../contrib/chat/common/participants/chatAgents.js';
3132
import { IChatTodoListService } from '../../contrib/chat/common/tools/chatTodoListService.js';
3233
import { IEditorGroupsService } from '../../services/editor/common/editorGroupsService.js';
@@ -350,6 +351,8 @@ class MainThreadChatSessionItemController extends Disposable implements IChatSes
350351
}
351352

352353
async newChatSessionItem(request: IChatAgentRequest, token: CancellationToken): Promise<IChatSessionItem | undefined> {
354+
warnOnUntitledSessionResource(request.sessionResource);
355+
353356
const dto = await raceCancellationError(this._proxy.$newChatSessionItem(this._handle, request, token), token);
354357
if (!dto) {
355358
return undefined;
@@ -366,6 +369,7 @@ class MainThreadChatSessionItemController extends Disposable implements IChatSes
366369

367370
acceptChange(change: { readonly addedOrUpdated: readonly IChatSessionItem[]; readonly removed: readonly URI[] }): void {
368371
for (const item of change.addedOrUpdated) {
372+
warnOnUntitledSessionResource(item.resource);
369373
this._items.set(item.resource, item);
370374
}
371375
for (const uri of change.removed) {
@@ -375,6 +379,7 @@ class MainThreadChatSessionItemController extends Disposable implements IChatSes
375379
}
376380

377381
addOrUpdateItem(item: IChatSessionItem): void {
382+
warnOnUntitledSessionResource(item.resource);
378383
this._items.set(item.resource, item);
379384
this._onDidChangeChatSessionItems.fire();
380385
}
@@ -384,6 +389,7 @@ class MainThreadChatSessionItemController extends Disposable implements IChatSes
384389
}
385390
}
386391

392+
387393
@extHostNamedCustomer(MainContext.MainThreadChatSessions)
388394
export class MainThreadChatSessions extends Disposable implements MainThreadChatSessionsShape {
389395
private readonly _itemControllerRegistrations = this._register(new DisposableMap<number, IDisposable & {
@@ -415,6 +421,7 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
415421
this._proxy = this._extHostContext.getProxy(ExtHostContext.ExtHostChatSessions);
416422

417423
this._register(this._chatSessionsService.onRequestNotifyExtension(({ sessionResource, updates, waitUntil }) => {
424+
warnOnUntitledSessionResource(sessionResource);
418425
const handle = this._getHandleForSessionType(sessionResource.scheme);
419426
this._logService.trace(`[MainThreadChatSessions] onRequestNotifyExtension received: scheme '${sessionResource.scheme}', handle ${handle}, ${updates.length} update(s)`);
420427
if (handle !== undefined) {
@@ -427,6 +434,7 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
427434
this._register(this._agentSessionsService.model.onDidChangeSessionArchivedState(session => {
428435
for (const [handle, { chatSessionType }] of this._itemControllerRegistrations) {
429436
if (chatSessionType === session.providerType) {
437+
warnOnUntitledSessionResource(session.resource);
430438
this._proxy.$onDidChangeChatSessionItemState(handle, session.resource, session.isArchived());
431439
}
432440
}
@@ -515,6 +523,7 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
515523

516524
$onDidChangeChatSessionOptions(handle: number, sessionResourceComponents: UriComponents, updates: ReadonlyArray<{ optionId: string; value: string }>): void {
517525
const sessionResource = URI.revive(sessionResourceComponents);
526+
warnOnUntitledSessionResource(sessionResource);
518527
this._chatSessionsService.notifySessionOptionsChange(sessionResource, updates);
519528
}
520529

@@ -622,6 +631,8 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
622631
}
623632

624633
private async _provideChatSessionContent(providerHandle: number, sessionResource: URI, token: CancellationToken): Promise<IChatSession> {
634+
warnOnUntitledSessionResource(sessionResource);
635+
625636
let session = this._activeSessions.get(sessionResource);
626637

627638
if (!session) {
@@ -711,6 +722,8 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
711722

712723
$handleProgressComplete(handle: number, sessionResource: UriComponents, requestId: string) {
713724
const resource = URI.revive(sessionResource);
725+
warnOnUntitledSessionResource(resource);
726+
714727
const observableSession = this._activeSessions.get(resource);
715728
if (!observableSession) {
716729
this._logService.warn(`No session found for progress completion: handle ${handle}, sessionResource ${resource}, requestId ${requestId}`);
@@ -803,3 +816,9 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
803816
}
804817
}
805818
}
819+
820+
function warnOnUntitledSessionResource(resource: URI): void {
821+
if (isUntitledChatSession(resource)) {
822+
console.trace(`[MainThreadChatSessions] untitled-style sessionResource detected ${resource.toString()}`);
823+
}
824+
}

0 commit comments

Comments
 (0)