Skip to content

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.

feat(ui): take the chat area down to the details, and finish the surfaces

codingFeng101d10df74f4cc6
diff --git a/client/app/SettingsDialog.tsx b/client/app/SettingsDialog.tsx
index 2f93c19..d24b454 100644
--- a/client/app/SettingsDialog.tsx
+++ b/client/app/SettingsDialog.tsx
@@ -106,7 +106,7 @@ function SecretInput({
href={docsUrl}
target="_blank"
rel="noreferrer"
- className="inline-flex items-center gap-1 text-xs text-primary hover:underline"
+ className="inline-flex items-center gap-1 text-xs text-primary-strong hover:underline"
>
{uiLang === "zh" ? "获取 Key" : "Get Key"}
<ExternalLink className="h-3.5 w-3.5" />
@@ -277,7 +277,7 @@ export function SettingsDialog() {
{isOpen &&
createPortal(
- <div className="animate-in fade-in fixed inset-0 z-[100] flex items-center justify-center bg-black/40 p-4 duration-200 backdrop-blur-sm">
+ <div className="animate-in fade-in fixed inset-0 z-[100] flex items-center justify-center bg-overlay/45 p-4 duration-base backdrop-blur-sm">
<div className="animate-in zoom-in-95 flex max-h-[90vh] w-full max-w-4xl flex-col overflow-hidden rounded-xl border border-border/50 bg-background shadow-2xl duration-200">
<div className="flex items-center justify-between border-b border-border/50 bg-muted/10 p-6">
<div>
diff --git a/client/index.css b/client/index.css
index e6d2118..5810a9d 100644
--- a/client/index.css
+++ b/client/index.css
@@ -23,9 +23,15 @@
--popover: 0 0% 100%;
--popover-foreground: 30 4% 10%;
- /* Clay — the one saturated colour in the system. Used sparingly. */
+ /* Clay — the one saturated colour in the system. Used sparingly.
+
+ Two values, because clay does two jobs. `--primary` is a fill, judged
+ against the near-white text sitting on it. As body text on a light
+ ground it only reaches 3.07:1, under AA, so anything clay-coloured and
+ small uses `--primary-strong` instead (5.6:1). */
--primary: 15 63% 60%;
--primary-foreground: 48 33% 98%;
+ --primary-strong: 15 58% 42%;
--secondary: 45 20% 93%;
--secondary-foreground: 30 6% 20%;
@@ -84,6 +90,8 @@
--primary: 15 63% 62%;
--primary-foreground: 30 5% 10%;
+ /* On the dark ground the fill value already clears AA as text (5.2:1). */
+ --primary-strong: 15 63% 62%;
--secondary: 48 3% 21%;
--secondary-foreground: 45 12% 90%;
diff --git a/client/pages/portal/PortalPage.tsx b/client/pages/portal/PortalPage.tsx
index 11074dc..b7f7383 100644
--- a/client/pages/portal/PortalPage.tsx
+++ b/client/pages/portal/PortalPage.tsx
@@ -339,7 +339,7 @@ function Header({
"relative whitespace-normal px-2.5 pb-2.5 pt-2 text-center font-medium leading-tight 2xl:max-w-none",
"transition-colors duration-fast ease-out-soft",
isChinese ? "max-w-[118px] text-[15px] 2xl:text-[16px]" : "max-w-[112px] text-[13px] 2xl:text-[14px]",
- isActive ? "text-primary" : "text-foreground/70 hover:text-foreground",
+ isActive ? "text-primary-strong" : "text-foreground/70 hover:text-foreground",
)}
onMouseEnter={() => id !== "home" && setActiveCanvas(id)}
onFocus={() => id !== "home" && setActiveCanvas(id)}
@@ -434,7 +434,7 @@ function SimpleCanvasDetailPage({
<h1 className={cn("font-display font-semibold text-foreground", isEnglish ? "text-[clamp(34px,3.5vw,50px)] leading-[1.05]" : "text-[clamp(40px,4.4vw,62px)] leading-[1.08]")}>{config.title}</h1>
</StaggerItem>
<StaggerItem>
- <h2 className={cn("font-display font-semibold leading-tight text-primary", isEnglish ? "mt-2 text-[clamp(18px,1.75vw,23px)]" : "mt-2.5 text-[clamp(22px,2.2vw,30px)]")}>{config.subtitle}</h2>
+ <h2 className={cn("font-display font-semibold leading-tight text-primary-strong", isEnglish ? "mt-2 text-[clamp(18px,1.75vw,23px)]" : "mt-2.5 text-[clamp(22px,2.2vw,30px)]")}>{config.subtitle}</h2>
</StaggerItem>
<StaggerItem>
<p className={cn("max-w-[620px] text-muted-foreground", isEnglish ? "mt-4 text-[clamp(15px,1.2vw,16px)] leading-7" : "mt-5 text-[17px] leading-8")}>{config.intro}</p>
@@ -450,7 +450,7 @@ function SimpleCanvasDetailPage({
isEnglish ? "px-4 py-2.5 text-[14px]" : "px-4 py-2.5 text-[15px]",
)}
>
- <Icon className="h-4 w-4 text-primary" />
+ <Icon className="h-4 w-4 text-primary-strong" />
<span className="whitespace-normal">{tag}</span>
</span>
))}
@@ -459,14 +459,14 @@ function SimpleCanvasDetailPage({
<StaggerItem className={cn(isEnglish ? "mt-5 space-y-2.5" : "mt-6 space-y-3")}>
{config.bullets.map((bullet) => (
<div key={bullet} className={cn("flex items-start gap-3 text-muted-foreground", isEnglish ? "text-[15px] leading-6" : "text-[16px] leading-7")}>
- <CheckCircle2 className="mt-1 h-[18px] w-[18px] shrink-0 text-primary" />
+ <CheckCircle2 className="mt-1 h-[18px] w-[18px] shrink-0 text-primary-strong" />
<span>{bullet}</span>
</div>
))}
</StaggerItem>
<StaggerItem className={cn(isEnglish ? "mt-6" : "mt-7")}>
- <div className={cn("max-w-[540px] font-display font-semibold text-primary", isEnglish ? "mb-2 text-[16px] leading-6" : "mb-2.5 text-[19px] leading-7")}>{config.slogan}</div>
+ <div className={cn("max-w-[540px] font-display font-semibold text-primary-strong", isEnglish ? "mb-2 text-[16px] leading-6" : "mb-2.5 text-[19px] leading-7")}>{config.slogan}</div>
{/* The brush-stroke plate stays — a hand-made mark suits the brand.
Only the palette moves from blueprint blue to clay. */}
<button
@@ -686,7 +686,7 @@ export function PortalPage({ onEnterWorkspace }: PortalPageProps) {
<span className="block">{copy.titleA}</span>
<span className="block">
<span>{copy.titleB}</span>
- <span className="text-primary">{copy.titleAccent}</span>
+ <span className="text-primary-strong">{copy.titleAccent}</span>
</span>
</h1>
</StaggerItem>
@@ -794,7 +794,7 @@ export function PortalPage({ onEnterWorkspace }: PortalPageProps) {
</section>
<section className="xl:hidden">
- <div className="mb-3 text-sm font-medium text-primary">{copy.mobileHint}</div>
+ <div className="mb-3 text-sm font-medium text-primary-strong">{copy.mobileHint}</div>
<div className="grid gap-3 sm:grid-cols-2">
{portalCanvasItems.map((item) => (
<button
diff --git a/client/shared/chat/chat-input.tsx b/client/shared/chat/chat-input.tsx
index 4e46675..68d6cb2 100644
--- a/client/shared/chat/chat-input.tsx
+++ b/client/shared/chat/chat-input.tsx
@@ -194,7 +194,7 @@ export function ChatInput({
el.setAttribute("data-token-kind", segment.tokenKind);
el.setAttribute("contenteditable", "false");
el.className = isOutline
- ? "inline-flex items-center gap-1.5 rounded-full border border-primary/30 bg-primary/[0.08] px-2 py-0.5 text-xs font-medium text-primary align-middle"
+ ? "inline-flex items-center gap-1.5 rounded-full border border-primary/30 bg-primary/[0.08] px-2 py-0.5 text-xs font-medium text-primary-strong align-middle"
: "inline-flex items-center gap-1.5 rounded-full border border-destructive/25 bg-destructive/[0.08] px-2 py-0.5 text-xs font-medium text-destructive align-middle";
const icon = document.createElement("span");
icon.className = isOutline
diff --git a/client/shared/chat/file-preview-list.tsx b/client/shared/chat/file-preview-list.tsx
index 267e0c8..f43d198 100644
--- a/client/shared/chat/file-preview-list.tsx
+++ b/client/shared/chat/file-preview-list.tsx
@@ -121,11 +121,11 @@ export function FilePreviewList({
) : (
<>
{pdfInfo?.isExtracting ? (
- <Loader2 className="h-5 w-5 text-primary animate-spin" />
+ <Loader2 className="h-5 w-5 text-primary-strong animate-spin" />
) : isPdf ? (
<FileText className="h-5 w-5 text-destructive" />
) : (
- <FileCode className="h-5 w-5 text-primary" />
+ <FileCode className="h-5 w-5 text-primary-strong" />
)}
</>
)}
diff --git a/client/shared/chat/history-dialog.tsx b/client/shared/chat/history-dialog.tsx
index 4c0c96f..91cbb94 100644
--- a/client/shared/chat/history-dialog.tsx
+++ b/client/shared/chat/history-dialog.tsx
@@ -74,7 +74,7 @@ export function HistoryDialog({
<div key={item.id} className="p-3 rounded-lg border border-border/50 bg-muted/20 hover:bg-muted/40 transition-colors flex items-center justify-between group">
<div className="flex flex-col gap-1 overflow-hidden">
<div className="flex items-center gap-2 text-sm font-medium">
- <span className="w-6 h-6 rounded-full bg-primary/12 text-primary flex items-center justify-center text-xs">
+ <span className="w-6 h-6 rounded-full bg-primary/12 text-primary-strong flex items-center justify-center text-xs">
{history.length - index}
</span>
<span>{formatDate(item.timestamp)}</span>
diff --git a/client/shared/chat/message-content.ts b/client/shared/chat/message-content.ts
index 34d2b9d..893563f 100644
--- a/client/shared/chat/message-content.ts
+++ b/client/shared/chat/message-content.ts
@@ -100,3 +100,20 @@ export function getUserOriginalText(message: UIMessage): string {
.replace(/\n\n\[(PDF|File):\s*[^\]]+\]\n[\s\S]*$/, "")
.trim();
}
+
+/**
+ * Whether a markdown `code` node is a fenced block rather than an inline span.
+ *
+ * react-markdown stopped passing an `inline` prop in v9, but the chat panels
+ * were still branching on it against v10. It is always `undefined` there, so
+ * `if (!inline)` matched everything and every inline `code` span rendered as a
+ * full-width code block.
+ *
+ * A tagged fence carries `language-*`; an untagged one still spans lines. A
+ * single-line untagged fence is the one case this reads as inline, which costs
+ * a chip instead of a block.
+ */
+export function isFencedCode(className?: string, children?: unknown): boolean {
+ if (/\blanguage-\w+/.test(String(className || ""))) return true;
+ return String(children ?? "").includes("\n");
+}
diff --git a/client/shared/chat/syntax-theme.ts b/client/shared/chat/syntax-theme.ts
new file mode 100644
index 0000000..5f9f59a
--- /dev/null
+++ b/client/shared/chat/syntax-theme.ts
@@ -0,0 +1,60 @@
+import type { PrismTheme } from "prism-react-renderer";
+
+/**
+ * Syntax colours for every code block in the app.
+ *
+ * All three chat panels used `themes.github`, a fixed light theme that also
+ * paints its own white background -- so once the surrounding panel followed the
+ * dark tokens, code blocks stayed a bright island in the middle of it.
+ *
+ * These are CSS variable references rather than literals, so the theme reacts
+ * to the token flip like everything else. The palette is deliberately narrow:
+ * most code is plain foreground, and only four roles get a hue.
+ */
+export const syntaxTheme: PrismTheme = {
+ plain: {
+ color: "hsl(var(--foreground) / 0.9)",
+ // Transparent so the block's own token surface shows through.
+ backgroundColor: "transparent",
+ },
+ styles: [
+ {
+ types: ["comment", "prolog", "doctype", "cdata"],
+ style: { color: "hsl(var(--muted-foreground) / 0.8)", fontStyle: "italic" },
+ },
+ {
+ types: ["punctuation"],
+ style: { color: "hsl(var(--muted-foreground) / 0.7)" },
+ },
+ {
+ types: ["tag", "keyword", "selector", "at-rule", "rule"],
+ style: { color: "hsl(var(--primary))" },
+ },
+ {
+ types: ["string", "attr-value", "char", "inserted"],
+ style: { color: "hsl(var(--success))" },
+ },
+ {
+ types: ["number", "boolean", "constant", "symbol"],
+ style: { color: "hsl(var(--warning))" },
+ },
+ {
+ types: ["attr-name", "property", "variable"],
+ style: { color: "hsl(var(--foreground) / 0.72)" },
+ },
+ {
+ types: ["function", "class-name"],
+ style: { color: "hsl(var(--foreground))", fontWeight: "500" },
+ },
+ {
+ types: ["operator", "entity", "url"],
+ style: { color: "hsl(var(--foreground) / 0.8)" },
+ },
+ {
+ types: ["deleted"],
+ style: { color: "hsl(var(--destructive))" },
+ },
+ { types: ["important", "bold"], style: { fontWeight: "600" } },
+ { types: ["italic"], style: { fontStyle: "italic" } },
+ ],
+};
diff --git a/client/shared/ui/button.tsx b/client/shared/ui/button.tsx
index f1bfafe..1301882 100644
--- a/client/shared/ui/button.tsx
+++ b/client/shared/ui/button.tsx
@@ -31,7 +31,7 @@ const buttonVariants = cva(
ghost:
"hover:bg-accent hover:text-accent-foreground",
link:
- "text-primary underline-offset-4 hover:underline active:translate-y-0",
+ "text-primary-strong underline-offset-4 hover:underline active:translate-y-0",
},
size: {
default: "h-9 px-4 py-2 has-[>svg]:px-3",
diff --git a/client/workspaces/cad/canvas/CadCanvas.tsx b/client/workspaces/cad/canvas/CadCanvas.tsx
index c92e0d8..1ce8c38 100644
--- a/client/workspaces/cad/canvas/CadCanvas.tsx
+++ b/client/workspaces/cad/canvas/CadCanvas.tsx
@@ -711,7 +711,7 @@ export function CadCanvas({
<div className="w-full h-full pt-16 p-6">
{viewMode === "analysis" && (
- <div className="w-full h-full bg-white dark:bg-zinc-900 shadow-sm rounded-xl overflow-auto border border-border/50 p-4">
+ <div className="w-full h-full bg-card shadow-soft rounded-xl overflow-auto border border-border/50 p-4">
<div className="grid gap-4 grid-cols-1 md:grid-cols-2">
{analysisSlots.map((img, idx) => (
<div key={`${img.title}-${idx}`} className="rounded-xl border border-border/50 overflow-hidden bg-background">
@@ -768,7 +768,7 @@ export function CadCanvas({
)}
{viewMode === "renders" && (
- <div className="w-full h-full bg-white dark:bg-zinc-900 shadow-sm rounded-xl overflow-auto border border-border/50 p-4">
+ <div className="w-full h-full bg-card shadow-soft rounded-xl overflow-auto border border-border/50 p-4">
<div className="grid gap-4 grid-cols-1 md:grid-cols-2 xl:grid-cols-3">
{renderSlots.map((img, idx) => (
<div key={`${img.title}-${idx}`} className="rounded-xl border border-border/50 overflow-hidden bg-background">
@@ -814,7 +814,7 @@ export function CadCanvas({
)}
{viewMode === "bom" && (
- <div className="w-full h-full bg-white dark:bg-zinc-900 shadow-sm rounded-xl overflow-auto border border-border/50 p-4">
+ <div className="w-full h-full bg-card shadow-soft rounded-xl overflow-auto border border-border/50 p-4">
{!bom || !Array.isArray(bom.columns) || bom.columns.length === 0 ? (
<div className="h-full w-full flex items-center justify-center text-muted-foreground text-sm">
{uiLang === "zh" ? "暂无物料清单" : "No BOM yet"}
diff --git a/client/workspaces/cad/chat/ChatMessageDisplay.tsx b/client/workspaces/cad/chat/ChatMessageDisplay.tsx
index 1854f78..ac47176 100644
--- a/client/workspaces/cad/chat/ChatMessageDisplay.tsx
+++ b/client/workspaces/cad/chat/ChatMessageDisplay.tsx
@@ -1,8 +1,8 @@
import React, { useRef, useEffect, useState, useCallback } from 'react';
-import { Check, ChevronDown, ChevronUp, Copy, Cpu, FileCode, FileText, Loader2, Minus, Pencil, Plus, Play, RotateCcw } from "lucide-react";
+import { Check, ChevronDown, ChevronUp, Copy, Cpu, FileCode, FileText, Minus, Pencil, Plus, Play, RotateCcw } from "lucide-react";
import ReactMarkdown from "react-markdown";
import remarkGfm from 'remark-gfm';
-import { Reasoning, ReasoningContent, ReasoningTrigger } from "@/shared/chat";
+import { Reasoning, ReasoningContent, ReasoningTrigger, Shimmer } from "@/shared/chat";
import { ScrollArea } from "@/shared/ui/scroll-area";
import { CodeBlock } from "@/workspaces/cad/chat/code-block";
import { useUiLanguage } from "@/shared/i18n";
@@ -533,7 +533,7 @@ export function ChatMessageDisplay({
className={cn(
"mx-0.5 inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium align-middle",
kind === "outline"
- ? "border-primary/25 bg-primary/[0.08] text-primary"
+ ? "border-primary/25 bg-primary/[0.08] text-primary-strong"
: "border-border bg-muted text-foreground/80"
)}
>
@@ -610,7 +610,7 @@ export function ChatMessageDisplay({
"inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] leading-4",
message.role === "user"
? t.kind === "outline"
- ? "border-primary/25 bg-primary/[0.08] text-primary"
+ ? "border-primary/25 bg-primary/[0.08] text-primary-strong"
: "border-border bg-muted text-foreground/80"
: "border-border bg-muted/40 text-foreground"
)}
@@ -643,7 +643,7 @@ export function ChatMessageDisplay({
{section.fileType === 'pdf' ? (
<FileText className="h-4 w-4 text-destructive" />
) : (
- <FileCode className="h-4 w-4 text-primary" />
+ <FileCode className="h-4 w-4 text-primary-strong" />
)}
<span className="text-xs font-medium truncate max-w-[150px] text-foreground">{section.filename}</span>
<span className="text-[10px] text-muted-foreground">({section.charCount} chars)</span>
@@ -679,7 +679,7 @@ export function ChatMessageDisplay({
className={cn(
"mx-1 inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium align-middle",
kind === "outline"
- ? "border-primary/25 bg-primary/[0.08] text-primary"
+ ? "border-primary/25 bg-primary/[0.08] text-primary-strong"
: "border-border bg-muted text-foreground/80"
)}
title={tr(`幻灯片 · ${label}`, `Slide · ${label}`)}
@@ -748,8 +748,10 @@ export function ChatMessageDisplay({
}
const renderMarkdown = (key: string, content: string) => (
<div key={key} className={cn(
- "prose prose-sm max-w-none break-words [overflow-wrap:anywhere] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
- "dark:prose-invert"
+ // 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"
)}>
<ReactMarkdown
remarkPlugins={[remarkGfm]}
@@ -827,8 +829,10 @@ export function ChatMessageDisplay({
return (
<div key={`${message.id}-assistant-seg-${idx}`} className="w-full min-w-0 max-w-full overflow-hidden space-y-2">
+ {/* No inner bubble here: the outer row already drops the card
+ for the assistant, and this was quietly putting it back. */}
{textSegments.length > 0 && (
- <div className="w-full min-w-0 max-w-full overflow-hidden break-words [overflow-wrap:anywhere] px-4 py-3 text-sm leading-relaxed bg-muted/60 text-foreground rounded-2xl rounded-bl-md">
+ <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)
@@ -873,7 +877,7 @@ export function ChatMessageDisplay({
<div className="flex items-center justify-between px-4 py-3 bg-muted/50">
<div className="flex items-center gap-2">
<div className="w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center">
- <Cpu className="w-3.5 h-3.5 text-primary" />
+ <Cpu className="w-3.5 h-3.5 text-primary-strong" />
</div>
<span className="text-sm font-medium text-foreground/80">
{tr("编辑图纸", "Edit Diagram")}
@@ -1031,10 +1035,9 @@ export function ChatMessageDisplay({
{showPendingIndicator && (
<div className="flex w-full justify-start animate-message-in mt-3">
<div className="max-w-[85%] min-w-0">
- <div className="flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground bg-muted/40 rounded-2xl rounded-bl-md">
- <Loader2 className="h-3 w-3 animate-spin" />
- <span>{tr("思考中...", "Thinking...")}</span>
- </div>
+ <Shimmer as="span" className="py-1 text-sm" duration={1.6}>
+ {tr("思考中...", "Thinking...")}
+ </Shimmer>
</div>
</div>
)}
diff --git a/client/workspaces/cad/chat/code-block.tsx b/client/workspaces/cad/chat/code-block.tsx
index b010ddb..e289935 100644
--- a/client/workspaces/cad/chat/code-block.tsx
+++ b/client/workspaces/cad/chat/code-block.tsx
@@ -1,6 +1,7 @@
import { useMemo, useState } from "react";
import { Check, ChevronDown, ChevronUp, Copy, Cpu, Play, X } from "lucide-react";
-import { Highlight, themes, type Language } from "prism-react-renderer";
+import { Highlight, type Language } from "prism-react-renderer";
+import { syntaxTheme } from "@/shared/chat/syntax-theme";
import { useUiLanguage } from "@/shared/i18n";
interface CodeBlockProps {
@@ -148,7 +149,7 @@ export function CodeBlock({
<div className="flex items-center justify-between px-4 py-3 bg-muted/50">
<div className="flex items-center gap-2">
<div className="w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center">
- <Cpu className="w-3.5 h-3.5 text-primary" />
+ <Cpu className="w-3.5 h-3.5 text-primary-strong" />
</div>
<span className="text-sm font-medium text-foreground/80">{tr("生成 CAD", "Generate CAD")}</span>
</div>
@@ -221,7 +222,7 @@ export function CodeBlock({
<span>{copied ? tr("已复制", "Copied") : tr("复制", "Copy")}</span>
</button>
</div>
- <Highlight theme={themes.github} code={displayCode} language={prismLanguage}>
+ <Highlight theme={syntaxTheme} code={displayCode} language={prismLanguage}>
{({
className: _className,
style,
diff --git a/client/workspaces/flow/chat/ChatInput.tsx b/client/workspaces/flow/chat/ChatInput.tsx
index aebe459..673255b 100644
--- a/client/workspaces/flow/chat/ChatInput.tsx
+++ b/client/workspaces/flow/chat/ChatInput.tsx
@@ -434,7 +434,7 @@ export function ChatInput({
<Brain
className={`h-3.5 w-3.5 ${
deepThinkingEnabled
- ? "text-primary"
+ ? "text-primary-strong"
: "text-muted-foreground"
}`}
/>
diff --git a/client/workspaces/flow/chat/ChatMessageDisplay.tsx b/client/workspaces/flow/chat/ChatMessageDisplay.tsx
index 481f58e..93c4c36 100644
--- a/client/workspaces/flow/chat/ChatMessageDisplay.tsx
+++ b/client/workspaces/flow/chat/ChatMessageDisplay.tsx
@@ -1,8 +1,10 @@
"use client"
+import remarkGfm from "remark-gfm"
import {
getMessageTextContent,
getUserOriginalText,
+ isFencedCode,
splitTextIntoFileSections,
type TextSection,
} from "@/shared/chat/message-content"
@@ -33,7 +35,6 @@ import {
Cpu,
FileCode,
FileText,
- Loader2,
Pencil,
Play,
RotateCcw,
@@ -47,6 +48,7 @@ import {
Reasoning,
ReasoningContent,
ReasoningTrigger,
+ Shimmer,
} from "@/shared/chat"
import { ScrollArea } from "@/shared/ui/scroll-area"
import { useFlowT } from "@/workspaces/flow/lib/translations"
@@ -350,7 +352,7 @@ export function ChatMessageDisplay({
<div className="flex items-center justify-between px-4 py-3 bg-muted/50">
<div className="flex items-center gap-2">
<div className="w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center">
- <Cpu className="w-3.5 h-3.5 text-primary" />
+ <Cpu className="w-3.5 h-3.5 text-primary-strong" />
</div>
<span className="text-sm font-medium text-foreground/80">
{getToolDisplayName(toolName)}
@@ -854,7 +856,7 @@ export function ChatMessageDisplay({
"pdf" ? (
<FileText className="h-4 w-4 text-destructive" />
) : (
- <FileCode className="h-4 w-4 text-primary" />
+ <FileCode className="h-4 w-4 text-primary-strong" />
)}
<span className="text-xs font-medium leading-none">
{
@@ -1063,18 +1065,18 @@ export function ChatMessageDisplay({
) : (
<div
key={`${message.id}-textsection-${partIndex}-${sectionIndex}`}
- className="prose prose-sm max-w-none break-words [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 dark:prose-invert"
+ className="prose prose-sm max-w-none break-words [&>*:first-child]:mt-0 [&>*:last-child]:mb-0"
>
<ReactMarkdown
+ remarkPlugins={[remarkGfm]}
components={{
code({
- inline,
className,
children,
...props
}: any) {
if (
- inline
+ !isFencedCode(className, children)
) {
return (
<code
@@ -1233,14 +1235,11 @@ export function ChatMessageDisplay({
{showPendingIndicator && (
<div className="flex w-full justify-start animate-message-in mt-3">
<div className="max-w-[85%] min-w-0">
- <div className="flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground bg-muted/40 rounded-2xl rounded-bl-md">
- <Loader2 className="h-3 w-3 animate-spin" />
- <span>
- {isParsingFiles
- ? t("message.parsing_files")
- : t("message.thinking")}
- </span>
- </div>
+ <Shimmer as="span" className="py-1 text-sm" duration={1.6}>
+ {isParsingFiles
+ ? t("message.parsing_files")
+ : t("message.thinking")}
+ </Shimmer>
</div>
</div>
)}
diff --git a/client/workspaces/flow/chat/code-block.tsx b/client/workspaces/flow/chat/code-block.tsx
index ee49922..1cbcfb6 100644
--- a/client/workspaces/flow/chat/code-block.tsx
+++ b/client/workspaces/flow/chat/code-block.tsx
@@ -1,7 +1,8 @@
"use client"
import { Check, Copy, Play, X } from "lucide-react"
-import { Highlight, themes } from "prism-react-renderer"
+import { Highlight } from "prism-react-renderer"
+import { syntaxTheme } from "@/shared/chat/syntax-theme"
import { useState } from "react"
interface CodeBlockProps {
@@ -98,7 +99,7 @@ export function CodeBlock({ code, language = "xml", onApply }: CodeBlockProps) {
<span>{copied ? "Copied" : "Copy"}</span>
</button>
</div>
- <Highlight theme={themes.github} code={code} language={language}>
+ <Highlight theme={syntaxTheme} code={code} language={language}>
{({
className: _className,
style,
diff --git a/client/workspaces/ppt/canvas/views/CreationStart.tsx b/client/workspaces/ppt/canvas/views/CreationStart.tsx
index ef8146b..0211a2b 100644
--- a/client/workspaces/ppt/canvas/views/CreationStart.tsx
+++ b/client/workspaces/ppt/canvas/views/CreationStart.tsx
@@ -84,13 +84,13 @@ export function CreationStart({
{creationMode !== "image_transform" ? (
<div className="space-y-4">
<label className="text-sm font-semibold text-foreground flex items-center gap-2">
- <span className="w-6 h-6 rounded-full bg-primary/12 text-primary text-xs flex items-center justify-center font-bold">1</span>
+ <span className="w-6 h-6 rounded-full bg-primary/12 text-primary-strong text-xs flex items-center justify-center font-bold">1</span>
{tr("选择或上传参考模板", "Choose or upload a reference template")}
</label>
<div className="grid gap-4 grid-cols-[repeat(auto-fill,minmax(180px,1fr))]">
<label className="cursor-pointer border-2 border-dashed rounded-xl transition-all duration-200 overflow-hidden relative aspect-video flex flex-col items-center justify-center group border-border hover:border-primary hover:bg-primary/[0.08]">
- <div className="flex flex-col items-center text-muted-foreground/70 group-hover:text-primary transition-colors">
+ <div className="flex flex-col items-center text-muted-foreground/70 group-hover:text-primary-strong transition-colors">
<div className="w-10 h-10 rounded-full bg-muted flex items-center justify-center mb-2 group-hover:bg-primary/12 transition-colors">
<Upload className="w-5 h-5" />
</div>
@@ -104,7 +104,7 @@ export function CreationStart({
title={tr("AI生成模板", "AI generate template")}
className="cursor-pointer border-2 border-dashed rounded-xl transition-all duration-200 overflow-hidden relative aspect-video flex flex-col items-center justify-center group border-border hover:border-primary hover:bg-primary/[0.08]"
>
- <div className="flex flex-col items-center text-muted-foreground/70 group-hover:text-primary transition-colors">
+ <div className="flex flex-col items-center text-muted-foreground/70 group-hover:text-primary-strong transition-colors">
<div className="w-10 h-10 rounded-full bg-muted flex items-center justify-center mb-2 group-hover:bg-primary/12 transition-colors">
<Sparkles className="w-5 h-5" />
</div>
@@ -151,7 +151,7 @@ export function CreationStart({
{/* Mode Selection & Input */}
<div className="space-y-4">
<label className="text-sm font-semibold text-foreground flex items-center gap-2">
- <span className="w-6 h-6 rounded-full bg-primary/12 text-primary text-xs flex items-center justify-center font-bold">{creationMode === "image_transform" ? "1" : "2"}</span>
+ <span className="w-6 h-6 rounded-full bg-primary/12 text-primary-strong text-xs flex items-center justify-center font-bold">{creationMode === "image_transform" ? "1" : "2"}</span>
{tr("输入内容", "Input")}
</label>
@@ -198,7 +198,7 @@ export function CreationStart({
className="space-y-3"
>
<div className="flex items-center gap-2 text-sm text-foreground/80">
- {creationMode === "beautify" ? <Sparkles className="w-4 h-4 text-primary" /> : creationMode === "image_transform" ? <Presentation className="w-4 h-4 text-primary" /> : <Lightbulb className="w-4 h-4 text-primary" />}
+ {creationMode === "beautify" ? <Sparkles className="w-4 h-4 text-primary-strong" /> : creationMode === "image_transform" ? <Presentation className="w-4 h-4 text-primary-strong" /> : <Lightbulb className="w-4 h-4 text-primary-strong" />}
<span>{modeCopy.hint}</span>
</div>
@@ -241,7 +241,7 @@ export function CreationStart({
type="checkbox"
checked={inputs.beautify.useTemplate}
onChange={(e) => inputs.beautify.setUseTemplate(e.target.checked)}
- className="h-4 w-4 rounded border-input text-primary focus:ring-ring"
+ className="h-4 w-4 rounded border-input text-primary-strong focus:ring-ring"
/>
</label>
diff --git a/client/workspaces/ppt/canvas/views/DeckView.tsx b/client/workspaces/ppt/canvas/views/DeckView.tsx
index 0277654..3807004 100644
--- a/client/workspaces/ppt/canvas/views/DeckView.tsx
+++ b/client/workspaces/ppt/canvas/views/DeckView.tsx
@@ -413,7 +413,7 @@ export function DeckView({
<div className="flex-1 space-y-6">
{(deck.currentSlide.content || []).map((point, i) => (
<div key={i} className="flex items-start gap-4 text-2xl leading-relaxed text-[#3B3833]">
- <span className="mt-2 text-primary">•</span>
+ <span className="mt-2 text-primary-strong">•</span>
<span>{point}</span>
</div>
))}
@@ -432,7 +432,7 @@ export function DeckView({
{(status.isApplyingEdits || status.isGeneratingImage) && (
<div className="absolute inset-0 z-50 flex items-center justify-center bg-background/60 backdrop-blur-[2px]">
<div className="flex flex-col items-center gap-3 bg-card shadow-soft-lg px-6 py-4 rounded-xl border border-primary/25">
- <Loader2 className="w-6 h-6 text-primary animate-spin" />
+ <Loader2 className="w-6 h-6 text-primary-strong animate-spin" />
<span className="text-sm font-medium text-foreground/80">{tr("幻灯片正在生成中...", "Generating slides...")}</span>
</div>
</div>
@@ -518,7 +518,7 @@ export function DeckView({
<div className="flex-1 space-y-8">
{(deck.slides[slideshow.index].content || []).map((point, i) => (
<div key={i} className="flex gap-6 text-3xl text-[#3B3833] leading-relaxed items-start">
- <span className="text-primary mt-2">•</span>
+ <span className="text-primary-strong mt-2">•</span>
<span>{point}</span>
</div>
))}
diff --git a/client/workspaces/ppt/canvas/views/GenerationProgress.tsx b/client/workspaces/ppt/canvas/views/GenerationProgress.tsx
index 0b90511..ec9cf0d 100644
--- a/client/workspaces/ppt/canvas/views/GenerationProgress.tsx
+++ b/client/workspaces/ppt/canvas/views/GenerationProgress.tsx
@@ -39,7 +39,7 @@ export function GenerationProgress({ step, progress, tr }: GenerationProgressPro
fill="transparent"
/>
<circle
- className="text-primary stroke-current transition-all duration-300 ease-in-out origin-center -rotate-90"
+ className="text-primary-strong stroke-current transition-all duration-300 ease-in-out origin-center -rotate-90"
strokeWidth="8"
strokeLinecap="round"
cx="50"
@@ -60,7 +60,7 @@ export function GenerationProgress({ step, progress, tr }: GenerationProgressPro
</div>
<div className="flex justify-center gap-2 text-xs text-muted-foreground">
- <div className={`flex items-center gap-1 ${isRendering ? "text-primary" : ""}`}>
+ <div className={`flex items-center gap-1 ${isRendering ? "text-primary-strong" : ""}`}>
{isRendering ? <Loader2 className="w-3 h-3 animate-spin" /> : <Check className="w-3 h-3" />}
<span>{tr("渲染图片", "Render images")}</span>
</div>
diff --git a/client/workspaces/ppt/canvas/views/OutlineReview.tsx b/client/workspaces/ppt/canvas/views/OutlineReview.tsx
index fd834b7..752061e 100644
--- a/client/workspaces/ppt/canvas/views/OutlineReview.tsx
+++ b/client/workspaces/ppt/canvas/views/OutlineReview.tsx
@@ -242,8 +242,8 @@ export function OutlineReview({
title={tr(`插入第 ${idx + 1} 张素材`, `Insert material ${idx + 1}`)}
className={`flex w-full items-center gap-2 rounded-md border px-2 py-1.5 text-left text-xs ${
materials.picker.activeIndex === idx
- ? "border-primary/40 bg-primary/12 text-primary ring-1 ring-primary/40"
- : "border-primary/30 bg-primary/[0.08] text-primary hover:bg-primary/15"
+ ? "border-primary/40 bg-primary/12 text-primary-strong ring-1 ring-primary/40"
+ : "border-primary/30 bg-primary/[0.08] text-primary-strong hover:bg-primary/15"
}`}
>
<img src={img.dataUrl} alt={img.name} className="h-8 w-8 rounded object-cover" />
@@ -323,7 +323,7 @@ export function OutlineReview({
<button
type="button"
onClick={() => materials.setPreview({ open: true, slideTitle: slide.title, item: img })}
- className="mt-1 w-full truncate text-center text-xs text-foreground hover:text-primary"
+ className="mt-1 w-full truncate text-center text-xs text-foreground hover:text-primary-strong"
title={tr("点击查看素材", "Click to preview material")}
>
{img.name}
diff --git a/client/workspaces/ppt/chat/ChatMessageDisplay.tsx b/client/workspaces/ppt/chat/ChatMessageDisplay.tsx
index 0ab52f2..d53fefa 100644
--- a/client/workspaces/ppt/chat/ChatMessageDisplay.tsx
+++ b/client/workspaces/ppt/chat/ChatMessageDisplay.tsx
@@ -1,8 +1,8 @@
import React, { useRef, useEffect, useState, useCallback } from 'react';
-import { Check, ChevronDown, ChevronUp, Copy, FileCode, FileText, Loader2, Pencil, RotateCcw } from "lucide-react";
+import { Check, ChevronDown, ChevronUp, Copy, FileCode, FileText, Pencil, RotateCcw } from "lucide-react";
import ReactMarkdown from "react-markdown";
import remarkGfm from 'remark-gfm';
-import { Reasoning, ReasoningContent, ReasoningTrigger } from "@/shared/chat";
+import { Reasoning, ReasoningContent, ReasoningTrigger, Shimmer } from "@/shared/chat";
import { ScrollArea } from "@/shared/ui/scroll-area";
import { CodeBlock } from "@/workspaces/ppt/chat/code-block";
import { useUiLanguage } from "@/shared/i18n";
@@ -10,6 +10,7 @@ import { cn } from "@/shared/lib/utils";
import {
getMessageTextContent,
getUserOriginalText,
+ isFencedCode,
splitTextIntoFileSections,
type MessagePart,
type UIMessage,
@@ -348,7 +349,7 @@ export function ChatMessageDisplay({
className={cn(
"mx-0.5 inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium align-middle",
kind === "outline"
- ? "border-primary/25 bg-primary/[0.08] text-primary"
+ ? "border-primary/25 bg-primary/[0.08] text-primary-strong"
: "border-border bg-muted text-foreground/80"
)}
>
@@ -425,7 +426,7 @@ export function ChatMessageDisplay({
"inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] leading-4",
message.role === "user"
? t.kind === "outline"
- ? "border-primary/25 bg-primary/[0.08] text-primary"
+ ? "border-primary/25 bg-primary/[0.08] text-primary-strong"
: "border-border bg-muted text-foreground/80"
: "border-border bg-muted/40 text-foreground"
)}
@@ -458,7 +459,7 @@ export function ChatMessageDisplay({
{section.fileType === 'pdf' ? (
<FileText className="h-4 w-4 text-destructive" />
) : (
- <FileCode className="h-4 w-4 text-primary" />
+ <FileCode className="h-4 w-4 text-primary-strong" />
)}
<span className="text-xs font-medium truncate max-w-[150px] text-foreground">{section.filename}</span>
<span className="text-[10px] text-muted-foreground">({section.charCount} chars)</span>
@@ -494,7 +495,7 @@ export function ChatMessageDisplay({
className={cn(
"mx-1 inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-xs font-medium align-middle",
kind === "outline"
- ? "border-primary/25 bg-primary/[0.08] text-primary"
+ ? "border-primary/25 bg-primary/[0.08] text-primary-strong"
: "border-border bg-muted text-foreground/80"
)}
title={tr(`幻灯片 · ${label}`, `Slide · ${label}`)}
@@ -563,8 +564,7 @@ export function ChatMessageDisplay({
}
return (
<div key={idx} className={cn(
- "prose prose-sm max-w-none break-words",
- "dark:prose-invert"
+ "prose prose-sm max-w-none break-words"
)}>
<ReactMarkdown
remarkPlugins={[remarkGfm]}
@@ -599,11 +599,11 @@ export function ChatMessageDisplay({
pre({ children }: any) {
return <>{children}</>;
},
- code({ node: _node, inline, className, children, ...props }: any) {
+ code({ node: _node, className, children, ...props }: any) {
const match = /language-(\w+)/.exec(className || "");
const isStreaming = status === "streaming" && isLastAssistantMessage;
const language = match?.[1] || "text";
- if (!inline) {
+ if (isFencedCode(className, children)) {
const ordinal = codeBlockOrdinal++;
return (
<CodeBlock
@@ -693,10 +693,9 @@ export function ChatMessageDisplay({
{showPendingIndicator && (
<div className="flex w-full justify-start animate-message-in mt-3">
<div className="max-w-[85%] min-w-0">
- <div className="flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground bg-muted/40 rounded-2xl rounded-bl-md">
- <Loader2 className="h-3 w-3 animate-spin" />
- <span>{tr("思考中...", "Thinking...")}</span>
- </div>
+ <Shimmer as="span" className="py-1 text-sm" duration={1.6}>
+ {tr("思考中...", "Thinking...")}
+ </Shimmer>
</div>
</div>
)}
diff --git a/client/workspaces/ppt/chat/ChatPanel.tsx b/client/workspaces/ppt/chat/ChatPanel.tsx
index 9611234..94d1d1b 100644
--- a/client/workspaces/ppt/chat/ChatPanel.tsx
+++ b/client/workspaces/ppt/chat/ChatPanel.tsx
@@ -707,7 +707,7 @@ const getPptTag = (slideId: string, title: string, kind: "outline" | "slide_imag
className={cn(
"h-8 w-8 p-0",
imageMode === "edit"
- ? "bg-primary/10 text-primary hover:bg-primary/15"
+ ? "bg-primary/10 text-primary-strong hover:bg-primary/15"
: "text-muted-foreground hover:text-foreground",
)}
>
@@ -724,7 +724,7 @@ const getPptTag = (slideId: string, title: string, kind: "outline" | "slide_imag
className={cn(
"h-8 w-8 p-0",
imageMode === "regenerate"
- ? "bg-primary/10 text-primary hover:bg-primary/15"
+ ? "bg-primary/10 text-primary-strong hover:bg-primary/15"
: "text-muted-foreground hover:text-foreground",
)}
>
diff --git a/client/workspaces/ppt/chat/code-block.tsx b/client/workspaces/ppt/chat/code-block.tsx
index 2698623..2c36178 100644
--- a/client/workspaces/ppt/chat/code-block.tsx
+++ b/client/workspaces/ppt/chat/code-block.tsx
@@ -1,5 +1,6 @@
import { useMemo, useRef, useState } from 'react';
-import { Highlight, themes, type Language } from "prism-react-renderer";
+import { Highlight, type Language } from "prism-react-renderer";
+import { syntaxTheme } from "@/shared/chat/syntax-theme";
import { ChevronRight, Loader2 } from 'lucide-react';
import { cn } from '@/shared/lib/utils';
@@ -66,8 +67,8 @@ export function CodeBlock({ code, language = "xml", isStreaming = false, blockId
{isStreaming ? (
<div className="flex items-center gap-2 ml-auto">
- <span className="text-[10px] text-primary animate-pulse">Generating code...</span>
- <Loader2 className="w-3.5 h-3.5 animate-spin text-primary" />
+ <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>
) : (
<span className="ml-auto text-[10px] opacity-70 font-mono">{normalizedCode.length} chars</span>
@@ -77,7 +78,7 @@ export function CodeBlock({ code, language = "xml", isStreaming = false, blockId
{isOpen && (
<div className="p-0 border-t border-border/50">
<div className="overflow-hidden w-full bg-sunken">
- <Highlight theme={themes.github} code={normalizedCode} language={prismLanguage}>
+ <Highlight theme={syntaxTheme} code={normalizedCode} language={prismLanguage}>
{({
style,
tokens,
diff --git a/tailwind.config.js b/tailwind.config.js
index 6d90cbd..680560d 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -30,6 +30,7 @@ export default {
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
+ strong: "hsl(var(--primary-strong))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
@@ -76,6 +77,76 @@ export default {
// defined here, so seven call sites rendered no shadow at all.
xs: "0 1px 2px hsl(var(--shadow-hue) / 0.05)",
},
+ /**
+ * The assistant's every reply renders through `prose`, and the stock
+ * plugin theme is its own grey ramp -- so the longest-lived text in the
+ * product was the one surface still ignoring the tokens. Driving the
+ * `--tw-prose-*` variables from them makes it follow the palette, and
+ * makes `dark:prose-invert` unnecessary: the tokens already flip.
+ */
+ typography: {
+ DEFAULT: {
+ css: {
+ "--tw-prose-body": "hsl(var(--foreground) / 0.88)",
+ "--tw-prose-headings": "hsl(var(--foreground))",
+ "--tw-prose-lead": "hsl(var(--muted-foreground))",
+ "--tw-prose-links": "hsl(var(--primary-strong))",
+ "--tw-prose-bold": "hsl(var(--foreground))",
+ "--tw-prose-counters": "hsl(var(--muted-foreground))",
+ "--tw-prose-bullets": "hsl(var(--muted-foreground) / 0.6)",
+ "--tw-prose-hr": "hsl(var(--border))",
+ "--tw-prose-quotes": "hsl(var(--foreground) / 0.9)",
+ "--tw-prose-quote-borders": "hsl(var(--primary) / 0.4)",
+ "--tw-prose-captions": "hsl(var(--muted-foreground))",
+ "--tw-prose-code": "hsl(var(--foreground))",
+ "--tw-prose-pre-code": "hsl(var(--foreground))",
+ "--tw-prose-pre-bg": "hsl(var(--sunken))",
+ "--tw-prose-th-borders": "hsl(var(--border))",
+ "--tw-prose-td-borders": "hsl(var(--border) / 0.6)",
+
+ maxWidth: "none",
+ lineHeight: "1.72",
+
+ "h1, h2, h3, h4": {
+ fontFamily: 'theme("fontFamily.display")',
+ letterSpacing: "-0.015em",
+ fontWeight: "600",
+ },
+
+ // The plugin wraps inline code in literal backticks; a tinted chip
+ // says the same thing without the punctuation.
+ "code::before": { content: '""' },
+ "code::after": { content: '""' },
+ ":not(pre) > code": {
+ backgroundColor: "hsl(var(--muted))",
+ border: "1px solid hsl(var(--border) / 0.6)",
+ borderRadius: "0.3rem",
+ padding: "0.1em 0.35em",
+ fontWeight: "500",
+ },
+
+ // A rule, not a box, and upright rather than italic.
+ blockquote: {
+ fontStyle: "normal",
+ fontWeight: "400",
+ borderLeftWidth: "2px",
+ paddingLeft: "1.1em",
+ },
+ "blockquote p:first-of-type::before": { content: '""' },
+ "blockquote p:last-of-type::after": { content: '""' },
+
+ a: {
+ fontWeight: "500",
+ textDecorationThickness: "1px",
+ textUnderlineOffset: "2px",
+ },
+
+ // Hairlines only; the plugin's default header rule is heavy.
+ "thead th": { fontWeight: "600", borderBottomWidth: "1px" },
+ hr: { borderTopWidth: "1px" },
+ },
+ },
+ },
transitionTimingFunction: {
"out-soft": "cubic-bezier(0.22, 1, 0.36, 1)",
"in-out-soft": "cubic-bezier(0.65, 0, 0.35, 1)",