fix(print-log): render one swatch per color for multi-color filament rows (#1731 part 1)

The per-archive Print Log table cell at ArchivesPage.tsx:3882 rendered
  filament_color as a single swatch with
  `backgroundColor: entry.filament_color.startsWith('#') ? ... : undefined`.

  For multi-color prints, the backend writes filament_color as a comma-joined
  string ("#FFFFFF,#000000,#FF0000"). The whole string trivially passed the
  startsWith('#') check but isn't a valid CSS color — the browser silently
  drops the declaration and the swatch falls back to its black/20% border,
  which on the dark theme reads as a barely-visible grey dot. Reporter's
  screenshots showed "PLA" text with no visible swatch at all. DB column
  was correct; render dropped the colors.

  The Archive Card view at ArchivesPage.tsx:1072-1083 and :2114-2125 already
  splits on comma and renders one swatch per color — only the Print Log
  table cell had been missed when multi-color support landed elsewhere.

  Fix mirrors the card pattern: wrap swatches in a flex container, split
  on comma, trim, render one w-3 h-3 swatch per color with
  backgroundColor and title={trimmed}. Single-color prints render one
  swatch (no behaviour change). Empty / non-hex entries fall through to
  no backgroundColor rather than poisoning the CSS for siblings.

  Does NOT cover the reporter's second symptom — new multi-color prints
  missing from filament usage history. That's usage_tracker._track_from_3mf
  and the slot-to-tray mapping chain; needs a support bundle (PRINT START
  + PRINT COMPLETE [UsageTracker] log lines + captured ams_mapping) before
  shape can be confirmed. Tracking as #1731 part 2.
This commit is contained in:
maziggy
2026-06-13 14:10:21 +02:00
parent be7e85344c
commit b8a3e7c2c9
4 changed files with 72 additions and 62 deletions
+1
View File
File diff suppressed because one or more lines are too long
+13 -4
View File
@@ -3881,10 +3881,19 @@ export function ArchivesPage() {
<td className="px-4 py-3">
<div className="flex items-center gap-1.5">
{entry.filament_color && (
<span
className="w-3 h-3 rounded-full border border-black/20 flex-shrink-0"
style={{ backgroundColor: entry.filament_color.startsWith('#') ? entry.filament_color : undefined }}
/>
<div className="flex items-center gap-0.5 flex-wrap">
{entry.filament_color.split(',').map((color, i) => {
const trimmed = color.trim();
return (
<span
key={i}
className="w-3 h-3 rounded-full border border-black/20 flex-shrink-0"
style={{ backgroundColor: trimmed.startsWith('#') ? trimmed : undefined }}
title={trimmed}
/>
);
})}
</div>
)}
<span className="text-bambu-gray-light text-xs">
{entry.filament_type || '—'}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -26,7 +26,7 @@
<!-- Splash screens for iOS -->
<link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
<script type="module" crossorigin src="/assets/index-BwzCCxhK.js"></script>
<script type="module" crossorigin src="/assets/index-DrU3fLKW.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-45eedLWT.css">
</head>
<body>