Skip to content

Commit 7832b5b

Browse files
committed
fix: Apply RippleUI theme colors to all generated HTML blocks
Ensure that createHtmlBlock applies the same theme-aware CSS as other HTML rendering functions, so generated elements respect dark/light mode theme preferences. This fixes incorrect colors in dark mode for agent response HTML blocks.
1 parent 7de51df commit 7832b5b

1 file changed

Lines changed: 51 additions & 1 deletion

File tree

static/app.js

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,57 @@ class GMGUIApp {
14581458
}
14591459
const content = document.createElement('div');
14601460
content.className = 'html-content';
1461-
content.innerHTML = this.sanitizeHtml(event.html);
1461+
1462+
// Get current theme to apply to HTML content
1463+
const currentTheme = document.documentElement.getAttribute('data-theme') ||
1464+
(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
1465+
1466+
// Apply theme-aware CSS for consistent colors in dark/light mode
1467+
const themeCSS = currentTheme === 'dark'
1468+
? `<style>
1469+
.html-content {
1470+
color: #f8fafc;
1471+
background: transparent;
1472+
}
1473+
.html-content p { color: #cbd5e1; }
1474+
.html-content h1, .html-content h2, .html-content h3,
1475+
.html-content h4, .html-content h5, .html-content h6 {
1476+
color: #f8fafc;
1477+
}
1478+
.html-content a { color: #6366f1; }
1479+
.html-content code { color: #c7d2fe; background: rgba(0,0,0,0.3); }
1480+
.html-content pre { background: rgba(0,0,0,0.5); color: #e0e7ff; }
1481+
.html-content table { border-color: #334155; }
1482+
.html-content th { background: #1a202c; color: #f8fafc; }
1483+
.html-content td { border-color: #334155; }
1484+
.html-content blockquote { border-color: #334155; color: #cbd5e1; }
1485+
.html-content ul, .html-content ol { color: #cbd5e1; }
1486+
.html-content li { color: #cbd5e1; }
1487+
</style>`
1488+
: `<style>
1489+
.html-content {
1490+
color: #1d2129;
1491+
background: transparent;
1492+
}
1493+
.html-content p { color: #475569; }
1494+
.html-content h1, .html-content h2, .html-content h3,
1495+
.html-content h4, .html-content h5, .html-content h6 {
1496+
color: #1d2129;
1497+
}
1498+
.html-content a { color: #4f46e5; }
1499+
.html-content code { color: #6366f1; background: rgba(99,102,241,0.1); }
1500+
.html-content pre { background: #f3f4f6; color: #1d2129; }
1501+
.html-content table { border-color: #e5e7eb; }
1502+
.html-content th { background: #f9fafb; color: #1d2129; }
1503+
.html-content td { border-color: #e5e7eb; }
1504+
.html-content blockquote { border-color: #e5e7eb; color: #475569; }
1505+
.html-content ul, .html-content ol { color: #475569; }
1506+
.html-content li { color: #475569; }
1507+
</style>`;
1508+
1509+
const enhancedHtml = themeCSS + this.sanitizeHtml(event.html);
1510+
content.innerHTML = enhancedHtml;
1511+
content.setAttribute('data-theme', currentTheme);
14621512
wrap.appendChild(content);
14631513
return wrap;
14641514
}

0 commit comments

Comments
 (0)