Fix filament consumption across retraction and E-only moves - #501
Open
remcoder wants to merge 2 commits into
Open
Fix filament consumption across retraction and E-only moves#501remcoder wants to merge 2 commits into
remcoder wants to merge 2 commits into
Conversation
|
Visit the preview URL for this PR (updated for commit c2d8b03): https://gcode-preview--pr501-codex-499-filament-c-1w4gfvnw.web.app (expires Sat, 10 Oct 2026 21:07:00 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 59bd114ae4847b32c2bba0b68620b9069a3e3531 |
- recordExtrusion moves from a free function + WeakMap onto JobStats as a method with a private #outstandingRetraction field - linear-move splits applyExtrusion and recordExtrusion into two steps - filament-consumption.ts is split into src/__tests__/job-stats.ts (unit) and describe blocks in the linear-move/arc-move command tests - CONTRIBUTING spells out one-test-file-per-module so feature-named test files stop appearing
sophiedeziel
approved these changes
Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #499.
M83; G1 E10reported zero filament, while retracting and restoring filament during movement counted that filament twice.Cause and fix
Linear and arc handlers counted only positive E deltas attached to XYZ moves. Both now send every signed delta to shared statistics accounting, including E-only moves. Outstanding retraction is tracked per stats object without expanding its public shape.
For a delta d and outstanding retraction r, newly consumed filament is
max(0, d - r)and the remaining retraction ismax(0, r - d). Negative deltas therefore increase retraction without subtracting prior consumption; positive deltas repay it before adding consumption. G92 only changes coordinates and leaves this accounting intact.Behavior changes
extrusionDistancenow means newly advanced filament, including stationary purges/primes and excluding recovery. The original signed delta still classifies paths, so recovery moves retain their rendering behavior. Existing command counters are unchanged.Checks
Assisted by OpenAI Codex (GPT-6).