fix(fusion_plating_shopfloor): job appearing in every not-yet-started stage

Regression from the partial-order board: _job_presences emitted a card
for any area containing a `ready` step. These recipes seed ALL downstream
steps to `ready` at job creation, so a job showed in every future stage
at once (e.g. WO-30061 across racking/receiving/plating/inspection) even
though no parts had advanced there.

Fix: a stage shows ONLY where parts physically are (qty_at_step > 0,
which includes the first-active seed) OR where a step is in_progress/
paused. A merely ready/pending future step with no parts no longer shows.
Strict sequential progress falls out for free — the qty_at_step seed sits
on the lowest-sequence non-terminal step and advances as each completes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-06-02 00:53:10 -04:00
parent ca44461b6f
commit a092c385ea
2 changed files with 14 additions and 4 deletions

View File

@@ -291,10 +291,20 @@ def _job_presences(job):
presences = []
for area, steps in by_area.items():
qty_here = sum((s.qty_at_step or 0) for s in steps)
actionable = any(
s.state in ('in_progress', 'paused', 'ready') for s in steps
# A stage shows ONLY where parts physically are (qty_here > 0 —
# which includes the first-active step's qty_at_step seed) OR where
# a step is actively being worked (in_progress / paused — e.g.
# drained to zero but not yet finished). A merely `ready` / `pending`
# step with NO parts is a FUTURE stage and must NOT show — otherwise
# the job appears in every not-yet-started step at once (these
# recipes seed all downstream steps to `ready`, so 6 ready steps =
# 6 phantom cards; bug on WO-30061). Strict sequential progress
# falls out for free because the qty_at_step seed always sits on the
# lowest-sequence non-terminal step and advances as each completes.
being_worked = any(
s.state in ('in_progress', 'paused') for s in steps
)
if qty_here > 0 or actionable:
if qty_here > 0 or being_worked:
presences.append((area, _pick_focus_step(steps), qty_here))
if not presences: