Sessions - add new context keys for ahead/behind (#303520)

This commit is contained in:
Ladislau Szomoru
2026-03-20 15:32:08 +00:00
committed by GitHub
parent c8fda5b0f6
commit 3a3a936a19

View File

@@ -91,6 +91,8 @@ const enum ChangesVersionMode {
const changesVersionModeContextKey = new RawContextKey<ChangesVersionMode>('sessions.changesVersionMode', ChangesVersionMode.AllChanges);
const isMergeBaseBranchProtectedContextKey = new RawContextKey<boolean>('sessions.isMergeBaseBranchProtected', false);
const hasOpenPullRequestContextKey = new RawContextKey<boolean>('sessions.hasOpenPullRequest', false);
const hasIncomingChangesContextKey = new RawContextKey<boolean>('sessions.hasIncomingChanges', false);
const hasOutgoingChangesContextKey = new RawContextKey<boolean>('sessions.hasOutgoingChanges', false);
// --- List Item
@@ -646,6 +648,18 @@ export class ChangesViewPane extends ViewPane {
return metadata?.pullRequestUrl !== undefined;
}));
this.renderDisposables.add(bindContextKey(hasIncomingChangesContextKey, this.scopedContextKeyService, reader => {
const repository = this.viewModel.activeSessionRepositoryObs.read(reader);
const repositoryState = repository?.state.read(reader);
return (repositoryState?.HEAD?.behind ?? 0) > 0;
}));
this.renderDisposables.add(bindContextKey(hasOutgoingChangesContextKey, this.scopedContextKeyService, reader => {
const repository = this.viewModel.activeSessionRepositoryObs.read(reader);
const repositoryState = repository?.state.read(reader);
return (repositoryState?.HEAD?.ahead ?? 0) > 0;
}));
const scopedServiceCollection = new ServiceCollection([IContextKeyService, this.scopedContextKeyService]);
const scopedInstantiationService = this.instantiationService.createChild(scopedServiceCollection);
this.renderDisposables.add(scopedInstantiationService);