Image Pipeline Playground
feat(frontend/inspector): remove load path input and wire assets
Mohammad Rajaeif8ec881daf35
diff --git a/frontend/src/features/inspector/FileParamInput.tsx b/frontend/src/features/inspector/FileParamInput.tsxindex 9636826..9c78a15 100644--- a/frontend/src/features/inspector/FileParamInput.tsx+++ b/frontend/src/features/inspector/FileParamInput.tsx@@ -1,7 +1,6 @@import { useEffect, useRef, useState } from 'react'-import { Box, Button, IconButton, TextField, Typography } from '@mui/material'+import { Box, Button, IconButton, Typography } from '@mui/material'import {- batchDisplayPath,batchFilePaths,batchPreviewUrls,isDesktopApp,@@ -14,11 +13,9 @@ import { notifyError, notifySuccess } from '../../notify'interface FileParamInputProps {field: ParamField- value: stringassetBatchId?: stringpreviewUrls?: string[]uploadedFiles?: string[]- onChange: (path: string) => voidonAssetBatchId?: (batchId: string) => voidonPreviews?: (dataUrls: string[], uploadedFiles: string[]) => voidonRemovePreview?: (index: number) => void@@ -60,11 +57,9 @@ function readFileAsDataUrl(file: File): Promise<string> {export function FileParamInput({field,- value,assetBatchId = '',previewUrls = [],uploadedFiles = [],- onChange,onAssetBatchId,onPreviews,onRemovePreview,@@ -80,7 +75,9 @@ export function FileParamInput({? `${previewUrls.length} images selected`: previewUrls.length === 1? '1 image selected'- : null+ : assetBatchId+ ? 'Images linked from asset registry'+ : 'No images selected'useEffect(() => {const input = folderRef.current@@ -91,13 +88,11 @@ export function FileParamInput({const applyBatch = (batchId: string,- path: string,urls: string[],files: string[],message: string,) => {onAssetBatchId?.(batchId)- onChange(path)onPreviews?.(urls, files)notifySuccess(message)}@@ -114,7 +109,6 @@ export function FileParamInput({const result = await registerLocalPaths([picked.path], { asFolder: true })applyBatch(result.batch.id,- batchDisplayPath(result.batch),batchPreviewUrls(result.batch),batchFilePaths(result.batch),result.count > 1 ? `${result.count} images loaded` : 'Image loaded',@@ -131,7 +125,6 @@ export function FileParamInput({})applyBatch(result.batch.id,- batchDisplayPath(result.batch),batchPreviewUrls(result.batch),batchFilePaths(result.batch),appending@@ -177,7 +170,6 @@ export function FileParamInput({const nextFiles = [...uploadedFiles, ...result.files]onAssetBatchId?.(result.asset_batch_id)onPreviews?.(nextUrls, nextFiles)- onChange(result.path)notifySuccess(result.count > 1? `Added ${result.count} images (${nextUrls.length} total)`@@ -186,7 +178,6 @@ export function FileParamInput({} else {onAssetBatchId?.(result.asset_batch_id)onPreviews?.(urls, result.files)- onChange(result.path)notifySuccess(result.count > 1 ? `${result.count} images loaded` : 'Image loaded',)@@ -203,17 +194,22 @@ export function FileParamInput({return (<Box sx={{ display: 'grid', gap: 1 }}>- <TextField- size="small"- label={field.label}- value={value}- onChange={(event) => onChange(event.target.value)}- helperText={- desktop- ? 'Native file dialogs register local paths (no copy).'- : (field.description ?? `Allowed: ${acceptAttr(field)}`)- }- />+ <Typography+ sx={{+ fontSize: 10,+ fontWeight: 700,+ letterSpacing: '0.06em',+ textTransform: 'uppercase',+ color: 'rgba(244,241,234,0.4)',+ }}+ >+ {field.label}+ </Typography>+ <Typography sx={{ fontSize: 12, color: 'rgba(244,241,234,0.55)', lineHeight: 1.4 }}>+ {desktop+ ? 'Native dialogs register local paths in the asset registry (no copy).'+ : (field.description ?? `Allowed: ${acceptAttr(field)}`)}+ </Typography><Boxsx={{display: 'flex',@@ -343,11 +339,9 @@ export function FileParamInput({))}</Box>)}- {summary && (- <Typography variant="caption" color="text.secondary">- {summary}- </Typography>- )}+ <Typography variant="caption" color="text.secondary">+ {summary}+ </Typography>{error && (<Typography variant="caption" color="error">{error}diff --git a/frontend/src/features/inspector/NodeInspector.tsx b/frontend/src/features/inspector/NodeInspector.tsxindex 06eb3a5..bed2c3a 100644--- a/frontend/src/features/inspector/NodeInspector.tsx+++ b/frontend/src/features/inspector/NodeInspector.tsx@@ -44,6 +44,7 @@ export function NodeInspector() {const fields = meta?.params ?? []const schema = buildSchema(fields)const isSaveImage = selected?.data.type === 'save_image'+ const isLoadImage = selected?.data.type === 'load_image'const isAnnotations = selected?.data.type === 'annotations'const { register, handleSubmit, reset, setValue, formState } = useForm({@@ -109,6 +110,9 @@ export function NodeInspector() {selected.data.params.filename ?? '{filename}_{index}.png',)}outputDir={String(selected.data.params.output_dir ?? '')}+ packaging={+ selected.data.params.packaging === 'zip' ? 'zip' : 'bare'+ }onFilenameChange={(filename) => {setValue('filename', filename, { shouldDirty: true, shouldValidate: true })updateNodeParams(selected.id, { filename })@@ -117,6 +121,56 @@ export function NodeInspector() {setValue('output_dir', outputDir, { shouldDirty: true, shouldValidate: true })updateNodeParams(selected.id, { output_dir: outputDir })}}+ onPackagingChange={(packaging) => {+ setValue('packaging', packaging, { shouldDirty: true, shouldValidate: true })+ updateNodeParams(selected.id, { packaging })+ }}+ />+ ) : isLoadImage ? (+ <FileParamInput+ field={{+ name: 'images',+ label: 'Images / Folder',+ type: 'file',+ default: '',+ accept: ['.png', '.jpg', '.jpeg', '.bmp', '.tif', '.tiff', '.webp', '.gif'],+ description: 'Select multiple images or a folder of images',+ }}+ assetBatchId={String(selected.data.params.asset_batch_id ?? '')}+ previewUrls={selected.data.localPreviewUrls ?? []}+ uploadedFiles={selected.data.uploadedFiles ?? []}+ onAssetBatchId={(batchId) => {+ setValue('asset_batch_id', batchId, {+ shouldDirty: true,+ shouldValidate: true,+ })+ updateNodeParams(selected.id, {+ asset_batch_id: batchId,+ sample: '',+ })+ }}+ onPreviews={(urls, files) => setLocalPreviews(selected.id, urls, files)}+ onRemovePreview={(index) => {+ const prevBatchId = String(selected.data.params.asset_batch_id ?? '')+ const result = removeLocalPreview(selected.id, index)+ if (!result) return+ setValue('asset_batch_id', result.assetBatchId, {+ shouldDirty: true,+ shouldValidate: true,+ })+ if (!result.file) return+ if (prevBatchId) {+ const name = result.file.replace(/^.*[\\/]/, '')+ void fetch(+ `/api/assets/${prevBatchId}/files/${encodeURIComponent(name)}`,+ { method: 'DELETE' },+ )+ } else {+ void fetch(`/api/uploads?path=${encodeURIComponent(result.file)}`, {+ method: 'DELETE',+ })+ }+ }}/>) : isAnnotations ? (<AnnotationsParams@@ -147,61 +201,16 @@ export function NodeInspector() {</Typography>)}{fields.map((field) => {- if (field.name === 'asset_batch_id' || field.name === 'output_dir') {+ if (+ field.name === 'asset_batch_id' ||+ field.name === 'sample' ||+ field.name === 'output_dir' ||+ field.name === 'packaging'+ ) {return null}if (field.type === 'file') {- return (- <FileParamInput- key={field.name}- field={field}- value={String(selected.data.params[field.name] ?? '')}- assetBatchId={String(selected.data.params.asset_batch_id ?? '')}- previewUrls={selected.data.localPreviewUrls ?? []}- uploadedFiles={selected.data.uploadedFiles ?? []}- onChange={(path) => {- setValue(field.name, path, { shouldDirty: true, shouldValidate: true })- updateNodeParams(selected.id, { [field.name]: path })- }}- onAssetBatchId={(batchId) => {- setValue('asset_batch_id', batchId, {- shouldDirty: true,- shouldValidate: true,- })- updateNodeParams(selected.id, { asset_batch_id: batchId })- }}- onPreviews={(urls, files) => setLocalPreviews(selected.id, urls, files)}- onRemovePreview={(index) => {- const prevBatchId = String(- selected.data.params.asset_batch_id ?? '',- )- const result = removeLocalPreview(selected.id, index)- if (!result) return- setValue(field.name, result.path, {- shouldDirty: true,- shouldValidate: true,- })- if (result.assetBatchId !== undefined) {- setValue('asset_batch_id', result.assetBatchId, {- shouldDirty: true,- shouldValidate: true,- })- }- if (!result.file) return- if (prevBatchId) {- const name = result.file.replace(/^.*[\\/]/, '')- void fetch(- `/api/assets/${prevBatchId}/files/${encodeURIComponent(name)}`,- { method: 'DELETE' },- )- } else {- void fetch(`/api/uploads?path=${encodeURIComponent(result.file)}`, {- method: 'DELETE',- })- }- }}- />- )+ return null}if (field.type === 'select' && field.options) {return (