Skip to content

Commit 04dba48

Browse files
waleedlatif1claude
andcommitted
fix(console): scope error-dedup to the block execution
The dedup keyed on block+message for 1.5s, but the toast stack clears on navigation — so a genuinely new same-block error within that window (e.g. a re-run, or after navigating) was suppressed with no replacement toast. Key the dedup on the block execution (getBlockExecutionKey) so only the same execution's addConsole/updateConsole double-fire collapses; a different execution always toasts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4ad93fc commit 04dba48

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

  • apps/sim/stores/terminal/console

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,29 @@ function appendWorkflowEntry(
241241
interface NotifyBlockErrorParams {
242242
error: unknown
243243
blockName: string
244+
blockId: string
245+
executionId?: string
244246
logContext: Record<string, unknown>
245247
}
246248

247249
/**
248250
* A single block failure surfaces through both `addConsole` (initial entry)
249251
* and `updateConsole` (streaming/finalize), so the same logical error asks to
250-
* toast twice within the same tick. Collapse identical (block + message)
251-
* notifications inside a short window so the user sees one toast per error.
252+
* toast twice within the same tick. Collapse them inside a short window. The
253+
* key is scoped to the block execution (not just block + message), so a re-run
254+
* or a different execution still toasts — even within the window, and even
255+
* after the stack was cleared on navigation.
252256
*/
253257
const NOTIFY_DEDUP_WINDOW_MS = 1500
254258
const recentErrorNotifications = new Map<string, number>()
255259

256-
const notifyBlockError = ({ error, blockName, logContext }: NotifyBlockErrorParams) => {
260+
const notifyBlockError = ({
261+
error,
262+
blockName,
263+
blockId,
264+
executionId,
265+
logContext,
266+
}: NotifyBlockErrorParams) => {
257267
const settings = getQueryClient().getQueryData<GeneralSettings>(generalSettingsKeys.settings())
258268
const isErrorNotificationsEnabled = settings?.errorNotificationsEnabled ?? true
259269

@@ -268,7 +278,7 @@ const notifyBlockError = ({ error, blockName, logContext }: NotifyBlockErrorPara
268278
for (const [key, shownAt] of recentErrorNotifications) {
269279
if (now - shownAt >= NOTIFY_DEDUP_WINDOW_MS) recentErrorNotifications.delete(key)
270280
}
271-
const dedupKey = `${displayName}: ${errorMessage}`
281+
const dedupKey = `${getBlockExecutionKey(blockId, executionId)}: ${errorMessage}`
272282
const lastShownAt = recentErrorNotifications.get(dedupKey)
273283
if (lastShownAt !== undefined && now - lastShownAt < NOTIFY_DEDUP_WINDOW_MS) return
274284
recentErrorNotifications.set(dedupKey, now)
@@ -340,6 +350,8 @@ export const useTerminalConsoleStore = create<ConsoleStore>()(
340350
notifyBlockError({
341351
error: createdEntry.error,
342352
blockName: createdEntry.blockName || 'Unknown Block',
353+
blockId: createdEntry.blockId,
354+
executionId: createdEntry.executionId,
343355
logContext: { entryId: createdEntry.id },
344356
})
345357
}
@@ -628,6 +640,8 @@ export const useTerminalConsoleStore = create<ConsoleStore>()(
628640
notifyBlockError({
629641
error: update.error,
630642
blockName: update.blockName || matchingEntry?.blockName || 'Unknown Block',
643+
blockId,
644+
executionId,
631645
logContext: { blockId },
632646
})
633647
}

0 commit comments

Comments
 (0)