mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 19:21:33 +02:00
Two related bugs in K-profile matching, same root cause. #1688 — spool form's PA-profile suggester (PAProfileSection via isMatchingCalibration in spool-form/utils.ts) matched K-profiles by parsing the profile NAME for material/brand/variant. Spools already store slicer_filament (the slicer preset id) and K-profiles already carry filament_id, but both were ignored — so a user's custom K-profile whose name doesn't agree with the slicer preset got silently dropped from suggestions even when the underlying filament_id was identical. #1689 — ConfigureAmsSlotModal's matchingKProfiles ran the same name-only logic on the slot's selected preset. A spool assigned under "Generic PLA" with a custom K-profile actively bound on the printer landed in the modal as "K profile not assigned, default 0.020 will be used", while the printer-card hover-card correctly showed the active profile. Two paths, only one was filtering by name. Shared root: spool preset ids and K-profile filament_ids look different but are equivalent after normalising. Spools store slicer_filament as the cloud setting_id form ("GFSG98_09" — _09 is the variant suffix, the S infix marks setting_id form); K-profiles store filament_id as the bare form ("GFG98"). Plain === doesn't work; both need normalising. This conversion already existed in the other direction at buildFilamentOptions (filament_id → "GFS" + filament_id.slice(2)), so the inverse toFilamentId helper is just the matching reverse, not new ground. Fix — one shared helper, two surfaces: - spool-form/utils.ts: new exports toFilamentId(id) (drops "_NN" variant suffix and strips the "S" in "GFS", so GFSG98_09 → GFG98) and isGenericFilamentId(id) (flags Bambu's generic GFx99 ids which are shared across many filaments and must NOT id-match — the name fallback handles those correctly). - isMatchingCalibration: gains slicer_filament?: string in formData, tries id-match (with generic exclusion) before the existing name parse. PAProfileSection already passes the full formData so no caller edit needed. Strictly additive precedence. - ConfigureAmsSlotModal.selectedPresetInfo: resolves a filamentId field (toFilamentId(cp.setting_id) for cloud presets, toFilamentId(builtinFilamentId) for builtin; empty for local / orca paths which fall through to name match). - ConfigureAmsSlotModal.matchingKProfiles: id-match check at the top of the per-profile predicate (preferred when both sides agree after normalisation), then the existing name-parse logic, then ALWAYS unshifts the slot's currently-active K-profile by slot_id === slotInfo.caliIdx — gated on activeIdx > 0 (so caliIdx 0/null doesn't leak unrelated profiles in), extruder-matched when slotInfo.extruderId is known. This is Spionkiller01's #1689 patch verbatim with the activeIdx > 0 guard added. SpoolBuddy: both kiosk K-profile surfaces reuse the shared components. SpoolBuddyWriteTagPage renders PAProfileSection; SpoolBuddyAmsPage renders ConfigureAmsSlotModal. Verified — fixes propagate automatically, no kiosk-specific edits. What this does NOT change: spools without slicer_filament, K-profiles without filament_id, and generic GFx99 ids all fall through to the existing name-based matching path. Strictly additive precedence; no input shape that matched under the old logic fails to match under the new. The #1053 cloud-preset PFUS* path is preserved because the toFilamentId regex /^GFS/ doesn't match a "PFU" prefix.