Resume cached timelines without replaying their tail (#3329)

* perf(timeline): resume cached history from its exact range

Warm launches were repainting cached history and then downloading the same bounded tail to rediscover that nothing changed. Persist synchronization authority only when the complete current canonical window can be encoded losslessly; otherwise retain the existing display-only fallback.

* test(timeline): hide replica setup behind E2E helper

* fix(timeline): bound persisted resume overflow

* test(timeline): cover workspace eviction catch-up order

* test(timeline): read persisted range from IndexedDB
This commit is contained in:
Mohamed Boudra
2026-08-14 12:57:44 +02:00
committed by GitHub
parent 30195d3bd1
commit f0bd2c8483
18 changed files with 707 additions and 75 deletions
+16
View File
@@ -308,6 +308,8 @@ export interface AgentTimelineCursorState {
export interface SessionReplicaTimeline {
agentId: string;
items: StreamItem[];
range: AgentTimelineCursorState | null;
hasOlder: boolean;
}
export interface SessionReplica {
@@ -789,6 +791,16 @@ export const useSessionStore = create<SessionStore>()(
const tasks = latestTasksFromStream(timeline.items);
if (tasks.length > 0) agentTasks.set(timeline.agentId, tasks);
}
const agentTimelineCursor = new Map<string, AgentTimelineCursorState>();
const agentTimelineHasOlder = new Map<string, boolean>();
const agentTimelineHasNewer = new Map<string, boolean>();
const agentAuthoritativeHistoryApplied = new Map<string, boolean>();
if (timeline?.range) {
agentTimelineCursor.set(timeline.agentId, timeline.range);
agentTimelineHasOlder.set(timeline.agentId, timeline.hasOlder);
agentTimelineHasNewer.set(timeline.agentId, false);
agentAuthoritativeHistoryApplied.set(timeline.agentId, true);
}
const agentLastActivity = new Map(prev.agentLastActivity);
for (const agent of replica.agents.values()) {
agentLastActivity.set(agent.id, agent.lastActivityAt);
@@ -806,6 +818,10 @@ export const useSessionStore = create<SessionStore>()(
hasWorkspaceDirectorySnapshot: true,
agentStreamTail,
agentTasks,
agentTimelineCursor,
agentTimelineHasOlder,
agentTimelineHasNewer,
agentAuthoritativeHistoryApplied,
},
},
agentLastActivity,