( state: ConsoleStore, workflowId: string, newEntry: ConsoleEntry, trimmedEntries: ConsoleEntry[] )
| 203 | } |
| 204 | |
| 205 | function appendWorkflowEntry( |
| 206 | state: ConsoleStore, |
| 207 | workflowId: string, |
| 208 | newEntry: ConsoleEntry, |
| 209 | trimmedEntries: ConsoleEntry[] |
| 210 | ): Pick<ConsoleStore, 'workflowEntries' | 'entryIdsByBlockExecution' | 'entryLocationById'> { |
| 211 | const workflowEntries = cloneWorkflowEntries(state.workflowEntries) |
| 212 | const previousEntries = workflowEntries[workflowId] ?? EMPTY_CONSOLE_ENTRIES |
| 213 | workflowEntries[workflowId] = trimmedEntries |
| 214 | |
| 215 | const entryLocationById = { ...state.entryLocationById } |
| 216 | const entryIdsByBlockExecution = { ...state.entryIdsByBlockExecution } |
| 217 | |
| 218 | const survivingIds = new Set(trimmedEntries.map((e) => e.id)) |
| 219 | const droppedEntries = previousEntries.filter((e) => !survivingIds.has(e.id)) |
| 220 | if (droppedEntries.length > 0) { |
| 221 | removeWorkflowIndexes(workflowId, droppedEntries, entryIdsByBlockExecution, entryLocationById) |
| 222 | } |
| 223 | |
| 224 | trimmedEntries.forEach((entry, index) => { |
| 225 | entryLocationById[entry.id] = { workflowId, index } |
| 226 | }) |
| 227 | |
| 228 | const blockExecutionKey = getBlockExecutionKey(newEntry.blockId, newEntry.executionId) |
| 229 | const existingIds = entryIdsByBlockExecution[blockExecutionKey] |
| 230 | if (existingIds) { |
| 231 | if (!existingIds.includes(newEntry.id)) { |
| 232 | entryIdsByBlockExecution[blockExecutionKey] = [...existingIds, newEntry.id] |
| 233 | } |
| 234 | } else { |
| 235 | entryIdsByBlockExecution[blockExecutionKey] = [newEntry.id] |
| 236 | } |
| 237 | |
| 238 | return { workflowEntries, entryIdsByBlockExecution, entryLocationById } |
| 239 | } |
| 240 | |
| 241 | interface NotifyBlockErrorParams { |
| 242 | error: unknown |
no test coverage detected