Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions playground/Stress/Stress.AppHost/InteractionCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ public static IResourceBuilder<T> AddInteractionCommands<T>(this IResourceBuilde
var interactionService = commandContext.Services.GetRequiredService<IInteractionService>();

var result = await interactionService.PromptProgressAsync(
"Please wait while resources are being downloaded...",
"Downloading resources",
"Please wait while resources are being downloaded...",
new ProgressInteractionOptions
{
PrimaryButtonText = "Cancel",
Expand Down Expand Up @@ -825,8 +825,8 @@ public static IResourceBuilder<T> AddInteractionCommands<T>(this IResourceBuilde
var interactionService = commandContext.Services.GetRequiredService<IInteractionService>();

var result = await interactionService.PromptProgressAsync(
null,
"Please wait while resources are being downloaded...",
title: null,
options: new ProgressInteractionOptions
{
Work = async ctx =>
Expand Down Expand Up @@ -855,8 +855,8 @@ public static IResourceBuilder<T> AddInteractionCommands<T>(this IResourceBuilde
using var cts = CancellationTokenSource.CreateLinkedTokenSource(commandContext.CancellationToken);

var progressTask = interactionService.PromptProgressAsync(
"This dialog has no cancel button. It will close automatically.",
"Processing",
"This dialog has no cancel button. It will close automatically.",
cancellationToken: cts.Token);

// Simulate background work, then close the dialog.
Expand All @@ -877,8 +877,8 @@ public static IResourceBuilder<T> AddInteractionCommands<T>(this IResourceBuilde
var interactionService = commandContext.Services.GetRequiredService<IInteractionService>();

var result = await interactionService.PromptProgressAsync(
"Please wait while data is being loaded...",
"Loading",
"Please wait while data is being loaded...",
new ProgressInteractionOptions
{
Work = async ctx =>
Expand All @@ -900,6 +900,7 @@ public static IResourceBuilder<T> AddInteractionCommands<T>(this IResourceBuilde
var interactionService = commandContext.Services.GetRequiredService<IInteractionService>();

var result = await interactionService.PromptProgressAsync(
null,
"Please wait...",
options: new ProgressInteractionOptions
{
Expand All @@ -923,8 +924,8 @@ public static IResourceBuilder<T> AddInteractionCommands<T>(this IResourceBuilde
var interactionService = commandContext.Services.GetRequiredService<IInteractionService>();

var result = await interactionService.PromptProgressAsync(
"Provisioning resources for **MyApp**.\n\nThis may take several minutes.",
"Deploying to Azure",
"Provisioning resources for **MyApp**.\n\nThis may take several minutes.",
new ProgressInteractionOptions
{
PrimaryButtonText = "Abort deployment",
Expand All @@ -948,8 +949,8 @@ public static IResourceBuilder<T> AddInteractionCommands<T>(this IResourceBuilde
var interactionService = commandContext.Services.GetRequiredService<IInteractionService>();

var result = await interactionService.PromptProgressAsync(
"Building and pushing container images to registry. This will take approximately 30 seconds.",
"Building container images",
"Building and pushing container images to registry. This will take approximately 30 seconds.",
new ProgressInteractionOptions
{
PrimaryButtonText = "Cancel build"
Expand Down
12 changes: 5 additions & 7 deletions playground/TypeScriptAppHost/apphost.mts
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,13 @@ await cache.withCommand(
}

const result = await interactionService.promptProgress(
"Processing",
"Please wait while data is being processed...",
{
title: "Processing",
options: {
primaryButtonText: "Cancel",
work: async () => {
// Simulate a long-running operation.
await new Promise<void>(resolve => setTimeout(resolve, 10000));
}
primaryButtonText: "Cancel",
work: async () => {
// Simulate a long-running operation.
await new Promise<void>(resolve => setTimeout(resolve, 10000));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ private async Task<ExecuteCommandResult> ExecuteCommandWithOptionalProgressAsync
options.PrimaryButtonText = InteractionStrings.CommandProgressCancelButtonText;
}

var progressResult = await interactionService.PromptProgressAsync(progressOptions.Message, title: progressOptions.Title, options: options, cancellationToken: cancellationToken).ConfigureAwait(false);
var progressResult = await interactionService.PromptProgressAsync(progressOptions.Title, progressOptions.Message, options: options, cancellationToken: cancellationToken).ConfigureAwait(false);

if (progressResult.Canceled)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Hosting/Ats/InteractionExports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ public static async Task<BoolInteractionResult> PromptNotification(
[AspireExport(RunSyncOnBackgroundThread = true)]
public static async Task<BoolInteractionResult> PromptProgress(
this IInteractionService interactionService,
string title,
string message,
string? title = null,
InteractionProgressOptions? options = null,
CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(interactionService);

var result = await interactionService.PromptProgressAsync(message, title, options?.ToOptions(), cancellationToken).ConfigureAwait(false);
var result = await interactionService.PromptProgressAsync(title, message, options?.ToOptions(), cancellationToken).ConfigureAwait(false);
return BoolInteractionResult.From(result);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Hosting/IInteractionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ public interface IInteractionService
/// through the <see cref="ProgressContext.CancellationToken"/> provided to the work callback.
/// </para>
/// </remarks>
/// <param name="message">The message to display in the progress dialog.</param>
/// <param name="title">The optional title of the progress dialog.</param>
/// <param name="message">The message to display in the progress dialog.</param>
/// <param name="options">Optional configuration for the progress interaction.</param>
/// <param name="cancellationToken">A token to cancel the operation and close the dialog.</param>
/// <returns>
/// An <see cref="InteractionResult{T}"/> containing <c>true</c> if the operation completed successfully,
/// or a canceled result if the user clicked the cancel button.
/// </returns>
[Experimental("ASPIREINTERACTION001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")]
Task<InteractionResult<bool>> PromptProgressAsync(string message, string? title = null, ProgressInteractionOptions? options = null, CancellationToken cancellationToken = default);
Task<InteractionResult<bool>> PromptProgressAsync(string? title, string message, ProgressInteractionOptions? options = null, CancellationToken cancellationToken = default);
}

internal record QueueLoadOptions(
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Hosting/InteractionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public async Task<InteractionResult<bool>> PromptNotificationAsync(string title,
}
}

public async Task<InteractionResult<bool>> PromptProgressAsync(string message, string? title = null, ProgressInteractionOptions? options = null, CancellationToken cancellationToken = default)
public async Task<InteractionResult<bool>> PromptProgressAsync(string? title, string message, ProgressInteractionOptions? options = null, CancellationToken cancellationToken = default)
{
EnsureServiceAvailable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18071,7 +18071,7 @@ type InteractionService interface {
PromptInputs(title string, message string, inputs []InteractionInputBuilder, options ...*PromptInputsOptions) InputsInteractionResult
PromptMessageBox(title string, message string, options ...*PromptMessageBoxOptions) (*BoolInteractionResult, error)
PromptNotification(title string, message string, options ...*PromptNotificationOptions) (*BoolInteractionResult, error)
PromptProgress(message string, options ...*PromptProgressOptions) (*BoolInteractionResult, error)
PromptProgress(title string, message string, options ...*PromptProgressOptions) (*BoolInteractionResult, error)
Err() error
}

Expand Down Expand Up @@ -18425,12 +18425,13 @@ func (s *interactionService) PromptNotification(title string, message string, op
}

// PromptProgress displays a progress dialog with an indeterminate progress indicator.
func (s *interactionService) PromptProgress(message string, options ...*PromptProgressOptions) (*BoolInteractionResult, error) {
func (s *interactionService) PromptProgress(title string, message string, options ...*PromptProgressOptions) (*BoolInteractionResult, error) {
if s.err != nil { var zero *BoolInteractionResult; return zero, s.err }
ctx := context.Background()
reqArgs := map[string]any{
"interactionService": s.handle.ToJSON(),
}
reqArgs["title"] = serializeValue(title)
reqArgs["message"] = serializeValue(message)
if len(options) > 0 {
merged := &PromptProgressOptions{}
Expand Down Expand Up @@ -29319,15 +29320,13 @@ func (o *PromptNotificationOptions) ToMap() map[string]any {

// PromptProgressOptions carries optional parameters for PromptProgress.
type PromptProgressOptions struct {
Title *string `json:"title,omitempty"`
Options *InteractionProgressOptions `json:"options,omitempty"`
CancellationToken *CancellationToken `json:"-"`
}

func (o *PromptProgressOptions) ToMap() map[string]any {
m := map[string]any{}
if o == nil { return m }
if o.Title != nil { m["title"] = serializeValue(o.Title) }
if o.Options != nil { m["options"] = serializeValue(o.Options) }
return m
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15354,25 +15354,22 @@ private BoolInteractionResult promptNotificationImpl(String title, String messag
}

/** Displays a progress dialog with an indeterminate progress indicator. */
public BoolInteractionResult promptProgress(String message, PromptProgressOptions optionsBag) {
var title = optionsBag == null ? null : optionsBag.getTitle();
public BoolInteractionResult promptProgress(String title, String message, PromptProgressOptions optionsBag) {
var options = optionsBag == null ? null : optionsBag.getOptions();
var cancellationToken = optionsBag == null ? null : optionsBag.getCancellationToken();
return promptProgressImpl(message, title, options, cancellationToken);
return promptProgressImpl(title, message, options, cancellationToken);
}

public BoolInteractionResult promptProgress(String message) {
return promptProgress(message, null);
public BoolInteractionResult promptProgress(String title, String message) {
return promptProgress(title, message, null);
}

/** Displays a progress dialog with an indeterminate progress indicator. */
private BoolInteractionResult promptProgressImpl(String message, String title, InteractionProgressOptions options, CancellationToken cancellationToken) {
private BoolInteractionResult promptProgressImpl(String title, String message, InteractionProgressOptions options, CancellationToken cancellationToken) {
Map<String, Object> reqArgs = new HashMap<>();
reqArgs.put("interactionService", AspireClient.serializeValue(getHandle()));
reqArgs.put("title", AspireClient.serializeValue(title));
reqArgs.put("message", AspireClient.serializeValue(message));
if (title != null) {
reqArgs.put("title", AspireClient.serializeValue(title));
}
if (options != null) {
reqArgs.put("options", AspireClient.serializeValue(options));
}
Expand Down Expand Up @@ -20622,16 +20619,9 @@ public PromptNotificationOptions cancellationToken(CancellationToken value) {

/** Options for PromptProgress. */
public final class PromptProgressOptions {
private String title;
private InteractionProgressOptions options;
private CancellationToken cancellationToken;

public String getTitle() { return title; }
public PromptProgressOptions title(String value) {
this.title = value;
return this;
}

public InteractionProgressOptions getOptions() { return options; }
public PromptProgressOptions options(InteractionProgressOptions value) {
this.options = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3015,12 +3015,11 @@ def prompt_notification(self, title: str, message: str, *, options: InteractionN
)
return typing.cast(BoolInteractionResult, result)

def prompt_progress(self, message: str, *, title: str | None = None, options: InteractionProgressOptions | None = None, timeout: int | None = None) -> BoolInteractionResult:
def prompt_progress(self, title: str, message: str, *, options: InteractionProgressOptions | None = None, timeout: int | None = None) -> BoolInteractionResult:
"""Displays a progress dialog with an indeterminate progress indicator."""
rpc_args: dict[str, typing.Any] = {'interactionService': self._handle}
rpc_args['title'] = title
rpc_args['message'] = message
if title is not None:
rpc_args['title'] = title
if options is not None:
rpc_args['options'] = options
if timeout is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12181,13 +12181,11 @@ impl IInteractionService {
}

/// Displays a progress dialog with an indeterminate progress indicator.
pub fn prompt_progress(&self, message: &str, title: Option<&str>, options: Option<InteractionProgressOptions>, cancellation_token: Option<&CancellationToken>) -> Result<BoolInteractionResult, Box<dyn std::error::Error>> {
pub fn prompt_progress(&self, title: &str, message: &str, options: Option<InteractionProgressOptions>, cancellation_token: Option<&CancellationToken>) -> Result<BoolInteractionResult, Box<dyn std::error::Error>> {
let mut args: HashMap<String, Value> = HashMap::new();
args.insert("interactionService".to_string(), self.handle.to_json());
args.insert("title".to_string(), serde_json::to_value(&title).unwrap_or(Value::Null));
args.insert("message".to_string(), serde_json::to_value(&message).unwrap_or(Value::Null));
if let Some(ref v) = title {
args.insert("title".to_string(), serde_json::to_value(v).unwrap_or(Value::Null));
}
if let Some(ref v) = options {
args.insert("options".to_string(), serde_json::to_value(v).unwrap_or(Value::Null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1648,12 +1648,6 @@ export interface GetValueAsyncOptions {
cancellationToken?: AbortSignal | CancellationToken;
}

export interface PromptProgressOptions {
title?: string;
options?: InteractionProgressOptions;
cancellationToken?: AbortSignal | CancellationToken;
}

export interface PublishAsDockerFileOptions {
/** Optional action to configure the container resource */
configure?: (obj: ContainerResource) => Promise<void>;
Expand Down Expand Up @@ -12765,7 +12759,7 @@ export interface InteractionService {
* Displays a progress dialog with an indeterminate progress indicator.
* @param options Additional options.
*/
promptProgress(message: string, options?: PromptProgressOptions): Promise<BoolInteractionResult>;
promptProgress(title: string, message: string, options?: InteractionProgressOptions, cancellationToken?: AbortSignal | CancellationToken): Promise<BoolInteractionResult>;
Comment thread
JamesNK marked this conversation as resolved.
Outdated
/**
* Prompts the user for a single input.
* @param options Additional options.
Expand Down Expand Up @@ -12834,7 +12828,7 @@ export interface InteractionServicePromise extends PromiseLike<InteractionServic
* Displays a progress dialog with an indeterminate progress indicator.
* @param options Additional options.
*/
promptProgress(message: string, options?: PromptProgressOptions): Promise<BoolInteractionResult>;
promptProgress(title: string, message: string, options?: InteractionProgressOptions, cancellationToken?: AbortSignal | CancellationToken): Promise<BoolInteractionResult>;
/**
* Prompts the user for a single input.
* @param options Additional options.
Expand Down Expand Up @@ -12945,12 +12939,9 @@ class InteractionServiceImpl implements InteractionService {

/**
* Displays a progress dialog with an indeterminate progress indicator.
* @param optionsBag Additional options.
* @param options Additional options.
*/
async promptProgress(message: string, optionsBag?: PromptProgressOptions): Promise<BoolInteractionResult> {
const title = optionsBag?.title;
const options = optionsBag?.options;
const cancellationToken = optionsBag?.cancellationToken;
async promptProgress(title: string, message: string, options?: InteractionProgressOptions, cancellationToken?: AbortSignal | CancellationToken): Promise<BoolInteractionResult> {
const __optionsForRpc = options === undefined || options === null ? options : { ...options };
if (__optionsForRpc !== undefined && __optionsForRpc !== null) {
const __optionsForRpcData = __optionsForRpc as Record<string, unknown>;
Expand All @@ -12964,8 +12955,7 @@ class InteractionServiceImpl implements InteractionService {
__optionsForRpcData["work"] = ____optionsForRpcWorkId;
}
}
const rpcArgs: Record<string, unknown> = { interactionService: this._handle, message };
if (title !== undefined) rpcArgs.title = title;
const rpcArgs: Record<string, unknown> = { interactionService: this._handle, title, message };
if (options !== undefined) rpcArgs.options = __optionsForRpc;
if (cancellationToken !== undefined) rpcArgs.cancellationToken = CancellationToken.fromValue(cancellationToken);
return await this._client.invokeCapability<BoolInteractionResult>(
Expand Down Expand Up @@ -13186,8 +13176,8 @@ class InteractionServicePromiseImpl implements InteractionServicePromise {
return this._promise.then(obj => obj.promptNotification(title, message, options, cancellationToken));
}

promptProgress(message: string, options?: PromptProgressOptions): Promise<BoolInteractionResult> {
return this._promise.then(obj => obj.promptProgress(message, options));
promptProgress(title: string, message: string, options?: InteractionProgressOptions, cancellationToken?: AbortSignal | CancellationToken): Promise<BoolInteractionResult> {
return this._promise.then(obj => obj.promptProgress(title, message, options, cancellationToken));
}

promptInput(title: string, message: string, input: Awaitable<InteractionInputBuilder>, options?: InteractionInputsDialogOptions, cancellationToken?: AbortSignal | CancellationToken): Promise<InputInteractionResult> {
Expand Down
Loading
Loading