fix(app): keep hidden timelines dormant

This commit is contained in:
Mohamed Boudra
2026-07-13 00:26:21 +02:00
parent 4f08ae8f8a
commit a5686ced3d
3 changed files with 31 additions and 1 deletions

View File

@@ -908,7 +908,7 @@ function ChatAgentContent({
}
return;
}
if (!isConnected || !hasSession) {
if (!isPaneFocused || !isConnected || !hasSession) {
return;
}
if (
@@ -969,6 +969,7 @@ function ChatAgentContent({
ensureAgentIsInitialized,
hasSession,
isConnected,
isPaneFocused,
missingAgentState.kind,
serverId,
]);

View File

@@ -183,4 +183,32 @@ describe("agent directory reconciliation", () => {
usage: { inputTokens: 20, outputTokens: 8 },
});
});
it("preserves usage when a stale buffered upsert omits it", () => {
const result = reconcileAgentDirectory({
previous: new Map(),
snapshot: [
{
...entry("agent", "idle"),
agent: {
...snapshot("agent", "idle"),
updatedAt: "2026-07-12T12:00:00.000Z",
lastUsage: { inputTokens: 10, outputTokens: 5 },
},
},
],
deltas: [
{
kind: "upsert",
agent: {
...snapshot("agent", "running"),
updatedAt: "2026-07-12T11:00:00.000Z",
},
project: entry("agent", "idle").project,
},
],
});
expect(result.entries[0]?.agent.lastUsage).toEqual({ inputTokens: 10, outputTokens: 5 });
});
});

View File

@@ -15,6 +15,7 @@ export function acceptAgentDirectoryUpdate<T extends AgentUpdateValue>(
incoming: T,
): T {
if (!current || timestamp(incoming.updatedAt) >= timestamp(current.updatedAt)) return incoming;
if (incoming.lastUsage === undefined) return current;
if (equal(incoming.lastUsage, current.lastUsage)) return current;
return { ...current, lastUsage: incoming.lastUsage };
}