Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(chat): mermaid theme — outlined minimalist, readable in both modes

Louis Beaumont4995e49a9daa
diff --git a/apps/screenpipe-app-tauri/components/rewind/mermaid-diagram.tsx b/apps/screenpipe-app-tauri/components/rewind/mermaid-diagram.tsx
index 4a2538c8f..d074c5eef 100644
--- a/apps/screenpipe-app-tauri/components/rewind/mermaid-diagram.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/mermaid-diagram.tsx
@@ -2,62 +2,121 @@
import { useEffect, useRef, useState } from "react";
-// Screenpipe brand theme: grayscale, sharp corners, minimal
+// Screenpipe brand theme — outlined minimalist (DESIGN.md):
+// white fills, black 1px borders, black text in light mode (inverted in dark).
+// Avoids the heavy filled-black-box look; matches the rest of the app's flat,
+// high-contrast, color-free aesthetic.
const SCREENPIPE_THEME = {
theme: "base" as const,
themeVariables: {
- primaryColor: "#000000",
- primaryTextColor: "#ffffff",
+ primaryColor: "#ffffff",
+ primaryTextColor: "#000000",
primaryBorderColor: "#000000",
- lineColor: "#666666",
- secondaryColor: "#ffffff",
- tertiaryColor: "#f0f0f0",
+ lineColor: "#000000",
+ secondaryColor: "#f5f5f5",
+ tertiaryColor: "#e5e5e5",
background: "#ffffff",
- mainBkg: "#000000",
- secondBkg: "#f0f0f0",
+ mainBkg: "#ffffff",
+ secondBkg: "#f5f5f5",
+ tertiaryBkg: "#e5e5e5",
border1: "#000000",
- border2: "#666666",
+ border2: "#000000",
arrowheadColor: "#000000",
fontFamily: "IBM Plex Mono, monospace",
fontSize: "14px",
nodeBorder: "#000000",
clusterBkg: "#f5f5f5",
clusterBorder: "#000000",
- defaultLinkColor: "#666666",
+ defaultLinkColor: "#000000",
titleColor: "#000000",
edgeLabelBackground: "#ffffff",
- nodeTextColor: "#ffffff",
+ nodeTextColor: "#000000",
+ textColor: "#000000",
+ labelColor: "#000000",
+ labelTextColor: "#000000",
+ actorTextColor: "#000000",
+ actorBorder: "#000000",
+ actorBkg: "#ffffff",
+ noteBkgColor: "#f5f5f5",
+ noteTextColor: "#000000",
+ noteBorderColor: "#000000",
},
};
-// Dark mode theme
const SCREENPIPE_THEME_DARK = {
theme: "base" as const,
themeVariables: {
- primaryColor: "#ffffff",
- primaryTextColor: "#000000",
+ primaryColor: "#000000",
+ primaryTextColor: "#ffffff",
primaryBorderColor: "#ffffff",
- lineColor: "#999999",
- secondaryColor: "#000000",
- tertiaryColor: "#1a1a1a",
+ lineColor: "#ffffff",
+ secondaryColor: "#1a1a1a",
+ tertiaryColor: "#262626",
background: "#000000",
- mainBkg: "#ffffff",
+ mainBkg: "#000000",
secondBkg: "#1a1a1a",
+ tertiaryBkg: "#262626",
border1: "#ffffff",
- border2: "#999999",
+ border2: "#ffffff",
arrowheadColor: "#ffffff",
fontFamily: "IBM Plex Mono, monospace",
fontSize: "14px",
nodeBorder: "#ffffff",
clusterBkg: "#1a1a1a",
clusterBorder: "#ffffff",
- defaultLinkColor: "#999999",
+ defaultLinkColor: "#ffffff",
titleColor: "#ffffff",
edgeLabelBackground: "#000000",
- nodeTextColor: "#000000",
+ nodeTextColor: "#ffffff",
+ textColor: "#ffffff",
+ labelColor: "#ffffff",
+ labelTextColor: "#ffffff",
+ actorTextColor: "#ffffff",
+ actorBorder: "#ffffff",
+ actorBkg: "#000000",
+ noteBkgColor: "#1a1a1a",
+ noteTextColor: "#ffffff",
+ noteBorderColor: "#ffffff",
},
};
+// Belt-and-suspenders CSS injected into the SVG to override any mermaid
+// internals that ignore theme variables (label foreignObject text, edge
+// labels, etc). Without this, certain node/text classes render with
+// hardcoded colors that look washed out.
+const themeStyle = (isDark: boolean) => {
+ const fg = isDark ? "#ffffff" : "#000000";
+ const bg = isDark ? "#000000" : "#ffffff";
+ const cluster = isDark ? "#1a1a1a" : "#f5f5f5";
+ return `
+ .node rect, .node polygon, .node circle, .node ellipse, .node path {
+ fill: ${bg} !important;
+ stroke: ${fg} !important;
+ stroke-width: 1px !important;
+ }
+ .cluster rect {
+ fill: ${cluster} !important;
+ stroke: ${fg} !important;
+ stroke-width: 1px !important;
+ }
+ .node .label, .node text, .nodeLabel, .nodeLabel p,
+ .cluster .label, .cluster text, .cluster-label text,
+ .edgeLabel, .edgeLabel p, .edgeLabel rect {
+ color: ${fg} !important;
+ fill: ${fg} !important;
+ }
+ .edgeLabel { background-color: ${bg} !important; }
+ .edgeLabel rect { fill: ${bg} !important; }
+ .flowchart-link, .edge-thickness-normal, .edge-pattern-solid, path.path {
+ stroke: ${fg} !important;
+ }
+ .arrowheadPath, marker path {
+ fill: ${fg} !important;
+ stroke: ${fg} !important;
+ }
+ `;
+};
+
interface MermaidDiagramProps {
chart: string;
className?: string;
@@ -67,6 +126,22 @@ export function MermaidDiagram({ chart, className }: MermaidDiagramProps) {
const containerRef = useRef<HTMLDivElement>(null);
const [svg, setSvg] = useState<string>("");
const [error, setError] = useState<string | null>(null);
+ const [isDark, setIsDark] = useState<boolean>(() =>
+ typeof document !== "undefined" &&
+ document.documentElement.classList.contains("dark"),
+ );
+
+ useEffect(() => {
+ if (typeof document === "undefined") return;
+ const observer = new MutationObserver(() => {
+ setIsDark(document.documentElement.classList.contains("dark"));
+ });
+ observer.observe(document.documentElement, {
+ attributes: true,
+ attributeFilter: ["class"],
+ });
+ return () => observer.disconnect();
+ }, []);
useEffect(() => {
const renderDiagram = async () => {
@@ -75,8 +150,6 @@ export function MermaidDiagram({ chart, className }: MermaidDiagramProps) {
try {
const { default: mermaid } = await import("mermaid");
- // Detect dark mode
- const isDark = document.documentElement.classList.contains("dark");
const theme = isDark ? SCREENPIPE_THEME_DARK : SCREENPIPE_THEME;
mermaid.initialize({
@@ -88,7 +161,11 @@ export function MermaidDiagram({ chart, className }: MermaidDiagramProps) {
const id = `mermaid-${Math.random().toString(36).substr(2, 9)}`;
const { svg: renderedSvg } = await mermaid.render(id, chart.trim());
- setSvg(renderedSvg);
+ const styled = renderedSvg.replace(
+ /<svg([^>]*)>/,
+ `<svg$1><style>${themeStyle(isDark)}</style>`,
+ );
+ setSvg(styled);
setError(null);
} catch (err) {
console.error("Mermaid render error:", err);
@@ -97,7 +174,7 @@ export function MermaidDiagram({ chart, className }: MermaidDiagramProps) {
};
renderDiagram();
- }, [chart]);
+ }, [chart, isDark]);
if (error) {
return (