Repository navigation
Multi-head 5/7: worker, UI and export wiring - #100
Conversation
Add a Multi-head mode to the Auto-paint tab (head count 2-8, search depth) that runs the analysis in a background worker, falls back to a normal single-head build with a notice when no usable plan is found, and is mutually exclusive with Flat Paint. Builds generate a Head Schedule in Print Instructions, and 3MF export writes the extruder count and swap checkpoints as pause markers. Settings persist with the rest of the auto-paint setup. The 3D preview still shows flat auto-paint colors; per-pixel mixing and per-nozzle mesh tagging are not ported to the layered build yet (see TODO in ThreeDView). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Also drop the docs-page sentence from the Multi-head changelog entry; the docs page lands in a later PR. 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: 4 (4 inline)
Scope: only what this PR adds on top of #96 + #99; the earlier PRs in this stack are reviewed in their own threads.
The worker, controls, persistence and schedule wiring are present, but multi-head exports can use incorrect head assignments. The asynchronous build and fallback instructions also have correctness issues, and the required translation check fails. TypeScript checks and ESLint passed; npm test reported 977 passes and one failure in the unchanged Windows file-association test. Local export and render reproductions confirmed incorrect extruder routing and hidden fallback instructions.
Reviewed by GPT 6.1 Sol
| builtModelState.autoPaintFilamentSwatches | ||
| )?.map((s) => s.hex) | ||
| : undefined, | ||
| extruderCount: multiHeadExportReady |
There was a problem hiding this comment.
[high] Multi-head exports use material order instead of head assignments
This enables multi-extruder export after a successful analysis, but ThreeDView never consumes the new filament/nozzle maps or sets mesh.userData.nozzleIndex. The exporter therefore assigns matIdx + 1, clamped to the head count. In a two-head model with several layer colors, later layers are assigned to head 2 even when the Head Schedule requires head 1; per-pixel filament assignments are also discarded. Generate and tag the geometry using the actual filament/nozzle assignments before enabling this export path, or retain a valid single-head fallback.
Reviewed by GPT 6.1 Sol
| htmlFor="multi-head-mode" | ||
| className="text-xs font-semibold text-foreground cursor-pointer" | ||
| > | ||
| Multi-head mode |
There was a problem hiding this comment.
[high] New UI strings fail the mandatory build check
node scripts/check-i18n-ui.mjs exits with coverage errors for the new Multi-head controls and Head Schedule text. Because npm run build starts with npm run check:i18n, these additions block builds and deployment despite TypeScript passing. Add translation keys and catalog entries, and render the new text through t/Trans, including the additions in PrintInstructions.tsx.
Reviewed by GPT 6.1 Sol
| hex: s.hex, | ||
| count: (s as { count?: number }).count, | ||
| })); | ||
| activeResult = await runMultiHead({ |
There was a problem hiding this comment.
[medium] An analysis can apply an obsolete image snapshot after the image changes
Nothing invalidates this awaited build when imageSrc changes. The controls remain mounted when switching to 2D, and the worker only terminates on another run or unmount. Start analysis for image A, switch to 2D and upload image B, then let analysis finish: this callback applies A's result and printableFeaturePixels to B. For equal-sized images, ThreeDView uses that stale pixel buffer, so the exported model can contain A's artwork. Associate the build with an image revision and discard or cancel obsolete work before calling onChange.
Reviewed by GPT 6.1 Sol
| <PrintInstructions | ||
| swapPlan={swapPlan} | ||
| multiHeadPlan={multiHeadPlan} | ||
| multiHeadMode={multiHeadMode && paintMode === 'autopaint'} |
There was a problem hiding this comment.
[medium] Single-head fallback builds hide their swap instructions
When analysis fails or finds no improving layout, the built snapshot correctly stores multiHeadMode: false, but the local toggle remains true. Passing that requested mode here makes PrintInstructions show “Build 3D Model” when multiHeadPlan is null, hiding the fallback model's valid start color and swaps even after a successful build. Derive the instruction mode from builtState when a built model exists, and reserve the pending-schedule prompt for an unbuilt model.
Reviewed by GPT 6.1 Sol
# Conflicts: # CHANGELOG.md
- Generate routed multi-head regions with shared topology and physical nozzle tags - Match 3MF extruders, filament colors, and pauses to the built Head Schedule - Preserve single-head fallback instructions and cancel obsolete analyses - Settle worker failures and analyze the cleaned printable palette - Localize controls and guides and add routing, export, topology, and lifecycle regressions - Translate build errors without rebuilding the model on language changes
Fixes for the automated reviewPushed This branch also merges the fixed lower layers (#96 and #99), so it builds on the corrected code. Findings
Also fixed
Behavior change vs. the PR description: the "Known limitation" no longer applies. Successful analyses now build routed per-color geometry, the 3D preview shows the routed colors, and the 3MF writes the head count as extruders plus Verification: Full unit suite 1,019/1,019 passes. E2E smoke specs pass (Flat Paint, height dithering, browser export flow, printable detail, smoothing strengths). A browser run with an 8-filament profile built a routed 3-head model: meshes tagged with heads 1-3, a 3MF using extruders 1-3 and 3 Fixed by GPT 6.1 Sol |
vycdev
left a comment
There was a problem hiding this comment.
Automated code review: second pass
Verdict: Needs changes · New or remaining findings: 2 (2 inline)
Reviewed head 8864f81, which includes the fixes for the first review. Scope: only what this PR adds on top of #96 + #99; the other PRs in this stack are reviewed in their own threads.
The four original findings are resolved. Two new edge cases still prevent valid multi-head builds: selecting more heads than available filaments, and printable colors with zero regional weight. TypeScript, i18n, and documentation checks passed; 1,018/1,019 unit tests passed, with only the documented NSIS sandbox failure.
First-pass findings
- ✅ Resolved: Multi-head exports use material order instead of head assignments. Successful builds now generate geometry from per-color filament paths and attach physical filament metadata and 1-based nozzle tags. Export tests verify assignments, geometry, colors, and schedule pauses.
- ✅ Resolved: New UI strings fail the mandatory build check. The controls, schedules, notices, and copied instructions use localized messages across all 12 catalogs. npm run check:i18n passes.
- ✅ Resolved: An analysis can apply an obsolete image snapshot after the image changes. Image changes and unmount invalidate the build revision and cancel the worker. The awaited analysis checks that revision before publishing its snapshot.
- ✅ Resolved: Single-head fallback builds hide their swap instructions. Instruction mode and routing data now follow the built snapshot. Fallback rendering tests confirm that the original start color and swaps remain visible.
Reviewed by GPT 6.1 Sol
| patchedSliceData.swatches.length !== layerCount || | ||
| nozzleAssignments.length !== multiHeadWindows.length || | ||
| windowRunFilaments.length !== multiHeadWindows.length || | ||
| nozzleAssignments.some((heads) => heads.length !== multiHeadCount) || |
There was a problem hiding this comment.
[medium] Valid plans are rejected when head count exceeds filament count
The analyzer clamps its head slots to Math.min(n, filaments.length, MAX_MULTI_HEAD_HEADS), but this validator compares their length against the unchanged selected count. I reproduced an improving two-filament analysis that builds successfully with 2 selected heads but falls back with the default 4, reporting that no improving layout exists. Pad nozzle assignments and non-windowed ranges with unused slots up to the selected physical head count before validation, so the schedule and export can retain those EMPTY heads.
Reviewed by GPT 6.1 Sol
| (data[source + 1] << 8) | | ||
| data[source + 2]; | ||
| const height = targets.get(key); | ||
| if (height === undefined) throw new Error(translate('printing:multiHead.invalidPlan')); |
There was a problem hiding this comment.
[medium] Handle printable colors omitted from weighted target mappings
Regional weighting can give a printable color zero weight, and final-stack generation omits those target mappings. For example, with edge priority, a color occurring only at the image's center has zero weight. I reproduced a successful routed analysis for such an image, but this lookup returns undefined and aborts the geometry build. Resolve missing colors through the same printable-palette fallback used by the analyzer's buildPixelData, and add regression coverage for zero-weight colors.
Reviewed by GPT 6.1 Sol
- Pad unused physical head slots before validating routed plans - Resolve omitted target colors through printable-palette matching - Cover unused heads, zero-weight colors, dithering, and routed geometry - Update the unreleased Multi-head changelog entry
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
Fixes for the second automated reviewPushed This branch merges the second-round fixes from the lower layers (#96 and #99), so it builds on the corrected code. Findings
Verification: After the merges: full unit suite 1,032/1,032, Fixed by GPT 6.1 Sol |
Multi-head fixes merged inPushed Verification: after the merge, full unit suite 1,034/1,034, Fixed by Claude Opus 5.5 |
Search fix merged inPushed Verification: after the merge, full unit suite 1,036/1,036, Fixed by Claude Opus 5.5 |
- Pass the final stack's appearance model to per-color rendering, so routed previews use the same calibration evidence as single-head builds - Fall back to the normal stack when the predicted usage-weighted mean CIEDE2000 gain is below 0.25, since small gains do not justify head swaps - Make test fixtures' predicted colors describe their own stacks - Test the fallback, usage weighting, and corrected preview colors
…o mph-split-6-docs # Conflicts: # CHANGELOG.md
|
Note 🤖 Claude Opus 5.5 responding on behalf of Victor Sandu Routed previews now use the full appearance model, and builds fall back when the predicted gain is too small to justify the head swaps. Pushed
Which tested head counts route:
In the last row, the layouts the search picked at 3 and 4 heads are predicted to be worse than single-head by 0.13 to 2.69; at 2 heads it finds no window. Those builds used to route. Rocco Layer-based at 4–6 heads falls back because CIEDE2000 barely moves, even though CIE76 improves by 3–4.5, so default-mode users will see the fallback more often. Better search results are tracked in #113. The test fixtures changed too: their predicted colors now describe their own stacks. Verified: after the merge, unit suite 1,041/1,041, |
Fifth of seven PRs splitting up #38 (Multi Print Head Capability). This is the part users see.
Depends on #96, #97, #98 and #99. Until they merge, this diff also shows those parts (the branch merges #96's branch). The new wiring is
multiHead.worker.ts,useMultiHeadWorker.ts,useSwapPlan.tsand the Auto-paint, 3D controls, Print Instructions andApp.tsxchanges.What
M600) markers so it works on an ordinary single-nozzle printer.Known limitation
The 3D preview still shows the flat auto-paint colors. Per-pixel color mixing and per-nozzle mesh tagging are not ported to the layered build yet (marked TODO in
ThreeDView.tsx); exported pause markers are unaffected.Tests
No new unit tests of its own: the hooks and UI logic here are not unit-tested yet.
tscis clean and the full unit suite passes (978 tests, 0 failures, 1 skipped).Series
mph-split-5-ui-wiring)mph-split-6-docs)mph-split-7-color-grouping)🤖 Generated with Claude Code