fix(theme): update code view on system theme change#2484
Conversation
Greptile SummaryReplaces a manual
Confidence Score: 5/5Safe to merge — the change is a clean, focused refactor of a single reactive subscription with no behavioral regressions. Both the subscribe and snapshot functions are defined at module level, giving useSyncExternalStore the stable references it requires. The useLayoutEffect/useEffect ordering that applies CSS classes before updating xterm themes is preserved. The only minor note is that the subscription is always active (even when an explicit theme is set) rather than conditionally, but effectiveTheme correctly falls back to theme in that case, so the extra listener is harmless. No correctness issues were found. No files require special attention.
|
| Filename | Overview |
|---|---|
| apps/emdash-desktop/src/renderer/lib/providers/theme-provider.tsx | Refactors system-theme subscription from a manual useEffect to useSyncExternalStore; stable module-level subscribe/snapshot functions are used correctly, and the layout-effect/effect ordering for applyTheme and applyThemeToAll is preserved. |
Sequence Diagram
sequenceDiagram
participant OS as OS Theme Change
participant MQ as matchMedia listener
participant React as React (useSyncExternalStore)
participant LE as useLayoutEffect
participant UE as useEffect
OS->>MQ: fires 'change' event
MQ->>React: calls onChange callback
React->>React: re-renders, calls getSystemTheme()
Note over React: systemTheme updated → effectiveTheme updated (when theme === null)
React->>LE: effectiveTheme changed
LE->>LE: applyTheme(effectiveTheme) — updates CSS class
React->>UE: effectiveTheme changed
UE->>UE: applyThemeToAll() — updates xterm / code editor
Reviews (1): Last reviewed commit: "fix(theme): update code view on system t..." | Re-trigger Greptile
Description
Screenshot/Recording (if applicable)
https://streamable.com/i13f4z
Checklist
messages and, when possible, the PR title