1
0
Fork 0
mirror of https://github.com/maziggy/bambuddy.git synced 2026-05-09 08:25:54 +02:00

[PR #643] [CLOSED] [Fix]: Non-Bambu Lab Spools can now be fully linked/unlinked to Spoolman #1091

Closed
opened 2026-05-07 00:15:58 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/643
Author: @shrunbr
Created: 3/7/2026
Status: Closed

Base: mainHead: main


📝 Commits (9)

  • 1f14c33 Expanded link logic to accept a generic spool tag (spool_tag, tray_uuid, or tag_uid) and validate 16/32-char hex values, including rejection of all-zero tags. Added a new unlink endpoint that clears Spoolman extra.tag for a given spool ID.
  • 46906f2 Updated the link validation expectation to match the new 16-or-32-hex rule. Added an integration test for the new unlink endpoint to verify extra.tag is cleared and success is returned.
  • 987eb9f Updated the link API call to send spool_tag instead of tray_uuid. Added a new unlinkSpool API helper that calls the new backend unlink route.
  • f8540a3 Switched modal data source from inventory spools to Spoolman unlinked spools so the list matches the backend response you shared. Updated the link action to call Spoolman link directly and use trayUuid or tagUid as the slot tag.
  • bbd3463 Refactored Spoolman card behavior so actions render correctly across linked/unlinked cases, and added support for an Unlink from Spoolman button under Open in Spoolman. Final UI rule now hides Unlink for Bambu Lab filament and shows it only for non-Bambu linked spools.
  • 0607577 Added fallback slot-tag generation so untagged slots can still be linked/unlinked reliably and linked spool lookups work consistently across AMS, AMS-HT, and external trays. Wired a new unlink mutation and passed per-slot unlink callbacks into the hover card, with query invalidation for linked/unlinked spool caches after unlink.
  • c1204ab Added/updated the noTrayUuid message to reflect that either tray UUID or tag UID is required when no slot tag is available. This keeps error text aligned with the new tag fallback and modal behavior.
  • f5f474a Added noTrayUuid message in the other languages. The translation was done using Google Translate.
  • 0e54389 Updated LinkSpoolModal tests to use Spoolman API instead of inventory API, with new UnlinkedSpool data structure and Select Spool UI text.

📊 Changes

12 files changed (+253 additions, -156 deletions)

View changed files

📝 backend/app/api/routes/spoolman.py (+56 -12)
📝 backend/tests/integration/test_spoolman_api.py (+18 -1)
📝 frontend/src/__tests__/components/LinkSpoolModal.test.tsx (+30 -60)
📝 frontend/src/api/client.ts (+6 -2)
📝 frontend/src/components/FilamentHoverCard.tsx (+62 -36)
📝 frontend/src/components/LinkSpoolModal.tsx (+25 -27)
📝 frontend/src/i18n/locales/de.ts (+1 -0)
📝 frontend/src/i18n/locales/en.ts (+1 -0)
📝 frontend/src/i18n/locales/fr.ts (+1 -0)
📝 frontend/src/i18n/locales/it.ts (+1 -0)
📝 frontend/src/i18n/locales/pt-BR.ts (+1 -0)
📝 frontend/src/pages/PrintersPage.tsx (+51 -18)

📄 Description

Description

This fixes the issue where the "Link to Spoolman" button was not showing for non-Bambu Lab spools. Generic tags are generated for each non-Bambu spool using Printer ID + AMS ID + Tray ID. This tag is then used in the extra.tag field within Spoolman.

In addition to fixing the spoolman linking issue, I've also added an Unlink from Spoolman button to non-Bambu spools which are linked so that the tag field can be cleared right from the interface rather than going into Spoolman to do it manually.

COPILOT WRITTEN SUMMARY BELOW

This pull request refactors and expands the Spoolman spool linking functionality to support both tray UUIDs and generic tag UIDs, improves validation and error handling, and adds support for unlinking spools. It also updates frontend components and tests to match these backend changes, ensuring a consistent user experience and robust integration.

#639

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

FRONTEND CHANGES

  • LinkSpoolModal now uses the Spoolman API and not the Inventory API
  • linkTagToSpool in LinkSpoolModal has been simplified to linkSpool(spoolId, spoolTag)
  • Added "Unlink from Spoolman" button below the "Open in Spoolman" button only on non-Bambu filaments
  • Updated FilamentHoverCard to show the Spoolman link button even when trayUuid is missing using failback tag generation
  • Added unlinkSpoolMutation in PrintersPage with cache invalidation for linked/unlinked spool maps
  • Implemented getFallbackSpoolTag() in PrintersPage to generate the 16-char ID for slots without RFID identifiers
  • Added onUnlinkSpool callbacks for standard AMS, AMS-HT and external tray slots
  • Updated linkSpool in client.ts to accept spoolTag parameter instead of object request
  • Added unlinkSpool(spoolId) method in client.ts
  • Updated all test expectations in LinkSpoolModal.test.tsx to use new Spoolman API methods, data structure and "Select Spool" UI text

BACKEND CHANGES

  • Updated LinkSpoolRequest in spoolman.py to accept spool_tag, tray_uuid or tag_uid
  • Modified link validation in spoolman.py to accept both 16 and 32-char hex tags
  • Added POST /spoolman/spools/{spool_id}/unlink endpoint in spoolman.py to clear extra.tag field
  • Updated link validation test expectation to "16 or 32 hex characters" in test_spoolman_api.py
  • Added unlink success test validating tag is cleared to empty JSON string in test_spoolman_api.py

TRANSLATIONS

  • Added translations for "noTrayUuid" key for missing tag scenarios

Screenshots

link-to-spoolman-button link-modal open-spoolman-unlink

Testing

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

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

N/A


🔄 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/643 **Author:** [@shrunbr](https://github.com/shrunbr) **Created:** 3/7/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (9) - [`1f14c33`](https://github.com/maziggy/bambuddy/commit/1f14c331ccb40cb2a8eab4373c78975676f73481) Expanded link logic to accept a generic spool tag (spool_tag, tray_uuid, or tag_uid) and validate 16/32-char hex values, including rejection of all-zero tags. Added a new unlink endpoint that clears Spoolman extra.tag for a given spool ID. - [`46906f2`](https://github.com/maziggy/bambuddy/commit/46906f2b82274d5394f57f2b45d8a7fd62bea38e) Updated the link validation expectation to match the new 16-or-32-hex rule. Added an integration test for the new unlink endpoint to verify extra.tag is cleared and success is returned. - [`987eb9f`](https://github.com/maziggy/bambuddy/commit/987eb9f71b6e697ed17272f6bbc50c5797e475cd) Updated the link API call to send spool_tag instead of tray_uuid. Added a new unlinkSpool API helper that calls the new backend unlink route. - [`f8540a3`](https://github.com/maziggy/bambuddy/commit/f8540a352afbfbe1358acbf94e56e254e1ec25cd) Switched modal data source from inventory spools to Spoolman unlinked spools so the list matches the backend response you shared. Updated the link action to call Spoolman link directly and use trayUuid or tagUid as the slot tag. - [`bbd3463`](https://github.com/maziggy/bambuddy/commit/bbd346339564cdefac41967f91506b33cf6a31ab) Refactored Spoolman card behavior so actions render correctly across linked/unlinked cases, and added support for an Unlink from Spoolman button under Open in Spoolman. Final UI rule now hides Unlink for Bambu Lab filament and shows it only for non-Bambu linked spools. - [`0607577`](https://github.com/maziggy/bambuddy/commit/060757714581b4063c81e2bbd672ed8f0658f90e) Added fallback slot-tag generation so untagged slots can still be linked/unlinked reliably and linked spool lookups work consistently across AMS, AMS-HT, and external trays. Wired a new unlink mutation and passed per-slot unlink callbacks into the hover card, with query invalidation for linked/unlinked spool caches after unlink. - [`c1204ab`](https://github.com/maziggy/bambuddy/commit/c1204abd7603e062451002ffc432460d87d210cb) Added/updated the noTrayUuid message to reflect that either tray UUID or tag UID is required when no slot tag is available. This keeps error text aligned with the new tag fallback and modal behavior. - [`f5f474a`](https://github.com/maziggy/bambuddy/commit/f5f474abe32391e16bd7875681bee3462cfb3859) Added noTrayUuid message in the other languages. The translation was done using Google Translate. - [`0e54389`](https://github.com/maziggy/bambuddy/commit/0e54389daacd2847ecc06c6c3c84ad0c56d93c91) Updated LinkSpoolModal tests to use Spoolman API instead of inventory API, with new UnlinkedSpool data structure and Select Spool UI text. ### 📊 Changes **12 files changed** (+253 additions, -156 deletions) <details> <summary>View changed files</summary> 📝 `backend/app/api/routes/spoolman.py` (+56 -12) 📝 `backend/tests/integration/test_spoolman_api.py` (+18 -1) 📝 `frontend/src/__tests__/components/LinkSpoolModal.test.tsx` (+30 -60) 📝 `frontend/src/api/client.ts` (+6 -2) 📝 `frontend/src/components/FilamentHoverCard.tsx` (+62 -36) 📝 `frontend/src/components/LinkSpoolModal.tsx` (+25 -27) 📝 `frontend/src/i18n/locales/de.ts` (+1 -0) 📝 `frontend/src/i18n/locales/en.ts` (+1 -0) 📝 `frontend/src/i18n/locales/fr.ts` (+1 -0) 📝 `frontend/src/i18n/locales/it.ts` (+1 -0) 📝 `frontend/src/i18n/locales/pt-BR.ts` (+1 -0) 📝 `frontend/src/pages/PrintersPage.tsx` (+51 -18) </details> ### 📄 Description ## Description This fixes the issue where the "Link to Spoolman" button was not showing for non-Bambu Lab spools. Generic tags are generated for each non-Bambu spool using Printer ID + AMS ID + Tray ID. This tag is then used in the extra.tag field within Spoolman. In addition to fixing the spoolman linking issue, I've also added an Unlink from Spoolman button to non-Bambu spools which are linked so that the tag field can be cleared right from the interface rather than going into Spoolman to do it manually. **COPILOT WRITTEN SUMMARY BELOW** This pull request refactors and expands the Spoolman spool linking functionality to support both tray UUIDs and generic tag UIDs, improves validation and error handling, and adds support for unlinking spools. It also updates frontend components and tests to match these backend changes, ensuring a consistent user experience and robust integration. ## Related Issue #639 ## Type of Change <!-- Mark the relevant option with an "x" --> - [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 **FRONTEND CHANGES** - LinkSpoolModal now uses the Spoolman API and not the Inventory API - linkTagToSpool in LinkSpoolModal has been simplified to linkSpool(spoolId, spoolTag) - Added "Unlink from Spoolman" button below the "Open in Spoolman" button only on non-Bambu filaments - Updated FilamentHoverCard to show the Spoolman link button even when trayUuid is missing using failback tag generation - Added unlinkSpoolMutation in PrintersPage with cache invalidation for linked/unlinked spool maps - Implemented getFallbackSpoolTag() in PrintersPage to generate the 16-char ID for slots without RFID identifiers - Added onUnlinkSpool callbacks for standard AMS, AMS-HT and external tray slots - Updated linkSpool in client.ts to accept spoolTag parameter instead of object request - Added unlinkSpool(spoolId) method in client.ts - Updated all test expectations in LinkSpoolModal.test.tsx to use new Spoolman API methods, data structure and "Select Spool" UI text **BACKEND CHANGES** - Updated LinkSpoolRequest in spoolman.py to accept spool_tag, tray_uuid or tag_uid - Modified link validation in spoolman.py to accept both 16 and 32-char hex tags - Added POST /spoolman/spools/{spool_id}/unlink endpoint in spoolman.py to clear extra.tag field - Updated link validation test expectation to "16 or 32 hex characters" in test_spoolman_api.py - Added unlink success test validating tag is cleared to empty JSON string in test_spoolman_api.py **TRANSLATIONS** - Added translations for "noTrayUuid" key for missing tag scenarios ## Screenshots <img width="757" height="725" alt="link-to-spoolman-button" src="https://github.com/user-attachments/assets/5395c298-6d68-4614-bef7-f6c6f71f0380" /> <img width="478" height="492" alt="link-modal" src="https://github.com/user-attachments/assets/bf9b9164-ea85-473f-8420-8f266e21badc" /> <img width="766" height="732" alt="open-spoolman-unlink" src="https://github.com/user-attachments/assets/b78d5c15-3614-4f91-b917-4acf2100962d" /> ## Testing - [X] I have tested this on my local machine - [X] I have tested with my printer model: <!-- e.g., X1C, P1S, A1 --> ## Checklist - [X] My code follows the project's coding style - [X] I have commented my code where necessary - [X] I have updated the documentation (if needed) - [X] My changes generate no new warnings - [X] I have tested my changes thoroughly ## Additional Notes N/A --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 00:15:58 +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-maziggy-1#1091
No description provided.