Conversation
The `Event` enum variants have been converted from tuple structs to
named-field structs, each gaining an `indent: usize` field that carries
the visual column at which the renderer should place the content. For
example, `Event::Block(String)` becomes `Event::Block { content: String,
indent: usize }`.
A new `InList` buffer state replaces the old ad-hoc list-streaming logic
inside `handle_buffering_paragraph`. It tracks `marker_column`,
`content_column`, ordering, delimiter, and item count, and pushes/pops a
parent-state stack when entering nested containers (sub-lists or fenced
code blocks inside list items). Each sibling marker triggers an
immediate flush of the preceding item as a `Block` with the list's
`marker_column` as its visual indent, so items stream individually
rather than buffering the whole list.
The `Buffer::flush() -> Option<String>` API is replaced by
`flush_events() -> Vec<Event>`, which correctly splits any queued items
at sibling-marker boundaries, renumbers ordered-list markers relative to
`start_number + items_flushed`, and emits the final partial segment as a
`Flush` event with the right indent.
`TerminalOptions` gains an `indent` field, threaded through
`Formatter::format_terminal_with`, `TerminalWriter::new`, and the chat
renderer's `print_block` / `print_code` / `terminal_options` helpers.
`TerminalWriter` seeds its initial `prefix` with `indent` spaces so
every rendered line starts at the requested visual column. A new
`indent_lines` helper in the chat renderer prepends the indent to raw
code-block lines that have already been highlighted.
The practical effect: when an LLM streams a response with nested lists
or fenced code blocks inside list items, each item and code line now
renders at the correct visual column as it arrives, rather than being
buffered until the whole list is received or rendered at column 0.
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
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.
The
Eventenum variants have been converted from tuple structs to named-field structs, each gaining anindent: usizefield that carries the visual column at which the renderer should place the content. For example,Event::Block(String)becomesEvent::Block { content: String, indent: usize }.A new
InListbuffer state replaces the old ad-hoc list-streaming logic insidehandle_buffering_paragraph. It tracksmarker_column,content_column, ordering, delimiter, and item count, and pushes/pops a parent-state stack when entering nested containers (sub-lists or fenced code blocks inside list items). Each sibling marker triggers an immediate flush of the preceding item as aBlockwith the list'smarker_columnas its visual indent, so items stream individually rather than buffering the whole list.The
Buffer::flush() -> Option<String>API is replaced byflush_events() -> Vec<Event>, which correctly splits any queued items at sibling-marker boundaries, renumbers ordered-list markers relative tostart_number + items_flushed, and emits the final partial segment as aFlushevent with the right indent.TerminalOptionsgains anindentfield, threaded throughFormatter::format_terminal_with,TerminalWriter::new, and the chat renderer'sprint_block/print_code/terminal_optionshelpers.TerminalWriterseeds its initialprefixwithindentspaces so every rendered line starts at the requested visual column. A newindent_lineshelper in the chat renderer prepends the indent to raw code-block lines that have already been highlighted.The practical effect: when an LLM streams a response with nested lists or fenced code blocks inside list items, each item and code line now renders at the correct visual column as it arrives, rather than being buffered until the whole list is received or rendered at column 0.