Skip to content

fix(terminal): new terminals respect selected color scheme#3343

Merged
gregpriday merged 3 commits intodevelopfrom
feature/issue-3335-new-terminals-ignore-selected
Mar 16, 2026
Merged

fix(terminal): new terminals respect selected color scheme#3343
gregpriday merged 3 commits intodevelopfrom
feature/issue-3335-new-terminals-ignore-selected

Conversation

@gregpriday
Copy link
Collaborator

Summary

  • New terminals (including pre-warmed pool instances) were always initialized with the default CSS-variable theme, ignoring any color scheme selected in Appearance settings
  • Both TerminalRegistryController.prewarm() and the XtermAdapter terminalOptions memo called getXtermOptions() without a theme argument, falling back to getTerminalThemeFromCSS()
  • The fix adds a selectEffectiveTheme selector to terminalColorSchemeStore and passes the resolved theme at construction time in both code paths

Resolves #3335

Changes

  • src/store/terminalColorSchemeStore.ts — adds selectEffectiveTheme selector and a getEffectiveTheme() snapshot helper for use outside React; deduplicates the theme computation that was previously inlined in two places
  • src/controllers/TerminalRegistryController.ts — reads getEffectiveTheme() from the store snapshot when building xterm options for pre-warmed terminals
  • src/components/Terminal/XtermAdapter.tsx — subscribes to selectEffectiveTheme in the terminalOptions memo so new instances created during React mount use the current scheme
  • src/store/slices/terminalRegistry/index.ts — passes getEffectiveTheme() when creating terminal instances inline (non-pool path)

Testing

  • npm run check passes (typecheck, lint, format all clean)
  • Manually verified: spawning a new terminal after selecting a custom scheme opens with that scheme applied immediately
  • Existing terminals continue to update live when the scheme changes via applyGlobalOptions in useTerminalConfig
  • Default (CSS-variable) theme still applies correctly when no custom scheme is selected

…nces

- Read useTerminalColorSchemeStore.getState().getEffectiveTheme() in addTerminal() prewarm block
- Add selectedSchemeId and customSchemes as deps in XtermAdapter terminalOptions memo
- Pass theme to getXtermOptions() in TerminalRegistryController.prewarm() for consistency
- Export selectEffectiveTheme from terminalColorSchemeStore for direct subscription
- Replace selectedSchemeId/customSchemes deps with effectiveTheme in XtermAdapter memo
- Eliminates getState() call inside useMemo, fixing react-hooks/exhaustive-deps warning
- Extract computeEffectiveTheme helper shared by selectEffectiveTheme and getEffectiveTheme
- Eliminates logic duplication and future drift risk
@gregpriday
Copy link
Collaborator Author

Review status: Ready

Clean refactor of getEffectiveTheme() into computeEffectiveTheme() + selectEffectiveTheme selector. Correctly wired into XtermAdapter, TerminalRegistryController.prewarm(), and terminalRegistry slice.

Cross-PR note: This PR must merge before PR #3345 (match terminal scheme to app theme). Both modify terminalColorSchemeStore.ts and XtermAdapter.tsx. PR #3345 will need a rebase after this merges — the getEffectiveTheme() inline code it modifies has been extracted to computeEffectiveTheme().

@gregpriday gregpriday merged commit 388f423 into develop Mar 16, 2026
4 checks passed
@gregpriday gregpriday deleted the feature/issue-3335-new-terminals-ignore-selected branch March 16, 2026 05:11
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.

New terminals ignore the selected terminal color scheme

1 participant