Conversation
…hat do not have any commits
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts the Sessions (Copilot Chat Sessions) isolation and branch selection logic to behave safely when a workspace contains an empty Git repository (no commits / no HEAD.commit), preventing worktree isolation and branch defaults from being derived from an invalid HEAD state.
Changes:
- Disable isolation picker affordances unless the repo has a valid
HEAD.commit. - Force CLI sessions into
workspaceisolation mode when the opened Git repo has noHEAD.commit. - Avoid deriving/displaying a “current branch” (and default branch) when
HEADhas no commit.
Show a summary per file
| File | Description |
|---|---|
| src/vs/sessions/contrib/copilotChatSessions/browser/isolationPicker.ts | Gates “has git repo” UI enablement on HEAD.commit so empty repos don’t offer isolation switching. |
| src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts | Forces workspace isolation for empty repos and avoids branch/default-branch derivation when HEAD.commit is missing. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts:346
- Similar to the
derivedcase above:head?.commit ? head.name : undefinedmay not narrowheadto a definedGitBranchin TypeScript, sohead.namecan produce a strict-null-check compile error. Use an explicit guard likeif (head && head.commit)(or keep everything optional-chained) before readinghead.name.
const head = this._gitRepository?.state.get().HEAD;
const currentBranch = head?.commit ? head.name : undefined;
this.setBranch(currentBranch ?? this._defaultBranch);
- Files reviewed: 2/2 changed files
- Comments generated: 2
src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts
Show resolved
Hide resolved
src/vs/sessions/contrib/copilotChatSessions/browser/copilotChatSessionsProvider.ts
Show resolved
Hide resolved
sandy081
approved these changes
Apr 9, 2026
joshspicer
pushed a commit
that referenced
this pull request
Apr 9, 2026
…hat do not have any commits (#308752) * Sessions - isolation/branch picker should handle empty repositories that do not have any commits * Fix the tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.