Skip to content

Conversation

@DonJayamanne
Copy link
Collaborator

@DonJayamanne DonJayamanne commented Jan 29, 2026

@DonJayamanne DonJayamanne self-assigned this Jan 29, 2026
@DonJayamanne DonJayamanne marked this pull request as ready for review January 29, 2026 17:05
Copilot AI review requested due to automatic review settings January 29, 2026 17:05
@DonJayamanne DonJayamanne changed the title Fallback to workspace folder if worktree creation fails Fallback to folder if worktree creation fails in bg sessions Jan 29, 2026
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 29, 2026
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

This pull request aims to fix the fallback behavior when worktree creation fails, ensuring that the system properly falls back to using the workspace folder without worktree isolation.

Changes:

  • Modified the initialization of workingDirectory to use sessionWorkspaceFolder as a fallback
  • Updated isWorkspaceFolderWithoutRepo flag to true when no repository is selected
  • Updated isWorkspaceFolderWithoutRepo flag to true when worktree creation fails
Comments suppressed due to low confidence (2)

src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts:1115

  • The ternary condition on selectedRepository is unnecessary because selectedRepository is always undefined at this point (it's declared as undefined on line 1114). This line will always evaluate to sessionWorkspaceFolder. Consider simplifying to: const workingDirectory = sessionWorkspaceFolder;
			const workingDirectory = selectedRepository ? this.workspaceService.getWorkspaceFolder(selectedRepository) : sessionWorkspaceFolder;

src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts:1148

  • When worktree creation fails at line 1148, workingDirectory may be undefined even though selectedRepository is defined. The workingDirectory variable is set at line 1115 before selectedRepository is potentially assigned (at lines 1120 or 1131). When falling back from a failed worktree creation, consider using this.workspaceService.getWorkspaceFolder(selectedRepository) to get the proper workspace folder for the repository, rather than relying on the stale workingDirectory value that was calculated before selectedRepository was known.
				return { workingDirectory, worktreeProperties: undefined, isWorkspaceFolderWithoutRepo: true, cancelled: false };

@DonJayamanne DonJayamanne added this pull request to the merge queue Jan 29, 2026
Merged via the queue into main with commit ab9aa0d Jan 29, 2026
19 checks passed
@DonJayamanne DonJayamanne deleted the don/tender-skunk branch January 29, 2026 17:41
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.

Background agents - Git repos with no commits don't appear to work

3 participants