Table of Contents

Class InlineActivityControl<T>

Namespace
ItTiger.TigerCli.Tui.Controls
Assembly
ItTiger.TigerCli.dll
Rich activity dialog control: a live CliGrid-backed layout (columns, rows, text and progress-bar elements) driven by named dynamic row values, plus a background operation and a single stop button (Cancel or Abort — never both). The operation runs on a background task and reports values through an ActivityContext; updates are applied on the modal-loop thread in AdvanceState(DateTime). Completion, failure and a confirmed stop all close the dialog without a keypress through CompletionResult.
public sealed class InlineActivityControl<T> : InlineControlBase, ICliRenderable

Type Parameters

T
Inheritance
InlineActivityControl<T>
Implements
Inherited Members

Remarks

Layout/measurement is entirely owned by CliGrid: text cells are single-line and clipped by the grid; progress bars are post-layout overlays (ProgressBar(Func<double>, char, char, char?, char?)) over a star column, so the grid resolves the bar width. The stop action flows through the hosting dialog's generic confirmation policy; on a confirmed stop the control begins a deferred completion (TryBeginDeferredCompletion(DialogResultKind)): it requests operation cancellation, switches to a "Cancelling…"/"Aborting…" view with no action button (the request has been accepted; the dialog only waits), and closes once the operation observes cancellation.

Constructors

InlineActivityControl(ICliAppShell, ActivityDialogSpec, Func<ActivityContext, CancellationToken, Task<T>>, ActivityStopMode, ActivitySpinnerSpec?)

Creates a control that runs and presents an asynchronous activity.
public InlineActivityControl(ICliAppShell shell, ActivityDialogSpec spec, Func<ActivityContext, CancellationToken, Task<T>> operation, ActivityStopMode stopMode = ActivityStopMode.Cancel, ActivitySpinnerSpec? spinner = null)

Parameters

shell ICliAppShell
The shell that hosts the control.
spec ActivityDialogSpec
The activity layout and non-interactive presentation specification.
operation Func<ActivityContext, CancellationToken, Task<T>>
The asynchronous activity to run.
stopMode ActivityStopMode
Whether the stop action is presented as cancellation or abort.
spinner ActivitySpinnerSpec
The spinner configuration, or null for the default spinner.

Properties

CanConfirm

True when the hosting dialog may complete this control with an Enter/OK action.
public override bool CanConfirm { get; }

Property Value

bool

CompletionResult

A result the control wants the modal to complete with without a keypress (e.g. an async operation finished). The hosting InlineDialog surfaces this through its own Result with precedence over key-/confirmation-driven results, and the shell loop breaks on it after pumping AdvanceState(DateTime). The default is NoResult (the control never self-completes).
public override DialogResultKind CompletionResult { get; }

Property Value

DialogResultKind

Hint

Optional status/hint text shown by the hosting dialog.
public override string? Hint { get; }

Property Value

string

HintMode

Formatting mode for Hint.
public override CliFormattingMode HintMode { get; }

Property Value

CliFormattingMode

OperationException

The exception thrown by the operation, or null when it did not fault.
public Exception? OperationException { get; }

Property Value

Exception

OperationTask

The operation task, exposed so callers can observe its completion if needed.
public Task? OperationTask { get; }

Property Value

Task

OperationValue

The value produced by the operation when it completed successfully.
public T? OperationValue { get; }

Property Value

T

Payload

Optional value produced by this control when its hosting dialog completes.
public override object? Payload { get; }

Property Value

object

Methods

AdvanceState(DateTime)

Called once per modal-loop iteration on the render thread (immediately before periodic overlays are advanced). Lets a control apply state that changed off the loop — for example the result of an asynchronous operation — and report whether the UI must re-render. The default does nothing. Implementations must be cheap and must not block the loop.
public override bool AdvanceState(DateTime nowUtc)

Parameters

nowUtc DateTime

Returns

bool

GetActivityOverlays()

Time-varying overlays this control exposes to its hosting InlineDialog (e.g. a loading spinner or a clock). The dialog adds them once through the normal overlay system and advances their tickers each modal-loop iteration. The default is none; the returned set must be structurally stable for the control's lifetime (only the tickers' content/active state changes).
public override IReadOnlyList<InlineActivityOverlay> GetActivityOverlays()

Returns

IReadOnlyList<InlineActivityOverlay>

GetWidgets()

Exposes the top-level widgets the hosting InlineDialog should place. The default wraps the control's own ToGrid() output into one focused widget, preserving the legacy single-content behavior. Composite controls override this to expose several widgets across different InlineDialogArea areas.
public override IReadOnlyList<InlineDialogWidget> GetWidgets()

Returns

IReadOnlyList<InlineDialogWidget>

HandleKey(KeyEvent)

Handles a key and optionally requests a dialog result. Returning NotHandled lets the hosting dialog apply fallback keys.
public override InlineKeyResult HandleKey(KeyEvent key)

Parameters

key KeyEvent

Returns

InlineKeyResult

OnModalClosed()

Called by the modal loop as it stops hosting this control (any exit path). Controls should stop tickers and abandon/ignore pending background results so a closed control is never mutated. The default does nothing.
public override void OnModalClosed()

OnModalOpened(CancellationToken)

Called by the modal loop as it starts hosting this control, supplying a token that is cancelled when the modal closes for any reason. Controls that start background work should observe it. The default does nothing.
public override void OnModalOpened(CancellationToken modalToken)

Parameters

modalToken CancellationToken

ToGrid()

Converts the component into a grid for measurement and rendering.
public override CliGrid ToGrid()

Returns

CliGrid

TryBeginDeferredCompletion(DialogResultKind)

Offered the chance to take over completion when the hosting dialog is about to commit a confirmed kind (Cancel/Abort) after its confirmation gate. Returning true means the control has begun a deferred completion (e.g. requested operation cancellation and switched to a "Cancelling…" view) and the dialog must stay open until the control reports a CompletionResult; returning false (the default) lets the dialog complete immediately with kind, preserving existing behavior.
public override bool TryBeginDeferredCompletion(DialogResultKind kind)

Parameters

kind DialogResultKind

Returns

bool