Skip to content

Commit 5e5fa60

Browse files
committed
Revert "feat(agentflow): update flow date change & save handlings and enhance examples"
This reverts commit 021cd20.
1 parent 021cd20 commit 5e5fa60

12 files changed

Lines changed: 83 additions & 726 deletions

File tree

packages/agentflow/TESTS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ These modules carry the highest risk. Test in the same PR when modifying.
3636
| `src/infrastructure/api/nodes.ts` | `getAllNodes`, `getNodeByName`, `getNodeIconUrl` | ✅ Done |
3737
| `src/infrastructure/store/AgentflowContext.tsx` | `agentflowReducer` (all actions), `normalizeNodes`. Remaining: `deleteNode()`, `duplicateNode()`, `updateNodeData()`, `getFlowData()` | 🟡 Partial |
3838
| `src/useAgentflow.ts` | `getFlow()`, `toJSON()`, `validate()`, `addNode()`, `clear()` | ⬜ Not yet — thin wrapper |
39-
| `src/features/canvas/hooks/useFlowHandlers.ts` | `handleConnect`, `handleNodesChange`, `handleEdgesChange`, `handleAddNode` — synchronous `onFlowChange` callbacks, dirty tracking, viewport resolution, change filtering | ✅ Done |
39+
| `src/features/canvas/hooks/useFlowHandlers.ts` | `onConnect`, `onNodesChange`, `onEdgesChange`, `onAddNode` | ⬜ Not yet — coupled to ReactFlow |
4040

4141
### Tier 2 — Feature Hooks & Dialogs
4242

@@ -70,7 +70,7 @@ Mostly JSX with minimal logic. Only add tests if business logic is introduced.
7070
| `src/atoms/NodeInputHandler.tsx` | If input rendering or position calculation logic changes | ⬜ Not yet |
7171
| `src/features/canvas/components/ConnectionLine.tsx` | If edge label determination logic becomes more complex | ⬜ Not yet |
7272
| `src/features/canvas/components/NodeStatusIndicator.tsx` | If status-to-color/icon mapping expands | ⬜ Not yet |
73-
| `src/Agentflow.tsx` | Integration test — dark mode, ThemeProvider, CSS variables, header rendering, keyboard shortcuts (Cmd+S / Ctrl+S save), generate flow dialog, imperative ref | ✅ Done |
73+
| `src/Agentflow.tsx` | Integration test — dark mode, ThemeProvider, CSS variables, header rendering, generate flow dialog, imperative ref | ✅ Done |
7474

7575
Files that are pure styling or data constants (`styled.ts`, `nodeIcons.ts`, `MainCard.tsx`, `Input.tsx`, etc.) do not need dedicated tests.
7676

@@ -127,7 +127,6 @@ Key features:
127127
- **Coverage thresholds**: uniform 80% floor (`branches`, `functions`, `lines`, `statements`) enforced per-path:
128128
- `./src/Agentflow.tsx`
129129
- `./src/core/`
130-
- `./src/features/canvas/hooks/useFlowHandlers.ts`
131130
- `./src/features/node-palette/search.ts`
132131
- `./src/infrastructure/api/`
133132
- **Coverage exclusions**:

packages/agentflow/examples/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function LoadingFallback() {
100100

101101
export default function App() {
102102
const [selectedExample, setSelectedExample] = useState<ExampleId>('basic')
103-
const [showProps, setShowProps] = useState(false)
103+
const [showProps, setShowProps] = useState(true)
104104
// Config loaded from environment variables
105105

106106
const currentExample = examples.find((e) => e.id === selectedExample)

packages/agentflow/examples/src/FlowStatePanel.tsx

Lines changed: 0 additions & 192 deletions
This file was deleted.

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

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
/**
22
* Basic Example
33
*
4-
* Demonstrates basic @flowiseai/agentflow usage with imperative methods,
5-
* onFlowChange tracking, and save flow functionality.
4+
* Demonstrates basic @flowiseai/agentflow usage with imperative methods.
65
*/
76

8-
import { useCallback, useRef, useState } from 'react'
7+
import { useRef, useState } from 'react'
98

109
import type { AgentFlowInstance, FlowData, ValidationResult } from '@flowiseai/agentflow'
1110
import { Agentflow } from '@flowiseai/agentflow'
1211

1312
import { apiBaseUrl, token } from '../config'
14-
import { FlowStatePanel } from '../FlowStatePanel'
1513

1614
// Example flow data
1715
const initialFlow: FlowData = {
@@ -35,22 +33,18 @@ const initialFlow: FlowData = {
3533
}
3634

3735
export function BasicExample() {
36+
// Config loaded from environment variables
3837
const agentflowRef = useRef<AgentFlowInstance>(null)
3938
const [validationResult, setValidationResult] = useState<ValidationResult | null>(null)
40-
const [currentFlow, setCurrentFlow] = useState<FlowData | null>(null)
41-
const [savedFlow, setSavedFlow] = useState<FlowData | null>(null)
42-
const [changeCount, setChangeCount] = useState(0)
4339

44-
const handleFlowChange = useCallback((flow: FlowData) => {
45-
setCurrentFlow(flow)
46-
setChangeCount((c) => c + 1)
47-
console.log('onFlowChange:', flow)
48-
}, [])
40+
const handleFlowChange = (flow: FlowData) => {
41+
console.log('Flow changed:', flow)
42+
}
4943

50-
const handleSave = useCallback((flow: FlowData) => {
51-
setSavedFlow(flow)
52-
console.log('onSave:', flow)
53-
}, [])
44+
const handleSave = (flow: FlowData) => {
45+
console.log('Flow saved:', flow)
46+
alert('Flow saved! Check console for data.')
47+
}
5448

5549
const handleValidate = () => {
5650
if (agentflowRef.current) {
@@ -104,20 +98,17 @@ export function BasicExample() {
10498
)}
10599
</div>
106100

107-
{/* Canvas + Flow State Panel */}
108-
<div style={{ flex: 1, display: 'flex', minHeight: 0 }}>
109-
<div style={{ flex: 1 }}>
110-
<Agentflow
111-
ref={agentflowRef}
112-
apiBaseUrl={apiBaseUrl}
113-
token={token ?? undefined}
114-
initialFlow={initialFlow}
115-
onFlowChange={handleFlowChange}
116-
onSave={handleSave}
117-
showDefaultHeader={true}
118-
/>
119-
</div>
120-
<FlowStatePanel currentFlow={currentFlow} savedFlow={savedFlow} changeCount={changeCount} />
101+
{/* Canvas */}
102+
<div style={{ flex: 1 }}>
103+
<Agentflow
104+
ref={agentflowRef}
105+
apiBaseUrl={apiBaseUrl}
106+
token={token ?? undefined}
107+
initialFlow={initialFlow}
108+
onFlowChange={handleFlowChange}
109+
onSave={handleSave}
110+
showDefaultHeader={true}
111+
/>
121112
</div>
122113
</div>
123114
)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ export function CustomUIExample() {
260260
apiBaseUrl={apiBaseUrl}
261261
token={token ?? undefined}
262262
initialFlow={initialFlow}
263-
renderHeader={(props: HeaderRenderProps) => <CustomHeader {...props} />}
264-
renderNodePalette={(props: PaletteRenderProps) => <CustomPalette {...props} />}
263+
renderHeader={(props) => <CustomHeader {...props} />}
264+
renderNodePalette={(props) => <CustomPalette {...props} />}
265265
showDefaultHeader={false}
266266
showDefaultPalette={false}
267-
onSave={(flow: FlowData) => {
267+
onSave={(flow) => {
268268
console.log('Saving flow:', flow)
269269
alert('Flow saved! Check console.')
270270
}}

packages/agentflow/jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ module.exports = {
3838
coverageThreshold: {
3939
'./src/Agentflow.tsx': { branches: 80, functions: 80, lines: 80, statements: 80 },
4040
'./src/core/': { branches: 80, functions: 80, lines: 80, statements: 80 },
41-
'./src/features/canvas/hooks/useFlowHandlers.ts': { branches: 80, functions: 80, lines: 80, statements: 80 },
4241
'./src/features/node-palette/search.ts': { branches: 80, functions: 80, lines: 80, statements: 80 },
4342
'./src/infrastructure/api/': { branches: 80, functions: 80, lines: 80, statements: 80 }
4443
},

packages/agentflow/src/Agentflow.test.tsx

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -305,65 +305,6 @@ describe('Agentflow Component', () => {
305305
})
306306
})
307307

308-
describe('Keyboard Shortcuts', () => {
309-
it('should trigger save on Cmd+S', async () => {
310-
const onSave = jest.fn()
311-
const { container } = render(<Agentflow {...defaultProps} onSave={onSave} />)
312-
313-
await waitFor(() => {
314-
expect(container.querySelector('.agentflow-container')).toBeInTheDocument()
315-
})
316-
317-
fireEvent.keyDown(document, { key: 's', metaKey: true })
318-
319-
expect(onSave).toHaveBeenCalledTimes(1)
320-
expect(onSave).toHaveBeenCalledWith(
321-
expect.objectContaining({
322-
nodes: expect.any(Array),
323-
edges: expect.any(Array)
324-
})
325-
)
326-
})
327-
328-
it('should trigger save on Ctrl+S', async () => {
329-
const onSave = jest.fn()
330-
const { container } = render(<Agentflow {...defaultProps} onSave={onSave} />)
331-
332-
await waitFor(() => {
333-
expect(container.querySelector('.agentflow-container')).toBeInTheDocument()
334-
})
335-
336-
fireEvent.keyDown(document, { key: 's', ctrlKey: true })
337-
338-
expect(onSave).toHaveBeenCalledTimes(1)
339-
})
340-
341-
it('should not trigger save on plain S key', async () => {
342-
const onSave = jest.fn()
343-
const { container } = render(<Agentflow {...defaultProps} onSave={onSave} />)
344-
345-
await waitFor(() => {
346-
expect(container.querySelector('.agentflow-container')).toBeInTheDocument()
347-
})
348-
349-
fireEvent.keyDown(document, { key: 's' })
350-
351-
expect(onSave).not.toHaveBeenCalled()
352-
})
353-
354-
it('should not error on Cmd+S when no onSave callback is provided', async () => {
355-
const { container } = render(<Agentflow {...defaultProps} />)
356-
357-
await waitFor(() => {
358-
expect(container.querySelector('.agentflow-container')).toBeInTheDocument()
359-
})
360-
361-
expect(() => {
362-
fireEvent.keyDown(document, { key: 's', metaKey: true })
363-
}).not.toThrow()
364-
})
365-
})
366-
367308
describe('Generate Flow', () => {
368309
it('should open generate dialog when button is clicked', async () => {
369310
const { container, getByTestId } = render(<Agentflow {...defaultProps} />)

0 commit comments

Comments
 (0)