CanvasAnvil is an open source AI diagram maker and flowchart generator - an infinite-canvas diagram editor and self-hosted drawio alternative that writes editable .drawio files. Text to diagram, then fix nodes, layout and labels in place. Also AI presentations, interior design CAD/BOM, posters and infographics.
TypeScript ai-agentsai-diagramai-presentationbomcadcanvasdiagramdiagram-generatordrawioflowchartinfographicspptppt-generatorpresentation-generatorreactsvgedittext-to-diagramtypescriptworkflow
feat(ui): give streaming a caret, and let wide tables scroll
codingFeng101ede81ebd7220
diff --git a/client/index.css b/client/index.cssindex 5810a9d..fbda825 100644--- a/client/index.css+++ b/client/index.css@@ -191,6 +191,43 @@box-shadow: inset 0 0 0 1px hsl(var(--border) / 0.7);}+ /* ---------------------------------------------------------------------+ Streaming caret.++ Sits at the end of the text the model is still writing. Attached with+ ::after rather than by splicing a node into the markdown output, so the+ renderer stays untouched and the caret lands on whatever the last block+ happens to be.++ Lists get it on their final item instead -- an ::after on the <ul> itself+ would break to its own line. `pre` and `table` are excluded: a blinking+ block inside a code fence or a table cell reads as content.+ --------------------------------------------------------------------- */+ .streaming-caret > :last-child:not(ul):not(ol):not(pre):not(table)::after,+ .streaming-caret > ul:last-child > li:last-child::after,+ .streaming-caret > ol:last-child > li:last-child::after {+ content: "";+ display: inline-block;+ width: 0.42em;+ height: 1.05em;+ margin-left: 0.1em;+ vertical-align: -0.19em;+ border-radius: 1px;+ background: hsl(var(--primary));+ animation: caret-blink 1.05s steps(1, end) infinite;+ }++ @keyframes caret-blink {+ 0%, 45% { opacity: 1; }+ 55%, 100% { opacity: 0; }+ }++ /* Wide tables scroll inside the message instead of stretching the panel. */+ .prose-scroll-x {+ overflow-x: auto;+ max-width: 100%;+ }+/* Paper grain for the landing ground. Cheap: one repeating gradient pair,no image request. */.bg-paper {diff --git a/client/workspaces/cad/chat/ChatMessageDisplay.tsx b/client/workspaces/cad/chat/ChatMessageDisplay.tsxindex 29a793c..b8a62b0 100644--- a/client/workspaces/cad/chat/ChatMessageDisplay.tsx+++ b/client/workspaces/cad/chat/ChatMessageDisplay.tsx@@ -739,12 +739,13 @@ export function ChatMessageDisplay({</div>);}- const renderMarkdown = (key: string, content: string) => (+ const renderMarkdown = (key: string, content: string, withCaret = false) => (<div key={key} className={cn(// No `dark:prose-invert`: the prose variables are driven// from the tokens now, and invert would overwrite them// with the plugin's own greys.- "prose prose-sm max-w-none break-words [overflow-wrap:anywhere] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0"+ "prose prose-sm max-w-none break-words [overflow-wrap:anywhere] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",+ withCaret && "streaming-caret")}><ReactMarkdownremarkPlugins={[remarkGfm]}@@ -756,6 +757,15 @@ export function ChatMessageDisplay({return "";}}components={{+ table({ children, ...props }: any) {+ return (+ <div className="prose-scroll-x my-4">+ <table {...props} className={cn("my-0", props?.className)}>+ {children}+ </table>+ </div>+ );+ },th({ children, ...props }: any) {return (<th@@ -828,7 +838,14 @@ export function ChatMessageDisplay({<div className="w-full min-w-0 max-w-full overflow-hidden break-words [overflow-wrap:anywhere] py-1 text-sm leading-relaxed text-foreground"><div className="space-y-3">{textSegments.map((seg, segIdx) =>- renderMarkdown(`${message.id}-assistant-markdown-${idx}-${segIdx}`, seg.content)+ renderMarkdown(+ `${message.id}-assistant-markdown-${idx}-${segIdx}`,+ seg.content,+ status === "streaming" &&+ isLastAssistantMessage &&+ codeSegments.length === 0 &&+ segIdx === textSegments.length - 1,+ ))}</div></div>diff --git a/client/workspaces/flow/chat/ChatMessageDisplay.tsx b/client/workspaces/flow/chat/ChatMessageDisplay.tsxindex 5f6c9d8..05f9cbd 100644--- a/client/workspaces/flow/chat/ChatMessageDisplay.tsx+++ b/client/workspaces/flow/chat/ChatMessageDisplay.tsx@@ -1,6 +1,7 @@"use client"import remarkGfm from "remark-gfm"+import { cn } from "@/shared/lib/utils"import {getMessageTextContent,getUserOriginalText,@@ -1065,11 +1066,33 @@ export function ChatMessageDisplay({) : (<divkey={`${message.id}-textsection-${partIndex}-${sectionIndex}`}- className="prose prose-sm max-w-none break-words [&>*:first-child]:mt-0 [&>*:last-child]:mb-0"+ className={cn(+ "prose prose-sm max-w-none break-words [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",+ // Caret only on the tail of the message still being written.+ status === "streaming" &&+ isLastAssistantMessage &&+ sectionIndex === sections.length - 1 &&+ "streaming-caret",+ )}><ReactMarkdownremarkPlugins={[remarkGfm]}components={{+ table({+ children,+ ...props+ }: any) {+ return (+ <div className="prose-scroll-x my-4">+ <table+ {...props}+ className={cn("my-0", props?.className)}+ >+ {children}+ </table>+ </div>+ )+ },code({className,children,diff --git a/client/workspaces/ppt/chat/ChatMessageDisplay.tsx b/client/workspaces/ppt/chat/ChatMessageDisplay.tsxindex 4ea8ab8..1fe5d80 100644--- a/client/workspaces/ppt/chat/ChatMessageDisplay.tsx+++ b/client/workspaces/ppt/chat/ChatMessageDisplay.tsx@@ -557,7 +557,12 @@ export function ChatMessageDisplay({}return (<div key={idx} className={cn(- "prose prose-sm max-w-none break-words"+ "prose prose-sm max-w-none break-words",+ // Only the tail of the message being written gets the caret.+ status === "streaming" &&+ isLastAssistantMessage &&+ idx === sections.length - 1 &&+ "streaming-caret",)}><ReactMarkdownremarkPlugins={[remarkGfm]}@@ -569,6 +574,15 @@ export function ChatMessageDisplay({return "";}}components={{+ table({ children, ...props }: any) {+ return (+ <div className="prose-scroll-x my-4">+ <table {...props} className={cn("my-0", props?.className)}>+ {children}+ </table>+ </div>+ );+ },th({ children, ...props }: any) {return (<thdiff --git a/client/workspaces/ppt/chat/code-block.tsx b/client/workspaces/ppt/chat/code-block.tsxindex 2c36178..ca4267d 100644--- a/client/workspaces/ppt/chat/code-block.tsx+++ b/client/workspaces/ppt/chat/code-block.tsx@@ -1,7 +1,9 @@import { useMemo, useRef, useState } from 'react';import { Highlight, type Language } from "prism-react-renderer";import { syntaxTheme } from "@/shared/chat/syntax-theme";-import { ChevronRight, Loader2 } from 'lucide-react';+import { Shimmer } from "@/shared/chat/shimmer";+import { useUiLanguage } from "@/shared/i18n";+import { ChevronRight } from 'lucide-react';import { cn } from '@/shared/lib/utils';interface CodeBlockProps {@@ -14,6 +16,7 @@ interface CodeBlockProps {const openStateById = new Map<string, boolean>();export function CodeBlock({ code, language = "xml", isStreaming = false, blockId }: CodeBlockProps) {+ const uiLang = useUiLanguage();const [isOpen, setIsOpen] = useState(() => {if (blockId && openStateById.has(blockId)) return Boolean(openStateById.get(blockId));return false;@@ -66,10 +69,14 @@ export function CodeBlock({ code, language = "xml", isStreaming = false, blockId<span className="uppercase font-semibold tracking-wider text-foreground/80">{normalizedLanguage}</span>{isStreaming ? (- <div className="flex items-center gap-2 ml-auto">- <span className="text-[10px] text-primary-strong animate-pulse">Generating code...</span>- <Loader2 className="w-3.5 h-3.5 animate-spin text-primary-strong" />- </div>+ // Same in-progress idiom as the chat's "thinking" line, and+ // translated -- this was the one hardcoded English string+ // left in the panel.+ <span className="ml-auto">+ <Shimmer as="span" className="text-[10px]" duration={1.6}>+ {uiLang === "zh" ? "正在生成代码..." : "Generating code..."}+ </Shimmer>+ </span>) : (<span className="ml-auto text-[10px] opacity-70 font-mono">{normalizedCode.length} chars</span>)}