Skip to content

fix(site): filter build timeline events by agent ID#21831

Merged
mafredri merged 4 commits intomainfrom
agent-events-k4x5
Feb 2, 2026
Merged

fix(site): filter build timeline events by agent ID#21831
mafredri merged 4 commits intomainfrom
agent-events-k4x5

Conversation

@mafredri
Copy link
Member

@mafredri mafredri commented Feb 2, 2026

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

@mafredri mafredri force-pushed the agent-events-k4x5 branch 3 times, most recently from 5eeeb01 to 6cea30d Compare February 2, 2026 10:02
...uniqScriptTimings,
...agentConnectionTimings,
].sort((a, b) => {
return new Date(a.started_at).getTime() - new Date(b.started_at).getTime();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: The mergeTimeRanges function already does this.

<ScriptsChart
timings={agentScriptTimings
.filter((t) => t.stage === view.stage.name)
timings={uniqScriptTimings
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: This seemed like a bug? We discard duplicates in the top view, but not in the detailed view.

const uniqScriptTimings = sortBy(
uniqBy(
sortBy(agentScriptTimings, (t) => new Date(t.started_at).getTime() * -1),
(t) => `${t.workspace_agent_id}:${t.display_name}`,
Copy link
Member Author

@mafredri mafredri Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 agentId field to the Stage type and updated agentStages function to accept and use agent IDs
  • Modified filtering logic in WorkspaceTimings to 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_name as the unique key)
  • Added comprehensive test story MultipleAgents with 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.

@mafredri mafredri marked this pull request as ready for review February 2, 2026 11:11
display: "flex",
flexDirection: "column",
height: 420,
height: "var(--collapse-body-height, 420px)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit(non-blocking): would be nice to upgrade these styles to tailwind as they're being touched but not going to block on this

Copy link
Contributor

@DanielleMaywood DanielleMaywood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like tailwind-ifying has added some extra height on the agent timeline component

Image

@mafredri
Copy link
Member Author

mafredri commented Feb 2, 2026

@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.

@mafredri
Copy link
Member Author

mafredri commented Feb 2, 2026

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.

@mafredri mafredri merged commit b612762 into main Feb 2, 2026
28 checks passed
@mafredri mafredri deleted the agent-events-k4x5 branch February 2, 2026 16:55
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Workspace build timeline shows the same data for both agents in a multi-agent workspace

3 participants