mirror of
https://github.com/crabwise-ai/crabwalk.git
synced 2026-08-14 00:57:52 +00:00
Fix duplicate messages on hydration
Use addAction() during hydration to apply aggregation logic
This commit is contained in:
@@ -172,12 +172,10 @@ export function hydrateFromServer(
|
||||
sessionsCollection.insert(session)
|
||||
}
|
||||
|
||||
// Insert all actions (rebuild runSessionMap as we go)
|
||||
for (const action of actions) {
|
||||
// Learn runId → sessionKey mapping
|
||||
if (action.sessionKey && !action.sessionKey.includes('lifecycle')) {
|
||||
runSessionMap.set(action.runId, action.sessionKey)
|
||||
}
|
||||
actionsCollection.insert(action)
|
||||
// Replay actions through addAction to apply aggregation logic
|
||||
// Sort by timestamp to ensure correct order
|
||||
const sortedActions = [...actions].sort((a, b) => a.timestamp - b.timestamp)
|
||||
for (const action of sortedActions) {
|
||||
addAction(action)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user