Skip to content

Sessions: derive PR icon from live GitHubPullRequestModel#308304

Merged
osortega merged 1 commit intomainfrom
copilot/salty-felidae
Apr 7, 2026
Merged

Sessions: derive PR icon from live GitHubPullRequestModel#308304
osortega merged 1 commit intomainfrom
copilot/salty-felidae

Conversation

@osortega
Copy link
Copy Markdown
Contributor

@osortega osortega commented Apr 7, 2026

Summary

Fixes: #308242

Migrates PR state detection from static extension metadata to a reactive core feature. Session card PR icons now update automatically when the GitHubPullRequestModel polling detects state changes (e.g. merged, closed, draft) — no extension round-trip needed.

Changes

src/vs/sessions/contrib/github/common/types.ts

  • Added computePullRequestIcon(state, isDraft?) — single source of truth for PR state → icon mapping
  • Handles both GitHubPullRequestState enum values and the string states the extension writes to metadata (including 'draft')

src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts

  • AgentSessionAdapter.gitHubInfo is now a derived() observable that combines:
    • Base info from extension metadata (owner, repo, prNumber, URL) — same as before
    • Live PR model from IGitHubService — reads prModel.pullRequest reactively
  • Falls back to metadata-based icon if the PR model hasn't loaded yet
  • Replaced inline icon switch in _extractPullRequestStateIcon with a call to the shared computePullRequestIcon helper
  • Injected IGitHubService into CopilotChatSessionsProvider and passed to adapters

Architecture

Extension writes metadata (pullRequestUrl, pullRequestState)
    ↓ (initial seed — owner, repo, prNumber, URL)
AgentSessionAdapter._extractGitHubInfo(session)
    ↓
derived(reader => {
    base = _baseGitHubInfo.read(reader)     // from metadata
    livePR = prModel.pullRequest.read(reader) // reactive, from polling
    icon = computePullRequestIcon(livePR.state, livePR.isDraft)
    return { ...base, pullRequest: { ...base.pullRequest, icon } }
})
    ↓
ISession.gitHubInfo (observable, auto-updates)
    ↓
sessionsList.ts autorun → re-renders icon ✓

Notes

  • No changes to polling behavior — existing GitHubActiveSessionRefreshContribution triggers refresh on session open, and existing polling handles the rest
  • Extension still writes metadata for backward compat and initial state before the model loads
  • PR model is cached by IGitHubService (keyed by owner/repo/prNumber), so multiple sessions for the same PR share a model

Copilot AI review requested due to automatic review settings April 7, 2026 18:58
@osortega osortega force-pushed the copilot/salty-felidae branch from f191a5b to adbcb9e Compare April 7, 2026 19:01
Copy link
Copy Markdown
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

This PR updates Sessions’ pull request status icon rendering to use the live, reactive GitHubPullRequestModel (polled by the core sessions GitHub feature) instead of relying solely on extension-written, static session metadata—so PR icons can update automatically as PR state changes.

Changes:

  • Added a shared computePullRequestIcon(state, isDraft?) helper to map PR state/draft → themed codicon.
  • Made AgentSessionAdapter.gitHubInfo reactive via derived(), combining metadata seed info with live IGitHubService PR model state.
  • Wired IGitHubService into CopilotChatSessionsProvider to supply adapters with the live PR model.
Show a summary per file
File Description
src/vs/sessions/contrib/github/common/types.ts Introduces shared PR state → icon mapping helper used by sessions UI.
src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts Switches PR icon derivation to a reactive observable that reads from GitHubPullRequestModel when available.
extensions/copilot/package-lock.json Lockfile metadata updates (adds dev: true flags on some entries).

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread src/vs/sessions/contrib/github/common/types.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Screenshot Changes

Base: 56fd4d60 Current: 08edd9b2

Changed (2)

chat/chatQuestionCarousel/SingleTextQuestion/Light
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Light
Before After
before after

Make AgentSessionAdapter.gitHubInfo a derived observable that reads
from the live GitHubPullRequestModel when available, falling back to
the extension-provided metadata icon. This lets session card PR icons
update reactively when polling detects state changes (e.g. merged,
closed) without an extension round-trip.

- Add computePullRequestIcon() to github/common/types.ts as the
  single source of truth for PR state → icon mapping
- Replace inline icon switch in _extractPullRequestStateIcon with
  a call to the shared helper
- Inject IGitHubService into CopilotChatSessionsProvider and pass
  it to AgentSessionAdapter for PR model access

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@osortega osortega force-pushed the copilot/salty-felidae branch from 164df36 to da84a7a Compare April 7, 2026 21:29
@osortega osortega marked this pull request as ready for review April 7, 2026 21:32
@osortega osortega enabled auto-merge (squash) April 7, 2026 21:33
@osortega osortega merged commit 7f963d3 into main Apr 7, 2026
23 checks passed
@osortega osortega deleted the copilot/salty-felidae branch April 7, 2026 21:53
@vs-code-engineering vs-code-engineering bot added this to the 1.116.0 milestone Apr 7, 2026
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.

Agents -- PR states don't update when clicking into sessions

3 participants