From ab008ec83d6813d3a8d7652d6cf9071152307a03 Mon Sep 17 00:00:00 2001 From: Agent Relay Date: Mon, 12 Jan 2026 15:14:34 +0000 Subject: [PATCH] Fix trajectory viewer showing wrong data by using unique step IDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step IDs were generated as `step-0`, `step-1`, etc. regardless of which trajectory they belonged to. This caused React key collisions when switching between trajectories - React would reuse DOM elements for steps with the same key, displaying stale data from the previous trajectory. Fix: Include trajectory ID in step IDs: `{trajectoryId}-step-{index}` This ensures each step has a unique key across all trajectories, so React properly unmounts old steps and mounts new ones when the user switches between trajectories. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/trajectory/integration.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/trajectory/integration.ts b/src/trajectory/integration.ts index d260d712c..51018a550 100644 --- a/src/trajectory/integration.ts +++ b/src/trajectory/integration.ts @@ -582,10 +582,13 @@ export async function listTrajectorySteps(trajectoryId?: string): Promise<{ } // Extract events from all chapters + // Include trajectory ID in step IDs to ensure uniqueness across trajectories + // This prevents React key collisions when switching between trajectories + const trajId = trajectory.id || 'unknown'; for (const chapter of trajectory.chapters || []) { for (const event of chapter.events || []) { steps.push({ - id: `step-${stepIndex++}`, + id: `${trajId}-step-${stepIndex++}`, timestamp: event.ts || Date.now(), type: mapEventType(event.type), title: event.content?.slice(0, 50) || event.type || 'Event',