AspireTerminal Methods
public sealed class AspireTerminal{ public ValueTask DisposeAsync() { // ... }}Returns
ValueTask A task representing the terminal cleanup operation.public sealed class AspireTerminal{ public string GetScreenText() { // ... }}Returns
stringThe current terminal screen text.Exceptions
InvalidOperationExceptionThe AppHost-owned terminal has already stopped.SendKeyAsync(AspireTerminalKey, CancellationToken) Section titled SendKeyAsync(AspireTerminalKey, CancellationToken)Taskpublic sealed class AspireTerminal{ public Task SendKeyAsync( AspireTerminalKey key, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
keyAspirecancellationToken CancellationToken optionalCancellation token.Returns
TaskA task representing the input operation.Exceptions
ArgumentExceptionkey is an uninitialized value.InvalidOperationExceptionThe AppHost-owned terminal has already stopped.OperationCanceledExceptionThe input operation was canceled by cancellationToken .Remarks
AspireTerminalKey and combine them with AspireTerminalKey.Ctrl , AspireTerminalKey.Shift , and AspireTerminalKey.Alt . For example, AspireTerminalKey.Ctrl(AspireTerminalKey.R) sends Control+R. Use AspireTerminal.SendTextAsync for arbitrary text rather than individual keys. Key encoding follows the terminal's current input mode; a key does not represent a physical key-down or key-up event. public sealed class AspireTerminal{ public Task SendTextAsync( string text, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
textstringThe text to send.cancellationToken CancellationToken optionalCancellation token.Returns
TaskA task representing the input operation.Exceptions
ArgumentNullExceptiontext is null.InvalidOperationExceptionThe AppHost-owned terminal has already stopped.OperationCanceledExceptionThe input operation was canceled by cancellationToken .public sealed class AspireTerminal{ public void Show() { // ... }}Remarks
TerminalPlacement.Dock terminals. Terminals in a dialog are revealed by that dialog, so this is a no-op for them. StartSection titled Startpublic sealed class AspireTerminal{ public void Start() { // ... }}Exceptions
InvalidOperationExceptionThe terminal has already stopped.Remarks
Starting is the caller's decision, not the dashboard's and not the interaction service's. Call this to have the workload running before anyone is looking at it — a terminal that is already running when a dialog opens shows its scrollback immediately, and automation can drive a terminal that is never displayed at all.
This is idempotent and does not block: it schedules the workload rather than waiting for it to produce output. Use Aspire to wait for the workload to reach a known state. It is also a no-op for Terminal terminals, whose workload is started by the resource.
WaitForTextAsync(string, TimeSpan?, CancellationToken) Section titled WaitForTextAsync(string, TimeSpan?, CancellationToken)Tasktext appears on the terminal screen. public sealed class AspireTerminal{ public Task WaitForTextAsync( string text, TimeSpan? timeout = null, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
textstringThe text to wait for.timeoutTimeSpan? optionalHow long to wait before giving up. Defaults to 30 seconds.cancellationToken CancellationToken optionalCancellation token.Returns
TaskA task that completes when the text appears on the terminal screen.Exceptions
ArgumentNullExceptiontext is null.TimeoutExceptionThe text did not appear before timeout elapsed.InvalidOperationExceptionThe AppHost-owned terminal has already stopped.