Repository navigation
fix(runtime): preserve line breaks in fake streams - #732
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preserve line terminators when FakeBackend splits its deterministic response into text deltas, and lock that source invariant with a runtime regression test.
Why
FakeBackend used
/.{1,9}/g, where.does not match line terminators. Structured Markdown therefore lost every newline during streaming and recovered them only intext_complete, creating an artificial whole-answer reflow at terminal completion.The original visual evidence came from this lossy FakeBackend stream rather than a production renderer handoff. Fixing the event source makes concatenated deltas equal the complete Markdown source, so completion no longer inserts missing line breaks.
Closes #731
Scope
Changed:
text_complete, including Markdown line breaks.Not included:
Verification
node --test packages/runtime/dist/__tests__/fake-backend.test.js(1 passed)npm --workspace @maka/runtime test(1229 passed, 2 skipped)npx playwright test --config e2e/playwright.config.ts(5 passed, run serially after the runtime build)User-facing impact
Development and E2E fake streams now preserve multiline and structured Markdown source through terminal completion. No production provider behavior, docs, changelog, migrations, or breaking changes.
Reviewer notes
The review focus is the source invariant: concatenated
text_deltapayloads must exactly equaltext_complete. The old expression deterministically violates it for line terminators; the runtime test is RED on the old expression and GREEN on this change.Checklist