Image Pipeline Playground
feat(frontend): improve inspector and code panel empty states
Mohammad Rajaeic602663d4773
diff --git a/README.md b/README.mdindex 90806b8..cf9debe 100644--- a/README.md+++ b/README.md@@ -79,8 +79,8 @@ docker compose up --build2. Connect ports, select a node, and edit parameters in the inspector.3. For **Load Images**, pick files or a folder (uploaded to the backend).4. Click **Run** to execute over WebSocket and watch previews fill in.-5. Use **Export** / **Load** to save or restore a workflow JSON file.-6. Click **Export Python** to fill the Monaco panel with a standalone script.+5. Use **Example** for the bundled Lena blur→Canny pipeline, or **Export** / **Load** for your own workflow JSON.+6. Click **Export Python** (header or code panel) to fill the Monaco panel with a standalone script.7. Open **About** (info button next to the brand) for project description, license, and GitHub.Example workflow: [`backend/examples/blur_canny.json`](backend/examples/blur_canny.json) (uses [`backend/examples/lena.png`](backend/examples/lena.png)).diff --git a/frontend/src/features/code/CodePanel.tsx b/frontend/src/features/code/CodePanel.tsxindex 9171e69..b3e4492 100644--- a/frontend/src/features/code/CodePanel.tsx+++ b/frontend/src/features/code/CodePanel.tsx@@ -1,29 +1,76 @@import Editor from '@monaco-editor/react'-import { Box, Typography } from '@mui/material'+import { Box, Button, Typography } from '@mui/material'import { useGraphStore } from '../../store/graphStore'+import { requestCodegen } from '../../hooks/useExecutionSocket'+import { notifyError, notifySuccess } from '../../notify'++export const DEFAULT_GENERATED_CODE = '# Run codegen to export a Python script\n'export function CodePanel() {const code = useGraphStore((s) => s.generatedCode)+ const setGeneratedCode = useGraphStore((s) => s.setGeneratedCode)+ const isExecuting = useGraphStore((s) => s.isExecuting)+ const nodeCount = useGraphStore((s) => s.nodes.length)+ const isPlaceholder = code.trim() === DEFAULT_GENERATED_CODE.trim() || !code.trim()++ const onExportPython = async () => {+ try {+ const next = await requestCodegen()+ setGeneratedCode(next)+ notifySuccess('Python script exported')+ } catch (error) {+ notifyError(error instanceof Error ? error.message : 'Codegen failed')+ }+ }return (<Box sx={{ height: '100%', display: 'flex', flexDirection: 'column' }}>- <Typography variant="subtitle1" sx={{ fontWeight: 700, px: 2, pt: 2 }}>+ <Typography+ variant="subtitle1"+ sx={{ fontFamily: '"Fraunces", Georgia, serif', fontWeight: 700, px: 2, pt: 2 }}+ >Python Export</Typography>- <Box sx={{ flex: 1, minHeight: 0 }}>- <Editor- height="100%"- defaultLanguage="python"- value={code}- theme="vs-dark"- options={{- readOnly: true,- minimap: { enabled: false },- fontSize: 13,- scrollBeyondLastLine: false,- }}- />- </Box>+ {isPlaceholder ? (+ <Box sx={{ flex: 1, px: 2, pb: 2, display: 'flex', flexDirection: 'column', gap: 1.5 }}>+ <Typography sx={{ color: 'rgba(244,241,234,0.55)', fontSize: 13, lineHeight: 1.5 }}>+ Generate a standalone OpenCV script from the current pipeline.+ </Typography>+ <Button+ variant="outlined"+ disabled={isExecuting || nodeCount === 0}+ onClick={() => void onExportPython()}+ sx={{+ alignSelf: 'flex-start',+ textTransform: 'none',+ fontWeight: 650,+ color: '#f0ebe3',+ borderColor: 'rgba(255,255,255,0.16)',+ '&:hover': {+ borderColor: 'rgba(125,206,160,0.45)',+ bgcolor: 'rgba(125,206,160,0.08)',+ },+ }}+ >+ Export Python+ </Button>+ </Box>+ ) : (+ <Box sx={{ flex: 1, minHeight: 0 }}>+ <Editor+ height="100%"+ defaultLanguage="python"+ value={code}+ theme="vs-dark"+ options={{+ readOnly: true,+ minimap: { enabled: false },+ fontSize: 13,+ scrollBeyondLastLine: false,+ }}+ />+ </Box>+ )}</Box>)}diff --git a/frontend/src/features/inspector/NodeInspector.tsx b/frontend/src/features/inspector/NodeInspector.tsxindex 23584b9..7343393 100644--- a/frontend/src/features/inspector/NodeInspector.tsx+++ b/frontend/src/features/inspector/NodeInspector.tsx@@ -53,14 +53,34 @@ export function NodeInspector() {}, [selected?.id, selected?.data.params, reset])if (!selected) {+ const nodeCount = nodes.lengthreturn (<Box sx={{ p: 2 }}>- <Typography variant="subtitle1" sx={{ fontWeight: 700 }}>+ <Typography+ variant="subtitle1"+ sx={{ fontFamily: '"Fraunces", Georgia, serif', fontWeight: 700, mb: 1 }}+ >Inspector</Typography>- <Typography variant="body2" color="text.secondary">- Select a node to edit parameters.+ <Typography variant="body2" sx={{ color: 'rgba(244,241,234,0.55)', mb: 2, lineHeight: 1.5 }}>+ {nodeCount === 0+ ? 'Drag a node from the palette, or load the Example pipeline to get started.'+ : 'Click a node on the canvas to edit its parameters here.'}</Typography>+ <Box+ component="ul"+ sx={{+ m: 0,+ pl: 2,+ color: 'rgba(244,241,234,0.45)',+ fontSize: 12,+ lineHeight: 1.7,+ }}+ >+ <li>Connect green inputs to orange outputs</li>+ <li>Press Run to execute with live previews</li>+ <li>Export saves workflow JSON; Export Python codegen</li>+ </Box></Box>)}