Commit 6e8ee8b
committed
fix(codex): streamTextResponse handles output_item.done + completed events
Previously the streaming SSE parser only fired on
\`response.output_text.delta\` events. For short prompts the backend
sometimes delivers the whole reply as a single
\`response.output_item.done\` (no per-token deltas), so the
AsyncThrowingStream finished without yielding any text. The demo's
chat bubble stayed at "..." forever.
Rewrite the streaming loop to inspect every event type and yield text
from whichever path the server chose:
- response.output_text.delta -> yield each delta as it arrives
- response.output_item.done -> if no deltas were yielded yet, stash
the assistant text for fallback
- response.completed -> if no deltas were yielded, yield the
full text from the response (or the
stashed item text)
- response.failed / .incomplete -> throw CodexError.backendError
Also surface the SSE event decoder as decodeSSEEvent(dataLines:) so the
delta extractor and the new fallback path share one parser.
No public API change. 46 kit tests still pass; demo's chat bubble now
fills in for both delta-streaming and one-shot replies.1 parent 0bb95f9 commit 6e8ee8b
1 file changed
Lines changed: 55 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
273 | 277 | | |
274 | | - | |
275 | | - | |
276 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
277 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
278 | 297 | | |
279 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
280 | 322 | | |
281 | 323 | | |
282 | 324 | | |
283 | 325 | | |
284 | 326 | | |
285 | 327 | | |
286 | 328 | | |
287 | | - | |
288 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
289 | 332 | | |
290 | 333 | | |
291 | 334 | | |
| |||
296 | 339 | | |
297 | 340 | | |
298 | 341 | | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
307 | 347 | | |
308 | 348 | | |
309 | | - | |
| 349 | + | |
310 | 350 | | |
311 | 351 | | |
312 | 352 | | |
| |||
0 commit comments