Skip to content

Sessions: fix stale CI checks when switching active session#304062

Merged
benibenj merged 3 commits intomainfrom
copilot/national-ape
Mar 23, 2026
Merged

Sessions: fix stale CI checks when switching active session#304062
benibenj merged 3 commits intomainfrom
copilot/national-ape

Conversation

@benibenj
Copy link
Contributor

Problem

When switching between sessions, CI checks could display stale "running" status even though the PR had already been merged. Two root causes:

  1. No immediate PR refresh on session switch — PR data was only updated on the next polling cycle (up to 30s for PR, 60s for CI), so switching sessions showed stale data.
  2. CI lookups used branch name (headRef) — After a PR is merged and the head branch is deleted, GitHub's API returns 404 for the branch-based CI check lookup, leaving stale data in the observables.

Fix

Use commit SHA for CI lookups

  • Added headSha field to IGitHubPullRequest (mapped from data.head.sha in the API response)
  • Changed CI check lookup from pr.headRef (branch name) to pr.headSha (commit SHA), which remains valid even after branch deletion

Immediate refresh on session change

  • Added GitHubActiveSessionRefreshContribution workbench contribution in the GitHub sessions contribution that watches the active session and immediately calls prModel.refresh() when the session changes
  • Tracks _lastSessionResource to only refresh when the session actually changes

CI polling lifecycle

  • Added ciModel.startPolling() / stopPolling() lifecycle management via reader.store in the CI model derived, ensuring polling is properly started for the active session and stopped when switching away

Files changed

  • src/vs/sessions/contrib/github/common/types.ts — Added headSha to IGitHubPullRequest
  • src/vs/sessions/contrib/github/browser/fetchers/githubPRFetcher.ts — Map head.sha from API response
  • src/vs/sessions/contrib/github/browser/github.contribution.ts — New GitHubActiveSessionRefreshContribution
  • src/vs/sessions/contrib/changes/browser/changesView.ts — Use headSha for CI lookups, manage CI polling lifecycle
  • src/vs/sessions/contrib/github/test/browser/githubModels.test.ts — Updated test helper

Copilot AI review requested due to automatic review settings March 23, 2026 11:55
@vs-code-engineering vs-code-engineering bot added this to the 1.114.0 milestone Mar 23, 2026
@benibenj benibenj marked this pull request as ready for review March 23, 2026 11:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes stale GitHub PR/CI status in the Sessions window when switching the active session, especially for merged PRs where the head branch may be deleted.

Changes:

  • Add headSha to the Sessions GitHub PR model and map it from the REST API response.
  • Switch CI check lookups in the Changes view from headRef (branch) to headSha (commit SHA).
  • Add a workbench contribution to immediately refresh PR data when the active session changes.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vs/sessions/contrib/github/common/types.ts Adds headSha to IGitHubPullRequest so CI can be queried by commit.
src/vs/sessions/contrib/github/browser/fetchers/githubPRFetcher.ts Maps data.head.sha into the PR model.
src/vs/sessions/contrib/github/browser/github.contribution.ts Adds a contribution that refreshes PR data immediately on session change.
src/vs/sessions/contrib/changes/browser/changesView.ts Uses headSha for CI lookups and starts/stops CI polling tied to the active session.
src/vs/sessions/contrib/github/test/browser/githubModels.test.ts Updates test helper PR objects to include headSha.

@benibenj benibenj merged commit 13d5f73 into main Mar 23, 2026
24 checks passed
@benibenj benibenj deleted the copilot/national-ape branch March 23, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants