-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Parent: #499
Problem
Every frame re-runs tree-sitter syntax highlighting and pulldown_cmark markdown parsing for all visible messages. For responses with multiple code blocks, this can take tens of milliseconds per frame, compounding with the event loop issue (#500) to cause UI freezes.
Locations
crates/zeph-tui/src/widgets/chat.rs:render_md()called per message per framecrates/zeph-tui/src/widgets/chat.rs:push_code_block_text()callsSYNTAX_HIGHLIGHTER.highlight()per code block per framecrates/zeph-tui/src/widgets/chat.rs:wrap_spans()iterates char-by-char per line per frame
Fix
Add a render cache to App or ChatMessage:
- Cache key: message content hash + terminal width
- Cache value: pre-rendered
Vec<Line<'static>> - Invalidate when: content changes (streaming), terminal resizes, tool expanded/compact toggles
- Streaming messages: cache only after
streamingflag becomesfalse
This eliminates redundant markdown parsing, syntax highlighting, and word wrapping for finalized messages.
Acceptance Criteria
- Finalized messages are rendered from cache (no re-parsing)
- Streaming messages still update in real-time
- Cache invalidates on terminal resize
- Frame time measurably decreases with many code blocks visible
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request