feat(workflow): add clear button to workflow test run panel

Features:
- Add refresh button to clear test run history (data, inputs, node highlights)
- Persist workflowRunningData when closing panel (from previous commit)

Code quality improvements:
- Refactor to declarative pattern: effectiveTab derived from state, not set in effects
- Replace && with ternary operators for conditional rendering (Vercel best practices)
- Fix created_by type: change from string to object to match backend API
- Remove `as any` type assertion, use proper type-safe access
- Title now declaratively shows status based on workflowRunningData presence

Files changed:
- use-workflow-interactions.ts: add handleClearWorkflowRunHistory hook
- workflow-preview.tsx: declarative tab state, clear button, type-safe props
- types.ts: fix created_by type definition
- test files: update mock data to match corrected types
This commit is contained in:
yyh
2026-01-28 22:48:27 +08:00
parent 2df4445aa7
commit f16516549e
6 changed files with 157 additions and 121 deletions

View File

@ -51,8 +51,19 @@ export const useWorkflowInteractions = () => {
}
}, [workflowStore, handleNodeCancelRunningStatus, handleEdgeCancelRunningStatus])
const handleClearWorkflowRunHistory = useCallback(() => {
workflowStore.setState({
workflowRunningData: undefined,
inputs: {},
files: [],
})
handleNodeCancelRunningStatus()
handleEdgeCancelRunningStatus()
}, [workflowStore, handleNodeCancelRunningStatus, handleEdgeCancelRunningStatus])
return {
handleCancelDebugAndPreviewPanel,
handleClearWorkflowRunHistory,
}
}