---
name: "LozengeFlyContext animation queue race condition on rapid updates"
---

# Bug 137: LozengeFlyContext animation queue race condition on rapid updates

## Description

In LozengeFlyContext.tsx, the useEffect that executes animations clears pending action refs at the start of each run. When rapid pipeline updates arrive, useLayoutEffect queues actions into refs, but the useEffect can clear them before they're processed. This breaks the diffing chain and causes the UI to stop reflecting state changes.

## How to Reproduce

1. Open the web UI
2. Trigger several pipeline state changes in quick succession (e.g., start multiple agents)
3. Observe that lozenge animations stop firing after a few updates
4. The pipeline state in the server is correct but the UI is stale

## Actual Result

The useEffect clears pendingFlyInActionsRef before processing, racing with useLayoutEffect that queues new actions. After a few rapid updates the animation queue gets into an inconsistent state and stops processing.

## Expected Result

Animation queue should handle rapid pipeline updates without losing actions or breaking the diffing chain.

## Acceptance Criteria

- [ ] No animation actions are lost during rapid pipeline updates
- [ ] Lozenge fly animations remain functional through sustained agent activity
