fix: ensure agents are removed from Mission Control UI on completion

Previously, agents that completed their work would remain visible in the
Mission Control UI until a manual page refresh. This occurred because
the AgentTracker._handle_agent_complete method silently dropped completion
messages when an agent wasn't tracked (e.g., due to missed start messages
from WebSocket connection issues).

Backend changes:
- Modified _handle_agent_complete in server/websocket.py to always emit
  completion messages, even for untracked agents
- Synthetic completions use agentIndex=-1 and agentName='Unknown' as
  sentinel values to indicate untracked agents

Frontend changes:
- Updated useWebSocket.ts to handle synthetic completions by removing
  agents by featureId when agentIndex is -1
- Added 30-minute stale agent cleanup as defense-in-depth for users who
  leave the UI open for extended periods
- Updated TypeScript types to allow 'Unknown' as valid agent name

Component updates:
- AgentAvatar.tsx: Added UNKNOWN_COLORS and UnknownSVG fallback for
  rendering unknown agents with a neutral gray question mark icon
- CelebrationOverlay.tsx, DependencyGraph.tsx: Updated interfaces to
  accept 'Unknown' agent names

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Auto
2026-01-23 13:19:45 +02:00
parent a03d945fcd
commit 1be42cc734
6 changed files with 94 additions and 35 deletions

View File

@@ -195,8 +195,8 @@ export interface AgentLogEntry {
// Agent update from backend
export interface ActiveAgent {
agentIndex: number
agentName: AgentMascot
agentIndex: number // -1 for synthetic completions
agentName: AgentMascot | 'Unknown'
agentType: AgentType // "coding" or "testing"
featureId: number
featureName: string
@@ -265,14 +265,15 @@ export interface WSLogMessage {
export interface WSAgentUpdateMessage {
type: 'agent_update'
agentIndex: number
agentName: AgentMascot
agentIndex: number // -1 for synthetic completions (untracked agents)
agentName: AgentMascot | 'Unknown'
agentType: AgentType // "coding" or "testing"
featureId: number
featureName: string
state: AgentState
thought?: string
timestamp: string
synthetic?: boolean // True for synthetic completions from untracked agents
}
export interface WSAgentStatusMessage {