Skip to content

Sessions - isolation/branch picker should handle empty repositories that do not have any commits#308752

Merged
lszomoru merged 2 commits intomainfrom
lszomoru/cooperative-orangutan
Apr 9, 2026
Merged

Sessions - isolation/branch picker should handle empty repositories that do not have any commits#308752
lszomoru merged 2 commits intomainfrom
lszomoru/cooperative-orangutan

Conversation

@lszomoru
Copy link
Copy Markdown
Member

@lszomoru lszomoru commented Apr 9, 2026

No description provided.

@lszomoru lszomoru requested a review from sandy081 April 9, 2026 10:56
@lszomoru lszomoru enabled auto-merge (squash) April 9, 2026 10:56
Copilot AI review requested due to automatic review settings April 9, 2026 10:56
@lszomoru lszomoru self-assigned this Apr 9, 2026
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

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 workspace isolation mode when the opened Git repo has no HEAD.commit.
  • Avoid deriving/displaying a “current branch” (and default branch) when HEAD has 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 derived case above: head?.commit ? head.name : undefined may not narrow head to a defined GitBranch in TypeScript, so head.name can produce a strict-null-check compile error. Use an explicit guard like if (head && head.commit) (or keep everything optional-chained) before reading head.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

@lszomoru lszomoru merged commit 7ba8bdd into main Apr 9, 2026
23 checks passed
@lszomoru lszomoru deleted the lszomoru/cooperative-orangutan branch April 9, 2026 12:31
@vs-code-engineering vs-code-engineering bot added this to the 1.116.0 milestone 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
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