VS Code: add resource context-menu Open terminal action#18260
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18260Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18260" |
There was a problem hiding this comment.
Pull request overview
This PR adds an "Open terminal" context-menu action on terminal-enabled resources in the Aspire VS Code extension tree view. It wires aspire terminal attach <resource> through the existing safe terminal command pipeline, opening the terminal in editor/document style via a new terminalTarget: 'editor' option on SendAspireCommandOptions. This addresses issue #18084 to make terminal attach discoverable directly from the resource tree.
Changes:
- Introduces
aspire-vscode.openResourceTerminalcommand with context-menu visibility gated on theterminal.enabledresource property, and supports--replicawhenterminal.replicaIndexmetadata is present. - Refactors
AspireTerminalProviderto extract a sharedcreateTerminalhelper and adds an editor-targeted terminal creation path (createAspireEditorTerminal), keeping default shared-terminal behavior for other commands. - Adds comprehensive unit and E2E tests covering the new command flow, context value generation, replica argument handling, and hostile-path safety.
Show a summary per file
| File | Description |
|---|---|
extension/src/views/AspireAppHostTreeProvider.ts |
Adds openResourceTerminal method, isTerminalEnabled/getTerminalReplicaIndex helpers, and wires canOpenTerminal into context values |
extension/src/utils/AspireTerminalProvider.ts |
Refactors terminal creation into createTerminal, adds createAspireEditorTerminal and terminalTarget option |
extension/src/extension.ts |
Registers openResourceTerminal command and adds E2E control command wiring |
extension/src/types/extensionApi.ts |
Adds openResourceTerminal to the E2E control command union type |
extension/package.json |
Declares the command, hides it from the palette, adds context-menu entry with when clause |
extension/package.nls.json |
Adds localized "Open terminal" string |
extension/loc/xlf/aspire-vscode.xlf |
Adds XLF translation source entry |
extension/src/test/appHostTreeView.test.ts |
Adds tests for context value, command arguments, replica index, and hostile path safety |
extension/src/test/aspireTerminalProvider.test.ts |
Adds test verifying editor terminal creation when terminalTarget is 'editor' |
extension/src/test/packageManifest.test.ts |
Adds assertion for the new context-menu when clause |
extension/src/test-e2e/treeActions.e2e.test.ts |
Adds E2E test for openResourceTerminal command suppression flow |
extension/src/test-e2e/packageSurface.e2e.test.ts |
Adds new command to surface expectations |
Copilot's findings
- Files reviewed: 12/12 changed files
- Comments generated: 1
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
- Log resource context values when terminal.enabled property is detected - Helps diagnose why terminal option may not be appearing in tree view Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
The test was failing because it didn't stub createEnvironment(), which requires the RPC server to be initialized. Fix by adding the stub like other tests in this suite do. Fixes test failure in extension_tests_win CI job. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The VS Code extension gates its "Open terminal" action on the `terminal.enabled` resource property, but that property (along with `terminal.replicaIndex`, `terminal.replicaCount`, and the sensitive `terminal.consumerUdsPath`) was only stamped on the dashboard gRPC path. `aspire describe` and the extension read the auxiliary backchannel, which surfaced the raw snapshot without terminal metadata, so the action never appeared. Extract the stamping logic into a shared `TerminalResourceSnapshotProperties` helper and apply it on both the dashboard path (`DashboardServiceData`) and the backchannel path (`AuxiliaryBackchannelRpcTarget`). The backchannel already redacts sensitive values to null, so the consumer UDS path is never leaked to the CLI; the CLI resolves the real socket via the terminal info RPC. Also removes the temporary debug logging from the extension tree provider. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Make createAspireEditorTerminal private (no external callers). - Remove dead initial assignment of terminalBefore in the tree-actions E2E test; declare it without an unused initializer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
The refactor that extracted createTerminal() left an unused `const terminalName = aspireTerminalName;` in getAspireTerminal(); createTerminal() now references aspireTerminalName directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Register an e2e-terminal resource via .WithTerminal() in the extension E2E AppHost fixture so a real Aspire CLI surfaces terminal.enabled and terminal.replicaIndex over the backchannel. Extend the tree action E2E test to open that resource's terminal (with execution suppressed) and assert the emitted 'terminal attach e2e-terminal' subcommand includes --replica, proving the terminal metadata flows end-to-end through a real CLI process while attach stays suppressed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Where's the PR testing report? |
|
Where's the screenshots and/or screen recording of using the feature. |
Resolved conflicts in two files caused by main's refactor that extracted the E2E control-command switch out of extension.ts into extension/src/testing/e2eStateFileBridge.ts: - extension/src/extension.ts: took main's slimmed file and kept this PR's openResourceTerminal command registration and disposable. - extension/src/testing/e2eStateFileBridge.ts: re-applied this PR's 'openResourceTerminal' case in the relocated executeE2eControlCommand switch. - extension/src/test-e2e/treeActions.e2e.test.ts: reconciled main's new try/finally suppression scoping with this PR's open-terminal assertions for e2e-worker (no --replica) and e2e-terminal (with --replica), declaring terminalBefore once. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
The open-terminal assertion hardcoded 'e2e-terminal', but the E2E harness
assigns resources a random suffix at runtime (e.g. e2e-terminal-awgvthgy), so
the emitted subcommand was "terminal attach 'e2e-terminal-awgvthgy' --replica
'0'" and the predicate's includes("terminal attach 'e2e-terminal'") never
matched, timing out on Windows and Linux. Resolve the real runtime name via
findResource(state, 'e2e-terminal').name (mirroring workerResourceName) and use
it for both the command invocation and the assertion.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests selector (audit mode)The full test matrix and all jobs still run in audit mode. The tests and jobs below are what selective CI would run under enforcement. Test projects (45 / 97)
Jobs (5)
Selection computed for commit |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
video of this working. thought i had attached it earlier Screen.Recording.2026-06-21.at.8.03.19.pm.mov |
|
Issue created: #1282
|
|
See the workflow run for details: https://github.com/microsoft/aspire/actions/runs/28000988919 Added documentation for the new Open terminal context-menu action in the Aspire VS Code extension, introduced in this PR for resources configured with
|
Description
This adds a dedicated resource action in the Aspire VS Code extension so terminal-enabled resources can be attached directly from the tree context menu. The goal is to make
aspire terminal attachdiscoverable and fast from the existing resource workflow, while opening the terminal in editor/document style.The change introduces
aspire-vscode.openResourceTerminal, shows it only for resources that exposeterminal.enabled, and routes execution through the existing safe terminal command pipeline. The handler runsaspire terminal attach <resource>and adds--apphostwhen available plus--replicawhenterminal.replicaIndexis present. To support the requested UX, terminal provider support was added for editor-targeted terminal creation without changing default shared-terminal behavior for other commands.Fixes #18084
Checklist
<remarks />and<code />elements on your triple slash comments?