Skip to content

Demo crashes with 'Station index -1 is out of range' at end of playback #238

Description

@williamthorsen

Problem

The demo crashes at the end with: Station index -1 is out of range [0, 7).

Root cause

In run-to-catwalk.ts, buildOrchestrator() returns stationIndex = -1 as a sentinel value when the run status is not completed or in_progress (e.g., failed, needs_manual_review).

The initial build path (addOrchestrator() in CatwalkScene.ts) correctly guards against this:

if (config.orchestrator.stationIndex < 0) return;

But the update path (applyDiff()) does NOT guard against it:

if (diff.orchestrator.moved !== null && this.orchestratorRef !== undefined) {
  const pos = layout.orchestratorPosition(diff.orchestrator.moved.to); // ← no -1 check
  this.orchestratorRef.animateMoveTo(vec(pos.x, pos.y));
}

When the demo transitions from completed (station 6) to a terminal state (station -1), applyDiff() passes -1 to orchestratorPosition(), which calls stationX(-1), which throws the range error.

Fix

Add a guard in applyDiff() for negative station indices. When the orchestrator moves to -1, it should be hidden (fade out + remove) rather than positioned.

Key files

  • packages/factory/src/client/visualizations/catwalk/scene/CatwalkScene.ts:82-87applyDiff() missing guard
  • packages/factory/src/client/visualizations/catwalk/mappers/run-to-catwalk.ts:181-190 — sentinel -1 value
  • packages/factory/src/client/visualizations/catwalk/layout/catwalk-layout.tsstationX() validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions