Skip to content

bugfix(jobStatusPage): stop layer jump on Z-hop + harden print-stats slots#258

Merged
HugoCLSC merged 4 commits into
devfrom
bugfix/jobstatus-layer-hardening
Jul 3, 2026
Merged

bugfix(jobStatusPage): stop layer jump on Z-hop + harden print-stats slots#258
HugoCLSC merged 4 commits into
devfrom
bugfix/jobstatus-layer-hardening

Conversation

@gmmcosta15

Copy link
Copy Markdown
Collaborator

Description

Select the type:

  • Feature
  • Bug fix
  • Code refactor
  • Documentation

Follow-up hardening for the jobStatusPage layer logic introduced in #208. Fixes a field-observed bug where the current-layer counter jumped whenever the toolhead raised Z (travel moves / Z-hop) to reach another region of the plate, and aligns the layer-source priority with Mainsail's getters.

  • Reject transient Z rises: the current layer now commits an advance only once Z has settled (confirmed across two samples) and never regresses, so Z-hop and travel moves no longer bump the layer number.
  • Respect reported totals: a Klipper-reported print_stats.info.total_layer (or current_file.layer_count) is no longer overwritten by the geometry estimate, matching Mainsail's getPrintMaxLayers priority.
  • on_flowguard_update: renamed params that shadowed the str/dict builtins, added type hints, and applied each key independently so a partial delta no longer raises KeyError.
  • handleCancel: replaced the disconnect+reconnect dance with a single UniqueConnection (guarded) connect.
  • showEvent: now calls super().showEvent().
  • Simplified toggle_thumbnail_expansion, merged the duplicate valid-state branch in _handle_print_state, and tidied the print-stats dispatch.

Motivation

The Z-based layer fallback read the instantaneous gcode_move.gcode_position[2], so any non-print Z motion (Z-hop, travel to a taller area) was interpreted as a layer change and the counter flickered. Since gcode_position is published on essentially every move, a two-sample "Z settled" filter reliably distinguishes a real layer advance from a transient hop while keeping the counter monotonic.
The layer-source priority was also corrected to match Mainsail so a reported total layer count is never clobbered by the geometry estimate.

Tests

New/updated cases: transient Z-hop does not bump the layer, layer never regresses, reported total_layer not overridden by estimate, flowguard partial vs full payload, plus the two-sample settle behavior.

@gmmcosta15 gmmcosta15 added the enhancement New feature or request. label Jul 1, 2026
@gmmcosta15 gmmcosta15 self-assigned this Jul 1, 2026
@HugoCLSC HugoCLSC merged commit 90c25ae into dev Jul 3, 2026
7 checks passed
@HugoCLSC HugoCLSC deleted the bugfix/jobstatus-layer-hardening branch July 3, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants