Skip to content

Initial working impl from blueprint#2

Merged
GhostTypes merged 4 commits intomainfrom
claude/printer-discovery-webui-011fJ1E2vK7B8WFy3WNe6T5f
Nov 23, 2025
Merged

Initial working impl from blueprint#2
GhostTypes merged 4 commits intomainfrom
claude/printer-discovery-webui-011fJ1E2vK7B8WFy3WNe6T5f

Conversation

@GhostTypes
Copy link
Copy Markdown
Member

No description provided.

claude and others added 4 commits November 22, 2025 21:53
This implementation adds full WebUI-based printer discovery, connection,
and management capabilities, bridging the gap that previously prevented
proper printer connections via CLI flags.

Backend Changes:
- Enhanced ConnectionEstablishmentService with timeout handling (10s),
  retry logic (3 attempts with exponential backoff), and improved error
  logging to fix CLI connection hangs
- Added discovery API routes (/api/discovery/scan, /api/discovery/scan-ip,
  /api/discovery/status, /api/discovery/cancel) for network scanning
- Added printer management routes (/api/printers/connect,
  /api/printers/disconnect, /api/printers/saved, /api/printers/reconnect)
- Integrated services with proper error handling and validation

Frontend Changes:
- Created printer-discovery feature with tabbed modal interface:
  * Network Scan tab: Auto-discover printers on local network
  * Manual Entry tab: Direct IP connection with printer type selection
  * Saved Printers tab: Reconnect to previously connected printers
- Added "Add Printer" button to header for easy access
- Implemented real-time discovery status updates and spinner
- Added printer card UI with connection status badges
- Full support for both 5M/Pro (new API) and legacy printers

Key Features:
- Network-wide printer discovery with IP matching
- Saved printer management (reconnect, delete)
- Smart printer type detection (5M family vs legacy)
- Check code validation for 5M/Pro printers
- IP address change detection for saved printers
- Comprehensive error handling and user feedback

This resolves the issue where CLI connections would hang during handshake
and enables full discovery/connection workflows from the WebUI, allowing
users to discover printers, match IPs, fetch serials for authentication,
and establish connections without CLI flags.
Fixes:
- Added AD5X and ad5x to 5M family printer detection (was only checking
  for "5M" or "Pro", causing AD5X to be incorrectly identified as legacy
  and failing to prompt for check code)
- Fixed oversized icons by constraining SVG dimensions to 16x16px for:
  * .add-printer-btn icons
  * .discovery-tab-btn icons
  * .btn icons
- Fixed saved printer card text alignment by making .printer-info a
  flex column with proper spacing

The AD5X is now correctly identified as a 5M family printer requiring
dual API connection with check code prompt.
Changed printer type detection to exactly match the backend
PrinterUtils.detectPrinterFamily() implementation:
- Removed overly broad 'Pro' check that could incorrectly catch legacy
  "Pro" models (e.g., Guider Pro, Creator Pro)
- Now only checks for '5m' and 'ad5x' (case-insensitive)
- This correctly identifies:
  * Adventurer 5M (contains '5m')
  * Adventurer 5M Pro (contains '5m')
  * AD5X (contains 'ad5x')
  * AD5X Pro (contains 'ad5x')
- Prevents false positives on legacy Pro models

Reference: FlashForgeUI-Electron/src/utils/PrinterUtils.ts:228-266
Complete the initial porting from FlashForgeUI-Electron to create a
standalone WebUI server for FlashForge 3D printers.

Major changes:
- Add comprehensive CLAUDE.md documentation covering architecture,
  build system, runtime modes, and common patterns
- Implement printer detection routes with 5M family detection logic
- Add mDNS printer discovery support via node-mdns-js
- Refine printer discovery UI with enhanced 5M detection
- Create data/printer_details.json for persistent printer storage
- Remove planning documents (BLUEPRINT, CURRENT_STATUS, etc.)
- Add .claude/commands/push.md for streamlined commits

This represents the first functional version, though not fully tested.
Multi-printer support, camera streaming, Spoolman integration, and
GridStack layout customization are all in place.
@GhostTypes GhostTypes self-assigned this Nov 23, 2025
@GhostTypes GhostTypes merged commit 3040293 into main Nov 23, 2025
@GhostTypes GhostTypes deleted the claude/printer-discovery-webui-011fJ1E2vK7B8WFy3WNe6T5f branch November 23, 2025 19:24
GhostTypes pushed a commit that referenced this pull request Jan 24, 2026
CRITICAL BUG FIX #2:
The previous commit (3910927) fixed the handler logic but introduced a new
initialization order bug that broke STARTUP connections.

PROBLEM:
Event handlers were registered AFTER connecting to printers, causing:
- connectPrinters() runs → backends emit 'backend-initialized'
- NO HANDLER REGISTERED YET → events lost
- Handlers registered after connection complete
- Result: NO MONITORS for startup connections (--last-used, --all-saved)

SOLUTION:
Moved event handler registration BEFORE connecting to printers:

CORRECT ORDER:
1. Initialize Spoolman tracker coordinator
2. Register event handlers (backend-initialized, connected)  ← BEFORE connection
3. Connect to printers (events fire → handlers receive them)
4. Start WebUI

This ensures handlers are ready when backend-initialized events fire during
BOTH startup connections AND dynamic connections.

VERIFIED FLOWS:
✅ Startup: --last-used → handler receives events during connectPrinters()
✅ Startup: --all-saved → handler receives events during connectPrinters()
✅ Dynamic: API /api/printers/connect → handler already registered
✅ Dynamic: API /api/printers/reconnect → handler already registered

Step numbering updated to reflect new order (10, 11, 12, 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