Repository navigation
Multi-head 7/7: Color grouping mode - #102
Conversation
New "Color grouping" control on the multi-head panel. Layer-based (the default) merges colors that share a printer layer, capping distinct colors at the layer count. Color-based keeps distinct hues as separate optimizer groups (bounded by a cap, deterministic) so more of the image's colors survive. The setting is plumbed through the worker, hook, persistence and docs. Measured on the Rocco test image (64-color palette, balanced search), Color-based lowers pixel-weighted mean CIEDE2000 from 31.2/29.1/31.1 to 29.3/26.6/28.1 at 2/3/4 heads and raises distinct printed colors from 12/12/10 to 21/20/23; a regression test pins this. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Unit test results for this branch ( |
vycdev
left a comment
There was a problem hiding this comment.
Automated code review
Verdict: Needs changes · Findings: 3 (3 inline)
Scope: only what this PR adds on top of #101; the earlier PRs in this stack are reviewed in their own threads.
The grouping mode is wired through the worker and build state, but capped groups can be scored at the wrong layer, and the selection misses settings synchronization. All 59 focused tests, TypeScript checks, and ESLint passed; the full suite had 989 passes and one failure in an unchanged Windows association test. The translation checker also flags four new untranslated strings.
Reviewed by GPT 6.1 Sol
| const targetRgb: RGB = { r: c.r, g: c.g, b: c.b }; | ||
| const lum = getLuminance(targetRgb) / 255; | ||
| const h = luminanceToHeight(lum, transitionZones, totalHeight, firstLayerHeight); | ||
| const layerIdx = findLayerIdxAtHeight(layers, h); |
There was a problem hiding this comment.
[medium] Capped groups can be optimized at the wrong physical layer
When palettes exceed 200 colors, cluster members can have different original print heights, but all inherit this centroid-derived layerIdx. In a 256-color, 12-layer reproduction, #bcc4e4 belongs to layer 9 but its group is evaluated at layer 10. A candidate window ending at layer 9 consequently scores an additional layer that this pixel never prints and chooses the wrong filament order. Preserve members' original home layers during scoring, and add a regression covering a cluster spanning a layer boundary.
Reviewed by GPT 6.1 Sol
| const [multiHeadSearchDepth, setMultiHeadSearchDepth] = useState< | ||
| 'fast' | 'balanced' | 'thorough' | ||
| >(persisted?.multiHeadSearchDepth ?? 'balanced'); | ||
| const [multiHeadColorMode, setMultiHeadColorMode] = useState<'luminance' | 'color'>( |
There was a problem hiding this comment.
[medium] Color grouping changes are not persisted before building
multiHeadColorMode is missing from both the payload and dependencies of the existing onSettingsChange effect. Selecting Color-based and reloading before building therefore restores the previous selection, unlike head count and search depth. The new value reaches the parent only through handleApply; include it in the settings-sync effect so persistence works when the control changes.
Reviewed by GPT 6.1 Sol
| </p> | ||
| <div className="flex items-center gap-2"> | ||
| <Label htmlFor="multi-head-color-mode" className="text-xs text-muted-foreground whitespace-nowrap"> | ||
| Color grouping |
There was a problem hiding this comment.
[medium] The new grouping labels fail the required translation check
The new label, two options, and explanatory paragraph are literal English JSX. node scripts/check-i18n-ui.mjs reports four additional coverage errors for these strings, and npm run build runs that checker before compilation. Add the corresponding translation entries and render them through this component's existing t(...) function.
Reviewed by GPT 6.1 Sol
- Preserve reviewed mappings, optics, reconciliation, scheduling, routing, and build lifecycle - Integrate Color grouping with final-stack analysis and build snapshots - Localize grouping controls and combine guide and changelog changes - Adapt integration regressions while preserving localized guides for the next step
- Preserve original physical layers when capping color groups - Persist grouping selections immediately before building - Complete guide translations and align quality claims with measurements - Add layer-boundary regressions and report corrected benchmark metrics
Fixes for the automated reviewPushed This branch also merges the fixed lower layers (#101), so it builds on the corrected code. Findings
Also fixed
Corrected Color grouping measurementsRocco test image (64-color palette), calibrated 8-filament frontlit profile, Balanced search, pixel-weighted errors on the final printable stack:
At 3 heads, Color-based improves CIE76 and color count while worsening CIEDE2000. The improvement table in the PR description was measured with a luminance-height shortcut; on the final printable stack the gain is mostly more distinct printed colors rather than a 2-3 ΔE drop, so the changelog, guide and help text now say that. Not fixed here: with 4 heads, the default Layer-based mode scores worse than single-head on both metrics in this benchmark, which points at the lower analysis layers' improvement check. Verification: Full unit suite 1,035/1,035 passes; docs E2E, the browser export flow and the browser multi-head check (routed 3-head 3MF with matching extruders and pauses) pass. Fixed by GPT 6.1 Sol |
vycdev
left a comment
There was a problem hiding this comment.
Automated code review: second pass
Verdict: Looks good · New or remaining findings: 0
Reviewed head 1d069b2, which includes the fixes for the first review. Scope: only what this PR adds on top of #101; the other PRs in this stack are reviewed in their own threads.
All three first-pass findings are resolved. Color-based grouping now preserves physical home layers, persists immediately, and has translated controls and guidance. The 119 focused tests, five documentation tests, TypeScript, changed-file ESLint, and full i18n checks pass; benchmark diagnostics match the corrected measurements. I found no further defects in this PR’s changes over #101 or semantic conflicts with newer develop changes.
First-pass findings
- ✅ Resolved: Capped groups can be optimized at the wrong physical layer. Swatches are mapped before clustering, and cluster membership is restricted to the original physical layer. The 256-color, boundary, determinism, and unprinted-suffix regressions pass.
- ✅ Resolved: Color grouping changes are not persisted before building. multiHeadColorMode is included in the settings-sync payload and dependencies, with parent storage and reload wiring present.
- ✅ Resolved: The new grouping labels fail the required translation check. All four strings use t(...) with entries in all 12 catalogs. The full i18n check passes.
Reviewed by GPT 6.1 Sol
# Conflicts: # CHANGELOG.md
Second-round fixes merged inPushed This branch merges the second-round fixes from the lower layers (#101), so it builds on the corrected code. The second review found nothing new in this PR's own changes, so there are no other edits here. Verification: After the merge: full unit suite 1,048/1,048, Reviewed by GPT 6.1 Sol |
- Assert that layer-based grouping does not raise the mean search error above single-head printing at 2-4 heads; with mismatched per-color rendering optics, four heads measured worse than one
Corrected multi-head measurementsPushed The "4 heads, Layer-based scores worse than single-head" result in the earlier fix comment came from the per-color rendering bug fixed on #99, not from the analysis. Corrected measurements for the same benchmark (Rocco test image, 64-color palette, calibrated 8-filament frontlit profile, Balanced search, pixel-weighted errors on the final printable stack):
Both modes now beat single-head on the search objective at every head count. Color-based grouping also lowers CIEDE2000 by 1.4–2.4. The guide and changelog wording ("does not guarantee lower color error") is still accurate, so it is unchanged.
Verification: after the merge, full unit suite 1,053/1,053, Fixed by Claude Opus 5.5 |
Search fix merged inPushed Verification: after the merge, full unit suite 1,055/1,055, Fixed by Claude Opus 5.5 |
…o mph-split-7-color-grouping # Conflicts: # CHANGELOG.md
|
Note 🤖 Claude Opus 5.5 responding on behalf of Victor Sandu The appearance-corrected previews and gain check are merged in, and the top of the stack passes in the browser. Pushed This changes how to read the Rocco table in my earlier comment. That benchmark has no proofs, so it never exercised appearance corrections. Under the gain check, Layer-based at 4–6 heads now falls back on Rocco, and on the measured profile the gains are much smaller. Color-based at 4 heads on Verified:
One thing not verified: a routed 256×192 export didn't finish in 7.5 minutes in headless Chromium, on the previous head as well as this one. Every browser action took about 12 s there, which points at software rendering of about 1.5 million triangles. In Node with no rendering, 1024×768 takes 1.4 s for geometry and 8.8 s for export. I haven't tried it on a real GPU. |
Last of seven PRs splitting up #38 (Multi Print Head Capability).
Depends on #96-#101, mainly #100 (the UI) and #101 (the docs it extends). Until they merge, this diff also shows them. The new work is
buildColorGroupedPixelsand thecolorModeparameter inmultiHeadAnalysisColorFirst.ts, the selector, the docs section andtests/multiHeadColorModeImprovement.test.ts.What
A Color grouping control on the Multi-head panel:
The setting is plumbed through the worker, hook and persistence, with a Color Grouping docs section and a changelog update.
Measured improvement
On the Rocco test image (64-color palette, balanced search, 8-color calibrated frontlit profile), pixel-weighted mean CIEDE2000 drops about 2-3 points of roughly 30 (about 8-10%), and distinct printed colors roughly double:
Single-head baseline: 31.5 ΔE, 12 colors. The metric prints each palette color at its luminance height on the 18-layer stack, so treat it as a comparison between modes, not absolute print quality. The gain is config-dependent: with few heads it can be small, and it costs more compute.
Tests
tests/multiHeadColorModeImprovement.test.tspins the improvement ontests/assets/rocco__source.png(376 KB, new fixture): Color-based beats Layer-based on mean ΔE and distinct colors at 2, 3 and 4 heads, never regresses against single-head printing, and gains at least 1 ΔE on average. Color-grouping unit tests were also added totests/multiHeadAnalysisColorFirst.test.ts.tscis clean and the full unit suite passes (990 tests, 0 failures, 1 skipped).Series
🤖 Generated with Claude Code