Combine repeated emissions for one text part id. OpenCode streams can look like snapshots (new value contains the previous value) or deltas (new value is only the next chunk). Handle both shapes.
(existing: str, new: str)
| 381 | |
| 382 | |
| 383 | def _merge_text(existing: str, new: str) -> str: |
| 384 | """Combine repeated emissions for one text part id. |
| 385 | |
| 386 | OpenCode streams can look like snapshots (new value contains the previous |
| 387 | value) or deltas (new value is only the next chunk). Handle both shapes. |
| 388 | """ |
| 389 | if not existing: |
| 390 | return new |
| 391 | if new.startswith(existing): |
| 392 | return new |
| 393 | if existing.startswith(new): |
| 394 | return existing |
| 395 | return existing + new |
| 396 | |
| 397 | |
| 398 | def _is_step_finish(event: dict[str, Any], part: dict[str, Any], part_type: str) -> bool: |
no outgoing calls
no test coverage detected