mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +00:00
Fix agent sessions reporting to status (#274848)
* Fix agent sessions reporting to status * Update src/vs/workbench/contrib/chat/browser/chatSessions/localChatSessionsProvider.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -74,20 +74,7 @@ export class LocalChatSessionsProvider extends Disposable implements IChatSessio
|
||||
'viewId' in widget.viewContext &&
|
||||
widget.viewContext.viewId === LocalChatSessionsProvider.CHAT_WIDGET_VIEW_ID) {
|
||||
this._onDidChange.fire();
|
||||
|
||||
// Listen for view model changes on this widget
|
||||
this._register(widget.onDidChangeViewModel(() => {
|
||||
this._onDidChange.fire();
|
||||
if (widget.viewModel) {
|
||||
this.registerProgressListener(widget.viewModel.model.requestInProgressObs);
|
||||
}
|
||||
}));
|
||||
|
||||
// Listen for title changes on the current model
|
||||
this.registerModelTitleListener(widget);
|
||||
if (widget.viewModel) {
|
||||
this.registerProgressListener(widget.viewModel.model.requestInProgressObs);
|
||||
}
|
||||
this._registerWidgetModelListeners(widget);
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -96,19 +83,25 @@ export class LocalChatSessionsProvider extends Disposable implements IChatSessio
|
||||
.filter(widget => typeof widget.viewContext === 'object' && 'viewId' in widget.viewContext && widget.viewContext.viewId === LocalChatSessionsProvider.CHAT_WIDGET_VIEW_ID);
|
||||
|
||||
existingWidgets.forEach(widget => {
|
||||
this._register(widget.onDidChangeViewModel(() => {
|
||||
this._onDidChange.fire();
|
||||
this.registerModelTitleListener(widget);
|
||||
}));
|
||||
this._registerWidgetModelListeners(widget);
|
||||
});
|
||||
}
|
||||
|
||||
// Register title listener for existing widget
|
||||
private _registerWidgetModelListeners(widget: IChatWidget): void {
|
||||
const register = () => {
|
||||
this.registerModelTitleListener(widget);
|
||||
if (widget.viewModel) {
|
||||
this.registerProgressListener(widget.viewModel.model.requestInProgressObs);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
// Listen for view model changes on this widget
|
||||
this._register(widget.onDidChangeViewModel(() => {
|
||||
register();
|
||||
this._onDidChangeChatSessionItems.fire();
|
||||
}));
|
||||
|
||||
register();
|
||||
}
|
||||
private registerProgressListener(observable: IObservable<boolean>) {
|
||||
const progressEvent = Event.fromObservableLight(observable);
|
||||
this._register(progressEvent(() => {
|
||||
|
||||
@@ -258,7 +258,6 @@ class ChatSessionsViewPaneContainer extends ViewPaneContainer {
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
|
||||
@ILogService logService: ILogService,
|
||||
@IChatSessionsService private readonly chatSessionsService: IChatSessionsService,
|
||||
) {
|
||||
super(
|
||||
AGENT_SESSIONS_VIEWLET_ID,
|
||||
@@ -277,30 +276,10 @@ class ChatSessionsViewPaneContainer extends ViewPaneContainer {
|
||||
viewDescriptorService,
|
||||
logService
|
||||
);
|
||||
|
||||
// Listen for session items changes and refresh the appropriate provider tree
|
||||
this._register(this.chatSessionsService.onDidChangeSessionItems((chatSessionType) => {
|
||||
this.refreshProviderTree(chatSessionType);
|
||||
}));
|
||||
}
|
||||
|
||||
override getTitle(): string {
|
||||
const title = nls.localize('chat.agent.sessions.title', "Agent Sessions");
|
||||
return title;
|
||||
}
|
||||
|
||||
private refreshProviderTree(chatSessionType: string): void {
|
||||
// Find the provider with the matching chatSessionType
|
||||
const providers = Array.from(this.chatSessionsService.getAllChatSessionItemProviders());
|
||||
const targetProvider = providers.find(provider => provider.chatSessionType === chatSessionType);
|
||||
|
||||
if (targetProvider) {
|
||||
// Find the corresponding view and refresh its tree
|
||||
const viewId = `${AGENT_SESSIONS_VIEWLET_ID}.${chatSessionType}`;
|
||||
const view = this.getView(viewId) as SessionsViewPane | undefined;
|
||||
if (view) {
|
||||
view.refreshTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import { IEditorGroupsService } from '../../../../../services/editor/common/edit
|
||||
import { IEditorService } from '../../../../../services/editor/common/editorService.js';
|
||||
import { IViewsService } from '../../../../../services/views/common/viewsService.js';
|
||||
import { IChatService } from '../../../common/chatService.js';
|
||||
import { IChatSessionItemProvider, localChatSessionType } from '../../../common/chatSessionsService.js';
|
||||
import { IChatSessionItemProvider, IChatSessionsService, localChatSessionType } from '../../../common/chatSessionsService.js';
|
||||
import { ChatConfiguration, ChatEditorTitleMaxLength } from '../../../common/constants.js';
|
||||
import { ACTION_ID_OPEN_CHAT } from '../../actions/chatActions.js';
|
||||
import { ChatViewId, IChatWidgetService } from '../../chat.js';
|
||||
@@ -98,6 +98,7 @@ export class SessionsViewPane extends ViewPane {
|
||||
@ICommandService private readonly commandService: ICommandService,
|
||||
@IChatWidgetService private readonly chatWidgetService: IChatWidgetService,
|
||||
@IEditorGroupsService private readonly editorGroupsService: IEditorGroupsService,
|
||||
@IChatSessionsService private readonly chatSessionsService: IChatSessionsService,
|
||||
) {
|
||||
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, hoverService);
|
||||
this.minimumBodySize = 44;
|
||||
@@ -120,6 +121,12 @@ export class SessionsViewPane extends ViewPane {
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(this.chatSessionsService.onDidChangeSessionItems((chatSessionType) => {
|
||||
if (provider.chatSessionType === chatSessionType && this.tree && this.isBodyVisible()) {
|
||||
this.refreshTreeWithProgress();
|
||||
}
|
||||
}));
|
||||
|
||||
if (provider) { // TODO: Why can this be undefined?
|
||||
this.scopedContextKeyService.createKey('chatSessionType', provider.chatSessionType);
|
||||
}
|
||||
@@ -186,12 +193,6 @@ export class SessionsViewPane extends ViewPane {
|
||||
);
|
||||
}
|
||||
|
||||
public refreshTree(): void {
|
||||
if (this.tree && this.isBodyVisible()) {
|
||||
this.refreshTreeWithProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private isEmpty() {
|
||||
// Check if the tree has the provider node and get its children count
|
||||
if (!this.tree?.hasNode(this.provider)) {
|
||||
|
||||
Reference in New Issue
Block a user