ngx-prompt-kit

Stream Controls

ngx-prompt-kit original — not part of ibelick/prompt-kit

A single button that swaps based on stream state — Stop while a response is streaming, Regenerate after it completes, Try again on error.

Examples

Streaming

State 'streaming' renders a Stop button. Click to abort the active request — wire (stop) to your AbortController.

Idle (after a response)

State 'idle' renders Regenerate when [canRegenerate]='true' (default). Set false to hide it — useful while there's no prior message to regenerate.

Error

State 'error' renders Try again with destructive styling. Same (regenerate) output — your handler can branch on whether the previous attempt failed.

Interactive

Click through a simulated lifecycle: idle → streaming → idle. Stop transitions to idle; Regenerate transitions back to streaming.

Current state: idle

Installation

Add the stream-controls component (and the cn() utility) to your project.

ng generate ngx-prompt-kit:stream-controls

Component API

PkStreamControls

PropTypeDefaultDescription
state"idle" | "streaming" | "error"Drives which button renders (required).
canRegenerateboolean true When false, the idle state renders nothing instead of a Regenerate button.
classstringExtra classes for the host.

Outputs

PropTypeDefaultDescription
stop() => voidFires when the Stop button is clicked (state="streaming").
regenerate() => voidFires when Regenerate or Try again is clicked (state="idle" or "error").