From 5a1fddf8ba1e1ecad3fdb08fa138e7264e49d669 Mon Sep 17 00:00:00 2001 From: mlogclub Date: Tue, 30 Jun 2026 15:56:27 +0800 Subject: [PATCH] feat: add InspectorParameterTabs component for improved input/output organization in NodeConfigPanel --- .../_components/node-config-panel.tsx | 141 ++++++++++++------ .../_components/workflow-config-sidebar.tsx | 2 +- 2 files changed, 96 insertions(+), 47 deletions(-) diff --git a/web/app/dashboard/ai-workflows/_components/node-config-panel.tsx b/web/app/dashboard/ai-workflows/_components/node-config-panel.tsx index e797869..3ce3e88 100644 --- a/web/app/dashboard/ai-workflows/_components/node-config-panel.tsx +++ b/web/app/dashboard/ai-workflows/_components/node-config-panel.tsx @@ -5,6 +5,7 @@ import { Trash2Icon } from "lucide-react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { OptionCombobox } from "@/components/option-combobox" import type { AIWorkflowDefinition, AIWorkflowNodeSpec } from "@/lib/api/admin" import { cn } from "@/lib/utils" @@ -77,7 +78,6 @@ export function NodeConfigPanel({ const canDelete = node.type !== "start" && node.type !== "end" const config = normalizeNodeConfig(node.data?.config) const branches = config.branches ?? [] - const updateData = (data: Partial) => { onChange(node.id, { ...(node.data ?? {}), @@ -85,6 +85,42 @@ export function NodeConfigPanel({ }) } const updateConfig = (nextConfig: Record) => updateData({ config: nextConfig }) + const inputFields = inputSchema.map((input) => { + const value = inputsValues[input.name] + return ( + + { + updateData({ + inputsValues: { + ...inputsValues, + [input.name]: next, + }, + }) + }} + /> + {input.description ? {input.description} : null} + + ) + }) + const outputFields = outputSchema.map((output) => { + const item = buildVariableSpecDisplay(output) + return ( + + {item.description ? {item.description} : null} + + ) + }) const updateBranch = (branch: WorkflowConditionBranch) => { const nextBranches = branches.some((item) => item.id === branch.id) ? branches.map((item) => (item.id === branch.id ? branch : item)) @@ -133,38 +169,13 @@ export function NodeConfigPanel({ ) : null}
- {inputSchema.length > 0 ? ( - - {inputSchema.map((input) => { - const value = inputsValues[input.name] - return ( - - { - updateData({ - inputsValues: { - ...inputsValues, - [input.name]: next, - }, - }) - }} - /> - {input.description ? {input.description} : null} - - ) - })} - - ) : null} + {showConditionBranches && (node.type === "condition" || branches.length > 0) ? ( ) : null} - - {outputSchema.length > 0 ? ( - - {outputSchema.map((output) => { - const item = buildVariableSpecDisplay(output) - return ( - - {item.description ? {item.description} : null} - - ) - })} - - ) : null}
) @@ -464,6 +462,57 @@ function ConditionFields({ ) } +function InspectorParameterTabs({ + inputCount, + outputCount, + inputContent, + outputContent, +}: { + inputCount: number + outputCount: number + inputContent: ReactNode + outputContent: ReactNode +}) { + const tabs = [ + inputCount > 0 ? { value: "input", label: "输入", count: inputCount, content: inputContent } : null, + outputCount > 0 ? { value: "output", label: "输出", count: outputCount, content: outputContent } : null, + ].filter((item): item is { value: string; label: string; count: number; content: ReactNode } => Boolean(item)) + + if (tabs.length === 0) { + return null + } + + if (tabs.length === 1) { + return ( + + {tabs[0].content} + + ) + } + + return ( +
+ +
+ + {tabs.map((tab) => ( + + {tab.label} + {tab.count} + + ))} + +
+ {tabs.map((tab) => ( + + {tab.content} + + ))} +
+
+ ) +} + function InspectorSection({ title, meta, diff --git a/web/app/dashboard/ai-workflows/_components/workflow-config-sidebar.tsx b/web/app/dashboard/ai-workflows/_components/workflow-config-sidebar.tsx index e94903a..8eaec95 100644 --- a/web/app/dashboard/ai-workflows/_components/workflow-config-sidebar.tsx +++ b/web/app/dashboard/ai-workflows/_components/workflow-config-sidebar.tsx @@ -115,7 +115,7 @@ export function WorkflowConfigPanel({
-
+