[PR #789] [MERGED] Add notification for no spool assigned for active trays, improve usage tracker logic in edge cases #1116

Closed
opened 2026-05-06 12:35:09 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/789
Author: @Keybored02
Created: 3/22/2026
Status: Merged
Merged: 3/24/2026
Merged by: @maziggy

Base: devHead: feature/no_assigned_spool


📝 Commits (10+)

  • aadf9f3 Revert "Set version"
  • 20ee781 Updated README
  • d4e38b5 Merge branch 'dev' of https://github.com/Keybored02/bambuddy into dev
  • 55eccd1 Add missing spool assignment notification feature
  • 9db0eff Implement spool ID resolution for mid-print reassignment and unit tests for tracking logic
  • b6b1dfe handle mid-print spool reassignments without breaking snapshot fallback
  • a43932f Add tray color resolution and update notification templates
  • 205d16e Merge branch 'dev' into feature/no_assigned_spool
  • 61cc941 Added locales
  • ae8fbdc Move functions to deedicated file

📊 Changes

28 files changed (+726 additions, -70 deletions)

View changed files

📝 backend/app/api/routes/notifications.py (+2 -0)
📝 backend/app/core/database.py (+8 -0)
📝 backend/app/core/websocket.py (+16 -0)
📝 backend/app/main.py (+6 -0)
📝 backend/app/models/notification.py (+1 -0)
📝 backend/app/models/notification_template.py (+6 -0)
📝 backend/app/schemas/notification.py (+5 -0)
📝 backend/app/schemas/notification_template.py (+15 -0)
📝 backend/app/services/notification_service.py (+41 -0)
backend/app/services/spool_assignment_notifications.py (+169 -0)
📝 backend/app/services/usage_tracker.py (+99 -47)
📝 backend/tests/conftest.py (+1 -0)
📝 backend/tests/integration/test_notifications_api.py (+36 -0)
backend/tests/unit/services/test_spool_assignment_notifications.py (+77 -0)
📝 backend/tests/unit/services/test_usage_tracker.py (+7 -3)
📝 backend/tests/unit/test_usage_tracker.py (+102 -1)
📝 frontend/src/__tests__/hooks/useWebSocket.test.ts (+56 -17)
📝 frontend/src/api/client.ts (+3 -0)
📝 frontend/src/components/NotificationProviderCard.tsx (+14 -0)
📝 frontend/src/contexts/ToastContext.tsx (+4 -1)

...and 8 more files

📄 Description

Description

Added print-start check for missing spool assignments: shows dismissible frontend warning and supports notification event/toggle in settings. Improved usage tracking: now correctly handles mid-print spool changes, using live assignment if changed after print start, otherwise falls back to snapshot.

Fixes #763

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition or update

Changes Made

  • Added a print-start check for missing spool assignments: if a print uses trays without assigned spools, a persistent, dismissible warning is shown in the frontend.
  • Introduced a new notification event and toggle (“Missing Spool Assignment”) under Print Events in notification settings.
    • This is fully integrated: backend model, schema, API, notification template, and frontend UI, with i18n support.
  • Notification content includes printer name, missing tray/slot, and expected material profile and color for better context.
  • Improved usage tracking logic: at print completion, if a spool assignment was changed during the print, the system now uses the live assignment (if its timestamp is after print start); otherwise, it falls back to the snapshot taken at print start. This ensures correct filament deduction even with mid-print spool changes.
  • Hardened the resolver to handle mocked DB flows and non-datetime values, and updated related unit/service tests for compatibility with the new logic.

Testing

  • I have tested this on my local machine
  • I have tested with my printer model: H2C

Checklist

  • My code follows the project's coding style
  • I have commented my code where necessary
  • I have updated the documentation (if needed)
  • My changes generate no new warnings
  • I have tested my changes thoroughly

Additional Notes


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/maziggy/bambuddy/pull/789 **Author:** [@Keybored02](https://github.com/Keybored02) **Created:** 3/22/2026 **Status:** ✅ Merged **Merged:** 3/24/2026 **Merged by:** [@maziggy](https://github.com/maziggy) **Base:** `dev` ← **Head:** `feature/no_assigned_spool` --- ### 📝 Commits (10+) - [`aadf9f3`](https://github.com/maziggy/bambuddy/commit/aadf9f365fdca6bce6489ee892114fd4611096b1) Revert "Set version" - [`20ee781`](https://github.com/maziggy/bambuddy/commit/20ee781a15a64c81ff42171a17bae8d10fc602b8) Updated README - [`d4e38b5`](https://github.com/maziggy/bambuddy/commit/d4e38b5105ddb0f0203d4ab675868997f30a89d2) Merge branch 'dev' of https://github.com/Keybored02/bambuddy into dev - [`55eccd1`](https://github.com/maziggy/bambuddy/commit/55eccd166fd915afd208b123d55b2e2700f6befb) Add missing spool assignment notification feature - [`9db0eff`](https://github.com/maziggy/bambuddy/commit/9db0eff751ddf6fe9c66737d64597137ebffb4c2) Implement spool ID resolution for mid-print reassignment and unit tests for tracking logic - [`b6b1dfe`](https://github.com/maziggy/bambuddy/commit/b6b1dfe9e782dffecabc6b53837653e69edc6f66) handle mid-print spool reassignments without breaking snapshot fallback - [`a43932f`](https://github.com/maziggy/bambuddy/commit/a43932f6bcc677cdfa1e081b70ef2189fce5375d) Add tray color resolution and update notification templates - [`205d16e`](https://github.com/maziggy/bambuddy/commit/205d16ed2174b29cd9195185781fd613ff311826) Merge branch 'dev' into feature/no_assigned_spool - [`61cc941`](https://github.com/maziggy/bambuddy/commit/61cc941040f78d01892090583e5014f8226b3089) Added locales - [`ae8fbdc`](https://github.com/maziggy/bambuddy/commit/ae8fbdcbeae572f70d504f79199a7df48756c9ab) Move functions to deedicated file ### 📊 Changes **28 files changed** (+726 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `backend/app/api/routes/notifications.py` (+2 -0) 📝 `backend/app/core/database.py` (+8 -0) 📝 `backend/app/core/websocket.py` (+16 -0) 📝 `backend/app/main.py` (+6 -0) 📝 `backend/app/models/notification.py` (+1 -0) 📝 `backend/app/models/notification_template.py` (+6 -0) 📝 `backend/app/schemas/notification.py` (+5 -0) 📝 `backend/app/schemas/notification_template.py` (+15 -0) 📝 `backend/app/services/notification_service.py` (+41 -0) ➕ `backend/app/services/spool_assignment_notifications.py` (+169 -0) 📝 `backend/app/services/usage_tracker.py` (+99 -47) 📝 `backend/tests/conftest.py` (+1 -0) 📝 `backend/tests/integration/test_notifications_api.py` (+36 -0) ➕ `backend/tests/unit/services/test_spool_assignment_notifications.py` (+77 -0) 📝 `backend/tests/unit/services/test_usage_tracker.py` (+7 -3) 📝 `backend/tests/unit/test_usage_tracker.py` (+102 -1) 📝 `frontend/src/__tests__/hooks/useWebSocket.test.ts` (+56 -17) 📝 `frontend/src/api/client.ts` (+3 -0) 📝 `frontend/src/components/NotificationProviderCard.tsx` (+14 -0) 📝 `frontend/src/contexts/ToastContext.tsx` (+4 -1) _...and 8 more files_ </details> ### 📄 Description ## Description Added print-start check for missing spool assignments: shows dismissible frontend warning and supports notification event/toggle in settings. Improved usage tracking: now correctly handles mid-print spool changes, using live assignment if changed after print start, otherwise falls back to snapshot. ## Related Issue <!-- Link to the issue this PR addresses (if applicable) --> Fixes #763 ## Type of Change <!-- Mark the relevant option with an "x" --> - [ ] Bug fix (non-breaking change that fixes an issue) - [x] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [x] Test addition or update ## Changes Made <!-- List the specific changes made in this PR --> - Added a print-start check for missing spool assignments: if a print uses trays without assigned spools, a persistent, dismissible warning is shown in the frontend. - Introduced a new notification event and toggle (“Missing Spool Assignment”) under Print Events in notification settings. - This is fully integrated: backend model, schema, API, notification template, and frontend UI, with i18n support. - Notification content includes printer name, missing tray/slot, and expected material profile and color for better context. - Improved usage tracking logic: at print completion, if a spool assignment was changed during the print, the system now uses the live assignment (if its timestamp is after print start); otherwise, it falls back to the snapshot taken at print start. This ensures correct filament deduction even with mid-print spool changes. - Hardened the resolver to handle mocked DB flows and non-datetime values, and updated related unit/service tests for compatibility with the new logic. ## Testing <!-- Describe how you tested your changes --> - [x] I have tested this on my local machine - [x] I have tested with my printer model: H2C ## Checklist - [x] My code follows the project's coding style - [x] I have commented my code where necessary - [ ] I have updated the documentation (if needed) - [x] My changes generate no new warnings - [x] I have tested my changes thoroughly ## Additional Notes <!-- Add any additional information that reviewers should know --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:35:09 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bambuddy#1116
No description provided.