Make InteractionInput.Name required and Label optional#10835
Conversation
30dda1d to
8b16283
Compare
|
@davidfowl @mitchdenny Alternatively, if you don't specify a name then the input isn't accessible by name, just using the index (current behavior). I'm not a fan of generating the name, but curious what you all think. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for accessing interaction inputs by name instead of just by index, implementing name-based access functionality for the interaction service. The changes enable users to specify optional names for inputs and access them through a new InteractionInputCollection class.
- Adds an optional
Nameproperty toInteractionInputfor explicit naming - Introduces
InteractionInputCollectionthat supports both indexed and name-based access with automatic name generation - Updates the interaction service API to return
InteractionInputCollectioninstead ofIReadOnlyList<InteractionInput>
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting/IInteractionService.cs | Adds InteractionInputCollection class with name-based access capabilities and updates InteractionInput with Name property |
| src/Aspire.Hosting/InteractionService.cs | Updates method signatures to use InteractionInputCollection and handles early validation/name generation |
| src/Aspire.Hosting/api/Aspire.Hosting.cs | Updates public API signatures to reflect the new collection type |
| tests/Aspire.Hosting.Tests/InteractionServiceTests.cs | Comprehensive test coverage for name-based access, validation, and edge cases |
| tests/Shared/TestInteractionService.cs | Updates test service implementation to work with new collection type |
Comments suppressed due to low confidence (1)
tests/Aspire.Hosting.Tests/InteractionServiceTests.cs:45
- This line creates a nested InteractionInputCollection by wrapping result.Data (which is already an InteractionInputCollection) in another collection. This could cause issues with the wrapped collection's functionality.
// Act 1
|
@JamesNK the API is experimental. We could make the Name required at this early stage? Better to be more explicit than less? |
|
There are scenarios where you don't want name to be required. For example: var result = await interactionService.PromptInputAsync(
title: "Hello world",
message: "What is your name?",
input: new InteractionInput { Label = "Name", InputType = InputType.Text });You wouldn't want to require a name here because it's never used. |
d488e04 to
57192b9
Compare
|
FYI I forced pushed to update this PR on top of main (for easier dogfooding). I think this change is fine. If there's no name it throws right? |
No, it generates a name from other information. Someone might want to prompt with one input and a name is pointless then. Options are:
Right now this PR is number 2. I think I prefer 3. @davidfowl @mitchdenny What do you think? |
|
How should compat errors be fixed?
Is there prior art I can follow? |
|
@copilot Make |
Done! I've implemented the requested change to make |
I like option 3 as well. |
d9689c2 to
3dbbe80
Compare
|
All changes done. I also updated Azure provisioning to reference by name |
davidfowl
left a comment
There was a problem hiding this comment.
Make sure we have a breaking change doc.
| // Check for duplicate names | ||
| foreach (var input in inputs) | ||
| { | ||
| if (usedNames.Contains(input.Name)) |
There was a problem hiding this comment.
Can we just call .Add and check the return value if it was added? And then throw if it wasn't added.
|
Looking good! |
|

This PR implements a breaking change to the
InteractionInputAPI as requested in #10834. Instead of makingNameoptional with auto-generation fromLabel, this change makesNamerequired andLabeloptional.API Changes
Before:
After:
Benefits
Implementation Details
EffectiveLabelproperty that returnsLabelif specified, otherwise returnsNameInteractionInputCollectionThis addresses the feedback from @JamesNK preferring option 3: making
Namerequired andLabeloptional, using name as label unless explicitly specified.Fixes #10834
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.