fix(app): narrow stream reducer cursor and agent values

This commit is contained in:
Mohamed Boudra
2026-02-23 19:34:25 +07:00
parent a43008e9c7
commit b167abfda5
@@ -921,6 +921,7 @@ function SessionProviderInternal({
// Apply cursor patch // Apply cursor patch
if (result.cursorChanged && result.cursor) { if (result.cursorChanged && result.cursor) {
const nextCursor = result.cursor;
setAgentTimelineCursor(serverId, (prev) => { setAgentTimelineCursor(serverId, (prev) => {
const current = prev.get(agentId); const current = prev.get(agentId);
if ( if (
@@ -936,20 +937,21 @@ function SessionProviderInternal({
} }
if ( if (
current && current &&
current.epoch === result.cursor.epoch && current.epoch === nextCursor.epoch &&
current.startSeq === result.cursor.startSeq && current.startSeq === nextCursor.startSeq &&
current.endSeq === result.cursor.endSeq current.endSeq === nextCursor.endSeq
) { ) {
return prev; return prev;
} }
const next = new Map(prev); const next = new Map(prev);
next.set(agentId, result.cursor); next.set(agentId, nextCursor);
return next; return next;
}); });
} }
// Apply agent patch (optimistic lifecycle) // Apply agent patch (optimistic lifecycle)
if (result.agentChanged && result.agent) { if (result.agentChanged && result.agent) {
const nextAgent = result.agent;
setAgents(serverId, (prev) => { setAgents(serverId, (prev) => {
const current = prev.get(agentId); const current = prev.get(agentId);
if (!current) { if (!current) {
@@ -958,9 +960,9 @@ function SessionProviderInternal({
const next = new Map(prev); const next = new Map(prev);
next.set(agentId, { next.set(agentId, {
...current, ...current,
status: result.agent.status, status: nextAgent.status,
updatedAt: result.agent.updatedAt, updatedAt: nextAgent.updatedAt,
lastActivityAt: result.agent.lastActivityAt, lastActivityAt: nextAgent.lastActivityAt,
}); });
return next; return next;
}); });