From 49a26d93d679ea9c5fd9c8646c94016ba04e4e99 Mon Sep 17 00:00:00 2001 From: Roman Barlos Date: Mon, 20 Apr 2026 14:29:20 +0300 Subject: [PATCH] fix(web): ensure readable text in dark code blocks on light theme The hard-coded dark code block background (#1f2937 / #292524) combined with `.prose` rules was producing near-black text in the light theme: `.prose pre` forced color #D6D3D1 and `.prose code:not(.md-code-block__code):not(.md-inline-code)` pulled the code element back to var(--foreground), overriding the Tailwind classes on the fallback
/.

Add a higher-specificity rule on .md-renderer .md-code-block {,pre,code}
that pins the text color to #e5e7eb regardless of theme, and tag the
 elements in the Rich/Simple markdown fallbacks with the existing
md-code-block__code class so the :not() guard kicks in and inheritance
resolves to the light color.
---
 web/app/globals.css                              | 11 +++++++++++
 web/components/common/RichMarkdownRenderer.tsx   |  2 +-
 web/components/common/SimpleMarkdownRenderer.tsx |  2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/web/app/globals.css b/web/app/globals.css
index 6433130c6..314d07e54 100644
--- a/web/app/globals.css
+++ b/web/app/globals.css
@@ -226,6 +226,17 @@
   box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
 }
 
+/* Force light text on dark code blocks regardless of theme. The wrapper
+   .md-code-block always uses a fixed dark background (#1f2937 / #292524),
+   so we need to override .prose pre (color: #D6D3D1) and any inherited
+   --foreground from the prose wrapper that would otherwise render as
+   near-black in the light theme. Specificity (0,2,1) beats .prose pre. */
+.md-renderer .md-code-block,
+.md-renderer .md-code-block pre,
+.md-renderer .md-code-block code {
+  color: #e5e7eb;
+}
+
 .md-renderer .md-code-block pre,
 .md-renderer .md-code-block code {
   background: transparent !important;
diff --git a/web/components/common/RichMarkdownRenderer.tsx b/web/components/common/RichMarkdownRenderer.tsx
index 30d4ec790..82902acf0 100644
--- a/web/components/common/RichMarkdownRenderer.tsx
+++ b/web/components/common/RichMarkdownRenderer.tsx
@@ -400,7 +400,7 @@ export default function RichMarkdownRenderer({
             {...lineProps}
           >
             
-              {raw}
+              {raw}
             
); diff --git a/web/components/common/SimpleMarkdownRenderer.tsx b/web/components/common/SimpleMarkdownRenderer.tsx index 28645641e..7a2f19857 100644 --- a/web/components/common/SimpleMarkdownRenderer.tsx +++ b/web/components/common/SimpleMarkdownRenderer.tsx @@ -262,7 +262,7 @@ export default function SimpleMarkdownRenderer({ className={`md-code-block ${gap} overflow-hidden rounded-xl border border-[var(--border)] bg-[#292524]`} >
-              {raw}
+              {raw}
             
);