Mathias Heider commited on
Commit
aa55842
·
1 Parent(s): 88322e0

ui: theme tokens follow the configured theme, not the viewer's OS scheme

Browse files

st.context.theme.type reports the OS preference ('dark' on a dark desktop)
even though Streamlit renders the single custom light theme, so dark tokens
were injected onto a light page (invisible title, black tiles). Use
st.get_option('theme.base') — the config is the one source of truth.

Files changed (1) hide show
  1. agent/ui_theme.py +9 -3
agent/ui_theme.py CHANGED
@@ -53,10 +53,16 @@ MONO = 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monosp
53
 
54
 
55
  def is_dark() -> bool:
56
- """Streamlit's active theme type ('light' unless the viewer picked dark)."""
 
 
 
 
 
 
57
  try:
58
- return (st.context.theme.type or "light") == "dark"
59
- except Exception: # AppTest / very old Streamlit
60
  return False
61
 
62
 
 
53
 
54
 
55
  def is_dark() -> bool:
56
+ """True only when the *configured* Streamlit theme is dark.
57
+
58
+ Deliberately NOT st.context.theme.type: with a single custom light theme
59
+ that call reports the viewer's OS preference ("dark" on a dark desktop)
60
+ while Streamlit still renders the light theme — injecting dark tokens on
61
+ a light page. The config is the one source of truth for the whole app.
62
+ """
63
  try:
64
+ return (st.get_option("theme.base") or "light") == "dark"
65
+ except Exception:
66
  return False
67
 
68