Skip to content

Use VS Code's worktree InputBox UI when checking out a PR in a worktree#8721

Draft
alexr00 with Copilot wants to merge 4 commits into
mainfrom
copilot/use-custom-ui-for-checkout
Draft

Use VS Code's worktree InputBox UI when checking out a PR in a worktree#8721
alexr00 with Copilot wants to merge 4 commits into
mainfrom
copilot/use-custom-ui-for-checkout

Conversation

Copilot AI commented May 5, 2026

Copy link
Copy Markdown
Contributor

"Checkout in Worktree" opened the OS save dialog, which is awkward (especially on Windows) and inconsistent with VS Code's built-in Git: Create Worktree... flow that uses an inline InputBox.

Changes — src/github/worktree.ts

  • Replace showSaveDialog with createInputBox in checkoutPRInWorktree, mirroring the built-in worktree UI: pre-filled editable path, prompt "Please provide a worktree path", ignoreFocusOut, and an inline folder-picker button (QuickInputButtonLocation.Inline, folder codicon) that opens showOpenDialog to pick a parent directory and re-joins the worktree name.
  • Default path now follows the built-in convention <parentDir>/<repoBasename>.worktrees/pr-<number> (was <parentDir>/pr-<number>), matching what users see from Git: Create Worktree....
  • Pre-select the trailing pr-<number> segment via valueSelection for quick rename.
  • Warn on collision with an existing worktree using repository.state.worktrees and InputBoxValidationSeverity.Warning (non-blocking, matching built-in).

Public signature of checkoutPRInWorktree and the subsequent "open in current/new window" prompt are unchanged.

const worktreePath = await promptForWorktreePath(repositoryToUse, worktreeName, defaultWorktreePath);
if (!worktreePath) {
    return; // User cancelled
}
const worktreeUri = vscode.Uri.file(worktreePath);

Copilot AI changed the title [WIP] Update checkout UI for worktree to match built-in feature Use VS Code's worktree InputBox UI when checking out a PR in a worktree May 5, 2026
Copilot finished work on behalf of alexr00 May 5, 2026 08:48
Copilot AI requested a review from alexr00 May 5, 2026 08:48

@alexr00 alexr00 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update branch and resolve conflicts.

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot update branch and resolve conflicts.

Merged main and resolved the conflict in src/github/worktree.ts in b6ef67b. Both sides used the same default path convention; kept the worktreeName variable so the prompt helper can pre-select the trailing pr-<number> segment.

Copilot AI requested a review from alexr00 July 15, 2026 14:55

@alexr00 alexr00 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This is not what I was looking for. I was thinking there would be some "create worktree" command that could be run instead of showing all of our own input boxes.

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot This is not what I was looking for. I was thinking there would be some "create worktree" command that could be run instead of showing all of our own input boxes.

Could you clarify which command you have in mind? The only worktree command exposed by VS Code's built-in Git extension is git.createWorktree, and its signature is (repository?: Repository) — it runs its own branch picker followed by its own path input box and doesn't accept a pre-selected branch/commitish (source). Invoking it would force the user to pick the PR branch manually from the list, losing the "checkout this PR in a worktree" entry point.

A few options I can see:

  1. Invoke git.createWorktree after we fetch the PR ref, and accept that the user still has to pick the branch from the built-in quick pick.
  2. Keep our own input box (this PR), but drop the custom widgets and just reuse the built-in path-picker logic via the Repository.createWorktree API we already call.
  3. Request a new API on the Git extension side (e.g. git.createWorktree accepting { commitish, branch }) so we can hand off the whole UI to it.

Which of these matches what you had in mind, or is it something else?

Copilot AI requested a review from alexr00 July 16, 2026 10:03

@alexr00 alexr00 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot

createWorktree?(options?: { path?: string; commitish?: string; branch?: string }): Promise<string>;
deleteWorktree?(path: string, options?: { force?: boolean }): Promise<void>;
??

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

createWorktree?(options?: { path?: string; commitish?: string; branch?: string }): Promise<string>;
deleteWorktree?(path: string, options?: { force?: boolean }): Promise<void>;
??

Got it — the path parameter is optional and createWorktree returns the resolved path. Removed all of our custom UI in ee8fb42 and now just call repository.createWorktree({ commitish, branch }), using the returned path for the follow-up "open in current/new window" prompt. The Git extension picks the location (respecting the user's saved worktree root) and handles path collisions itself.

Copilot AI requested a review from alexr00 July 16, 2026 10:29
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.

Use same UI for checkout in worktree as built-in VS Code worktree feature

2 participants