Port grok-build streaming markdown rendering to coder-lite #104
- AtlantisPleb opened this issue 4d ago
-
AtlantisPleb
closed this as completed in
3b3a7b44d ago -
A Author 4d ago Done in
3b3a7b46fb. This one matters more than its number: coder-lite is the UI the owner will drive, so its rendering is the product.crates/coder-lite/src/markdown/carriesStreamingMarkdownRendererwith checkpoint freezing, syntect highlighting,anstyle/supports-coloradaptation, URL scanning with OSC 8, LaTeX→Unicode, tables, mermaid,MarkdownStyle, and CJK-awareword_wrap_lines_with_joiners(). Plus a wrap cache keyed by(width, generation)so frozen rows wrap once.Identity held.
markdown/theme.rsis ours, not ported: one amber on one background, elements told apart by weight/dim/italic/underline, syntect's colours flattened byamberize. A test asserts every painted cell on a page of mixed markdown is exactly#FFB000on#080600. Spinner frames and theEntry/CoderUiframe are unchanged.Mutation-verified rather than eyeballed. Disabling freezing →
reparsed 4612595 bytes for a 23090-byte document. Breaking the wrap cache →word-wrapped 90599 lines to display 599. Batching instead of streaming → all three streaming tests fail.Three bugs found by running it, two of them in the port itself. A hidden
link_outerglued URLs to their labels (the forgehttps://…); a visiblecode_languageswallowed the newline after a fence (rustfn main() {); and — caught only from a real frame dump —Entry::push_textappended a chunk toself.textbefore seeding the renderer fromself.text, so the first chunk of every stream rendered twice. That last one is the mirror of the rule this repo keeps enforcing: there were tests for content dropped and none for content duplicated. Both now covered.The rebase over four concurrent coder-lite commits kept all four, verified by a
rebase_contract.rssuite; one had silently reverted the bullet spacing and was restored.Judgement calls, flagged: edition 2024 for
coder-liteonly; new deps in the crate's ownCargo.tomlrather than the workspace's; the fence language tag is hidden, matching grok-build's production theme, with the body never hidden and a test for unknown languages;↳markers are not painted because upstream has none and adding a visible marker would change how coder-lite looks.642 tests pass, and
cargo run -p coder-lite -- --devbuilds and runs under a real pty.
Context
coder-lite currently renders assistant output with
ratatui-markdown. This gives basic bold/italic/lists/code blocks, but it is not the Grok Build engine.What grok-build has that we do not
StreamingMarkdownRendererwith checkpoint freezing — only re-renders the tail as new tokens arrive, avoiding O(n²) re-parsing.anstyle+supports-colorcolor adaptation for 16/256-color terminals.syntect-based syntax highlighting (vs optional tree-sitter).$E=mc^2$→E=mc²).word_wrap_lines_with_joiners()with CJK-aware width and continuation markers (↳) so copied text can be reconstructed.MarkdownStyleper-element padding/margins, vpad, block backgrounds, and thexai-grok-pagerEntryRendereraccent column /┃chrome.(width, generation, theme).Goal
Bring
crates/coder-litecloser to the Grok rendering / line spacing behavior. The engine lives inxai-org/grok-buildundercrates/codegen/xai-grok-markdownandcrates/codegen/xai-grok-pager/src/scrollback.This is a future work item; do not start until it is pulled into a sprint.