sessions: decouple sessions layer from agent sessions dependencies (#306132)

* refactor: remove unused import and update session status check in SessionsManagementService

* refactor: remove public getGitHubContext method and change its visibility to private in SessionsManagementService

* refactor: remove getGitHubContextForSession method and its fallback logic in SessionsManagementService

* refactor: replace pullRequest with gitHubInfo in session data structures and related logic

* refactor: rename ISessionGitHubInfo to IGitHubInfo and update references across session data structures

* refactor: update GitHub info structure to encapsulate pull request details

* refactor: update session management to utilize gitHubInfo for pull request details

* refactor: simplify file URI resolution in CodeReviewService and remove unused method from SessionsManagementService

* refactor: remove unused getSessionRepositoryUri method and related logic from SessionsManagementService

* refactor: update session type constants to use string literals in sessionTypes and sessionsManagementService

* refactor: update pull request handling to utilize gitHubInfo in ChangesViewPane

* refactor: replace AgentSessionProviders with session type constants across sessions layer

Replace direct imports of AgentSessionProviders enum from the workbench
agent sessions layer with CopilotCLISessionType/CopilotCloudSessionType
constants from the sessions layer's own sessionTypes module.

Simplify workspaceFolderManagement to use session workspace data instead
of provider-specific branching. Remove fileTreeView component.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* refactor: remove agent sessions dependencies from changes and mode picker

- changesTitleBarWidget: use ISessionsManagementService instead of
  IAgentSessionsService for session lookup and change events
- changesView: use sessionManagementService.onDidChangeSessions signal
- modePicker: replace AgentSessionProviders with CopilotCLISessionType

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: add missing gitHubInfo to mock session in codeReviewService tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix compilation

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Sandeep Somavarapu
2026-03-29 20:43:12 +02:00
committed by GitHub
parent 1bff585f1a
commit fcecb74ef9
22 changed files with 170 additions and 893 deletions

View File

@@ -295,7 +295,7 @@ class ChangesViewModel extends Disposable {
// Active session changes
this.sessionsChangedSignal = observableSignalFromEvent(this,
this.agentSessionsService.model.onDidChangeSessions);
this.sessionManagementService.onDidChangeSessions);
// Active session resource
this.activeSessionResourceObs = derivedOpts({ equalsFn: isEqual }, reader => {
@@ -841,17 +841,17 @@ export class ChangesViewPane extends ViewPane {
this.renderDisposables.add(bindContextKey(hasPullRequestContextKey, this.scopedContextKeyService, reader => {
const activeSession = this.sessionManagementService.activeSession.read(reader);
const activeSessionPullRequest = activeSession?.pullRequest.read(reader);
return activeSessionPullRequest?.uri !== undefined;
const gitHubInfo = activeSession?.gitHubInfo.read(reader);
return gitHubInfo?.pullRequest?.uri !== undefined;
}));
this.renderDisposables.add(bindContextKey(hasOpenPullRequestContextKey, this.scopedContextKeyService, reader => {
const activeSession = this.sessionManagementService.activeSession.read(reader);
const activeSessionPullRequest = activeSession?.pullRequest.read(reader);
if (activeSessionPullRequest?.uri === undefined) {
const gitHubInfo = activeSession?.gitHubInfo.read(reader);
if (gitHubInfo?.pullRequest?.uri === undefined) {
return false;
}
const iconId = activeSessionPullRequest.icon?.id;
const iconId = gitHubInfo.pullRequest.icon?.id;
return iconId !== undefined &&
(iconId === Codicon.gitPullRequestDraft.id ||
iconId === Codicon.gitPullRequest.id);
@@ -1127,11 +1127,11 @@ export class ChangesViewPane extends ViewPane {
if (!session) {
return undefined;
}
const context = this.sessionManagementService.getGitHubContextForSession(session.resource);
if (!context || context.prNumber === undefined) {
const gitHubInfo = session.gitHubInfo.read(reader);
if (!gitHubInfo?.pullRequest) {
return undefined;
}
const prModel = this.gitHubService.getPullRequest(context.owner, context.repo, context.prNumber);
const prModel = this.gitHubService.getPullRequest(gitHubInfo.owner, gitHubInfo.repo, gitHubInfo.pullRequest.number);
const pr = prModel.pullRequest.read(reader);
if (!pr) {
return undefined;
@@ -1139,7 +1139,7 @@ export class ChangesViewPane extends ViewPane {
// Use the PR's headSha (commit SHA) rather than the branch
// name so CI checks can still be fetched after branch deletion
// (e.g. after the PR is merged).
const ciModel = this.gitHubService.getPullRequestCI(context.owner, context.repo, pr.headSha);
const ciModel = this.gitHubService.getPullRequestCI(gitHubInfo.owner, gitHubInfo.repo, pr.headSha);
ciModel.refresh();
ciModel.startPolling();
reader.store.add({ dispose: () => ciModel.stopPolling() });