fix(ams): don't map AMS placeholders to empty trays (Upload & Print with an empty slot below the used filament) #98

Manually merged
viewit merged 1 commits from walterioo/KX-Bridge-Release:fix/empty-tray-placeholder-auto-mapping into nightly 2026-07-24 15:15:47 +02:00
Contributor

Description

Printing via OrcaSlicer's "Upload and print" failed — or fed from the wrong
spool — whenever the AMS had an empty slot below the used filament (e.g.
printing with Filament 4 while slot 3 was empty). Printing with all slots full
already worked.

Root cause: _start_print_build_auto_ams_box_mapping keeps the mapping
positional (entry N = TN) by inserting a placeholder at each gap, but the
placeholder's ams_index pointed at the gap's own index. For an empty slot that
references a physically empty tray, and the printer rejects a mapping entry aimed
at an empty tray — even for a tool the GCode never actually calls — so the print
broke at filament load.

Fix: the placeholder entry is kept (positional alignment, entry N = TN, is
preserved); only what it points at changes. Gap placeholders now point their
ams_index (and color/material) at a definitely-loaded fallback tray (the
highest loaded slot) instead of the gap's own empty index. The all-slots-full
path is unchanged.

Type

  • Bug fix
  • Feature
  • Documentation
  • Refactoring

Tested with

  • OrcaSlicer: Upload and print flow
  • Printer: Anycubic Kobra X (KX1), firmware 1.2.0.6
  • Moonraker/Klipper: v0.9.3-1 / v0.12.0-1 (bridge-reported)

Checklist

  • Tests added/updated (tests/test_auto_ams_box_mapping_empty_slot.py)
  • CHANGELOG.md updated (NIGHTLY_CHANGELOG.md)
  • No debug code included
## Description Printing via OrcaSlicer's **"Upload and print"** failed — or fed from the wrong spool — whenever the AMS had an **empty slot below the used filament** (e.g. printing with Filament 4 while slot 3 was empty). Printing with all slots full already worked. Root cause: `_start_print` → `_build_auto_ams_box_mapping` keeps the mapping positional (entry N = TN) by inserting a placeholder at each gap, but the placeholder's `ams_index` pointed at the gap's own index. For an empty slot that references a physically empty tray, and the printer rejects a mapping entry aimed at an empty tray — even for a tool the GCode never actually calls — so the print broke at filament load. Fix: the placeholder entry is kept (positional alignment, entry N = TN, is preserved); only what it points at changes. Gap placeholders now point their `ams_index` (and color/material) at a definitely-loaded fallback tray (the highest loaded slot) instead of the gap's own empty index. The all-slots-full path is unchanged. ## Type - [x] Bug fix - [ ] Feature - [ ] Documentation - [ ] Refactoring ## Tested with - OrcaSlicer: Upload and print flow - Printer: Anycubic Kobra X (KX1), firmware 1.2.0.6 - Moonraker/Klipper: v0.9.3-1 / v0.12.0-1 (bridge-reported) ## Checklist - [x] Tests added/updated (`tests/test_auto_ams_box_mapping_empty_slot.py`) - [x] CHANGELOG.md updated (NIGHTLY_CHANGELOG.md) - [x] No debug code included
walterioo added 1 commit 2026-07-23 03:33:14 +02:00
fix(ams): point gap placeholders at a loaded tray, not an empty one
Some checks failed
PR Check / lint-and-test (pull_request) Failing after 1s
2f222a0b93
Printing via OrcaSlicer "Upload and print" failed or fed the wrong spool
when the slot below the used filament was empty (e.g. Filament 4 with slot
3 empty); all-slots-full worked.

_start_print -> _build_auto_ams_box_mapping keeps the AMS mapping positional
(entry N = TN) by inserting a placeholder at each gap. The placeholder's
ams_index pointed at the gap's own index, which for an empty slot references
a physically empty tray. The printer rejects a mapping entry aimed at an
empty tray even for a tool the GCode never calls, so the print broke.

Point gap placeholders (ams_index/color/material) at a definitely-loaded
fallback tray (the highest loaded slot) instead. Positional alignment is
preserved; the all-full path is unchanged.

Adds tests/test_auto_ams_box_mapping_empty_slot.py (invariant: every mapping
entry references a loaded/status-5 tray).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
viewit manually merged commit 20daa6b6b8 into nightly 2026-07-24 15:15:47 +02:00
Owner

thx for the great PR !

thx for the great PR !
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: viewit/KX-Bridge-Release#98
No description provided.