mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-18 07:47:23 +01:00
sessions: fix title bar context menu and session type icons (#306419)
sessions: fix title bar context menu and session icons - Fix Unpin action missing from title bar context menu by looking up actual pinned state via SessionsView instead of hardcoding false - Remove context menu for new/unsent sessions where actions like delete, pin, and archive don't apply - Use session type icons (Codicon.copilot, Codicon.cloud) for AgentSessionAdapter instead of provider-level icons Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
6a7e1b4bd3
commit
b7308211d2
@@ -640,7 +640,7 @@ class AgentSessionAdapter implements ISessionData {
|
|||||||
this.resource = session.resource;
|
this.resource = session.resource;
|
||||||
this.providerId = providerId;
|
this.providerId = providerId;
|
||||||
this.sessionType = session.providerType;
|
this.sessionType = session.providerType;
|
||||||
this.icon = session.icon;
|
this.icon = this._getSessionTypeIcon(session);
|
||||||
this.createdAt = new Date(session.timing.created);
|
this.createdAt = new Date(session.timing.created);
|
||||||
this._workspace = observableValue(this, this._buildWorkspace(session));
|
this._workspace = observableValue(this, this._buildWorkspace(session));
|
||||||
this.workspace = this._workspace;
|
this.workspace = this._workspace;
|
||||||
@@ -692,6 +692,17 @@ class AgentSessionAdapter implements ISessionData {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _getSessionTypeIcon(session: IAgentSession): ThemeIcon {
|
||||||
|
switch (session.providerType) {
|
||||||
|
case AgentSessionProviders.Background:
|
||||||
|
return CopilotCLISessionType.icon;
|
||||||
|
case AgentSessionProviders.Cloud:
|
||||||
|
return CopilotCloudSessionType.icon;
|
||||||
|
default:
|
||||||
|
return session.icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _extractDescription(session: IAgentSession): string | undefined {
|
private _extractDescription(session: IAgentSession): string | undefined {
|
||||||
if (!session.description) {
|
if (!session.description) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { IWorkbenchLayoutService, Parts } from '../../../../workbench/services/l
|
|||||||
import { Menus } from '../../../browser/menus.js';
|
import { Menus } from '../../../browser/menus.js';
|
||||||
import { IWorkbenchContribution } from '../../../../workbench/common/contributions.js';
|
import { IWorkbenchContribution } from '../../../../workbench/common/contributions.js';
|
||||||
import { IActionViewItemService } from '../../../../platform/actions/browser/actionViewItemService.js';
|
import { IActionViewItemService } from '../../../../platform/actions/browser/actionViewItemService.js';
|
||||||
import { ISessionsManagementService } from './sessionsManagementService.js';
|
import { ISessionsManagementService, IsNewChatSessionContext } from './sessionsManagementService.js';
|
||||||
import { autorun, observableSignalFromEvent } from '../../../../base/common/observable.js';
|
import { autorun, observableSignalFromEvent } from '../../../../base/common/observable.js';
|
||||||
import { ThemeIcon } from '../../../../base/common/themables.js';
|
import { ThemeIcon } from '../../../../base/common/themables.js';
|
||||||
import { IsAuxiliaryWindowContext } from '../../../../workbench/common/contextkeys.js';
|
import { IsAuxiliaryWindowContext } from '../../../../workbench/common/contextkeys.js';
|
||||||
@@ -30,6 +30,8 @@ import { ISessionsProvidersService } from './sessionsProvidersService.js';
|
|||||||
import { SessionStatus } from '../common/sessionData.js';
|
import { SessionStatus } from '../common/sessionData.js';
|
||||||
import { SHOW_SESSIONS_PICKER_COMMAND_ID } from './sessionsActions.js';
|
import { SHOW_SESSIONS_PICKER_COMMAND_ID } from './sessionsActions.js';
|
||||||
import { IsSessionArchivedContext, IsSessionPinnedContext, IsSessionReadContext, SessionItemContextMenuId } from './views/sessionsList.js';
|
import { IsSessionArchivedContext, IsSessionPinnedContext, IsSessionReadContext, SessionItemContextMenuId } from './views/sessionsList.js';
|
||||||
|
import { SessionsView, SessionsViewId } from './views/sessionsView.js';
|
||||||
|
import { IViewsService } from '../../../../workbench/services/views/common/viewsService.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sessions Title Bar Widget - renders the active chat session title
|
* Sessions Title Bar Widget - renders the active chat session title
|
||||||
@@ -66,6 +68,7 @@ export class SessionsTitleBarWidget extends BaseActionViewItem {
|
|||||||
@IContextKeyService private readonly contextKeyService: IContextKeyService,
|
@IContextKeyService private readonly contextKeyService: IContextKeyService,
|
||||||
@ISessionsProvidersService private readonly sessionsProvidersService: ISessionsProvidersService,
|
@ISessionsProvidersService private readonly sessionsProvidersService: ISessionsProvidersService,
|
||||||
@ICommandService private readonly commandService: ICommandService,
|
@ICommandService private readonly commandService: ICommandService,
|
||||||
|
@IViewsService private readonly viewsService: IViewsService,
|
||||||
) {
|
) {
|
||||||
super(undefined, action, options);
|
super(undefined, action, options);
|
||||||
|
|
||||||
@@ -256,8 +259,13 @@ export class SessionsTitleBarWidget extends BaseActionViewItem {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.contextKeyService.getContextKeyValue<boolean>(IsNewChatSessionContext.key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isPinned = this.viewsService.getViewWithId<SessionsView>(SessionsViewId)?.sessionsControl?.isSessionPinned(sessionData) ?? false;
|
||||||
const contextOverlay: [string, boolean | string][] = [
|
const contextOverlay: [string, boolean | string][] = [
|
||||||
[IsSessionPinnedContext.key, false],
|
[IsSessionPinnedContext.key, isPinned],
|
||||||
[IsSessionArchivedContext.key, sessionData.isArchived.get()],
|
[IsSessionArchivedContext.key, sessionData.isArchived.get()],
|
||||||
[IsSessionReadContext.key, sessionData.isRead.get()],
|
[IsSessionReadContext.key, sessionData.isRead.get()],
|
||||||
['chatSessionType', sessionData.sessionType],
|
['chatSessionType', sessionData.sessionType],
|
||||||
|
|||||||
Reference in New Issue
Block a user