Skip to content

Visualization crashes on switch to diagram view #136

Description

@williamthorsen

Toggling a working factory view can trigger at least two different bugs.

1. Displays diagram in the visualization container; error in console

Run codeassembly/87:

  • diagram displays
  • error is seen in console:
run-to-flow.ts:260 Uncaught TypeError: Cannot read properties of undefined (reading 'orchestrated-reviewer')
    at buildReviewerNodes (run-to-flow.ts:260:48)
    at createFlowConfig (run-to-flow.ts:666:25)
    at FlowDiagram.tsx:61:32
    at FlowDiagramInner (FlowDiagram.tsx:61:18)

2. Displays nothing in the visualization container; error in console

Example: codeassembly/CODY-113

run-to-flow.ts:260 Uncaught TypeError: Cannot read properties of undefined (reading 'orchestrated-reviewer')
    at buildReviewerNodes (run-to-flow.ts:260:48)
    at createFlowConfig (run-to-flow.ts:666:25)
    at FlowDiagram.tsx:61:32
    at FlowDiagramInner (FlowDiagram.tsx:61:18)

Root cause

extractReviewerNames() in run-to-flow.ts correctly handles three data shapes for reviewer names (flat reviewers record, iterations[].perReviewer, and reviewerDetails). However, four downstream access sites assume parallelReview.reviewers is always a defined object. For V2 run data, the Zod .partial().loose() schema doesn't enforce the reviewers field, so it can be undefined at runtime despite the TypeScript type declaring it as required.

Affected access sites (all in run-to-flow.ts):

  • Line 260 in buildReviewerNodes — primary crash location
  • Line 286 in resolveReviewerStatus
  • Line 524 in buildReviewerEdges
  • Line 572 in buildReviewerEdges (re-review section)

Proposed solution

Add optional chaining (?.) at all 4 access sites. All downstream uses of the resulting reviewerInfo already handle undefined via optional chaining or explicit checks.

Acceptance criteria

  • No crash when switching to diagram view for runs with V2 data where parallelReview.reviewers is absent
  • Reviewer nodes render gracefully (with idle status) when reviewer info is unavailable
  • Regression tests added: exercises both iterations[].perReviewer and reviewerDetails paths with reviewers undefined

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions