sessions: port Copilot CLI PR detection to session open#4708
Conversation
There was a problem hiding this comment.
Pull request overview
Ports Copilot CLI pull request detection in the VS Code-node chat sessions implementation from refresh-time polling/debounced checks to a session-open triggered flow (aligned with prior work), and persists both PR URL and state when detected.
Changes:
- Remove the refresh-time/debounced PR detection path from
CopilotCLIChatSessionContentProvider. - Trigger PR detection as a fire-and-forget operation when an existing session is opened, persisting
pullRequestUrl+pullRequestState. - Add unit tests covering session-open PR detection, persistence, and the merged-state skip path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts | Moves PR detection to session-open, persists PR URL/state, updates detection helpers’ return types. |
| src/extension/chatSessions/vscode-node/test/copilotCLIChatSessions.spec.ts | Adds focused unit coverage for session-open PR detection behavior and persistence. |
| await this.copilotCLIWorktreeManagerService.setWorktreeProperties(session.sessionId, { | ||
| ...worktreeProperties, | ||
| pullRequestUrl: prUrl, | ||
| pullRequestState: prState, |
There was a problem hiding this comment.
handlePullRequestCreated can persist pullRequestState: undefined when session.createdPullRequestUrl is already present (because prState is only set in the !prUrl branch). This can unintentionally clear an existing persisted PR state and leave the session metadata inconsistent. Consider defaulting prState to 'open' (as in copilotCLIChatSessionsContribution.ts) and/or preserving the existing worktreeProperties.pullRequestState when prState is undefined (e.g. prState ?? worktreeProperties.pullRequestState).
| pullRequestState: prState, | |
| pullRequestState: prState ?? worktreeProperties.pullRequestState, |
What changed
chatSessions/vscode-node/copilotCLIChatSessions.tsto match PR sessions: stop polling for PR detection #4699pullRequestUrlandpullRequestStatewhen detection succeedsWhy
The newer node-side chat sessions file still had the older background refresh-based detection logic. This brings it in sync with the behavior already introduced elsewhere so PR metadata is discovered at session open time and state stays consistent.
Validation
npm run compilenpm run lintnpm run test:unit -- src/extension/chatSessions/vscode-node/test/copilotCLIChatSessions.spec.tsReviewer notes
copilotCLIShim.ps1the same way other terminal-related specs do so Vitest can import the module cleanlyhandlePullRequestCreatedwas also updated to preservepullRequestStatefor consistency with the session-open detection path