Skip to content

Re-apply xterm theme when app theme changes - #62

Merged
frenchie4111 merged 1 commit into
ness-dev:mainfrom
big-guy:xterm-retheme
May 23, 2026
Merged

frenchie4111 merged 1 commit into
ness-dev:mainfrom
big-guy:xterm-retheme

Conversation

@big-guy

@big-guy big-guy commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Extracts the xterm theme construction into buildTerminalTheme() (reads --color-app / --color-fg-bright from :root).
  • Adds a MutationObserver on document.documentElement watching data-theme and inline style so the terminal re-skins live whenever theme-apply.ts swaps the app theme — both built-in switches and custom-theme overrides.

Previously the terminal pulled its background/foreground from CSS variables once at mount and never re-read them, so switching themes left the terminal frozen at whatever it was painted with at init. We didn't notice this before because every theme was dark — switching between dark themes left the terminal looking close enough to right that nothing was obviously broken. With the new light/dark/system mode + custom themes from #47, the mismatch is glaring.

MutationObserver is used rather than keying off useActiveTheme() to avoid a child-before-parent useEffect race where XTerminal would re-read CSS vars before theme-apply.ts had written the new values.

Test plan

  • npm run typecheck clean
  • npx electron-vite build clean
  • Open a terminal, switch between a light and dark theme in Settings → Appearance, confirm the terminal background/foreground updates immediately
  • Switch to a custom theme loaded from disk, confirm the terminal picks it up
  • Open a fresh terminal after switching themes, confirm it still paints with the active theme on mount

🤖 Generated with Claude Code

Extract theme construction into buildTerminalTheme() and watch :root for
data-theme / style mutations so the terminal re-skins live alongside the
rest of the app instead of staying frozen at mount time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@frenchie4111
frenchie4111 merged commit e77cb57 into ness-dev:main May 23, 2026
@big-guy
big-guy deleted the xterm-retheme branch May 23, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants