Expand dark theme coverage across client UI

This commit is contained in:
Shantur Rathore
2025-10-28 18:19:17 +00:00
parent 8858fe052b
commit 1ce5b125a9
12 changed files with 197 additions and 107 deletions

View File

@@ -1,5 +1,5 @@
import { createEffect, createSignal, onMount, onCleanup } from "solid-js"
import { renderMarkdown, onLanguagesLoaded } from "../lib/markdown"
import { renderMarkdown, onLanguagesLoaded, initMarkdown } from "../lib/markdown"
import type { TextPart } from "../types/message"
interface MarkdownProps {
@@ -15,11 +15,16 @@ export function Markdown(props: MarkdownProps) {
createEffect(async () => {
const part = props.part
const text = part.text || ""
const dark = Boolean(props.isDark)
const themeKey = dark ? "dark" : "light"
latestRequestedText = text
if (part.renderCache && part.renderCache.text === text) {
setHtml(part.renderCache.html)
await initMarkdown(dark)
const cache = part.renderCache
if (cache && cache.text === text && cache.theme === themeKey) {
setHtml(cache.html)
return
}
@@ -28,12 +33,13 @@ export function Markdown(props: MarkdownProps) {
if (latestRequestedText === text) {
setHtml(rendered)
part.renderCache = { text, html: rendered }
part.renderCache = { text, html: rendered, theme: themeKey }
}
} catch (error) {
console.error("Failed to render markdown:", error)
if (latestRequestedText === text) {
setHtml(text)
part.renderCache = { text, html: text, theme: themeKey }
}
}
})