Repository navigation
Show configured templates in the initial aspire new picker - #21754
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21754Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21754" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Direct selection of configured templates from the initial picker lacks terminal end-to-end coverage, leaving keyboard selection and generation unverified outside the search flow.
1 open issue
What changed in this PR
This PR makes configured Git and directory templates discoverable in the initial interactive aspire new picker, alongside built-in templates.
Changes:
- Adds source-qualified configured entries while preserving built-in ordering and exact template identity.
- Reuses existing discovery and consent handling, with tests for collisions, source failures, and no-fetch boundaries.
- Documents the initial-picker behavior and discovery exclusions.
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/Commands/NewCommandLocalTemplateTests.SourceListGit.cs | Tests inherited-source consent, cached decline, and global sources. |
| tests/Aspire.Cli.Tests/Commands/NewCommandLocalTemplateTests.InitConfig.cs | Updates configuration-source tests for direct picker selection. |
| tests/Aspire.Cli.Tests/Commands/NewCommandLocalTemplateTests.ConfiguredSources.cs | Tests directory-template selection, duplicate labels, and built-in-only exclusions. |
| tests/Aspire.Cli.Tests/Commands/NewCommandLocalTemplateTests.ConfiguredGitSources.cs | Covers direct Git-template selection, collisions, failures, and no-fetch boundaries. |
| tests/Aspire.Cli.Tests/Commands/NewCommandLocalTemplateTests.ConfiguredGitSourceObjects.cs | Updates scoped-source and Git-ref tests for initial selection. |
| src/Aspire.Cli/Commands/NewCommand.cs | Adds configured templates to the initial picker and shares unique-label handling. |
| docs/specs/git-templating.md | Documents picker discovery, source identity, warnings, and exclusions. |
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🔵 Needs a closer look
Hex1b end-to-end coverage is missing for selecting a configured template directly from the initial grouped picker and verifying source-specific generated output.
1 file not reviewed
src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs: Generated file
Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
The existing E2E scenario still waits for removed search prompts and will time out; it needs updating to use the grouped picker and exercise description-only type-to-search.
2 open issues
1 file not reviewed
src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs: Generated file
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🔵 Needs a closer look
The existing configured-source E2E test still drives the removed search/retry/back flow, causing it to time out before template selection; it must be updated for the grouped picker while retaining generated-output assertions.
2 open issues
1 file not reviewed
src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs: Generated file
Review effort: Balanced
|
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. |
There was a problem hiding this comment.
🔵 Needs a closer look
The configured-template E2E test still waits for removed search prompts, causing a deterministic timeout, and must be updated to search and select within the unified picker.
2 open issues
1 file not reviewed
src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs: Generated file
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The configured-template E2E scenario still waits for removed submenu prompts and will time out before generation, so it needs updating to exercise the new picker and retain generated-output assertions.
2 open issues
1 file not reviewed
src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs: Generated file
Review effort: Balanced
|
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. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the configured-template picker changes.
No open issues 🎉
2 resolved since last review
1 file not reviewed
src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs: Generated file
Review effort: Balanced
Share invocation-scoped warning state across init configuration, templates, and other source consumers while retaining consent prompts and warnings in subsequent commands. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Tests selector3 / 101 PR test projects · 4 PR jobs, from 58 changed files. Selected PR test projects (3 / 101)
Selected PR jobs (4)
How these were chosen — grouped by what changed📦 affected project 🔧 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
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. |
|
Pull request created: #2057
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#2057 targeting Updated Note This draft PR needs human review before merging. |
## Description Configured template sources currently appear in the `aspire new` picker under a friendly name or alias alone, making it difficult to tell which repository and ref will supply a template. Show that provenance directly in each source heading while retaining the friendly name. Git headings now use `Name (repository @ ref)`. An omitted ref is explicitly displayed as `default branch`, rather than guessing a branch name or displaying the acquired commit. Directory headings use `Name (path)` instead. Built-in grouping, collision-safe source IDs and selections, trust/consent behavior, acquisition semantics, and the extension's flat-choice protocol remain unchanged. Existing literal-text escaping and terminal-width cropping apply to the expanded headings. Follow-up to #21754. No new dependencies. ### User-facing usage Run `aspire new` with configured template sources. Example headings: ```text Company templates (https://github.com/example/templates @ release/templates) company (https://github.com/example/templates @ default branch) Company templates (/work/templates) ``` ### Screenshots / Recordings > **This PR includes CLI prompt changes.** TODO: add a screenshot or recording of `aspire new` with Git and directory sources, including a narrow terminal. > > Rendered console snapshots cover full headings at 120 columns and literal-text escaping/cropping at 40 columns. No screenshot or recording is attached. <!-- Add screenshots/recordings here --> ### Validation - `./restore.sh` — passed. - `dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.NewCommandLocalTemplateTests' --filter-class '*.ConsoleInteractionServiceTests' --filter-class '*.ExtensionInteractionServiceTests' --filter-class '*.TemplateSourceConfigurationTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'` — passed, 750 tests. - `git diff --check` — passed. Coverage includes configured/default refs, commit and fully qualified branch refs, friendly names and alias fallback, directory sources, inherited sources, duplicate names, credential-bearing source rejection, markup-containing locations, and width-aware rendering. Git acquisition uses the existing test runner, not live repositories. Quarantined/outerloop tests and the full repository suite were not run. Fixes # (issue) ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] 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 - [x] 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 - [x] No --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
## Description Configured template sources currently appear in the `aspire new` picker under a friendly name or alias alone, making it difficult to tell which repository and ref will supply a template. Show that provenance directly in each source heading while retaining the friendly name. Git headings now use `Name (repository @ ref)`. An omitted ref is explicitly displayed as `default branch`, rather than guessing a branch name or displaying the acquired commit. Directory headings use `Name (path)` instead. Built-in grouping, collision-safe source IDs and selections, trust/consent behavior, acquisition semantics, and the extension's flat-choice protocol remain unchanged. Existing literal-text escaping and terminal-width cropping apply to the expanded headings. Follow-up to #21754. No new dependencies. ### User-facing usage Run `aspire new` with configured template sources. Example headings: ```text Company templates (https://github.com/example/templates @ release/templates) company (https://github.com/example/templates @ default branch) Company templates (/work/templates) ``` ### Screenshots / Recordings > **This PR includes CLI prompt changes.** TODO: add a screenshot or recording of `aspire new` with Git and directory sources, including a narrow terminal. > > Rendered console snapshots cover full headings at 120 columns and literal-text escaping/cropping at 40 columns. No screenshot or recording is attached. <!-- Add screenshots/recordings here --> ### Validation - `./restore.sh` — passed. - `dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.NewCommandLocalTemplateTests' --filter-class '*.ConsoleInteractionServiceTests' --filter-class '*.ExtensionInteractionServiceTests' --filter-class '*.TemplateSourceConfigurationTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'` — passed, 750 tests. - `git diff --check` — passed. Coverage includes configured/default refs, commit and fully qualified branch refs, friendly names and alias fallback, directory sources, inherited sources, duplicate names, credential-bearing source rejection, markup-containing locations, and width-aware rendering. Git acquisition uses the existing test runner, not live repositories. Quarantined/outerloop tests and the full repository suite were not run. Fixes # (issue) ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] 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 - [x] 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 - [x] No --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> (cherry picked from commit db62c35)
## Description Configured template sources currently appear in the `aspire new` picker under a friendly name or alias alone, making it difficult to tell which repository and ref will supply a template. Show that provenance directly in each source heading while retaining the friendly name. Git headings now use `Name (repository @ ref)`. An omitted ref is explicitly displayed as `default branch`, rather than guessing a branch name or displaying the acquired commit. Directory headings use `Name (path)` instead. Built-in grouping, collision-safe source IDs and selections, trust/consent behavior, acquisition semantics, and the extension's flat-choice protocol remain unchanged. Existing literal-text escaping and terminal-width cropping apply to the expanded headings. Follow-up to #21754. No new dependencies. ### User-facing usage Run `aspire new` with configured template sources. Example headings: ```text Company templates (https://github.com/example/templates @ release/templates) company (https://github.com/example/templates @ default branch) Company templates (/work/templates) ``` ### Screenshots / Recordings > **This PR includes CLI prompt changes.** TODO: add a screenshot or recording of `aspire new` with Git and directory sources, including a narrow terminal. > > Rendered console snapshots cover full headings at 120 columns and literal-text escaping/cropping at 40 columns. No screenshot or recording is attached. <!-- Add screenshots/recordings here --> ### Validation - `./restore.sh` — passed. - `dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.NewCommandLocalTemplateTests' --filter-class '*.ConsoleInteractionServiceTests' --filter-class '*.ExtensionInteractionServiceTests' --filter-class '*.TemplateSourceConfigurationTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'` — passed, 750 tests. - `git diff --check` — passed. Coverage includes configured/default refs, commit and fully qualified branch refs, friendly names and alias fallback, directory sources, inherited sources, duplicate names, credential-bearing source rejection, markup-containing locations, and width-aware rendering. Git acquisition uses the existing test runner, not live repositories. Quarantined/outerloop tests and the full repository suite were not run. Fixes # (issue) ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] 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 - [x] 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 - [x] No --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> (cherry picked from commit db62c35)
## Summary Documents the CLI changes from microsoft/aspire#21754 (configured templates in the `aspire new` picker), together with the related template-source command reference. This PR now **consolidates #1974 and #1983**, which are being closed in favor of this one. - `aspire new`: new **Select a template** section that describes the grouped picker, entry labels, truncation, and search behavior. A **Configure template sources** subsection links to `aspire template source add` and `remove` instead of encouraging direct config-file edits. - New reference pages: `aspire template`, `aspire template source`, `aspire template source add` (trust confirmation and `--yes`, from #1983), `aspire template source list`, and `aspire template source remove`. - Registers the new pages under an **aspire template** group in the CLI reference sidebar, and adds `aspire template` to the root `aspire` command table. - Adds `cli-command-sidebar.vitest.test.ts` (from #1983), which ensures that every CLI command page appears in the sidebar. Validated against the `release/17.0` CLI source: - `add` takes `name`, `--path`, `--repository`, `--ref`, and `-y/--yes`. It has no display-name option. - Source names must be 1–64 ASCII letters, digits, dots, hyphens, or underscores, starting with a letter or digit. - `add` fails if the name already exists. - `list` supports `--format`. #1974's "Search for more templates" section was dropped because #21754 replaced it with the grouped picker. ## Third-party links and affiliations None ## Validation - `npx vitest run --config vitest.config.ts tests/unit/cli-command-sidebar.vitest.test.ts tests/unit/seo-lengths.vitest.test.ts tests/unit/cli-config-schema.vitest.test.ts` (in `src/frontend`): passed (18 tests) - `npx prettier --check` and `npx eslint --max-warnings 0` on the sidebar config and new test: passed - Live preview via `aspire start --isolated`: all seven changed or new command pages return 200 and show the new sidebar entries.


Description
Show templates from configured Git and directory sources alongside built-in templates in interactive
aspire new, without a separate source submenu. This builds on #21329, #21388, and #21420; it does not close those already-merged issues/PRs.The terminal picker uses nonselectable source headings, retains built-in ordering and defaults, and selects the exact discovered template object even when names collide. Leaves use
Template Name (Template Description)without repeating the source or short name; missing descriptions leave just the name. The separate search action has been removed from the initial picker; explicit template search/invocation support is unchanged.Template source objects support optional
displayNamein global and accepted init-source configuration, for example:{ "templateSources": { "company": { "repository": "https://github.com/example/templates", "displayName": "Company templates" } } }Missing, null, empty, or space-only display names use the alias. Other types and control characters fail existing strict configuration validation.
aspire config set templateSources.company.displayName "Company templates" --globaledits an existing source; no new flag is added. Typed load/save, source listing, configuration edits and runtime inheritance preserve the field. Global-over-inherited alias collisions replace the entire definition, including the display name. Inherited values are never persisted to global or generated-project configuration.Aliases remain the stable group identity, command reference and source-disambiguating flat label; identical display names do not merge sources or select a different source. Headings now use bold/default foreground, following existing CLI section headings such as
aspire doctor, rather than Spectre's faded disabled grey. Leaf-only navigation is unchanged.Grouped console labels normalize multiline whitespace and truncate the combined name/description with an ellipsis to the available terminal-cell width, reserving arrow, indentation and padding. Source headings and the selected-value echo also fit the width. Spectre's cell-aware cropping preserves grapheme clusters, wide characters and combining sequences; metadata is safely escaped. Full template metadata is retained.
The pinned Spectre.Console 0.57.2 uses the same converter for display and search and has no separate search predicate. Following the explicit UX decision to keep Spectre and truncate in the CLI, case-insensitive search matches only the visible prefix of a truncated label, not its hidden tail. No dependency update or custom prompt is introduced. Type-to-search moves to a matching choice; it does not filter the list.
Grouping and terminal display labels are optional interaction-service metadata. VS Code retains the unchanged flat
string[]RPC and complete unique source-qualified labels; extension grouping and description search remain deferred. Existing inherited-source consent/no-fetch boundaries, explicit and noninteractive flows, source acquisition warnings, cached snapshots, authentication protections, and post-action authorization remain intact.Validation for the latest friendly-heading revision:
Result: 1048 passed, 0 failed, 1 skipped. Covers typed serialization and schema, strict field validation, source updates/listing, inherited display names without persistence, complete global alias precedence, duplicate friendly headings and exact template generation, consent/no-fetch, unchanged extension fallback, terminal cell-width thresholds and narrow terminals, Unicode/combining sequences, escaped markup, normalized multiline labels and visible-prefix-only search. Rendering and configuration snapshots were reviewed and the suite rerun successfully.
Result: both passed. Localized display-name validation and allowed-field diagnostics regenerated.
A refreshed screenshot of the actual repository-built CLI, with friendly source names, bold/default headings and a long description cropped with an ellipsis, is provided in the associated Copilot handoff, not uploaded GitHub media. Earlier screenshots and the description-search recording predate these latest formatting changes. No cloud resources or external account changes were used.
Checklist
<remarks />and<code />elements on your triple slash comments?