|
| 1 | +# Delta for Chat Streaming |
| 2 | + |
| 3 | +## MODIFIED Requirements |
| 4 | + |
| 5 | +### Requirement: Chat text is accumulated from canonical delta events |
| 6 | + |
| 7 | +The chat streaming client MUST append text only from events that represent text deltas for the supported OpenCode version. |
| 8 | + |
| 9 | +#### Scenario: Part delta received |
| 10 | + |
| 11 | +- GIVEN an event with type `message.part.delta` |
| 12 | +- AND its field represents text |
| 13 | +- WHEN the event belongs to the active session |
| 14 | +- THEN the delta value MUST be appended exactly once |
| 15 | + |
| 16 | +#### Scenario: Part snapshot received |
| 17 | + |
| 18 | +- GIVEN an event with type `message.part.updated` |
| 19 | +- WHEN it contains a full part snapshot |
| 20 | +- THEN the snapshot MUST NOT be blindly appended as a new text delta |
| 21 | + |
| 22 | +### Requirement: Prompt submission waits for event-stream readiness |
| 23 | + |
| 24 | +The chat streaming client MUST wait for SSE connection readiness before sending `prompt_async`. |
| 25 | + |
| 26 | +#### Scenario: SSE cannot connect |
| 27 | + |
| 28 | +- GIVEN a session has been selected |
| 29 | +- AND the SSE connection fails before becoming ready |
| 30 | +- WHEN a streaming chat is started |
| 31 | +- THEN `prompt_async` MUST NOT be submitted |
| 32 | +- AND the streaming result MUST fail with the transport error |
| 33 | + |
| 34 | +### Requirement: SSE terminal failures propagate to the chat result |
| 35 | + |
| 36 | +Transport failure after connection MUST complete the corresponding streaming chat exceptionally unless the chat has already reached a terminal state. |
| 37 | + |
| 38 | +#### Scenario: Connection drops during generation |
| 39 | + |
| 40 | +- GIVEN streaming generation is active |
| 41 | +- WHEN the SSE transport fails |
| 42 | +- THEN the streaming result MUST fail without waiting only for the overall read timeout |
| 43 | + |
| 44 | +### Requirement: Local cancellation does not implicitly abort shared server work |
| 45 | + |
| 46 | +Cancelling the local stream MUST release local SSE and timeout resources, while server-side session abort remains explicit. |
| 47 | + |
| 48 | +#### Scenario: Local subscriber cancels |
| 49 | + |
| 50 | +- GIVEN a server-side session is generating |
| 51 | +- WHEN one local subscriber cancels its stream |
| 52 | +- THEN the local subscription MUST close |
| 53 | +- AND the SDK MUST NOT implicitly invoke session abort |
0 commit comments