Skip to content

Fix VS Code resource command file inputs - #19895

Open
Copilot wants to merge 1 commit into
mainfrom
copilot/fix-vscode-codelens-file-input
Open

Fix VS Code resource command file inputs#19895
Copilot wants to merge 1 commit into
mainfrom
copilot/fix-vscode-codelens-file-input

Conversation

Copilot AI commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

VS Code resource commands invoked from the tree or CodeLens silently canceled when a command declared an InputType.File argument. The extension did not recognize file inputs in the resource-command contract, so commands such as "Import bingo squares" never displayed a picker.

This change adds end-to-end support for those arguments:

  • Opens VS Code's native file picker and honors multiple-file and extension-filter metadata.
  • Carries file-specific metadata through the AppHost snapshot and CLI JSON contracts.
  • Copies selected files into AppHost-managed temporary storage with count, type, and size validation before exposing them through InteractionInput.GetFiles().
  • Refreshes managed copies after dynamic-loading and validation callbacks so those callbacks can safely inspect and dispose their file collections.
  • Advertises the local-path transport capability in command metadata. Older CLI/AppHost combinations show an upgrade message rather than invoking the command with missing files.

User-facing usage

Given a resource command argument such as:

new InteractionInput
{
    Name = "squares",
    InputType = InputType.File,
    Required = true,
    FileFilter = ".json",
    MaxFileSize = 1024
}

clicking the command's CodeLens or tree action now opens the VS Code file picker. The command callback receives a managed file:

using var files = context.Arguments["squares"].GetFiles();
var selectedFile = files.Single();

Screenshots / Recordings

This PR includes UI changes. Please add screenshots or screen recordings so reviewers can evaluate the visual changes without running locally.

  • For before/after comparisons, place them side-by-side or label them clearly.
  • For interactive changes (animations, transitions, new flows), prefer a short screen recording (GIF or video).
  • If you cannot capture visuals now, note what scenario to test and mark this section as TODO.

TODO: Capture the "Import bingo squares" CodeLens opening VS Code's native file picker. The extension build could not be bootstrapped in this environment because the configured Corepack package download returned HTTP 403.

Validation

  • Added VS Code extension unit coverage for single-file, multiple-file, filter, and compatibility-gating behavior.
  • Added AppHost coverage for snapshot metadata and managed file materialization across dynamic loading, validation, and command execution.
  • Added CLI snapshot-mapping coverage for file metadata and the compatibility marker.
  • git diff --check and localization JSON/source checks pass.
  • Targeted test execution was attempted, but the configured Corepack and Microsoft.DotNet.Arcade.Sdk package downloads returned HTTP 403.

Security considerations

The extension and AppHost exchange local file paths because both execute in the same local or remote workspace trust boundary. The AppHost normalizes each path, verifies that the file exists, enforces the configured file-count, extension, and size limits, and performs a bounded copy into repository-managed temporary storage. The copy is size-checked while streaming to prevent a file from growing beyond the limit after the initial metadata check. A security review has not yet been performed.

Fixes # (issue)

Created from a Microsoft Teams conversation.

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
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

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.

2 participants