Skip to content

Commit 176f1a2

Browse files
committed
fix(notifications): mismatching workflow ID
1 parent 9a9131a commit 176f1a2

File tree

1 file changed

+12
-9
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/notifications

1 file changed

+12
-9
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/notifications/notifications.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { memo, useCallback } from 'react'
1+
import { memo, useCallback, useMemo } from 'react'
22
import clsx from 'clsx'
33
import { X } from 'lucide-react'
4-
import { useParams } from 'next/navigation'
54
import { Button } from '@/components/emcn'
65
import { createLogger } from '@/lib/logs/console/logger'
76
import { useRegisterGlobalCommands } from '@/app/workspace/[workspaceId]/providers/global-commands-provider'
@@ -13,6 +12,7 @@ import {
1312
useNotificationStore,
1413
} from '@/stores/notifications'
1514
import { useTerminalStore } from '@/stores/terminal'
15+
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
1616

1717
const logger = createLogger('Notifications')
1818
const MAX_VISIBLE_NOTIFICATIONS = 4
@@ -23,15 +23,18 @@ const MAX_VISIBLE_NOTIFICATIONS = 4
2323
* Shows both global notifications and workflow-specific notifications
2424
*/
2525
export const Notifications = memo(function Notifications() {
26-
const params = useParams()
27-
const workflowId = params.workflowId as string
26+
const activeWorkflowId = useWorkflowRegistry((state) => state.activeWorkflowId)
2827

29-
const notifications = useNotificationStore((state) =>
30-
state.notifications.filter((n) => !n.workflowId || n.workflowId === workflowId)
31-
)
28+
const allNotifications = useNotificationStore((state) => state.notifications)
3229
const removeNotification = useNotificationStore((state) => state.removeNotification)
3330
const clearNotifications = useNotificationStore((state) => state.clearNotifications)
34-
const visibleNotifications = notifications.slice(0, MAX_VISIBLE_NOTIFICATIONS)
31+
32+
const visibleNotifications = useMemo(() => {
33+
if (!activeWorkflowId) return []
34+
return allNotifications
35+
.filter((n) => !n.workflowId || n.workflowId === activeWorkflowId)
36+
.slice(0, MAX_VISIBLE_NOTIFICATIONS)
37+
}, [allNotifications, activeWorkflowId])
3538
const isTerminalResizing = useTerminalStore((state) => state.isResizing)
3639

3740
/**
@@ -85,7 +88,7 @@ export const Notifications = memo(function Notifications() {
8588
{
8689
id: 'clear-notifications',
8790
handler: () => {
88-
clearNotifications(workflowId)
91+
clearNotifications(activeWorkflowId ?? undefined)
8992
},
9093
overrides: {
9194
allowInEditable: false,

0 commit comments

Comments
 (0)