Skip to content

Commit 06f36af

Browse files
committed
handle old records
1 parent 7437ac9 commit 06f36af

File tree

1 file changed

+7
-3
lines changed
  • apps/sim/stores/terminal/console

1 file changed

+7
-3
lines changed

apps/sim/stores/terminal/console/store.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,6 @@ export const useTerminalConsoleStore = create<ConsoleStore>()(
287287
return entry
288288
}
289289

290-
// For loop/parallel iterations, match on iterationCurrent to update the correct entry.
291-
// Without this, all iterations of the same block would be updated with the last iteration's output.
292290
if (
293291
typeof update === 'object' &&
294292
update.iterationCurrent !== undefined &&
@@ -411,9 +409,15 @@ export const useTerminalConsoleStore = create<ConsoleStore>()(
411409
},
412410
merge: (persistedState, currentState) => {
413411
const persisted = persistedState as Partial<ConsoleStore> | undefined
412+
const entries = (persisted?.entries ?? currentState.entries).map((entry, index) => {
413+
if (entry.executionOrder === undefined) {
414+
return { ...entry, executionOrder: index + 1 }
415+
}
416+
return entry
417+
})
414418
return {
415419
...currentState,
416-
entries: persisted?.entries ?? currentState.entries,
420+
entries,
417421
isOpen: persisted?.isOpen ?? currentState.isOpen,
418422
}
419423
},

0 commit comments

Comments
 (0)