Sessions - refactor updating a pull request (#303558)

* Sessions - refactor updating a pull request

* Apply suggestion from @Copilot

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:
Ladislau Szomoru
2026-03-20 17:57:00 +00:00
committed by GitHub
parent 4818a0e094
commit bc389a0b22
3 changed files with 32 additions and 4 deletions

View File

@@ -654,10 +654,15 @@ export class ChangesViewPane extends ViewPane {
return (repositoryState?.HEAD?.behind ?? 0) > 0;
}));
this.renderDisposables.add(bindContextKey(hasOutgoingChangesContextKey, this.scopedContextKeyService, reader => {
const outgoingChangesObs = derived(reader => {
const repository = this.viewModel.activeSessionRepositoryObs.read(reader);
const repositoryState = repository?.state.read(reader);
return (repositoryState?.HEAD?.ahead ?? 0) > 0;
return repositoryState?.HEAD?.ahead ?? 0;
});
this.renderDisposables.add(bindContextKey(hasOutgoingChangesContextKey, this.scopedContextKeyService, reader => {
const outgoingChanges = outgoingChangesObs.read(reader);
return outgoingChanges > 0;
}));
const scopedServiceCollection = new ServiceCollection([IContextKeyService, this.scopedContextKeyService]);
@@ -666,6 +671,7 @@ export class ChangesViewPane extends ViewPane {
this.renderDisposables.add(autorun(reader => {
const { added, removed } = topLevelStats.read(reader);
const outgoingChanges = outgoingChangesObs.read(reader);
const sessionResource = this.viewModel.activeSessionResourceObs.read(reader);
// Read code review state to update the button label dynamically
@@ -726,6 +732,13 @@ export class ChangesViewPane extends ViewPane {
if (action.id === 'github.copilot.chat.createPullRequestCopilotCLIAgentSession.createPR') {
return { showIcon: true, showLabel: true, isSecondary: false };
}
if (action.id === 'github.copilot.chat.createPullRequestCopilotCLIAgentSession.updatePR') {
const customLabel = outgoingChanges > 0
? localize('updatePRWithOutgoingChanges', 'Update Pull Request {0}↑', outgoingChanges)
: localize('updatePR', 'Update Pull Request');
return { customLabel, showIcon: true, showLabel: true, isSecondary: false };
}
if (action.id === 'github.copilot.chat.openPullRequestCopilotCLIAgentSession.openPR') {
return { showIcon: true, showLabel: false, isSecondary: true };
}