Skip to content

Implement catwalk layout engine #178

Description

@williamthorsen

Goal

Pure function that computes all spatial positions from phase/agent configuration. No Excalibur dependency — just geometry.

Tasks

  • Create src/client/visualizations/catwalk/layout/catwalk-layout.ts
  • Implement computeCatwalkLayout() function that takes phase/agent configuration and returns:
    • Station X positions (asymmetric content-extent spacing with fixed inter-station gap)
    • Dynamic canvas/platform width computed from layout (not a fixed value)
    • Agent positions (X, Y for each agent within a station)
    • Orchestrator position (X, Y for a given station index)
    • Chute endpoints (top and bottom for each agent position)
    • Gate positions (midpoint between adjacent stations)
    • Rail and ground line endpoints
    • Canvas bounds
  • Port the prototype's content-driven layout algorithm (final prototype at commit fe19d60 on branch 162, in demos/catwalk/):
    • Each station has asymmetric extents: left = agent half-width + input artifact overhang; right = agent half-width + output overhang
    • Fixed STATION_GAP (30px) between adjacent stations' content edges
    • PLATFORM_W computed dynamically from total layout
  • Support compact layout mode: remove absent stations entirely and recompute positions for visible stations only
  • Accept variable agent counts per station (e.g., Review may have 1–4 reviewers depending on the run)
  • Unit tests for layout computation

Key algorithm

The prototype uses layoutStations(phaseIndices) which:

  1. Computes per-station left extent (agents half-width + ART_W * 1.5 + 11 input overhang)
  2. Computes per-station right extent (agents half-width + ART_W / 2 output overhang)
  3. Places stations sequentially with STATION_GAP between content edges
  4. Returns positions array and computed platformW

Compact mode filters to visible station indices only, then runs the same algorithm.

The agent count per station is not fixed — it comes from the run data. The layout must handle any number of agents at any station.

Acceptance criteria

  • Layout is deterministic (same input → same output)
  • No Excalibur imports
  • Canvas width is computed, not fixed
  • Tests cover: single-agent stations, multi-agent stations (Review with 4 agents), single reviewer, absent stations, compact mode

Metadata

Metadata

Labels

featureAdded or improved external functionalityscope:factory

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions