You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# BUG-014: Run Page Showing Stale Screenshots from Previous Run
2
+
3
+
**Status:** ✅ Fixed
4
+
**Priority:** High
5
+
**Component:** Frontend (SvelteKit Component State Management)
6
+
**Affected Route:**`/run/[id]`
7
+
8
+
---
9
+
10
+
## Problem Statement
11
+
12
+
When navigating between multiple runs (e.g., clicking "Detect My First Drift" multiple times), the run page displays screenshots from the PREVIOUS run alongside or instead of the current run's screenshots.
13
+
14
+
**User Impact:**
15
+
- Confusing UX - users see old data mixed with new data
16
+
- Data integrity concerns - which screenshots belong to which run?
17
+
- Hard to trust the system when it shows stale state
18
+
19
+
---
20
+
21
+
## Root Cause Analysis
22
+
23
+
### The Bug
24
+
25
+
SvelteKit **reuses component instances** when navigating between pages with the same route pattern (e.g., `/run/abc` → `/run/xyz`). The run page component (`/run/[id]/+page.svelte`) had:
26
+
27
+
1. State arrays initialized once: `let graphNodes = $state([])`
28
+
2.`onMount()` hook that started streaming based on `page.params.id`
29
+
3.**NO logic to watch for route param changes**
30
+
4.**NO reset of state arrays when navigating to a different run**
31
+
32
+
**What happened:**
33
+
1. User visits `/run/abc` → component mounts, loads screenshots for run `abc`
34
+
2. User starts another run → navigates to `/run/xyz`
35
+
3.**SvelteKit reuses the same component instance** (performance optimization)
36
+
4.`onMount()` doesn't fire again (component already mounted)
37
+
5.`graphNodes` array still contains screenshots from run `abc`
38
+
6. New stream for run `xyz`**appends** to the existing array
39
+
7.**Result: Stale screenshots from run `abc` shown on run `xyz` page**
40
+
41
+
### Backend Was Correct
42
+
43
+
The backend graph streaming service correctly scopes queries by `runId`:
0 commit comments