Last Updated: 2026-03-11
This document covers the renderer process, component system, settings dialog, and UI patterns.
-
ComponentManager(src/renderer/src/ui/components/ComponentManager.ts) registers every component fromsrc/renderer/src/ui/components/**, initializes them in DOM order, and fans outpolling-updatepayloads. Keep component constructors idempotent—GridStack recreates DOM nodes frequently. -
Grid/backplane orchestration lives in
src/renderer/src/gridController.ts+src/renderer/src/ui/gridstack/*. These modules handle component registration, palette toggles, edit mode, layout serialization, and widget hydration (log panel, job info, etc.). -
Printer tabs (
src/renderer/src/ui/components/printer-tabs/*) provide the multi-context UX. IPC events from tabs feed directly intoPrinterContextManager; avoid bypassing these events when adding context-sensitive UI. -
Renderer helpers:
src/renderer/src/perPrinterStorage.ts(layout + shortcut persistence per context),src/renderer/src/shortcutButtons.ts(top-bar shortcuts + dialog wiring),src/renderer/src/logging.ts(shared log forwarding). Touch these only when changing renderer-wide behaviors. -
Component dialogs reuse the same component stack via
src/main/windows/factories/ComponentDialogWindowFactory.ts,src/renderer/src/ui/component-dialog/*, and the mirrored preload (component-dialog-preload.ts). Import typings withimport typeonly—runtime.d.tsimports break the preload bootstrap.
The settings dialog uses a modular, section-based architecture for improved maintainability and testability:
-
Base Contract:
src/renderer/src/ui/settings/sections/SettingsSection.tsdefines theSettingsSectioninterface withinitialize()anddispose()lifecycle hooks. All sections implement this contract. -
Section Implementations (
src/renderer/src/ui/settings/sections/*.ts):AutoUpdateSection: Auto-update configuration and version checkingDesktopThemeSection: Theme selection with live CSS variable updatesDiscordWebhookSection: Discord webhook configuration and testingInputDependencySection: Manages dependent input states (e.g., port fields enabled only when feature is enabled)PrinterContextSection: Per-printer context indicator and settings toggleRoundedUISection: Rounded UI toggle with platform compatibility checks and CSS injectionSpoolmanTestSection: Spoolman server connection testingTabSection: Tab navigation state management
-
Orchestrator:
src/renderer/src/ui/settings/settings-renderer.tsinstantiates all sections, coordinates lifecycle, manages dual settings routing (global config.json vs. per-printer printer_details.json), and handles save/validation logic. -
Type Definitions:
src/renderer/src/ui/settings/types.tsandsrc/renderer/src/ui/settings/types/external.tsprovide shared interfaces for settings APIs and mutable state.
- Create a new class in
src/renderer/src/ui/settings/sections/implementing theSettingsSectioninterface - Instantiate and wire it in
settings-renderer.ts'sinitializeElements()method - Call
initialize()during setup anddispose()during cleanup - Keep section logic isolated—sections should not directly manipulate other sections' state
Initialization Order:
1. CSS & Icon Loading (Lucide icons)
2. Debug State Initialization (initializeDebugState)
3. Platform Detection & Theme Application
4. Legacy UI Controller Setup (LegacyUiController)
5. Shortcut System Initialization
6. Placeholder UI Setup
7. Polling Listeners (polling-update IPC)
8. Printer Tabs Initialization
9. State Tracking (printer state, backend events)
10. Renderer Ready Signal
Key Controllers:
RendererGridController: Manages GridStack integration and component lifecycleLegacyUiController: Handles legacy UI updates and compatibilityShortcutButtonController: Manages top-bar shortcuts and dialog wiring
Per-Printer State Tracking:
printerSerialMap: Maps context IDs to printer serial numbersactiveContextId/activeContextSerial: Track current active context- Layout and shortcut persistence via
loadLayoutForSerial/saveLayoutForSerial
- Singleton:
export const componentManager = new ComponentManager() - Registration:
registerComponent(component) - Initialization:
initializeAll()- callsinitialize()on all - Update Distribution:
updateAll(data)- fans out polling data - Lifecycle:
destroyAll(),removeComponent(id),reinitializeComponent(id)
abstract class BaseComponent {
abstract readonly componentId: string;
abstract readonly templateHTML: string;
abstract update(data: ComponentUpdateData): void;
protected abstract setupEventListeners(): Promise<void>;
}Component definitions are centrally defined in src/shared/component-definitions.ts and shared between Main process (Palette window) and Renderer process (Grid UI).
These components are registered in COMPONENT_REGISTRY_DATA for use in the GridStack dashboard:
- camera-preview (main)
- controls-grid (main)
- model-preview (main)
- job-stats (main)
- printer-status (status-bar)
- temperature-controls (status-bar)
- filtration-controls (status-bar)
- additional-info (status-bar)
- spoolman-tracker (main) - directory:
spoolman/ - ifs-station (main) - IFS Material Station for AD5X printers
- log-panel (utility)
These components are exported from the component system but are not in the GridStack registry:
- job-info (main) - Job information display component
- printer-tabs (multi-printer) - Tab system for printer context switching
Total: 13 Exported Components
export const gridStackManager = new GridStackManager('.grid-stack');Operations:
initialize(options): 12 columns, 80px cell heightaddWidget(config, element): Add with position/sizeremoveWidget(element): Remove and cleanupserialize(): Export layoutenable()/disable(): Toggle editingonChange(callback): Layout change listener
- Storage: localStorage with per-printer keys
saveLayout(serial, layout): PersistloadLayout(serial): Restore with defaults- Keys:
gridstack-layout-<serial>,gridstack-layout
- Toggle: CTRL+E
- Features: Drag/resize handles, remove buttons, palette integration
- State: Edit mode disabled when no printer connected
- Purpose: Central component metadata lookup for GridStack widgets
- Functions:
getComponentDefinition(id),getAllComponents() - Source: Imports definitions from
src/shared/component-definitions.ts
- Purpose: Default layout configurations for GridStack dashboard
- Exports:
DEFAULT_GRID_OPTIONS,DEFAULT_WIDGETS,DEFAULT_LAYOUT - Helpers:
getDefaultLayout(),isValidLayout(),mergeWithDefaults() - Grid: 12-column grid, 80px cell height, 8px margins
- Purpose: TypeScript type definitions for GridStack integration
- Key Types:
GridStackWidgetConfig,LayoutConfig,GridOptions,ComponentDefinition
addTab(context): Create tab with status indicatorremoveTab(contextId): Remove from UIsetActiveTab(contextId): Highlight activeupdateTab(contextId, updates): Update label/status
tab-clicked event
↓
Save current layout → localStorage
↓
Switch context (IPC)
↓
Load new layout ← localStorage
↓
Reload grid → ComponentManager.updateAll(cached data)
↓
Update tabs
Display grid components in modal windows
- Modal blocking
- Frameless with custom title bar
- Per-component sizes
- Own ComponentManager instance
- Same polling updates as main window
Main → createComponentDialog(componentId)
↓
Load component-dialog.html
↓
Send componentId via IPC
↓
Dialog creates component
↓
Polling updates forwarded
Renderer & Components
src/renderer/src/renderer.ts,src/renderer/src/gridController.ts,src/renderer/src/shortcutButtons.ts,src/renderer/src/perPrinterStorage.ts,src/renderer/src/logging.tssrc/renderer/src/ui/components/**(ComponentManager, printer tabs, job info, etc.) +src/renderer/src/ui/gridstack/**for layout/palette logicsrc/renderer/src/ui/component-dialog/**– component dialog renderer + preload mirrorssrc/renderer/src/ui/legacy/LegacyUiController.ts– legacy UI compatibility layer
GridStack System
src/renderer/src/ui/gridstack/GridStackManager.ts– grid initialization and widget managementsrc/renderer/src/ui/gridstack/LayoutPersistence.ts– layout save/load with localStoragesrc/renderer/src/ui/gridstack/EditModeController.ts– edit mode toggle and UIsrc/renderer/src/ui/gridstack/ComponentRegistry.ts– component metadata lookupsrc/renderer/src/ui/gridstack/defaults.ts– default layout configurationssrc/renderer/src/ui/gridstack/types.ts– TypeScript type definitions
Shared Definitions
src/shared/component-definitions.ts– central component registry shared between Main and Renderer
Settings Dialog
src/renderer/src/ui/settings/settings-renderer.ts– main orchestrator for dual settings management (global + per-printer)src/renderer/src/ui/settings/sections/SettingsSection.ts– base interface for modular sectionssrc/renderer/src/ui/settings/sections/*.ts– individual setting sections (AutoUpdate, DesktopTheme, Discord, InputDependency, PrinterContext, RoundedUI, SpoolmanTest, Tab)src/renderer/src/ui/settings/types.ts,src/renderer/src/ui/settings/types/external.ts– shared type definitions