UI: Fix dark theme using light theme syntax highlighting

This commit is contained in:
oobabooga 2026-03-14 14:01:34 -07:00
parent beab346f48
commit c09a367c64
2 changed files with 10 additions and 0 deletions

View file

@ -2,6 +2,12 @@
// Main
// ------------------------------------------------
// Sync highlight.js theme with the actual Gradio theme
var defined_hljs_css = document.body.classList.contains("dark") ? "file/css/highlightjs/github-dark.min.css" : "file/css/highlightjs/github.min.css";
if (document.getElementById("highlight-css").getAttribute("href") !== defined_hljs_css) {
document.getElementById("highlight-css").setAttribute("href", defined_hljs_css);
}
let main_parent = document.getElementById("chat-tab").parentNode;
let extensions = document.getElementById("extensions");

View file

@ -218,6 +218,10 @@ def create_interface():
shared.gradio['interface'].load(partial(ui.apply_interface_values, {}, use_persistent=True), None, gradio(ui.list_interface_input_elements()), show_progress=False)
# Sync theme_state with the actual client-side theme so that
# autosave always writes the correct dark_theme value.
shared.gradio['interface'].load(None, None, gradio('theme_state'), js='() => document.body.classList.contains("dark") ? "dark" : "light"')
extensions_module.create_extensions_tabs() # Extensions tabs
extensions_module.create_extensions_block() # Extensions block