Skip to content

Type Alias: GuardedOutcome<T>

GuardedOutcome<T> = { status: "ok"; value: T; } | { status: "stale"; value: T; } | { status: "timeout"; } | { error: unknown; status: "error"; }

Defined in: modal/effect.ts:22

Guarded async effects (modal-interaction-lessons §4.4, rules §3.6 and the timeout half of §3.11).

Modal effects — mic acquisition, screen captures, model round-trips — are launched from a command and deliver results as events. Two disciplines are structural here so no call site can forget them:

  • Completion-time revalidation. Launch-time checks are worthless for slow effects: a screenshot that resolves after the share picker (seconds later) can land in a turn that was already sent. stillValid is re-checked when the result arrives; a stale result is returned as "stale" so the caller drops it instead of folding it in.
  • A ceiling. Timeouts are part of the effect, not the caller's problem — no mode may wedge on a promise (the "Enter waits for a transcript that will never come" class). The ceiling aborts the signal and resolves "timeout".

guardedEffect never rejects; every outcome is data the caller folds.

Type Parameters

T

T

Union Members

Type Literal

{ status: "ok"; value: T; }


Type Literal

{ status: "stale"; value: T; }

Completed, but stillValid() said the world moved on — drop the value.


Type Literal

{ status: "timeout"; }


Type Literal

{ error: unknown; status: "error"; }