mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-11 17:52:31 +03:00
/api/logs/[id]'s live "Generating… / Thinking…" preview (extractPartialAssistantText) parsed each stream-chunk-log array element independently. Each element is one raw network read, timestamp-prefixed for the debug display — not one complete SSE `data:` line — so a single JSON value (a `reasoning_content` delta) routinely splits across two or more elements. Parsing per-element in isolation silently failed JSON.parse on the split pieces and dropped them, leaving gaps in the reconstructed text that read as garbled/scrambled reasoning once the survivors were concatenated — reported live via a dashboard screenshot of an in-progress conversation. Fix: strip each element's timestamp prefix and concatenate the whole array into one continuous string first, then split into lines and parse — so a value split across elements rejoins correctly before JSON.parse ever sees it. Same reconstruction technique already proven correct for the final, completed response body; this brings the in-flight preview path in line. Covered by tests/unit/logs-detail-partial-reasoning-chunk-split.test.ts, including a direct demonstration that the pre-fix per-element parse fails on each half of a split value in isolation (proving genuine TDD, not a coincidental pass) while the fixed concatenate-first parse recovers the full text.