Skip to content

Image Pipeline Playground

feat(frontend/notifications): integrate notistack for enhanced notification system

Mohammad Rajaei6bdccbd18950
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 436e4ab..fc599bb 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -15,6 +15,7 @@
"@mui/material": "^9.2.0",
"@tanstack/react-query": "^5.101.4",
"@xyflow/react": "^12.11.2",
+ "notistack": "^3.0.2",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"react-hook-form": "^7.83.0",
@@ -2367,7 +2368,8 @@
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
- "license": "MIT"
+ "license": "MIT",
+ "peer": true
},
"node_modules/d3-color": {
"version": "3.1.0",
@@ -2941,6 +2943,15 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/goober": {
+ "version": "2.1.19",
+ "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.19.tgz",
+ "integrity": "sha512-U7veizMqxyKlM58+Z5j2ngJBH/r9siDmxpvNxSw0PylF6WQvrASJEZrxh1hidRBJc2jqoBVSyOban5u8m+6Rxg==",
+ "license": "MIT",
+ "peerDependencies": {
+ "csstype": "^3.0.10"
+ }
+ },
"node_modules/hasown": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
@@ -3533,6 +3544,37 @@
"node": ">=18"
}
},
+ "node_modules/notistack": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/notistack/-/notistack-3.0.2.tgz",
+ "integrity": "sha512-0R+/arLYbK5Hh7mEfR2adt0tyXJcCC9KkA2hc56FeWik2QN6Bm/S4uW+BjzDARsJth5u06nTjelSw/VSnB1YEA==",
+ "license": "MIT",
+ "dependencies": {
+ "clsx": "^1.1.0",
+ "goober": "^2.0.33"
+ },
+ "engines": {
+ "node": ">=12.0.0",
+ "npm": ">=6.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/notistack"
+ },
+ "peerDependencies": {
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
+ }
+ },
+ "node_modules/notistack/node_modules/clsx": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz",
+ "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 9bfca2b..9e9963c 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -18,6 +18,7 @@
"@mui/material": "^9.2.0",
"@tanstack/react-query": "^5.101.4",
"@xyflow/react": "^12.11.2",
+ "notistack": "^3.0.2",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"react-hook-form": "^7.83.0",
diff --git a/frontend/src/app/App.tsx b/frontend/src/app/App.tsx
index 05c30ec..fa94041 100644
--- a/frontend/src/app/App.tsx
+++ b/frontend/src/app/App.tsx
@@ -5,19 +5,20 @@ import { NodeInspector } from '../features/inspector/NodeInspector'
import { CodePanel } from '../features/code/CodePanel'
import { useGraphStore } from '../store/graphStore'
import { requestCodegen, useExecutionSocket } from '../hooks/useExecutionSocket'
+import { notifyError, notifySuccess } from '../notify'
import { AppHeader } from './AppHeader'
export default function App() {
const setGeneratedCode = useGraphStore((s) => s.setGeneratedCode)
- const appendLog = useGraphStore((s) => s.appendLog)
const { run, cancel } = useExecutionSocket()
const onExport = async () => {
try {
const code = await requestCodegen()
setGeneratedCode(code)
+ notifySuccess('Python script exported')
} catch (error) {
- appendLog(error instanceof Error ? error.message : 'Codegen failed')
+ notifyError(error instanceof Error ? error.message : 'Codegen failed')
}
}
diff --git a/frontend/src/app/AppHeader.tsx b/frontend/src/app/AppHeader.tsx
index b56eb85..10d18c4 100644
--- a/frontend/src/app/AppHeader.tsx
+++ b/frontend/src/app/AppHeader.tsx
@@ -150,7 +150,7 @@ export function AppHeader({ onRun, onCancel, onExport }: AppHeaderProps) {
'linear-gradient(180deg, rgba(255,255,255,0.03), transparent), radial-gradient(ellipse 50% 120% at 0% 0%, rgba(125,206,160,0.08), transparent 55%)',
}}
>
- <Stack direction="row" spacing={1.25} alignItems="center" sx={{ minWidth: 0 }}>
+ <Stack direction="row" spacing={1.25} sx={{ alignItems: 'center', minWidth: 0 }}>
<BrandMark />
<Box sx={{ minWidth: 0 }}>
<Typography
@@ -193,8 +193,8 @@ export function AppHeader({ onRun, onCancel, onExport }: AppHeaderProps) {
<Stack
direction="row"
spacing={1}
- alignItems="center"
sx={{
+ alignItems: 'center',
px: 1,
py: 0.5,
borderRadius: 1.5,
@@ -220,7 +220,7 @@ export function AppHeader({ onRun, onCancel, onExport }: AppHeaderProps) {
/>
</Stack>
- <Stack direction="row" spacing={1} alignItems="center">
+ <Stack direction="row" spacing={1} sx={{ alignItems: 'center' }}>
{isExecuting ? (
<Button
variant="outlined"
diff --git a/frontend/src/app/AppSnackbarProvider.tsx b/frontend/src/app/AppSnackbarProvider.tsx
new file mode 100644
index 0000000..09ad3a3
--- /dev/null
+++ b/frontend/src/app/AppSnackbarProvider.tsx
@@ -0,0 +1,80 @@
+import type { ReactNode } from 'react'
+import {
+ MaterialDesignContent,
+ SnackbarProvider,
+ closeSnackbar,
+ type CustomContentProps,
+} from 'notistack'
+import { Box, IconButton } from '@mui/material'
+import { forwardRef } from 'react'
+
+const baseContentSx = {
+ fontFamily: '"IBM Plex Sans", "Segoe UI", sans-serif',
+ fontSize: 13,
+ fontWeight: 600,
+ borderRadius: '10px',
+ boxShadow: '0 12px 32px rgba(0,0,0,0.45)',
+ border: '1px solid rgba(255,255,255,0.08)',
+} as const
+
+const StyledContent = forwardRef<HTMLDivElement, CustomContentProps>((props, ref) => {
+ const variant = props.variant ?? 'default'
+ const colors: Record<string, { bg: string; fg: string }> = {
+ success: { bg: '#1b3d2f', fg: '#b8f0cf' },
+ error: { bg: '#3d1b1b', fg: '#ffb4a8' },
+ info: { bg: '#1b2a3d', fg: '#a8d4ff' },
+ warning: { bg: '#3d2e1b', fg: '#ffd59a' },
+ default: { bg: '#1e1e1e', fg: '#f4f1ea' },
+ }
+ const tone = colors[variant] ?? colors.default
+
+ return (
+ <MaterialDesignContent
+ ref={ref}
+ {...props}
+ style={{
+ ...baseContentSx,
+ backgroundColor: tone.bg,
+ color: tone.fg,
+ }}
+ />
+ )
+})
+StyledContent.displayName = 'StyledSnackbarContent'
+
+function DismissButton({ snackbarId }: { snackbarId: string | number }) {
+ return (
+ <IconButton
+ size="small"
+ aria-label="Dismiss"
+ onClick={() => closeSnackbar(snackbarId)}
+ sx={{ color: 'inherit', opacity: 0.7, '&:hover': { opacity: 1 } }}
+ >
+ <Box component="span" sx={{ fontSize: 14, lineHeight: 1 }}>
+ ×
+ </Box>
+ </IconButton>
+ )
+}
+
+export function AppSnackbarProvider({ children }: { children: ReactNode }) {
+ return (
+ <SnackbarProvider
+ maxSnack={4}
+ dense
+ preventDuplicate
+ autoHideDuration={4000}
+ anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
+ action={(key) => <DismissButton snackbarId={key} />}
+ Components={{
+ success: StyledContent,
+ error: StyledContent,
+ info: StyledContent,
+ warning: StyledContent,
+ default: StyledContent,
+ }}
+ >
+ {children}
+ </SnackbarProvider>
+ )
+}
diff --git a/frontend/src/features/canvas/NodeMenu.tsx b/frontend/src/features/canvas/NodeMenu.tsx
index be1a939..b0d3941 100644
--- a/frontend/src/features/canvas/NodeMenu.tsx
+++ b/frontend/src/features/canvas/NodeMenu.tsx
@@ -1,4 +1,5 @@
import { useCallback, useState, type MouseEvent, type ReactNode } from 'react'
+/* eslint-disable react-refresh/only-export-components -- hook + private menu UI helpers */
import {
Box,
Divider,
@@ -241,7 +242,7 @@ export function useNodeMenu({
</ListItemIcon>
<ListItemText
primary="Duplicate"
- primaryTypographyProps={{ fontSize: 13, fontWeight: 600 }}
+ slotProps={{ primary: { sx: { fontSize: 13, fontWeight: 600 } } }}
/>
<ShortcutHint keys={`${modKey}+D`} />
</MenuItem>
@@ -265,7 +266,7 @@ export function useNodeMenu({
</ListItemIcon>
<ListItemText
primary="Delete"
- primaryTypographyProps={{ fontSize: 13, fontWeight: 600, color: '#ff8a80' }}
+ slotProps={{ primary: { sx: { fontSize: 13, fontWeight: 600, color: '#ff8a80' } } }}
/>
<ShortcutHint keys="Del" />
</MenuItem>
diff --git a/frontend/src/features/inspector/FileParamInput.tsx b/frontend/src/features/inspector/FileParamInput.tsx
index 448ad6b..596dd0b 100644
--- a/frontend/src/features/inspector/FileParamInput.tsx
+++ b/frontend/src/features/inspector/FileParamInput.tsx
@@ -1,6 +1,7 @@
import { useEffect, useRef, useState } from 'react'
import { Box, Button, IconButton, Stack, TextField, Typography } from '@mui/material'
import type { ParamField } from '../../types'
+import { notifyError, notifySuccess } from '../../notify'
interface FileParamInputProps {
field: ParamField
@@ -97,7 +98,9 @@ export function FileParamInput({
a.name.localeCompare(b.name, undefined, { numeric: true }),
)
if (files.length === 0) {
- setError(`No supported images selected (${acceptAttr(field)})`)
+ const message = `No supported images selected (${acceptAttr(field)})`
+ setError(message)
+ notifyError(message)
return
}
setBusy(true)
@@ -109,9 +112,14 @@ export function FileParamInput({
onPreviews?.(urls, result.files)
onChange(result.path)
onBatchCount?.(result.count)
+ notifySuccess(
+ result.count > 1 ? `${result.count} images loaded` : 'Image loaded',
+ )
} catch (err) {
onPreviews?.([], [])
- setError(err instanceof Error ? err.message : 'Upload failed')
+ const message = err instanceof Error ? err.message : 'Upload failed'
+ setError(message)
+ notifyError(message)
} finally {
setBusy(false)
}
diff --git a/frontend/src/features/palette/NodePalette.tsx b/frontend/src/features/palette/NodePalette.tsx
index c9d5ffe..2c2e0c2 100644
--- a/frontend/src/features/palette/NodePalette.tsx
+++ b/frontend/src/features/palette/NodePalette.tsx
@@ -10,6 +10,7 @@ import {
} from '@mui/material'
import { useGraphStore } from '../../store/graphStore'
import type { NodeMetadata } from '../../types'
+import { notifyError } from '../../notify'
async function fetchNodes(): Promise<NodeMetadata[]> {
const response = await fetch('/api/nodes')
@@ -287,6 +288,10 @@ export function NodePalette() {
if (data) setNodeCatalog(data)
}, [data, setNodeCatalog])
+ useEffect(() => {
+ if (error) notifyError('Could not load node catalog')
+ }, [error])
+
const filtered = useMemo(() => {
const needle = query.trim().toLowerCase()
if (!needle) return catalog
@@ -363,26 +368,28 @@ export function NodePalette() {
value={query}
onChange={(event) => setQuery(event.target.value)}
placeholder="Search nodes…"
- InputProps={{
- startAdornment: (
- <InputAdornment position="start">
- <Typography sx={{ color: 'rgba(255,255,255,0.35)', fontSize: 13 }}>⌕</Typography>
- </InputAdornment>
- ),
- endAdornment: query ? (
- <InputAdornment position="end">
- <IconButton
- size="small"
- aria-label="Clear search"
- onClick={() => setQuery('')}
- sx={{ color: 'rgba(255,255,255,0.4)' }}
- >
- <Typography component="span" sx={{ fontSize: 12, lineHeight: 1 }}>
- ×
- </Typography>
- </IconButton>
- </InputAdornment>
- ) : undefined,
+ slotProps={{
+ input: {
+ startAdornment: (
+ <InputAdornment position="start">
+ <Typography sx={{ color: 'rgba(255,255,255,0.35)', fontSize: 13 }}>⌕</Typography>
+ </InputAdornment>
+ ),
+ endAdornment: query ? (
+ <InputAdornment position="end">
+ <IconButton
+ size="small"
+ aria-label="Clear search"
+ onClick={() => setQuery('')}
+ sx={{ color: 'rgba(255,255,255,0.4)' }}
+ >
+ <Typography component="span" sx={{ fontSize: 12, lineHeight: 1 }}>
+ ×
+ </Typography>
+ </IconButton>
+ </InputAdornment>
+ ) : undefined,
+ },
}}
sx={{
'& .MuiInputBase-root': {
diff --git a/frontend/src/hooks/useExecutionSocket.ts b/frontend/src/hooks/useExecutionSocket.ts
index 28c8b0c..0feaf74 100644
--- a/frontend/src/hooks/useExecutionSocket.ts
+++ b/frontend/src/hooks/useExecutionSocket.ts
@@ -1,5 +1,6 @@
import { useCallback, useRef } from 'react'
import { useGraphStore } from '../store/graphStore'
+import { notifyError, notifyInfo, notifySuccess } from '../notify'
import type { ExecutionEvent } from '../types'
export function useExecutionSocket() {
@@ -18,6 +19,7 @@ export function useExecutionSocket() {
socketRef.current?.close()
socketRef.current = null
setIsExecuting(false)
+ notifyInfo('Pipeline cancelled')
}, [setIsExecuting])
const run = useCallback(() => {
@@ -56,12 +58,22 @@ export function useExecutionSocket() {
}
if (event.type === 'log' && event.message) appendLog(event.message)
if (event.type === 'error') {
- appendLog(event.message ?? 'Execution failed')
+ const detail = event.message ?? 'Execution failed'
+ appendLog(detail)
+ notifyError(detail)
setIsExecuting(false)
setActiveNodeId(null)
}
- if (event.type === 'done' || event.type === 'cancelled') {
- appendLog(event.message ?? event.type)
+ if (event.type === 'done') {
+ appendLog(event.message ?? 'done')
+ notifySuccess(event.message ?? 'Pipeline finished')
+ setIsExecuting(false)
+ setActiveNodeId(null)
+ socket.close()
+ }
+ if (event.type === 'cancelled') {
+ appendLog(event.message ?? 'cancelled')
+ notifyInfo(event.message ?? 'Pipeline cancelled')
setIsExecuting(false)
setActiveNodeId(null)
socket.close()
@@ -70,6 +82,7 @@ export function useExecutionSocket() {
socket.onerror = () => {
appendLog('WebSocket error')
+ notifyError('Could not connect to the execution server')
setIsExecuting(false)
}
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx
index 67bc6e9..00d205e 100644
--- a/frontend/src/main.tsx
+++ b/frontend/src/main.tsx
@@ -3,6 +3,7 @@ import { createRoot } from 'react-dom/client'
import { CssBaseline, ThemeProvider, createTheme } from '@mui/material'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import App from './app/App'
+import { AppSnackbarProvider } from './app/AppSnackbarProvider'
import './index.css'
const theme = createTheme({
@@ -29,7 +30,9 @@ createRoot(document.getElementById('root')!).render(
<QueryClientProvider client={queryClient}>
<ThemeProvider theme={theme}>
<CssBaseline />
- <App />
+ <AppSnackbarProvider>
+ <App />
+ </AppSnackbarProvider>
</ThemeProvider>
</QueryClientProvider>
</StrictMode>,
diff --git a/frontend/src/notify.ts b/frontend/src/notify.ts
new file mode 100644
index 0000000..1e4b5a0
--- /dev/null
+++ b/frontend/src/notify.ts
@@ -0,0 +1,30 @@
+import { enqueueSnackbar, type OptionsObject, type VariantType } from 'notistack'
+
+const defaults: OptionsObject = {
+ autoHideDuration: 4000,
+ anchorOrigin: { vertical: 'bottom', horizontal: 'center' },
+}
+
+export function notify(
+ message: string,
+ variant: VariantType = 'default',
+ options?: OptionsObject,
+) {
+ enqueueSnackbar(message, { ...defaults, variant, ...options })
+}
+
+export function notifySuccess(message: string, options?: OptionsObject) {
+ notify(message, 'success', options)
+}
+
+export function notifyError(message: string, options?: OptionsObject) {
+ notify(message, 'error', { autoHideDuration: 6000, ...options })
+}
+
+export function notifyInfo(message: string, options?: OptionsObject) {
+ notify(message, 'info', options)
+}
+
+export function notifyWarning(message: string, options?: OptionsObject) {
+ notify(message, 'warning', options)
+}