Port printer monitoring to backend-agnostic printer.Printer interface#41
Port printer monitoring to backend-agnostic printer.Printer interface#41kennhung wants to merge 2 commits into
Conversation
Make moonraker.Monitor implement internal/printer's Printer and Thumbnailer interfaces, and switch main.go/internal/web/internal/controller to depend on printer.Printer instead of the concrete *moonraker.Monitor, paving the way for additional backends. Regenerate the Swagger/OpenAPI client and update the frontend to match the resulting neutral DTO shape. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ReviewOverview: this PR extracts a backend-agnostic Issues found1. printDuration := printer.Seconds(m.printerObjects.PrintStats.GetPrintDuration().Seconds())
totalDuration := printer.Seconds(m.printerObjects.PrintStats.GetTotalDuration().Seconds())
...
remaining := totalDuration - printDurationKlipper's The previous code computed a real ETA from the slicer's 2. Nothing outside Minor / non-blocking
No security concerns; import paths and |
Job()'s EstimatedRemaining was computed as total_duration - print_duration (Klipper's accumulated pause time, not an ETA), regressing the pre-port frontend logic. Restore the original two-path estimate: slicer's estimated_time scaled by progress, falling back to extrapolating from print_duration/progress, with total_duration kept separate for the print/total display fields as before. Also remove PrinterObjects()/LatestJob()/LoadedFile(), which have had no external callers since web/controller moved onto printer.Printer. Addresses review feedback on PR #41. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Thanks for the review — pushed 1dc2b83. Fixed:
Confirmed intentional (no change):
Still haven't been able to smoke-test locally (port 8080 occupied by an unrelated already-running dev server), so this is verified by |
Summary
moonraker.Monitorimplement the newinternal/printer.Printer(andprinter.Thumbnailer) interface, dropping its duplicatePrinterState/MonitorConfigtypes in favor of the shared ones.main.go,internal/web, andinternal/controllerto depend onmap[string]printer.Printerinstead of the concrete*moonraker.Monitor, so a future second backend can be added without touching these layers.PrinterDTO to embed the neutralprinter.Job/printer.PrinterState/printer.ErrorInfotypes instead of Moonraker-raw structs; regenerate Swagger/OpenAPI + the frontend axios client accordingly.frontend/src/types.ts,utils.ts,PrinterCard.tsx,App.tsxto match the new DTO shape (drops theloadedFile/latestJobUUID-matching hack in favor ofjob.status === "in_progress").Test plan
go build ./...andgo vet ./...npx tsc -b && vite buildinfrontend/npm run lintinfrontend/(only pre-existing generated-client warnings remain)/api/v1/printersand the dashboard against a live printer (blocked locally by another dev server already bound to :8080)🤖 Generated with Claude Code