Skip to content

Streaming markdown - #1920

Merged
easong-openai merged 25 commits into
mainfrom
easong/markdown-attempt-2
Aug 8, 2025
Merged

easong-openai merged 25 commits into
mainfrom
easong/markdown-attempt-2

Conversation

@easong-openai

Copy link
Copy Markdown
Contributor

We wait until we have an entire newline, then format it with markdown and stream in to the UI. This reduces time to first token but is the right thing to do with our current rendering model IMO. This will also make word wrapping a lot easier.

@easong-openai

Copy link
Copy Markdown
Contributor Author

Not ready to merge yet

@github-actions

github-actions Bot commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

Summary

Adds newline-delimited streaming support and robust word-wrapping:

  • core/client.rs now emits a final “\n\n” on response.reasoning_summary_text.done.
  • LiveRingWidget calculates height via wrapped lines; bottom_pane exposes test helpers; extensive unit/integration tests added.
  • ChatWidget rewrites buffering logic using new markdown_stream::{MarkdownNewlineCollector, RenderedLineStreamer} plus an interrupt queue for concurrent events.
  • New modules/tests (markdown_stream, vt100_streaming_no_dup, etc.) improve coverage.

Review

Looks like a well-scoped quality-of-life update—better streaming UX and testability.

Strengths

  • core/src/client.rs hunk @@-484 handles the missing newline elegantly, preventing UI bleed-through.
  • tui/src/bottom_pane/live_ring_widget.rs hunks @@-29/-40 correctly reuse the shared word_wrap_lines helper—no mid-word splits, unit+integration tests confirm.
  • Helpful #[cfg(test)] accessors (e.g., bottom_pane mod hunk @@-369) keep production surface minimal while enabling granular assertions.

Suggestions

  • tui/markdown_stream.rs: consider a brief module-level doc explaining the newline-gating contract so future contributors know why collectors/streamers are paired.
  • LiveRingWidget desired_height (hunk @@-29): word_wrap_lines counts plain lines; if wide-glyph (double-width) support is planned, note that this may under-estimate width.
  • ChatWidget interrupt queue logic (large addition starting at hunk @@-112): a small comment on ordering guarantees (FIFO vs priority) would clarify expectations for future maintainers.

Otherwise, code is tidy, tests comprehensive—good to merge once CI is green!


View workflow run

| "response.reasoning_summary_part.added"
| "response.reasoning_summary_text.done" => {
// Currently, we ignore these events, but we handle them
| "response.reasoning_summary_part.added" => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we want this change independent of the markdown work?

// Currently, we ignore this event, but we handle it
// separately to skip the logging message in the `other` case.
}
"response.reasoning_summary_text.done" => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong line, I meant this one

let line = lines[i];
let trimmed_start = line.trim_start();
let fence_token = if trimmed_start.starts_with("```") {
"```"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I believe a fenced code block is "at least three backticks" [where the closing delimiter has to be the same number] so that you can have a sequence of three backticks in the code block. Admittedly pretty rare and not sure if our models would take advantage of that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do if you ask them to write a markdown tutorial!

@easong-openai
easong-openai merged commit 2b71398 into main Aug 8, 2025
@easong-openai
easong-openai deleted the easong/markdown-attempt-2 branch August 8, 2025 01:26
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants