diff --git a/frontend/src/app/pages/Dashboard/DashboardViewCard.tsx b/frontend/src/app/pages/Dashboard/DashboardViewCard.tsx index de6e5335..b0a91e0d 100644 --- a/frontend/src/app/pages/Dashboard/DashboardViewCard.tsx +++ b/frontend/src/app/pages/Dashboard/DashboardViewCard.tsx @@ -14,7 +14,7 @@ import { useAppDispatch } from '@/shared/hooks'; import { API_BASE, getAuthToken } from '@/shared/config'; import { useClaudeTokens } from '@/shared/styles/ThemeContext'; import ViewPreview, { ViewPreviewHandle } from '@/app/pages/Views/ViewPreview'; -import { getDefault } from '@/app/pages/Views/InputSchemaForm'; +import { getDefault } from '@/shared/inputSchemaDefaults'; import { useOverlayScrollPassthrough } from './useOverlayScrollPassthrough'; import { useRuntimePreviewUrl, diff --git a/frontend/src/app/pages/Views/InputSchemaForm.tsx b/frontend/src/app/pages/Views/InputSchemaForm.tsx index 567660dc..c4efba1c 100644 --- a/frontend/src/app/pages/Views/InputSchemaForm.tsx +++ b/frontend/src/app/pages/Views/InputSchemaForm.tsx @@ -13,16 +13,7 @@ import Button from '@mui/material/Button'; import AddIcon from '@mui/icons-material/Add'; import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline'; import { useClaudeTokens } from '@/shared/styles/ThemeContext'; - -interface SchemaNode { - type?: string; - properties?: Record; - items?: SchemaNode; - required?: string[]; - enum?: string[]; - description?: string; - default?: any; -} +import { getDefault, type SchemaNode } from '@/shared/inputSchemaDefaults'; interface Props { schema: SchemaNode; @@ -32,26 +23,6 @@ interface Props { depth?: number; } -function getDefault(schema: SchemaNode): any { - if (schema.default !== undefined) return schema.default; - switch (schema.type) { - case 'string': return ''; - case 'number': return 0; - case 'boolean': return false; - case 'array': return []; - case 'object': { - const obj: Record = {}; - if (schema.properties) { - for (const [k, v] of Object.entries(schema.properties)) { - obj[k] = getDefault(v); - } - } - return obj; - } - default: return ''; - } -} - const InputSchemaForm: React.FC = ({ schema, value, onChange, label, depth = 0 }) => { const c = useClaudeTokens(); @@ -258,5 +229,4 @@ const InputSchemaForm: React.FC = ({ schema, value, onChange, label, dept ); }; -export { getDefault }; export default InputSchemaForm; diff --git a/frontend/src/app/pages/Views/ViewEditor.tsx b/frontend/src/app/pages/Views/ViewEditor.tsx index bea754df..60bf9bd3 100644 --- a/frontend/src/app/pages/Views/ViewEditor.tsx +++ b/frontend/src/app/pages/Views/ViewEditor.tsx @@ -36,7 +36,7 @@ import AgentChat from '../AgentChat/AgentChat'; import RefreshIcon from '@mui/icons-material/Refresh'; import ViewPreview, { ViewPreviewHandle } from './ViewPreview'; import TerminalPanel, { TerminalLine } from './TerminalPanel'; -import { getDefault } from './InputSchemaForm'; +import { getDefault } from '@/shared/inputSchemaDefaults'; import CodeEditor from './CodeEditor'; import { ElementSelectionProvider } from '@/app/components/ElementSelectionContext'; import { captureViewThumbnail } from './captureViewThumbnail'; diff --git a/frontend/src/app/pages/Views/ViewRunDialog.tsx b/frontend/src/app/pages/Views/ViewRunDialog.tsx index 28f43e84..92e2cf60 100644 --- a/frontend/src/app/pages/Views/ViewRunDialog.tsx +++ b/frontend/src/app/pages/Views/ViewRunDialog.tsx @@ -11,7 +11,8 @@ import WarningAmberIcon from '@mui/icons-material/WarningAmber'; import { Output, executeOutput, OutputExecuteResult, getFrontendCode, getBackendCode, buildServeUrl, SERVE_BASE } from '@/shared/state/outputsSlice'; import { useAppDispatch } from '@/shared/hooks'; import { useClaudeTokens } from '@/shared/styles/ThemeContext'; -import InputSchemaForm, { getDefault } from './InputSchemaForm'; +import InputSchemaForm from './InputSchemaForm'; +import { getDefault } from '@/shared/inputSchemaDefaults'; import ViewPreview from './ViewPreview'; interface Props { diff --git a/frontend/src/shared/inputSchemaDefaults.ts b/frontend/src/shared/inputSchemaDefaults.ts new file mode 100644 index 00000000..1073c6ae --- /dev/null +++ b/frontend/src/shared/inputSchemaDefaults.ts @@ -0,0 +1,29 @@ +export interface SchemaNode { + type?: string; + properties?: Record; + items?: SchemaNode; + required?: string[]; + enum?: string[]; + description?: string; + default?: any; +} + +export function getDefault(schema: SchemaNode): any { + if (schema.default !== undefined) return schema.default; + switch (schema.type) { + case 'string': return ''; + case 'number': return 0; + case 'boolean': return false; + case 'array': return []; + case 'object': { + const obj: Record = {}; + if (schema.properties) { + for (const [k, v] of Object.entries(schema.properties)) { + obj[k] = getDefault(v); + } + } + return obj; + } + default: return ''; + } +}