feat(vela): support end-to-end mocked turn cancelation

This commit is contained in:
2026-04-08 19:49:31 +02:00
parent ff78fc4c8f
commit 0d5b53be00
7 changed files with 197 additions and 9 deletions

View File

@@ -62,7 +62,8 @@ type ClientEvent =
- a mocked turn emits deterministic `transcript.final`, `response.text.delta`, `response.completed`, and `session.state` events in protocol-valid order
- `input_audio.append` updates the ephemeral session record and moves the session to `listening`
- `input_audio.commit` resets the minimal buffered state and returns the session to `idle`
- `response.cancel` resets the minimal session state back to `idle`
- `response.cancel` is safe to send even when no mocked turn is active
- `response.cancel` stops any still-pending mocked turn events for the active turn and resets the minimal session state back to `idle`
- a second mocked-turn trigger during an active mocked turn produces `error` with code `mocked_turn_in_flight`
- malformed JSON produces `error` with code `invalid_json`
- invalid envelopes or unsupported client event names produce `error` with code `invalid_message`
@@ -85,6 +86,8 @@ Notes:
- this UI state is transport-oriented and is separate from the shared gateway `session.state` payload
- `session.state` currently reflects the gateway session phase (`idle`, `listening`, `thinking`, `speaking`)
- the UI disables the mocked-turn control until `session.ready` arrives, while disconnected, or while a mocked turn is already in flight
- the UI shows a cancel control and enables it only while a mocked turn is active
- after cancel returns the gateway to `idle`, the UI clears the active-turn indicator but keeps any transcript or response text that was already rendered
- the UI treats malformed server messages, browser WebSocket errors, and gateway `error` events as safe error states instead of throwing
### Server → Client
@@ -134,7 +137,7 @@ Notes:
- the content is intentionally fixed and obviously mocked
- no audio, STT, LLM, TTS, or external providers participate in this flow
- `response.cancel` can stop the mocked turn early and return the session to `idle`
- `response.cancel` can stop the mocked turn early, suppress any later mocked response events for that turn, and return the session to `idle`
## Contract Scope for This Increment
@@ -162,6 +165,14 @@ idle
→ idle
```
Current mocked-pipeline behavior:
- during an active mocked turn, `response.cancel` returns the session to `idle` immediately
- any mocked turn timers that have not fired yet are dropped, so no later `response.text.delta` or `response.completed` events are emitted for the cancelled turn
- once `idle` is restored, the same WebSocket session can start another mocked turn without reconnecting
More general future-state expectations:
`response.cancel` can occur at:
- listening → restart