mirror of
https://github.com/zeronsh/comet.git
synced 2026-11-16 18:57:19 +00:00
* Render Mermaid diagrams in chat replies Assistant replies now draw ```mermaid fences as diagrams with the file preview's engine, fence frame, source toggle, Copy action and lightbox. Inline images in chat keep their text rendering. Streaming never renders a fence that may still be growing: only blocks a later row of the same reply follows, or blocks of a completed reply, request a diagram, so per-token commits start no render work. Until a diagram is ready the fence shows its source, and a failed render keeps the source with the engine's diagnostic in a header marker. Rows request their fences while laying out, so only painted diagrams are rendered, one at a time off the UI thread; requests whose rows scrolled away are dropped. Results are retained under a byte budget, least recently painted first out. A swap remeasures only the rows painting it and uses the existing layout signals, so the bottom pin follows and the own-turn runway absorbs the change without moving the sent prompt. * Account prepared SVGs at their current raster, not the largest possible decode_image reserved the largest preview any view could request (900x480 at 4x density) for every SVG and Mermaid diagram, so a 177x348 class diagram counted 7.6 MiB against the 64 MiB media budgets. The file preview stopped drawing diagrams after about eight per document, the chat cache retained about eight, and the lightbox had little room left to enlarge. Media now counts its source plus the CPU and GPU copies of the raster it holds. Since admission no longer reserves headroom, the file preview and the chat diagram cache re-check their budget before a larger re-raster (MediaImage::preview_within); a variant that does not fit keeps the current raster. * Draw Mermaid diagrams in Zeron's style Render diagrams on a transparent canvas so they sit on the fence body, with rounded hairline cards for nodes, muted labels and connectors, and a soft accent tint on default decisions, sequence notes and activations. Gantt bars take their hues from the accent and gridlines use the theme border. Explicit style and classDef colors are kept. Tighter spacing keeps labels larger once a diagram is scaled to the reading column, and the lightbox draws diagrams on a plate in the fence body color. * Gate Linux-only Mermaid cache test helpers ready_count and ready_media serve the transcript tests, which only compile on Linux, so they were dead code (with a warning) on macOS and Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Wing <contact@winglee.io> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
15 KiB
80 lines
15 KiB