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.
<pk-stream-controls
state="streaming"
(stop)="abortController.abort()"
/>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.
<pk-stream-controls
state="idle"
(regenerate)="resend()"
/>Error
State 'error' renders Try again with destructive styling. Same (regenerate) output — your handler can branch on whether the previous attempt failed.
<pk-stream-controls
state="error"
(regenerate)="retry()"
/>Interactive
Click through a simulated lifecycle: idle → streaming → idle. Stop transitions to idle; Regenerate transitions back to streaming.
Current state: idle
<pk-stream-controls
[state]="streamState()"
(stop)="abort()"
(regenerate)="send()"
/>Installation
Add the stream-controls component (and the cn() utility) to your project.
ng generate ngx-prompt-kit:stream-controlsComponent API
PkStreamControls
| Prop | Type | Default | Description |
|---|---|---|---|
| state | "idle" | "streaming" | "error" | — | Drives which button renders (required). |
| canRegenerate | boolean | true | When false, the idle state renders nothing instead of a Regenerate button. |
| class | string | — | Extra classes for the host. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| stop | () => void | — | Fires when the Stop button is clicked (state="streaming"). |
| regenerate | () => void | — | Fires when Regenerate or Try again is clicked (state="idle" or "error"). |