Skip to content

Add support for file types to interaction service#10233

Closed
JamesNK wants to merge 4 commits intomainfrom
jamesnk/file-input
Closed

Add support for file types to interaction service#10233
JamesNK wants to merge 4 commits intomainfrom
jamesnk/file-input

Conversation

@JamesNK
Copy link
Member

@JamesNK JamesNK commented Jul 3, 2025

Description

Add support for file input with InteractionService. The max file size is currently 2MB. If we want to support larger files then we'll need to increase the max allowed message size in gRPC.

Select file:
image

Uploaded file:
image

TODO: CLI needs to be updated to support new input type.

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
  • Does the change require an update in our Aspire docs?

@davidfowl
Copy link
Member

Do the CLI too (or does that just work)

@JamesNK
Copy link
Member Author

JamesNK commented Jul 3, 2025

No it doesn't. I'll update the CLI in a follow up PR.

@JamesNK JamesNK force-pushed the jamesnk/file-input branch from 3b2231b to a44a7d0 Compare July 3, 2025 07:17
@JamesNK JamesNK marked this pull request as ready for review July 3, 2025 08:41
Copilot AI review requested due to automatic review settings July 3, 2025 08:41
@JamesNK JamesNK requested a review from mitchdenny as a code owner July 3, 2025 08:41
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

Adds support for file‐type inputs in the interaction service, from the Protobuf definition through server handling, data model, and UI component.

  • Extended the Protobuf schema and generated C# mappings to include value_bytes and a File input type.
  • Updated DashboardServiceData and DashboardService to propagate file contents end‐to‐end.
  • Enhanced the Blazor input dialog and view model to handle file selection, progress, and display.
  • Added a new end‐to‐end test for the file‐input interaction in DashboardServiceTests.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Aspire.Hosting.Tests/Dashboard/DashboardServiceTests.cs New test exercising file‐input prompt round‐trip.
src/Aspire.Hosting/Dashboard/proto/dashboard_service.proto Protobuf: added value_bytes and INPUT_TYPE_FILE.
src/Aspire.Hosting/Dashboard/DashboardServiceData.cs Server: store incoming ValueBytes on InteractionInput.
src/Aspire.Hosting/Dashboard/DashboardService.cs Server: serialize/deserialize ValueBytes in gRPC.
src/Aspire.Hosting/ApplicationModel/IInteractionService.cs Model: added ValueBytes and SetValueBytes.
src/Aspire.Dashboard/Model/InputViewModel.cs ViewModel: expose ValueBytes, FileName, progress.
src/Aspire.Dashboard/Components/Dialogs/InteractionsInputDialog.razor.css CSS: include .uploaded-file-container in layout.
src/Aspire.Dashboard/Components/Dialogs/InteractionsInputDialog.razor.cs Dialog: new file‐input event handlers and validation.
src/Aspire.Dashboard/Components/Dialogs/InteractionsInputDialog.razor UI: markup for buffer‐mode file input with progress.
playground/Stress/Stress.AppHost/InteractionCommands.cs Example: log file input length in sample commands.
Comments suppressed due to low confidence (2)

src/Aspire.Hosting/ApplicationModel/IInteractionService.cs:137

  • This public API addition is missing XML documentation. Please add a <summary>, <remarks>, and <code> example for the new ValueBytes property to meet our triple‐slash comment requirements.
    public byte[]? ValueBytes { get => _valueBytes; init => _valueBytes = value; }

src/Aspire.Dashboard/Components/Dialogs/InteractionsInputDialog.razor.cs:139

  • The new file‐input progress and completion handlers lack unit or component tests. Consider adding tests (e.g., using bUnit or a similar framework) to cover progress updates and final file buffer handling.
    private async Task OnFileInputProgress(InputViewModel inputModel, FluentInputFileEventArgs args)

@JamesNK JamesNK requested review from captainsafia and davidfowl July 3, 2025 08:43
@adamint
Copy link
Member

adamint commented Jul 3, 2025

Add support for file input with InteractionService. The max file size is currently 2MB. If we want to support larger files then we'll need to increase the max allowed message size in gRPC.

I think we should support larger files. Or at least add a setting to opt into larger file size limits

@JamesNK
Copy link
Member Author

JamesNK commented Jul 4, 2025

I don't want a setting. How big? 3MB 5MB 10MB 100MB? What is the use case?

Communication between app host and dashboard/CLI uses RPC. That means the whole file will sit in memory and there are limits on how large the file can and should be. No file size limit would require adding a bespoke way of sending the file to the app host using streaming.

@JamesNK
Copy link
Member Author

JamesNK commented Jul 4, 2025

@captainsafia This PR also adds support for files in CLI.

@mitchdenny
Copy link
Member

mitchdenny commented Jul 4, 2025

This is cool. I think a good proof point of this might be adding support for uploading files in the blob container in Azure storage ... and selecting a sql script to run against a sql server/sql database.

internal static class InteractionConfig
{
public const int MaxFileSizeMegabytes = 2;
public const int MaxFileSizeBytes = MaxFileSizeMegabytes * 1024 * 1024;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ultimate constraint here is what we are willing to carry around in memory since the data handling here is not streamed, its copying values around. I think 2MB is quite low, I would think 100MB might be a better choice but I don't think you could go much higher without changing to a streaming approach.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Kestrel max body size default is about 30 MB. I'd rather not mess around with exceeding Kestrel defaults if it's not nessessary.

I'll increase the max size to 25 MB.

@davidfowl
Copy link
Member

I don’t love this approach. I think there are 2 scenarios:

  1. Local apphost, the files are alll on the same computer so there’s no need to send it over grpc. The file path is enough as the client and server are within the same trust boundary
  2. We should be modeling a streaming endpoint so we don’t need to buffer.

The user should get a stream, not byte[]. In the first scenario is an optimization.

@JamesNK
Copy link
Member Author

JamesNK commented Jul 4, 2025

Streaming would be way more complicated.

  • There would need to be a new streaming API.
  • The file would need to save to disk somewhere. It's not being used right away. It's used when the interaction is marked as complete.
  • It would need to return an ID back to the client to say that the upload was to this temporary location
  • The interaction would need to include that ID
  • The interaction service would need to assosicate the file ID with the file input, there would need to be an API to get a stream over the saved file
  • There would need to be something to clean up temporary files from disk.

@JamesNK
Copy link
Member Author

JamesNK commented Jul 9, 2025

@davidfowl What do you want to do here?

@davidfowl
Copy link
Member

I’d much prefer this to be using steams and I’m worried about supporting the protocol for both non streaming and streaming. We could fake it on the consumer side by making the API stream based and can change the underlying protocol in 9.5 to actually support it.

@JamesNK JamesNK closed this Jul 30, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants