Last Updated: 2026-03-11 17:36 ET (America/New_York)
This document covers camera streaming, Spoolman filament tracking, and notification systems.
-
Go2rtcServiceprovides unified camera streaming using go2rtc as the streaming gateway. It replaces both the old MJPEG proxy and RTSP-to-WebSocket approaches with a single, consistent interface. -
Go2rtcBinaryManagerhandles the go2rtc binary lifecycle (download, update, start/stop). The binary is stored in the userData directory and automatically managed. -
Ports are hardcoded in
Go2rtcBinaryManager: 1984 for the go2rtc API, 8555 for WebRTC. These are fixed values and do not require dynamic allocation. -
go2rtc handles all protocol conversion internally: RTSP/MJPEG sources are converted to WebRTC, MSE, or MJPEG fallback for browser consumption. This eliminates the canvas rotation bug from JSMpeg and reduces latency to ~500ms.
-
Renderer-side components (
src/renderer/src/ui/components/camera-preview) and WebUI (src/main/webui/static/features/camera.ts) consume go2rtc streams viavideo-rtc.js(WebRTC) or native<video>elements.
- Unified streaming for all camera types (builtin RTSP, custom MJPEG/RTSP)
- Protocol-agnostic: go2rtc handles RTSP → WebRTC/MSE/MJPEG conversion
- Per-context stream management with unique stream names
- Automatic reconnection built into go2rtc
- No ffmpeg dependency for basic streaming (go2rtc includes native RTSP support)
- Status monitoring and stream info API
- Downloads platform-specific go2rtc binary on first use
- Stores binary in userData/go2rtc/
- Checks for updates on startup (optional, version-pinned by default)
- Manages binary process lifecycle (start/stop/restart)
- Configures go2rtc with streams from active printer contexts
- Provides shared camera stream reconciliation helpers for desktop IPC and WebUI routes
- Main entry point:
resolveAndEnsureCameraStream()- resolves camera config and ensures go2rtc stream exists - Combines camera configuration resolution with go2rtc stream management
- Handles stream cleanup when cameras become unavailable
- Returns
EnsuredCameraStreamwith resolved config and stream configuration
- Priority-based camera resolution: custom camera > OEM camera > none
- MJPEG and RTSP stream type detection via URL protocol parsing
- URL validation with detailed error messages (protocol, hostname, format)
- Context-aware camera configuration retrieval (per-printer or global settings)
- Proxy URL formatting for go2rtc WebSocket and MJPEG endpoints
The following services have been replaced by go2rtc:
CameraProxyService(MJPEG proxy) → now handled by go2rtcRtspStreamService(node-rtsp-stream + ffmpeg) → now handled by go2rtc
Do not use these legacy services for new code.
-
Configuration toggles live in
AppConfig:SpoolmanEnabled,SpoolmanServerUrl,SpoolmanUpdateMode. IPC handlers insrc/main/ipc/handlers/spoolman-handlers.tsexpose config/get/set/selection APIs to both renderer and WebUI. -
SpoolmanIntegrationServiceis the source of truth for active spool assignments. It persists selections per printer inprinter_details.json, enforces AD5X/material-station blocking (feature detection + model prefix), validates configuration, and emits events for desktop/WebUI consumers. Do not bypass it. -
SpoolmanServicewraps the REST API with 10 s timeouts, usage updates (weight or length), search, and connectivity checks.SpoolmanUsageTracker+MultiContextSpoolmanTrackerlisten for print completion/cooling to submit usage updates, whileSpoolmanHealthMonitorpings the server and resets cache/UI state when connectivity flips. -
WebUI routing lives in
src/main/webui/server/routes/spoolman-routes.ts; the static client feature issrc/main/webui/static/features/spoolman.ts. Keep API responses consistent between desktop and WebUI flows. -
Renderer dialogs:
src/renderer/src/ui/spoolman-dialog,src/renderer/src/ui/spoolman-offline-dialog, and spool badges/components embedded in both the main gridstack dashboard and component dialogs. Maintainspoolman-changedevents so everything rehydrates correctly.
- REST API client (10s timeout)
- Operations: ping, getSpool, searchSpools, useFilament
- Single source of truth for active spool selections
- Per-printer persistence in printer_details.json
- AD5X/material-station blocking
- Event broadcasting: 'spoolman-changed'
- Listen to 'cooling-complete' events
- Calculate usage from job metadata
- Submit to Spoolman API
- Per-context tracker instances
- Manages per-context SpoolmanUsageTracker instances for all connected printers
- Maps context IDs to individual SpoolmanUsageTracker instances
- Listens to PrinterContextManager events for context lifecycle (creation/removal)
- Creates trackers when print state monitors are ready for each context
- Handles automatic cleanup when contexts are removed
- Works in both GUI and headless modes (no mode-specific checks)
- Forwards events from individual trackers to global listeners
- Singleton pattern with global instance via
getMultiContextSpoolmanTracker()
-
Desktop notifications flow through
src/main/services/notifications/NotificationService+PrinterNotificationCoordinator. -
MultiContextNotificationCoordinatorensures every context gets its own coordinator regardless of which tab is active. -
Discord integration (
src/main/services/discord/DiscordNotificationService.ts) mirrors printer events to webhook embeds with rate limiting and per-context timers. Config keys:DiscordSync,WebhookUrl,DiscordUpdateIntervalMinutes. -
Web push notifications are specced in
ai_specs/webui-push-notifications.md. Implementations should addWebPushService, subscription managers, and WebUI UI/worker updates without regressing desktop/Discord flows.
- Desktop notification wrapper
- Platform compatibility detection
- Lifecycle events (sent, clicked, closed)
- 24-hour retention
- Silent notification support
- Per-printer notification coordinators
- Shared NotificationService
- Independent state per context
- Notification types: completion, cooling, errors, material station
- Webhook integration
- Timer-based updates (configurable interval, default 5min)
- Event-driven: Print complete, printer cooled, idle transition
- Per-context tracking with state caching
- Rich embeds with temperatures, progress, material usage
- Rate limiting (1s delay between messages)
-
PrinterDetailsManagermanages JSON persistence for printers, last-used serials, per-printer settings (camera, LEDs, spoolman, custom features) and stores runtime context-to-printer mappings. -
SavedPrinterServiceexposes helpers to match discovered printers, track IP changes, and updatelastConnected. It is the single source for UI lists and headless boot data. -
AutoConnectServiceandConnectionFlowManagerrely on these stores to auto-launch saved printers or rehydrate contexts after restarts.
Camera, Notifications & Ports
src/main/services/Go2rtcService.ts,Go2rtcBinaryManager.ts,CameraStreamCoordinator.tssrc/main/utils/camera-utils.tssrc/main/ipc/camera-ipc-handler.ts,src/main/webui/server/routes/camera-routes.tssrc/main/services/notifications/*,src/main/services/discord/DiscordNotificationService.ts
Spoolman & Filament
src/main/services/SpoolmanIntegrationService.ts,SpoolmanService.ts,SpoolmanUsageTracker.ts,SpoolmanHealthMonitor.ts,MultiContextSpoolmanTracker.tssrc/main/ipc/handlers/spoolman-handlers.ts,src/renderer/src/ui/spoolman-dialog/*,src/renderer/src/ui/spoolman-offline-dialog/*src/main/webui/server/routes/spoolman-routes.ts,src/main/webui/static/features/spoolman.ts