mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 00:08:34 +02:00
[PR #1200] [Fix] Dual-UID spool identification, use tray_uuid end-to-end #1176
Labels
No labels
A1
automated
automated
bug
bug
Closed due to inactivity
contrib
dependencies
dependencies
duplicate
enhancement
feedback
hold
invalid
Notes
P1S
pull-request
security
ThumbsUp
user-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/bambuddy-maziggy-1#1176
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/maziggy/bambuddy/pull/1200
Author: @Keybored02
Created: 5/3/2026
Status: 🔄 Open
Base:
dev← Head:fix/tray_uuid📝 Commits (8)
601184aAdd block 9 to NFC readerefdaf0aMigrate to tray_uuidc40d856fix(spool): ensure tag removal clears state for fresh card displayf947075fix(spool): add optional tag_uid_2 field to MatchedSpool interface60456c7fix(spool): add optional tag_uid_2 field to SpoolBuddy components75225effix(spool): add optional tag_uid_2 field to SpoolBuddyDashboard116495bfix(spool): allow tagId and tagUid to be nullable in LinkSpoolModal and SpoolInfoCard847b6c2Merge branch 'dev' into fix/tray_uuid📊 Changes
24 files changed (+247 additions, -150 deletions)
View changed files
📝
backend/app/api/routes/inventory.py(+29 -9)📝
backend/app/api/routes/spoolbuddy.py(+3 -0)📝
backend/app/core/database.py(+4 -0)📝
backend/app/models/spool.py(+4 -1)📝
backend/app/schemas/spool.py(+3 -0)📝
backend/app/services/spool_tag_matcher.py(+96 -77)📝
frontend/src/__tests__/components/AssignSpoolModal.test.tsx(+3 -0)📝
frontend/src/__tests__/components/SpoolFormBulk.test.tsx(+1 -0)📝
frontend/src/__tests__/components/SpoolFormModal.test.tsx(+1 -0)📝
frontend/src/__tests__/pages/InventoryPageGrouping.test.ts(+1 -0)📝
frontend/src/__tests__/pages/InventoryPageLowStock.test.tsx(+3 -0)📝
frontend/src/api/client.ts(+2 -1)📝
frontend/src/components/SpoolFormModal.tsx(+2 -2)📝
frontend/src/components/spoolbuddy/InventorySpoolInfoCard.tsx(+7 -2)📝
frontend/src/components/spoolbuddy/LinkSpoolModal.tsx(+1 -1)📝
frontend/src/components/spoolbuddy/SpoolInfoCard.tsx(+8 -3)📝
frontend/src/components/spoolbuddy/TagDetectedModal.tsx(+7 -2)📝
frontend/src/hooks/useSpoolBuddyState.ts(+16 -2)📝
frontend/src/pages/InventoryPage.tsx(+7 -4)📝
frontend/src/pages/spoolbuddy/SpoolBuddyDashboard.tsx(+23 -15)...and 4 more files
📄 Description
Description
Adds a secondary
tag_uid_2field so a spool can be identified by two different hardware UIDs (different physical tags). Fixes tray_uuid being silently dropped when adding a new spool through SpoolBuddy — it's now saved and used as the primary match identifier end-to-end. Also fixes the spool card staying visible on the SpoolBuddy dashboard after removing a freshly-added spool.Related Issue
Fixes #984
Documentation
Companion docs PRs (delete lines that don't apply):
Pick one:
Type of Change
Changes Made
Adds an optional secondary hardware UID column per spool, to handle the real-world case where the same physical tag is reported with a different first byte by different NFC reader hardware. The second slot is strictly opt-in — it is never auto-assigned; it can only be set explicitly via the PATCH /spools/{id}/link-tag API or the spool form.
New tag_uid_2 VARCHAR(16) column on the spool table with an inline _safe_execute migration
All matching logic (get_spool_by_tag, fuzzy fallback) searches both columns transparently via a shared _fuzzy_uid_match() helper
Conflict checks in the link-tag route cover both columns on active and archived spools
Frontend displays the primary UID with both in the tooltip; "tagged/untagged" filters and the write-tag page check both columns
Previously, when a Bambu Lab spool was scanned by SpoolBuddy and the user created a new inventory entry or linked it to an existing spool, the tray_uuid (read from MIFARE Classic block 9) was silently dropped. This meant subsequent scans matched by hardware UID only, losing the more-reliable UUID-based matching.
spoolbuddy_unknown_tag and spoolbuddy_tag_matched WebSocket broadcasts now include tray_uuid
useSpoolBuddyState carries tray_uuid through state (unknownTrayUuid, currentTrayUuid)
SpoolBuddyDashboard tracks displayedTrayUuid alongside displayedTagId, and passes it to createSpool and linkTagToSpool calls
tag_type is set to 'bambulab' (not 'generic') when a tray_uuid is present
After a quick-add, removing the spool from the scale/reader left the card visible. The tag-removal useEffect only cleared state when hiddenTagId was set (i.e. the user had closed the card), so a freshly-added spool — where the card was never manually closed — was never cleared on physical removal.
The else-branch now clears displayedTagId/displayedTrayUuid whenever either is non-null, unconditionally
Screenshots
Testing
Checklist
Additional Notes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.