Skip to content

fix(runtime): preserve line breaks in fake streams - #732

Merged
Astro-Han merged 7 commits into
mainfrom
fix/731-markdown-completion-handoff
Jul 11, 2026
Merged

Astro-Han merged 7 commits into
mainfrom
fix/731-markdown-completion-handoff

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

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 in text_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:

  • Make FakeBackend deltas concatenate exactly to text_complete, including Markdown line breaks.
  • Add a deterministic runtime stream-integrity regression test.

Not included:

  • No renderer, Streamdown, smooth-stream, or production provider behavior changes.
  • No Electron geometry regression. The attempted test sampled only after the completed Markdown root mounted, so it did not reliably exercise the handoff and was removed.

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)
  • CI: typecheck, test, and e2e passed

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_delta payloads must exactly equal text_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

  • Scope matches the PR title and excludes unrelated changes
  • Verification lists commands and results
  • User-facing impact and non-applicable docs/changelog/migrations are noted
  • Risk and review focus are called out
  • UI screenshots are not applicable because production UI code is unchanged

@Astro-Han
Astro-Han merged commit 3bf21ad into main Jul 11, 2026
3 checks passed
@Astro-Han
Astro-Han deleted the fix/731-markdown-completion-handoff branch July 11, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ui): prevent structured Markdown reflow during post-terminal handoff

1 participant