# Todo 49.3 Stale Replay Token Order Plan **Status:** done ## Goal Make the replay generation guard directional: only a replay for the selected session may supersede the active replay. ## Scope - Exit `loadSessionReplay()` before incrementing the generation token when `sessionId !== currentSessionId`. - Add an executable JS regression where the current replay starts first and a stale replay is invoked second. - Preserve the Todo 49.2 success/failure ordering coverage. ## Files - Modify: `src/agent_lab/presentation/static/app.js` - Modify: `tests/test_websocket_api.py` ## Verification - `uv run pytest tests/test_websocket_api.py -q` - `node --check src/agent_lab/presentation/static/app.js` - `uv run pytest` - `git diff --check` ## Observe / Update - A replay for a non-selected session now exits before advancing the load generation or starting fetches. - Reverse-order executable JS regression passes alongside Todo 49.2 race coverage. - WebSocket tests passed (`78 passed`); full suite passed (`388 passed`) with the existing Starlette warning.