Skip to content

Use VS Code file pickers instead of prompting for strings#14556

Merged
adamint merged 2 commits intodotnet:release/13.2from
adamint:dev/adamint/vscode-file-pickers-12758
Mar 2, 2026
Merged

Use VS Code file pickers instead of prompting for strings#14556
adamint merged 2 commits intodotnet:release/13.2from
adamint:dev/adamint/vscode-file-pickers-12758

Conversation

@adamint
Copy link
Member

@adamint adamint commented Feb 18, 2026

Description

I've been using aspire new a lot when creating new projects for 13.2 testing. Needing to actually type out a file path each time instead of being allowed to use the file picker is an aggravating experience, especially because you need to remember that the relative directory of the path is the workspace root - and when no workspace folder is open, it's the home directory.

This adds a file picker capability to the CLI and extension that will use the native OS file picker when in extension mode and with the right CLI version. Falls back to the current behavior (prompting string)

Fixes #12758

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

@github-actions
Copy link
Contributor

github-actions bot commented Feb 18, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14556

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14556"

@adamint adamint marked this pull request as ready for review February 18, 2026 22:14
Copilot AI review requested due to automatic review settings February 18, 2026 22:14
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 PR adds native file/directory picker support when Aspire CLI is running under the VS Code extension, using a new IInteractionService.PromptForFilePathAsync API and a negotiated file-pickers.v1 capability between the CLI and extension.

Changes:

  • Added PromptForFilePathAsync to the CLI interaction abstraction and implemented it in console + extension interaction services (with capability-based fallback to string prompting).
  • Extended the CLI↔extension backchannel/RPC surface with a new promptForFilePath endpoint that uses vscode.window.showOpenDialog.
  • Updated key call sites (agent init / new / update) and test doubles to use the new file path prompt.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Aspire.Cli/Interaction/IInteractionService.cs Adds the PromptForFilePathAsync interaction API.
src/Aspire.Cli/Interaction/ExtensionInteractionService.cs Routes file path prompting to the extension when file-pickers.v1 is available; falls back to string prompting.
src/Aspire.Cli/Interaction/ConsoleInteractionService.cs Adds console-mode implementation (currently delegates to PromptForStringAsync).
src/Aspire.Cli/Backchannel/ExtensionBackchannel.cs Adds backchannel method to invoke promptForFilePath RPC.
src/Aspire.Cli/Utils/ExtensionHelper.cs Defines the file-pickers.v1 capability constant.
src/Aspire.Cli/Commands/NewCommand.cs Switches output path prompting to PromptForFilePathAsync (directory mode).
src/Aspire.Cli/Commands/AgentInitCommand.cs Switches workspace root prompting to PromptForFilePathAsync (directory mode).
src/Aspire.Cli/Projects/ProjectUpdater.cs Switches NuGet config directory prompting to PromptForFilePathAsync (directory mode).
extension/src/server/interactionService.ts Implements promptForFilePath endpoint via showOpenDialog and wires it up.
extension/src/capabilities.ts Advertises file-pickers.v1.
extension/src/loc/strings.ts / extension/package.nls.json / extension/loc/xlf/aspire-vscode.xlf Adds localized labels for the picker UI.
tests/** Updates test implementations/mocks for the new interaction method.
Comments suppressed due to low confidence (1)

extension/src/server/interactionService.ts:175

  • promptForFilePath doesn’t validate promptText the way promptForString / promptForSecretString do. For consistency (and to avoid showing a dialog with an empty title or logging confusing messages), consider adding the same if (!promptText) { ...; return null; } guard here as well.
    async promptForFilePath(promptText: string, defaultValue: string | null, directory: boolean): Promise<string | null> {
        extensionLogOutputChannel.info(`Prompting for file path: ${promptText}, directory: ${directory}, default: ${defaultValue ?? 'null'}`);

Add PromptForFilePathAsync to IInteractionService that uses native OS file
pickers when the VS Code extension supports the file-pickers.v1 capability.
Falls back to PromptForStringAsync for older extensions or console mode.

Call sites updated: AgentInitCommand, NewCommand, ProjectUpdater.

Fixes dotnet#12758
@adamint adamint force-pushed the dev/adamint/vscode-file-pickers-12758 branch from 0b6affb to b454775 Compare March 2, 2026 17:44
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adamint adamint merged commit f65c4f0 into dotnet:release/13.2 Mar 2, 2026
346 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 2, 2026
mitchdenny pushed a commit that referenced this pull request Mar 5, 2026
Add PromptForFilePathAsync to IInteractionService that uses native OS file
pickers when the VS Code extension supports the file-pickers.v1 capability.
Falls back to PromptForStringAsync for older extensions or console mode.

Call sites updated: AgentInitCommand, NewCommand, ProjectUpdater.

Fixes #12758

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 VS Code file pickers instead of prompting for strings

3 participants