Update agent lastActivityAt on stream events
Problem: lastActivityAt was only updated when agent_state messages arrived (which only happens on agent lifecycle changes), not when the agent was actively streaming output. This meant the agent directory showed stale "last activity" times. Solution: Update agent.lastActivityAt whenever agent_stream events arrive, using the event's timestamp. Now lastActivityAt tracks real-time activity. Updates happen on: 1. agent_state message → lastActivityAt = updatedAt (from server) 2. agent_stream message → lastActivityAt = event.timestamp (real-time!) This ensures the agent directory always shows fresh activity times. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -628,6 +628,17 @@ export function SessionProvider({ children, serverUrl, serverId }: SessionProvid
|
||||
next.set(agentId, false);
|
||||
return next;
|
||||
});
|
||||
|
||||
// Update agent's lastActivityAt to track stream activity
|
||||
setAgents(serverId, (prev) => {
|
||||
const agent = prev.get(agentId);
|
||||
if (!agent) {
|
||||
return prev;
|
||||
}
|
||||
const next = new Map(prev);
|
||||
next.set(agentId, { ...agent, lastActivityAt: parsedTimestamp });
|
||||
return next;
|
||||
});
|
||||
});
|
||||
|
||||
const unsubAgentStreamSnapshot = ws.on("agent_stream_snapshot", (message) => {
|
||||
|
||||
Reference in New Issue
Block a user