From f8c32042ed5206d294fe73f1a3b2b74cd3f7bb7a Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Mon, 30 Mar 2026 19:32:10 +0000 Subject: [PATCH] Sessions - more actions polish in the Changes view (#306442) --- .../contrib/changes/browser/changesView.ts | 22 +++++++++++++++++++ .../browser/views/sessionsViewActions.ts | 12 +++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/vs/sessions/contrib/changes/browser/changesView.ts b/src/vs/sessions/contrib/changes/browser/changesView.ts index f44fcb7d469..75ccada74f3 100644 --- a/src/vs/sessions/contrib/changes/browser/changesView.ts +++ b/src/vs/sessions/contrib/changes/browser/changesView.ts @@ -108,6 +108,7 @@ const enum IsolationMode { const changesVersionModeContextKey = new RawContextKey('sessions.changesVersionMode', ChangesVersionMode.BranchChanges); const isMergeBaseBranchProtectedContextKey = new RawContextKey('sessions.isMergeBaseBranchProtected', false); const isolationModeContextKey = new RawContextKey('sessions.isolationMode', IsolationMode.Workspace); +const hasGitRepositoryContextKey = new RawContextKey('sessions.hasGitRepository', true); const hasPullRequestContextKey = new RawContextKey('sessions.hasPullRequest', false); const hasOpenPullRequestContextKey = new RawContextKey('sessions.hasOpenPullRequest', false); const hasIncomingChangesContextKey = new RawContextKey('sessions.hasIncomingChanges', false); @@ -265,6 +266,7 @@ class ChangesViewModel extends Disposable { readonly activeSessionIsolationModeObs: IObservable; readonly activeSessionRepositoryObs: IObservableWithChange; readonly activeSessionChangesObs: IObservable; + readonly activeSessionHasGitRepositoryObs: IObservable; readonly activeSessionFirstCheckpointRefObs: IObservable; readonly activeSessionLastCheckpointRefObs: IObservable; @@ -373,6 +375,19 @@ class ChangesViewModel extends Disposable { : undefined; }); + // Active session has git repository + this.activeSessionHasGitRepositoryObs = derived(reader => { + const sessionResource = this.activeSessionResourceObs.read(reader); + if (!sessionResource) { + return false; + } + + this.sessionsChangedSignal.read(reader); + const model = this.agentSessionsService.getSession(sessionResource); + + return model?.metadata?.repositoryPath !== undefined; + }); + // Active session first checkpoint ref this.activeSessionFirstCheckpointRefObs = derived(reader => { const sessionResource = this.activeSessionResourceObs.read(reader); @@ -834,6 +849,10 @@ export class ChangesViewPane extends ViewPane { return this.viewModel.activeSessionIsolationModeObs.read(reader); })); + this.renderDisposables.add(bindContextKey(hasGitRepositoryContextKey, this.scopedContextKeyService, reader => { + return this.viewModel.activeSessionHasGitRepositoryObs.read(reader); + })); + this.renderDisposables.add(bindContextKey(isMergeBaseBranchProtectedContextKey, this.scopedContextKeyService, reader => { const activeSession = this.sessionManagementService.activeSession.read(reader); return activeSession?.workspace.read(reader)?.repositories[0]?.baseBranchProtected === true; @@ -952,6 +971,9 @@ export class ChangesViewPane extends ViewPane { if (action.id === 'github.copilot.sessions.commitChanges') { return { showIcon: true, showLabel: true, isSecondary: false }; } + if (action.id === 'agentSession.markAsDone') { + return { showIcon: true, showLabel: true, isSecondary: false }; + } return undefined; } diff --git a/src/vs/sessions/contrib/sessions/browser/views/sessionsViewActions.ts b/src/vs/sessions/contrib/sessions/browser/views/sessionsViewActions.ts index c409f6a06d7..c688a3d4f19 100644 --- a/src/vs/sessions/contrib/sessions/browser/views/sessionsViewActions.ts +++ b/src/vs/sessions/contrib/sessions/browser/views/sessionsViewActions.ts @@ -14,7 +14,7 @@ import { IQuickInputService } from '../../../../../platform/quickinput/common/qu import { IStorageService, StorageScope, StorageTarget } from '../../../../../platform/storage/common/storage.js'; import { KeybindingsRegistry, KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js'; import { IViewsService } from '../../../../../workbench/services/views/common/viewsService.js'; -import { EditorsVisibleContext, IsAuxiliaryWindowContext } from '../../../../../workbench/common/contextkeys.js'; +import { EditorsVisibleContext, IsAuxiliaryWindowContext, IsSessionsWindowContext } from '../../../../../workbench/common/contextkeys.js'; import { IChatWidgetService } from '../../../../../workbench/contrib/chat/browser/chat.js'; import { AUX_WINDOW_GROUP } from '../../../../../workbench/services/editor/common/editorService.js'; import { SessionsCategories } from '../../../../common/categories.js'; @@ -634,6 +634,16 @@ registerAction2(class MarkSessionAsDoneAction extends Action2 { SessionsWelcomeVisibleContext.negate(), IsNewChatSessionContext.negate() ) + }, + { + id: MenuId.ChatEditingSessionChangesToolbar, + group: 'navigation', + order: 1, + when: ContextKeyExpr.and( + IsSessionsWindowContext, + ContextKeyExpr.equals('sessions.hasPullRequest', true), + ContextKeyExpr.equals('sessions.hasOpenPullRequest', false), + ) }] }); }