This document is the authoritative overview of the current Catppuccin StarryNight theme implementation. It reflects the consolidated lifecycle/visual systems that replaced the legacy AdvancedThemeSystem + facade stack. Use it alongside the AGENTS rules for day-to-day work and keep it in sync with source modules under src-js/ and src/.
src-js/theme.entry.tsis the only runtime entry point. It patches React requires, waits for Spicetify readiness, loads the Catppuccin CSS theme, then instantiatesThemeLifecycleCoordinatorwithADVANCED_SYSTEM_CONFIG.- Degraded mode is triggered when essential APIs (
Spicetify.Player,Spicetify.Platform) are missing. In that caseThemeLifecycleCoordinator.initializeDegradedMode()keeps CSS-driven visuals alive while monitoring for API availability throughDegradedModeCoordinator. - Full mode calls
initializeAllSystems()andsetupMusicAnalysisAndColorExtraction(), wiring music sync, color harmony, and registering post-init UI controllers (CardDOMWatcher, AberrationManager, DragPreviewManager, QuickAddRadialMenu, etc.). - Settings UI is lazy-loaded via
ui/components/StarryNightSettings, only when React/ReactDOM are available. Debug mode exposes(window as any).Y3Kwith lifecycle, performance, and music sync handles.
-
src-js/core/lifecycle/ThemeLifecycleCoordinator.ts- Owns progressive initialization, health monitoring, cleanup.
- Delegates system wiring to
SystemIntegrationCoordinatorand stores cached handles (e.g.,simplePerformanceCoordinator,webglSystemsIntegration). - Manages color state via
ColorEventCoordinator,ColorStateManager, andColorProcessorsingletons.
-
src-js/core/integration/SystemIntegrationCoordinator.ts- Executes phased initialization (
core,visual,services, etc.), coordinating dependencies and sequencing. - Creates/returns shared singletons:
VisualEffectsCoordinator,InfrastructureSystemCoordinator,MusicSyncService,CSSVariableWriter,SimplePerformanceCoordinator,EnhancedDeviceTierDetector,WebGLSystemsIntegration,ColorHarmonyEngine,SpicetifyColorBridge. - Registers health/performance observers and exposes
getCachedNonVisualSystem/getCachedVisualSystemhelpers.
- Executes phased initialization (
-
src-js/core/events/EventBus.ts- Replaces the old UnifiedEventBus; all systems publish/subscribe through
unifiedEventBuswith structured topics (e.g.,music:beat,colors:harmonized,performance:quality-level).
- Replaces the old UnifiedEventBus; all systems publish/subscribe through
-
src-js/visual/effects/VisualEffectsCoordinator.ts- Singleton that implements
IManagedSystemand holds the sharedVisualEffectState. - Registers
BackgroundSystemParticipants (e.g.,FluidGradientBackgroundSystem,WebGLGradientStrategy,UnifiedParticleSystem,SidebarVisualEffectsSystem). - Exposes participant lifecycle, quality scaling, health checks, metrics, and CSS variable batching.
- Singleton that implements
-
Background strategies live under
src-js/visual/strategies/:ColorStrategySelectorchooses a backend (webgl,css,hybrid) and returns configured strategies.WebGLGradientStrategy,DynamicGradientStrategy,DepthLayeredStrategy,ColorStrategyRegistryeach implementIManagedSystemand register themselves with the coordinator.
-
UI enhancements:
- Managers:
Card3DManager,GlassmorphismManager,SidebarVisualEffectsSystem,AudioVisualController(all undersrc-js/ui/). - Interactions:
ui/interactions/DragPreviewManager.ts(enhanced drag ghost) andui/interactions/PlaylistQuickAddMenu.ts(Quick Add radial) replace the legacyeffects/*implementations. - Atmospheric/Depth controllers (
visual/effects/DepthLayerController.ts,visual/atmospheric/AtmosphericCrystalsSystem.ts) subscribe to music and performance events via the coordinator.
- Managers:
-
src-js/visual/backgrounds/FluidGradientBackgroundSystem.ts- Primary gradient rendering system with four-tier progressive enhancement: Basic (CSS) → Standard (WebGL) → Enhanced (Liquid shader) → Full (Liquid + Corridor effects).
- Wraps
WebGLGradientBackgroundSysteminternally for base WebGL functionality. RenderingModeSelectorchooses optimal mode based on device capabilities (WebGL support, shader compilation success, device tier).- Runtime mode switching via
switchRenderingMode()with proper resource cleanup and automatic rollback on failure. - Performance-based adaptation: Monitors FPS and automatically downgrades/upgrades rendering mode (45 FPS downgrade threshold, 55 FPS upgrade threshold).
- Hysteresis pattern prevents mode thrashing (3 consecutive low FPS frames for downgrade, 5 for upgrade).
- Settings:
sn-corridor-effects-mode(auto/enabled/disabled) andsn-rendering-mode(auto/basic/standard/enhanced/full).
-
src-js/visual/backgrounds/RenderingModeSelector.ts- Capability detection: WebGL availability, liquid shader compilation, corridor shader compilation, device tier.
- Mode selection algorithm respects user preferences with automatic fallback chains.
- Debug logging provides transparency for capability detection and mode selection reasoning.
-
src-js/audio/MusicSyncService.ts- Centralizes Spicetify Player integration, beat detection, enhanced BPM analysis, caching, and event publication.
- Emits
music:*events on the unified event bus and provides metrics, predictive beat scheduling, and graceful degradation.
-
Refer to
docs/COLOR_AND_AUDIO.mdfor full music/color processing (MusicSync + OKLAB pipeline, SCSS integration).
- Performance modules under
src-js/core/performance/(e.g.,PerformanceMonitor.ts,SimplePerformanceCoordinator.ts,EnhancedDeviceTierDetector.ts,GradientPerformanceOptimizer.ts) expose quality scaling hooks consumed by both lifecycle and visual systems. - Settings live in
src-js/config:globalConfig.tscontains platform/environment flags.advanced-system-config.tsexposes developer toggles (debug, feature flags, performance tiers).- Runtime changes emit
year3000SystemSettingsChangedevents listened to by managers such asCard3DManagerandSidebarVisualEffectsSystem.
- SCSS sources in
src/define Catppuccin tokens, layouts, and system-specific styles. They compile touser.cssvia SASS/PostCSS. - TypeScript sources in
src-js/compile totheme.jsvia ESBuild. Both artifacts sit at repo root and are deployed byinstall.sh/install-hybrid.sh/install.ps1. - Visual systems rely on synchronized CSS variables (
--sn-*,--spice-*).CSSVariableWriterensures synchronized updates between music/color output and SCSS expectations.
Spicetify APIs -> theme.entry -> ThemeLifecycleCoordinator
-> SystemIntegrationCoordinator (creates shared systems)
-> MusicSyncService -> unifiedEventBus 'music:*'
-> ColorHarmonyEngine -> SpicetifyColorBridge + CSSVariableWriter
-> VisualEffectsCoordinator
-> BackgroundSystemParticipant.onVisualStateUpdate()
-> UI controllers & strategies adjust DOM/WebGL output
PerformanceMonitor -> unifiedEventBus 'performance:*' -> Coordinators adjust quality levels
Settings Manager -> year3000SystemSettingsChanged -> Managers sync configs
- Document only current modules. When referencing deprecated systems, label them clearly and point to replacements.
- Verify path aliases (
@/) againsttsconfig.jsonbefore adding examples. - Highlight degraded-mode behavior whenever systems depend on optional Spicetify APIs.
- When adding new systems, ensure they implement
IManagedSystemfromsrc-js/types/systems.tsand register throughSystemIntegrationCoordinatororVisualEffectsCoordinatorinstead of ad-hoc wiring.
- Add mermaid or sequence diagrams once verified against runtime traces.
- Link to future consolidated guides (
BUILD_AND_DEPLOY.md,COLOR_AND_AUDIO.md,STYLING_AND_TOKENS.md,SETTINGS_AND_CONFIG.md) as they are authored. - Record verification notes in
plans/documentation-cleanup.mdwhenever this document is updated.