fix(site): filter build timeline events by agent ID#21831
Conversation
5eeeb01 to
6cea30d
Compare
| ...uniqScriptTimings, | ||
| ...agentConnectionTimings, | ||
| ].sort((a, b) => { | ||
| return new Date(a.started_at).getTime() - new Date(b.started_at).getTime(); |
There was a problem hiding this comment.
Review: The mergeTimeRanges function already does this.
| <ScriptsChart | ||
| timings={agentScriptTimings | ||
| .filter((t) => t.stage === view.stage.name) | ||
| timings={uniqScriptTimings |
There was a problem hiding this comment.
Review: This seemed like a bug? We discard duplicates in the top view, but not in the detailed view.
6cea30d to
0d64e94
Compare
| const uniqScriptTimings = sortBy( | ||
| uniqBy( | ||
| sortBy(agentScriptTimings, (t) => new Date(t.started_at).getTime() * -1), | ||
| (t) => `${t.workspace_agent_id}:${t.display_name}`, |
There was a problem hiding this comment.
Review: Moved this closer to where it's used. Previously this could filter out another agents script that has the same display name, so the uniqueness condition was changed. Also note that sort condition was changed from Date (which loses precision) to the ISO 8601 timestamp string as they sort correctly lexicographically.
However, since the existing DuplicatedScriptTiming test was added with limited understanding of the problem, it's unclear whether this unique filtering is even needed anymore.
Note: Since we now use this below, we reverse the sort.
0d64e94 to
a86901c
Compare
When a workspace has multiple agents (e.g., main + devcontainer), the build timeline was showing all events duplicated under each agent instead of filtering by the agent they belong to. Added agentId to the Stage type and filter timings by workspace_agent_id so each agent section only shows its own events. Fixes #18002
a86901c to
66845c9
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the workspace build timeline was showing duplicate events across multiple agents instead of filtering by agent ID. The fix adds agent ID tracking to stages and filters timings appropriately so each agent section only displays its own events.
Changes:
- Added
agentIdfield to theStagetype and updatedagentStagesfunction to accept and use agent IDs - Modified filtering logic in
WorkspaceTimingsto filter timings by both stage name and workspace_agent_id for agent stages - Updated deduplication logic for script timings to scope by agent ID (using
workspace_agent_id:display_nameas the unique key) - Added comprehensive test story
MultipleAgentswith test data demonstrating proper agent separation - Changed collapseBody height to use a CSS variable for better flexibility in stories
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| site/src/modules/workspaces/WorkspaceTiming/WorkspaceTimings.tsx | Core fix: refactored timing deduplication and filtering to properly scope by agent ID; changed height to use CSS variable |
| site/src/modules/workspaces/WorkspaceTiming/StagesChart.tsx | Added optional agentId field to Stage type; updated agentStages function to accept and pass through agent ID |
| site/src/modules/workspaces/WorkspaceTiming/WorkspaceTimings.stories.tsx | Added MultipleAgents test story to verify proper agent separation; updated InvalidTimeRange story with required agent IDs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| display: "flex", | ||
| flexDirection: "column", | ||
| height: 420, | ||
| height: "var(--collapse-body-height, 420px)", |
There was a problem hiding this comment.
nit(non-blocking): would be nice to upgrade these styles to tailwind as they're being touched but not going to block on this
990f11c to
475118d
Compare
|
@DanielleMaywood unless we accept the changed header size, I'm thinking we'll revert the Tailwind changes. Not sure how it should be fixed/changed. |
This reverts commit 456613f.
0f6e052 to
6203185
Compare
|
FWIW, I attempted to Tailwindify, but reproducing the original got too complex so I'm cutting it as I don't have more time to work on this. |

When a workspace has multiple agents (e.g., main + devcontainer), the
build timeline was showing all events duplicated under each agent
instead of filtering by the agent they belong to.
Added agentId to the Stage type and filter timings by workspace_agent_id
so each agent section only shows its own events.
Fixes #18002
Generated with
mux• Model:anthropic:claude-opus-4-5• Cost:$11.48$21.48