Repository navigation
feat(AFC): add auto-map button to print dialog - #2017
Conversation
Signed-off-by: Sergei Rozhkov <zmod@zmod.link>
Bundle size report (gzip)
120 chunks compared, 23 changed. Sizes are gzip, matching what nginx serves. |
|
I need that too |
|
|
|
This branch is out-of-date with the base branch |
Updated |
|
@jimmyjon711 can I get you to take a look at this please? |
jimmyjon711
left a comment
There was a problem hiding this comment.
@pedrolamas Seems like a good addition to me, thanks again @ghzserg for this addition.
20261107-1759-13.5479727.mp4
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
The change needs revision because a moderate issue was found where the auto-map logic can silently skip tools or loaded lanes lacking a filament color entry, potentially making the action a no-op even when material-only matches are still possible.
1 open issue
What changed in this PR
Adds an Auto-map button to the AFC print-start lane assignment dialog, automatically mapping file tools to loaded lanes by preferring material matches and then selecting the closest filament color match, emitting SET_MAP only for actual changes.
Changes:
- Add an Auto-map secondary action to the AFC print-start dialog footer.
- Implement auto-mapping logic (material preference + color distance) and send mapping updates via
SET_MAPonly when needed. - Add the English i18n label for the new button.
Review comments to address:
- Disable Auto-map until
currentFilemetadata (and optionally tool list) is available to avoid a “does nothing” UX. - Align material mismatch handling with existing logic, especially when
filament_typeis unknown (e.g.,"--"), and validate/normalize color strings before conversion. - Avoid no-op behavior when colors are missing: fall back to material-only matching instead of skipping tools/lanes.
- Current greedy assignment may be non-optimal when tools compete for lanes; this conflicts with “best matching” expectations.
| File | Summary |
|---|---|
src/locales/en.yaml |
Adds the AutoMap translation string used by the new UI button. |
src/components/widgets/afc/dialogs/AfcPrintStartDialog.vue |
Adds the Auto-map button and implements lane selection + SET_MAP emission logic based on material preference and color matching. |
This pull request requires changes.
Review effort: Balanced
|
Hi @ghzserg, thank you for opening this Pull Request. Can I ask that you please check the copilot findings? |
…g on ties Signed-off-by: Sergei Rozhkov <zmod@zmod.link>
Signed-off-by: Sergei Rozhkov <zmod@zmod.link>
|
Hi @pedrolamas, thanks for taking a look. The Copilot finding is addressed in 94fe3e6: tools without a file color and loaded lanes without a lane color now take part in auto-map. When color is missing on either side the pair is ranked by material only, and on equal score the lane the tool is already mapped to wins, so the result stays deterministic and doesn't overwrite a mapping the user already chose. 3eabdd0 additionally treats invalid color strings (AFC's SET_COLOR doesn't validate input) as missing instead of comparing them as black. lint and type-check pass. Happy to squash if you prefer a single commit. |
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
The change still has a moderate unresolved defect in AfcPrintStartDialog.vue where unnormalized filament color hex strings can make TinyColor parsing fail and break the intended color-matching behavior.
1 open issue
1 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
A moderate active finding flags that the dialog’s greedy one-pass lane assignment can yield non-optimal tool→lane matches under the “each lane used once” constraint, undermining the stated guarantee that every tool gets its best available lane and warranting a more optimal matching approach.
1 open issue
1 resolved since last review
Review effort: Balanced
pedrolamas
left a comment
There was a problem hiding this comment.
Cursor review of the auto-map matcher.
The button, the footer, and the SET_MAP batch look right. AFC's cmd_SET_MAP swaps with the lane that currently owns the tool, and emitting each lane once (skipping lanes that already have the target) stays correct under that swap. Invalid colors are dropped, and missing colors lose to any real ΔE.
Two matcher issues should be fixed before this matches the PR description:
- The greedy pass can leave a tool on a much worse lane.
- A tool with no
filament_typeis ranked as a material match for every lane, which is not whatisFilamentTypeValiddoes.
Recommendation: change the matcher. The SET_MAP wiring can stay.
|
@ghzserg got a few comments more from my AI agents, please do take a look when you have the chance (hopefuly this is the last bit) and thank you for your help and patience! |
…arnings, feedback Signed-off-by: Sergei Rozhkov <zmod@zmod.link>
|
Thanks @pedrolamas — all four points addressed in 8055c8a: the matcher is now a separate util with a minimum-cost assignment and specs, material and weight follow the row warnings, and a click without changes shows a message. lint, type-check and the new unit tests pass. |
The #actions slot replaces AppDialog's default buttons, so the prop was never rendered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Signed-off-by: Sergei Rozhkov <zmod@zmod.link>
|
@pedrolamas Thanks for the review! While working on this dialog, an idea crossed my mind. |
|
Thanks @ghzserg, really appreciate the quick turnaround on all the review comments! I'm happy with where this is now, so I'll approve and merge it as-is. The start-macro idea is interesting, but it's a bigger change than this PR, so I would leave it as a follow-up if you are ok with that? While there is no "official" cross-interface channel for Fluidd and Mainsail, if you post something on this Discord channel and tag me on it, we can start a discussion there. |
|
Discord is blocked in my country, so I cannot post anything there or even register an account. |
|
Fair enough, please open a new issue here then and we can follow up there. As discussed, I will now merge and close this PR. |

Description
Adds an Auto-map button to the AFC lane assignment dialog shown on print start.
On click, each tool used by the file is mapped to the best matching lane with filament loaded:
filament_typeare preferred (same check as the existing material mismatch warning);filament_colorsand the lane color).Each lane is assigned at most once, so the generated
SET_MAPsequence gives the expected result regardless of order, also with AFC's swap semantics. Only mappings that actually change are sent, the same way as a manual lane selection in the dialog. The tool rows update fromlane.mapas usual.The button sits on the left of the dialog footer, following the existing pattern in
SpoolSelectionDialog(secondary action on the left, Cancel/Print on the right).No new dependencies: color parsing uses
@ctrl/tinycolor, which is already in the project.Testing
pnpm run lintandpnpm run type-checkpass.