Skip to content

Commit 5ae1b42

Browse files
committed
Test changes
1 parent 88e7510 commit 5ae1b42

12 files changed

Lines changed: 61 additions & 38 deletions

File tree

packages/agentflow/examples/src/demos/CustomNodeExample.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Custom Node Example
33
*
44
* Demonstrates how a node can carry its own InputParam[] definitions
5-
* in data.inputs, bypassing the API schema. The node includes show/hide
5+
* in data.inputParams, bypassing the API schema. The node includes show/hide
66
* conditions so double-clicking it opens the real EditNodeDialog with
77
* conditional field visibility.
88
*
@@ -170,7 +170,7 @@ const customNodeInputParams: InputParam[] = [
170170

171171
// ── Canvas flow data with a custom node carrying its own input definitions ─
172172

173-
const initialInputValues: Record<string, unknown> = { provider: '', enableMemory: false, outputFormat: 'text' }
173+
const initialInputs: Record<string, unknown> = { provider: '', enableMemory: false, outputFormat: 'text' }
174174

175175
const canvasFlow: FlowData = {
176176
nodes: [
@@ -183,8 +183,8 @@ const canvasFlow: FlowData = {
183183
name: 'customNodeDemo',
184184
label: 'Custom Node',
185185
color: '#64B5F6',
186-
inputs: customNodeInputParams,
187-
inputValues: initialInputValues,
186+
inputParams: customNodeInputParams,
187+
inputs: initialInputs,
188188
outputAnchors: [{ id: 'customNode_0-output-0', name: 'output', label: 'Output', type: 'string' }]
189189
}
190190
}
@@ -277,12 +277,12 @@ function VisibilityStatePanel({ inputValues }: { inputValues: Record<string, unk
277277
// ── Component ──────────────────────────────────────────────────────────────
278278

279279
export function CustomNodeExample() {
280-
const [inputValues, setInputValues] = useState<Record<string, unknown>>(initialInputValues)
280+
const [inputValues, setInputValues] = useState<Record<string, unknown>>(initialInputs)
281281

282282
const handleFlowChange = useCallback((flow: FlowData) => {
283283
const node = flow.nodes.find((n) => n.id === 'customNode_0')
284-
if (node?.data?.inputValues) {
285-
setInputValues(node.data.inputValues)
284+
if (node?.data?.inputs) {
285+
setInputValues(node.data.inputs)
286286
}
287287
}, [])
288288

@@ -322,7 +322,7 @@ export function CustomNodeExample() {
322322
export const CustomNodeExampleProps = {
323323
apiBaseUrl: '{from environment variables}',
324324
token: '{from environment variables}',
325-
initialFlow: 'FlowData (custom node with data.inputs)',
325+
initialFlow: 'FlowData (custom node with data.inputParams + data.inputs)',
326326
onFlowChange: '(flow: FlowData) => void',
327327
renderHeader: '(props: HeaderRenderProps) => ReactNode'
328328
}

packages/agentflow/examples/src/demos/DarkModeExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const sampleFlow: FlowData = {
3939
label: 'AI Assistant',
4040
color: '#4DD0E1',
4141
outputAnchors: [{ id: 'agentAgentflow_0-output-0', name: 'output', label: 'Output', type: 'string' }],
42-
inputValues: {
42+
inputs: {
4343
agentModel: 'chatAnthropic',
4444
agentModelConfig: {
4545
modelName: 'claude-3-5-sonnet'

packages/agentflow/examples/src/demos/MultiNodeFlow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const translationFlow: FlowData = {
3838
label: 'Translator',
3939
color: '#64B5F6',
4040
outputAnchors: [{ id: 'llmAgentflow_0-output-0', name: 'output', label: 'Output', type: 'string' }],
41-
inputValues: {
41+
inputs: {
4242
llmModel: 'chatGoogleGenerativeAI',
4343
llmModelConfig: {
4444
modelName: 'gemini-2.0-flash'

packages/agentflow/src/atoms/ConditionBuilder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function ConditionBuilder({
8888
{arrayItems.map((itemValues, index) => {
8989
const itemData: NodeData = {
9090
...data,
91-
inputValues: itemValues
91+
inputs: itemValues
9292
}
9393

9494
return (

packages/agentflow/src/atoms/RichTextEditor.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useEffect, useMemo, useRef } from 'react'
22

33
import { Box } from '@mui/material'
44
import { styled } from '@mui/material/styles'
5+
import type { CodeBlockLowlightOptions } from '@tiptap/extension-code-block-lowlight'
56
import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight'
67
import Placeholder from '@tiptap/extension-placeholder'
78
import { EditorContent, useEditor } from '@tiptap/react'
@@ -40,9 +41,28 @@ export interface RichTextEditorProps {
4041
// Use .extend() to set enableTabIndentation/tabSize because the v2 types from
4142
// @tiptap/extension-code-block (peer dep) don't include these v3-only options.
4243
// See: https://github.com/ueberdosis/tiptap/issues/7613
44+
const codeBlockLowlightFallback: CodeBlockLowlightOptions = {
45+
lowlight,
46+
languageClassPrefix: 'language-',
47+
exitOnTripleEnter: true,
48+
exitOnArrowDown: true,
49+
defaultLanguage: null,
50+
enableTabIndentation: false,
51+
tabSize: 4,
52+
HTMLAttributes: {}
53+
}
54+
4355
const CustomCodeBlock = CodeBlockLowlight.extend({
44-
addOptions() {
45-
return { ...this.parent?.(), lowlight, enableTabIndentation: true, tabSize: 2 }
56+
addOptions(): CodeBlockLowlightOptions {
57+
const inherited = this.parent?.()
58+
return {
59+
...codeBlockLowlightFallback,
60+
...inherited,
61+
lowlight,
62+
languageClassPrefix: 'language-',
63+
enableTabIndentation: true,
64+
tabSize: 2
65+
}
4666
}
4767
})
4868

@@ -168,7 +188,7 @@ export function RichTextEditor({ value, onChange, placeholder, disabled = false,
168188
// Sync external value changes into the editor (e.g. when parent state updates)
169189
useEffect(() => {
170190
if (editor && value !== editor.getHTML()) {
171-
editor.commands.setContent(value, false)
191+
editor.commands.setContent(value, { emitUpdate: false })
172192
}
173193
}, [editor, value])
174194

packages/agentflow/src/atoms/ScenariosInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function ScenariosInput({ inputParam, data, disabled = false, onDataChang
8787
{arrayItems.map((itemValues, index) => {
8888
const itemData: NodeData = {
8989
...data,
90-
inputValues: itemValues
90+
inputs: itemValues
9191
}
9292

9393
return (

packages/agentflow/src/core/node-catalog/nodeFilters.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { DEFAULT_AGENTFLOW_NODES } from '../node-config'
2-
import type { NodeData } from '../types'
32

43
/**
54
* Filter nodes based on allowed components list
65
* @param allNodes - All available nodes from API
76
* @param allowedComponents - Array of allowed node names (optional)
87
* @returns Filtered array of nodes
98
*/
10-
export function filterNodesByComponents(allNodes: NodeData[], allowedComponents?: string[]): NodeData[] {
9+
export function filterNodesByComponents<T extends { name: string }>(allNodes: T[], allowedComponents?: string[]): T[] {
1110
// If no filter specified, return all agentflow nodes
1211
if (!allowedComponents || allowedComponents.length === 0) {
1312
return allNodes.filter((node) => DEFAULT_AGENTFLOW_NODES.includes(node.name))
@@ -28,15 +27,15 @@ export function isAgentflowNode(nodeName: string): boolean {
2827
}
2928

3029
/**
31-
* Group nodes by category
30+
* Group nodes by category (palette API entries or any node-like object with `category`).
3231
*/
33-
export function groupNodesByCategory(nodes: NodeData[]): Record<string, NodeData[]> {
32+
export function groupNodesByCategory<T extends { category?: string }>(nodes: T[]): Record<string, T[]> {
3433
return nodes.reduce((acc, node) => {
3534
const category = node.category || 'Other'
3635
if (!acc[category]) {
3736
acc[category] = []
3837
}
3938
acc[category].push(node)
4039
return acc
41-
}, {} as Record<string, NodeData[]>)
40+
}, {} as Record<string, T[]>)
4241
}

packages/agentflow/src/features/canvas/containers/StickyNote.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ function StickyNoteComponent({ data }: StickyNoteProps) {
5757
multiline
5858
rows={3}
5959
placeholder={inputParam?.placeholder || 'Add a note...'}
60-
value={data.inputValues?.[inputParam?.name || 'note'] ?? inputParam?.default ?? ''}
60+
value={
61+
(data.inputs?.[inputParam?.name || 'note'] as string | undefined) ??
62+
(inputParam?.default as string | undefined) ??
63+
''
64+
}
6165
onChange={(e) => {
6266
if (inputParam) {
63-
const updatedInputValues = {
64-
...data.inputValues,
67+
const nextInputs = {
68+
...(data.inputs ?? {}),
6569
[inputParam.name]: e.target.value
6670
}
67-
updateNodeData(data.id, { inputValues: updatedInputValues })
71+
updateNodeData(data.id, { inputs: nextInputs })
6872
}
6973
}}
7074
sx={{

packages/agentflow/src/features/node-editor/ConfigInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface ConfigInputProps {
2020
arrayIndex?: number | null // For array-based configs: the index of the array item.
2121
parentArrayParam?: InputParam | null // For array-based configs: the parent array param definition.
2222
onConfigChange: (
23-
// Callback to persist config values to the parent node's inputValues.
23+
// Callback to persist config values to the parent node's `data.inputs` map.
2424
configKey: string,
2525
configValues: Record<string, unknown>,
2626
arrayContext?: { parentParamName: string; arrayIndex: number }

packages/agentflow/src/features/node-palette/AddNodesDrawer.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { IconMinus, IconPlus, IconSearch, IconX } from '@tabler/icons-react'
2222

2323
import { MainCard } from '@/atoms'
2424
import { tokens } from '@/core/theme/tokens'
25-
import type { ApiNodeData, NodeData } from '@/core/types'
25+
import type { ApiNodeData } from '@/core/types'
2626
import { useApiContext } from '@/infrastructure/store'
2727

2828
import { NodeListItem } from './NodeListItem'
@@ -36,9 +36,9 @@ export interface AddNodesDrawerProps {
3636
/** Available nodes to display */
3737
nodes: ApiNodeData[]
3838
/** Callback when a node drag starts */
39-
onDragStart?: (event: React.DragEvent, node: NodeData) => void
39+
onDragStart?: (event: React.DragEvent, node: ApiNodeData) => void
4040
/** Callback when a node is clicked (alternative to drag) */
41-
onNodeClick?: (node: NodeData) => void
41+
onNodeClick?: (node: ApiNodeData) => void
4242
}
4343

4444
/**
@@ -49,7 +49,7 @@ function AddNodesDrawerComponent({ nodes, onDragStart, onNodeClick }: AddNodesDr
4949
const { apiBaseUrl } = useApiContext()
5050

5151
const [searchValue, setSearchValue] = useState('')
52-
const [filteredNodes, setFilteredNodes] = useState<Record<string, NodeData[]>>({})
52+
const [filteredNodes, setFilteredNodes] = useState<Record<string, ApiNodeData[]>>({})
5353
const [open, setOpen] = useState(false)
5454
const [categoryExpanded, setCategoryExpanded] = useState<Record<string, boolean>>({})
5555

@@ -59,7 +59,7 @@ function AddNodesDrawerComponent({ nodes, onDragStart, onNodeClick }: AddNodesDr
5959
const drawerMaxHeight = useDrawerMaxHeight(open, paperRef)
6060

6161
// Group nodes by category
62-
const groupNodes = useCallback((nodeList: NodeData[], expandAll = false) => {
62+
const groupNodes = useCallback((nodeList: ApiNodeData[], expandAll = false) => {
6363
const grouped = groupNodesByCategory(nodeList)
6464
setFilteredNodes(grouped)
6565

@@ -118,11 +118,11 @@ function AddNodesDrawerComponent({ nodes, onDragStart, onNodeClick }: AddNodesDr
118118
}))
119119
}
120120

121-
const handleDragStart = (event: React.DragEvent, node: NodeData) => {
121+
const handleDragStart = (event: React.DragEvent, node: ApiNodeData) => {
122122
onDragStart?.(event, node)
123123
}
124124

125-
const handleNodeClick = (node: NodeData) => {
125+
const handleNodeClick = (node: ApiNodeData) => {
126126
onNodeClick?.(node)
127127
}
128128

0 commit comments

Comments
 (0)