Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 23, 2025

✅ Build Error Fixed

Latest Changes (Import Fix)

Fixed Build Error

  • Error: No matching export in "src/pages/scenario/flowgram/nodes/constants.ts" for import "NODE_TYPES"
  • Root Cause: Incorrect import name - trying to import NODE_TYPES when the actual export is WorkflowNodeType
  • Fix: Changed import statement in DemoTools.tsx to use correct export name

Changes in This Commit

// BEFORE (incorrect)
import { NODE_TYPES } from '../../nodes/constants';

// AFTER (correct)
import { WorkflowNodeType } from '../../nodes/constants';

The constants file exports WorkflowNodeType enum:

export enum WorkflowNodeType {
  START = 'start',
  END = 'end',
  HTTP = 'http',
  SCRIPT = 'script',
  CONDITION = 'condition',
  DELAY = 'delay',
  LOOP = 'loop',
}

Previous Changes (Flowgram Pattern Compliance)

All 6 feedback points addressed:

1. Fixed Zoom API Usage

  • Reading: playgroundTools.zoom
  • Writing: playgroundTools.config.updateZoom(value)

2. Node Addition with useAddNode Hook

  • Created hooks/use-add-node.ts following Flowgram pattern
  • Uses nodePanelService for proper node creation

3. Minimap in DemoTools

  • Created components/minimap.tsx
  • Integrated into toolbar
  • Removed createMinimapPlugin from useEditorProps

4. Fixed createHistoryNodePlugin

  • Now accepts opts parameter: createHistoryNodePlugin({})

5. Custom Panel Manager Plugin

  • Updated with custom tools factory

6. NodePanel Component

  • Created components/node-panel/index.tsx
  • Used in createFreeNodePanelPlugin({ renderer: NodePanel })

Status

✅ Build Error Resolved - The import error is fixed. All components follow official Flowgram.ai patterns. Build should now succeed.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add Scenario Mode: Complete visual workflow automation system with flowgram.ai</issue_title>
<issue_description>### Clear and concise description of the problem

🎨 工作流编辑,工作流的操作和数据编辑都在画布内

1. 独立的工作流编辑器模态框

  • 创建新的 WorkflowEditorModal 组件,与场景创建/编辑完全解耦
  • 场景列表页面新增"编辑工作流"按钮
  • 创建/编辑场景时,工作流编辑在单独的全屏模态框中进行

2. Flowgram 风格的布局 (参考官方 Demo)

左侧画布区域:

  • 展示工作流的小节点卡片
  • 节点以紧凑的卡片形式显示
  • 显示节点图标、标签和类型
  • 支持点击选中节点

右侧编辑面板:

  • 点击节点后,右侧显示详细的编辑表单
  • 表单包含节点的所有配置选项
  • 动态表单根据节点类型变化
  • 固定宽度 400px,高度自适应

底部工具栏: (参考官方 Demo)

  • 快速添加各类节点按钮
  • 验证工作流按钮
  • 保存和关闭按钮

3. 数据流改进

场景列表页
  ↓
点击"新建场景" → 打开场景信息表单 (名称、描述等)
  ↓
点击"编辑工作流" → 打开独立的工作流编辑器
  ↓
在画布中添加和配置节点
  ↓
点击节点 → 右侧显示详细配置面板
  ↓
保存 → 更新场景的 workflowGraph
  ↓
提交场景 → 调用后端 API

🎨 UI 设计 (UI Design)

画布区域 (左侧):

┌─────────────────────────────┐
│  [工具栏: 添加节点按钮...]   │
├─────────────────────────────┤
│                             │
│   ┌──────┐  ┌──────┐       │
│   │ 节点1 │  │ 节点2 │       │
│   └──────┘  └──────┘       │
│                             │
│   ┌──────┐                 │
│   │ 节点3 │                 │
│   └──────┘                 │
│                             │
└─────────────────────────────┘

编辑面板 (右侧):

┌──────────────────┐
│   节点配置        │
├──────────────────┤
│                  │
│  [标签]          │
│  [类型选择]      │
│  [参数1]         │
│  [参数2]         │
│  ...            │
│                  │
│  [保存] [删除]   │
│                  │
└──────────────────┘

🔧 技术细节 (Technical Details)

新的布局结构:

  • 使用 flex 布局:左侧自适应,右侧固定 400px
  • 左侧最小宽度: 600px
  • 右侧固定宽度: 400px
  • 全屏模态框: width: 95vw, height: 90vh

状态管理:

  • selectedNodeId: 当前选中的节点 ID
  • localGraph: 本地工作流图状态
  • 编辑后通过 onOk 回调返回更新的图

📝 用户体验改进 (UX Improvements)

之后:

  • ✅ 独立的全屏工作流编辑器
  • ✅ 左侧画布清晰展示所有节点
  • ✅ 右侧专注于节点编辑
  • ✅ 更符合 Flowgram 官方 Demo 的设计理念
  • ✅ 更好的视觉层次和信息组织

🎯 参考设计 (Reference Design)

基于 Flowgram 官方 Demo: https://github.com/bytedance/flowgram.ai/tree/main/apps/demo-free-layout

实现了类似的:

  • 左右分栏布局
  • 小节点卡片展示
  • 右侧详细编辑面板
  • 清晰的视觉层次
Original prompt

This section details on the original issue you should resolve

动态执行脚本(如变量监听、API响应触发、脚本错误回调等),建议新增「场景模式」功能,将面板升级自动化运维中枢。

Suggested solution

增加多样化触发器
变量监听:支持环境变量/配置文件变更监听
Webhook触发器:开放API端点接收外部触发
任务状态触发器:基于其他任务的成功/失败状态触发
时间触发器:增强现有cron表达式,支持秒级精度
系统事件:磁盘空间/内存占用等硬件指标触发

动态响应机制
多条件嵌套:支持AND/OR逻辑的条件组合
延时执行:设置触发后的延迟执行时间
失败熔断:连续失败N次后自动禁用任务
自适应重试:根据错误类型配置重试策略

Alternative

No response

Additional context

No response

Validations

  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.</issue_description>

Comments on the Issue (you are @copilot in this section)

Suggested solution

🎨 工作流编辑,工作流的操作和数据编辑都在画布内

1. 独立的工作流编辑器模态框

  • 创建新的 WorkflowEditorModal 组件,与场景创建/编辑完全解耦
  • 场景列表页面新增"编辑工作流"按钮
  • 创建/编辑场景时,工作流编辑在单独的全屏模态框中进行

2. Flowgram 风格的布局 (参考官方 Demo)

左侧画布区域:

  • 展示工作流的小节点卡片
  • 节点以紧凑的卡片形式显示
  • 显示节点图标、标签和类型
  • 支持点击选中节点

右侧编辑面板:

  • 点击节点后,右侧显示详细的编辑表单
  • 表单包含节点的所有配置选项
  • 动态表单根据节点类型变化
  • 固定宽度 400px,高度自适应

底部工具栏: (参考官方 Demo)

  • 快速添加各类节点按钮
  • 验证工作流按钮
  • 保存和关闭按钮

3. 数据流改进

场景列表页
  ↓
点击"新建场景" → 打开场景信息表单 (名称、描述等)
  ↓
点击"编辑工作流" → 打开独立的工作流编辑器
  ↓
在画布中添加和配置节点
  ↓
点击节点 → 右侧显示详细配置面板
  ↓
保存 → 更新场景的 workflowGraph
  ↓
提交场景 → 调用后端 API

🎨 UI 设计 (UI Design)

画布区域 (左侧):

┌─────────────────────────────┐
│  [工具栏: 添加节点按钮...]   │
├─────────────────────────────┤
│                             │
│   ┌──────┐  ┌──────┐       │
│   │ 节点1 │  │ 节点2 │       │
│   └──────┘  └──────┘       │
│                             │
│   ┌──────┐                 │
│   │ 节点3 │                 │
│   └──────┘                 │
│                             │
└─────────────────────────────┘

编辑面板 (右侧):

┌──────────────────┐
│   节点配置        │
├──────────────────┤
│                  │
│  [标签]          │
│  [类型选择]      │
│  [参数1]         │
│  [参数2]         │
│  ...            │
│                  │
│  [保存] [删除]   │
│                  │
└──────────────────┘

🔧 技术细节 (Technical Details)

新的布局结构:

  • 使用 flex 布局:左侧自适应,右侧固定 400px
  • 左侧最小宽度: 600px
  • 右侧固定宽度: 400px
  • 全屏模态框: width: 95vw, height: 90vh

状态管理:

  • selectedNodeId: 当前选中的节点 ID
  • localGraph: 本地工作流图状态
  • 编辑后通过 onOk 回调返回更新的图

📝 用户体验改进 (UX Improvements)

之后:

  • ✅ 独立的全屏工作流编辑器
  • ✅ 左侧画布清晰展示所有节点
  • ✅ 右侧专注于节点编辑
  • ✅ 更符合 Flowgram 官方 Demo 的设计理念
  • ✅ 更好的视觉层次和信息组织

🎯 参考设计 (Reference Design)

基于 Flowgram 官方 Demo: https://github.com/bytedance/flowgram.ai/tree/main/apps/demo-free-layout

实现了类似的:

  • 左右分栏布局
  • 小节点卡片展示
  • 右侧详细编辑面板
  • 清晰的视觉层次
Original prompt

This section details on the original issue you should resolve

动态执行脚本(如变量监听、API响应触发、脚本错误回调等),建议新增「场景模式」功能,将面板升级自动化运维中枢。

Suggested sol...

Custom agent used: Bug Fixer
Fix this issue following our error handling pattern.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 23, 2025
@vercel
Copy link

vercel bot commented Nov 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
qinglong Ready Ready Preview Comment Nov 23, 2025 5:53pm
qinglong-back Ready Ready Preview Comment Nov 23, 2025 5:53pm

Copilot AI changed the title [WIP] Add Scenario mode for visual workflow automation system Add Scenario Mode: Visual workflow automation with Flowgram.ai-inspired editor Nov 23, 2025
Copilot AI requested a review from whyour November 23, 2025 05:52
Copilot finished work on behalf of whyour November 23, 2025 05:52
@whyour
Copy link
Owner

whyour commented Nov 23, 2025

@copilot workflowEditorModal 使用 https://flowgram.ai/examples/free-layout/free-feature-overview.html#%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5 实现参考
https://github.com/bytedance/flowgram.ai/tree/main/apps/demo-free-layout

src/
├── app.tsx # 应用入口文件
├── editor.tsx # 编辑器主组件
├── initial-data.ts # 初始化数据配置
├── assets/ # 静态资源
├── components/ # 组件库
│ ├── index.ts
│ ├── add-node/ # 添加节点组件
│ ├── base-node/ # 基础节点组件
│ ├── comment/ # 注释组件
│ ├── group/ # 分组组件
│ ├── line-add-button/ # 连线添加按钮
│ ├── node-menu/ # 节点菜单
│ ├── node-panel/ # 节点添加面板
│ ├── selector-box-popover/ # 选择框弹窗
│ ├── sidebar/ # 侧边栏
│ ├── testrun/ # 测试运行组件
│ │ ├── hooks/ # 测试运行钩子
│ │ ├── node-status-bar/ # 节点状态栏
│ │ ├── testrun-button/ # 测试运行按钮
│ │ ├── testrun-form/ # 测试运行表单
│ │ ├── testrun-json-input/ # JSON输入组件
│ │ └── testrun-panel/ # 测试运行面板
│ └── tools/ # 工具组件
├── context/ # React Context
│ ├── node-render-context.ts # 当前渲染节点 Context
│ ├── sidebar-context # 侧边栏 Context
├── form-components/ # 表单组件库
│ ├── form-content/ # 表单内容
│ ├── form-header/ # 表单头部
│ ├── form-inputs/ # 表单输入
│ └── form-item/ # 表单项
│ └── feedback.tsx # 表单校验错误渲染
├── hooks/
│ ├── index.ts
│ ├── use-editor-props.tsx # 编辑器属性钩子
│ ├── use-is-sidebar.ts # 侧边栏状态钩子
│ ├── use-node-render-context.ts # 节点渲染上下文钩子
│ └── use-port-click.ts # 端口点击钩子
├── nodes/ # 节点定义
│ ├── index.ts
│ ├── constants.ts # 节点常量定义
│ ├── default-form-meta.ts # 默认表单元数据
│ ├── block-end/ # 块结束节点
│ ├── block-start/ # 块开始节点
│ ├── break/ # 中断节点
│ ├── code/ # 代码节点
│ ├── comment/ # 注释节点
│ ├── condition/ # 条件节点
│ ├── continue/ # 继续节点
│ ├── end/ # 结束节点
│ ├── group/ # 分组节点
│ ├── http/ # HTTP节点
│ ├── llm/ # LLM节点
│ ├── loop/ # 循环节点
│ ├── start/ # 开始节点
│ └── variable/ # 变量节点
├── plugins/ # 插件系统
│ ├── index.ts
│ ├── context-menu-plugin/ # 右键菜单插件
│ ├── runtime-plugin/ # 运行时插件
│ │ ├── client/ # 客户端
│ │ │ ├── browser-client/ # 浏览器客户端
│ │ │ └── server-client/ # 服务器客户端
│ │ └── runtime-service/ # 运行时服务
│ └── variable-panel-plugin/ # 变量面板插件
│ └── components/ # 变量面板组件
├── services/ # 服务层
│ ├── index.ts
│ └── custom-service.ts # 自定义服务
├── shortcuts/ # 快捷键系统
│ ├── index.ts
│ ├── constants.ts # 快捷键常量
│ ├── shortcuts.ts # 快捷键定义
│ ├── type.ts # 类型定义
│ ├── collapse/ # 折叠快捷键
│ ├── copy/ # 复制快捷键
│ ├── delete/ # 删除快捷键
│ ├── expand/ # 展开快捷键
│ ├── paste/ # 粘贴快捷键
│ ├── select-all/ # 全选快捷键
│ ├── zoom-in/ # 放大快捷键
│ └── zoom-out/ # 缩小快捷键
├── styles/ # 样式文件
├── typings/ # 类型定义
│ ├── index.ts
│ ├── json-schema.ts # JSON Schema类型
│ └── node.ts # 节点类型定义
└── utils/ # 工具函数
├── index.ts
└── on-drag-line-end.ts # 拖拽连线结束处理

Copy link
Contributor Author

Copilot AI commented Nov 23, 2025

@copilot workflowEditorModal 使用 https://flowgram.ai/examples/free-layout/free-feature-overview.html#%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5 实现参考
https://github.com/bytedance/flowgram.ai/tree...

I'll refactor the workflowEditorModal to use the official Flowgram.ai library (@flowgram.ai/free-layout-editor) following the demo-free-layout structure. This will provide a more robust and feature-rich workflow editor with proper node management, visual connections, and the plugin architecture.

Key changes:

  1. Install Flowgram.ai dependencies
  2. Restructure workflow editor to use Flowgram components
  3. Implement node registries following the demo pattern
  4. Add proper plugins (snap, lines, minimap, etc.)
  5. Integrate with existing scenario management

Starting implementation now...

- Installed @flowgram.ai packages (free-layout-editor and plugins)
- Created node registries following Flowgram pattern
- Implemented FlowgramEditor component with proper integration
- Simplified workflowEditorModal to use Flowgram
- Added necessary translations
- All builds succeed

Co-authored-by: whyour <[email protected]>
Copilot finished work on behalf of whyour November 23, 2025 06:08
@whyour
Copy link
Owner

whyour commented Nov 23, 2025

Following Flowgram demo structure:
- Created tools component directory with index, styles, zoom-select, add-node-dropdown
- Implemented FloatingTools positioned at bottom-left (like Flowgram demo)
- Added undo/redo buttons with history integration
- Added zoom selector dropdown (50%, 100%, 150%, 200%)
- Added fit-view button for canvas fitting
- Added Add Node dropdown with all node types
- Updated FlowgramEditor to use new tools component
- Removed old toolbar from editor
- Added 6 new translation keys (zh-CN + en-US)
- Following exact Flowgram UI patterns with styled-components

Co-authored-by: whyour <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 23, 2025

@copilot 参考 https://github.com/bytedance/flowgram.ai/tree/main/apps/demo-free-layout/src/components/tools 的工具写法
<img width="687" height="69" alt="image" src="https://github.com/user-att...

Implemented in commit 54e2468. The toolbar has been refactored to follow the Flowgram demo structure exactly:

New Structure:

  • Floating toolbar at bottom-left (like Flowgram demo)
  • Zoom dropdown with presets (50%, 100%, 150%, 200%)
  • Fit View button
  • Undo/Redo buttons with history integration
  • Add Node dropdown with all node types

The tools component is now located in src/pages/scenario/flowgram/components/tools/ and follows the same pattern as the Flowgram demo with:

  • Professional styled-components matching the demo's visual style
  • Proper integration with Flowgram's APIs (history, playground, viewport, nodeService)
  • Clean, minimal design with white background and shadow
  • All node creation happens at viewport center using Flowgram's API

This replaces the old custom toolbar and provides a more professional, Flowgram-native experience.

Created DemoTools plugin with comprehensive toolbar:
- Plugin structure following @flowgram.ai/panel-manager-plugin pattern
- Positioned at top-center matching Flowgram demo screenshot
- Integrated with Flowgram's history, playground, and viewport APIs
- Tools include: fit view, grid view, zoom controls, lock/unlock, comments
- Undo/Redo with real-time state management
- Add Node dropdown with all node types
- Test Run button (green)
- Added 13 new translation keys (zh-CN + en-US)
- Removed old bottom-left tools component
- Plugin automatically renders via layer system

Co-authored-by: whyour <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 23, 2025

@copilot 自定义 plugin 参考 https://github.com/bytedance/flowgram.ai/blob/main/apps/demo-free-layout/src/plugins/panel-manager-plugin/index.tsx 创建 DemoTools

Created custom DemoTools plugin in commit a1b21e8 following the Flowgram demo-free-layout pattern.

Implementation:

  • Plugin structure at src/pages/scenario/flowgram/plugins/tools-plugin/
  • Uses createPlugin() API with layer system (matching panel-manager-plugin pattern)
  • Comprehensive toolbar with all controls shown in screenshot:
    • Fit View, Grid View
    • Zoom display with dropdown (50%, 75%, 100%, 125%, 150%, 200%)
    • Zoom In/Out, Fit Canvas
    • Lock/Unlock, Comments
    • Undo/Redo (with history integration and state management)
    • Alerts
    • Add Node dropdown (blue button)
    • Test Run button (green)
  • Positioned at top-center
  • Integrated with Flowgram APIs: usePlaygroundTools, useHistoryService, useNodeService
  • Dark mode compatible
  • 13 new translation keys added

The plugin automatically renders via Flowgram's layer system when registered in the plugins array.

@whyour
Copy link
Owner

whyour commented Nov 23, 2025

@copilot

  1. playgroundTools 获取比例是 playgroundTools.zoom,修改缩放是 playgroundTools.config.updateZoom
  2. 添加 node 用的是 useAddNode 参考https://github.com/bytedance/flowgram.ai/blob/main/apps/demo-free-layout/src/components/add-node/use-add-node.ts
  3. minimap 也放到 tools 中,参考 https://github.com/bytedance/flowgram.ai/blob/main/apps/demo-free-layout/src/components/tools/minimap.tsx, 移除 useEditorProps 的 createMinimapPlugin
  4. Expected 1 arguments, but got 0.ts(2554) index.d.ts(2142, 32): An argument for 'opts' was not provided.
    (alias) createHistoryNodePlugin(opts: unknown): Plugin
    import createHistoryNodePlugin
  5. useEditorProps 中 createPanelManagerPlugin 创建的是自定义的 tools
  6. createFreeNodePanelPlugin({
    renderer: NodePanel,
    }), NodePanel 参考 https://github.com/bytedance/flowgram.ai/blob/main/apps/demo-free-layout/src/components/node-panel/index.tsx

@whyour
Copy link
Owner

whyour commented Nov 23, 2025

@copilot src/pages/scenario/flowgram/plugins/tools-plugin/DemoTools.tsx:24:9:
24 │ import { NODE_TYPES } from '../../nodes/constants';
╵ ~~~~~~~~~~
fatal - Error: Build failed with 1 error:
src/pages/scenario/flowgram/plugins/tools-plugin/DemoTools.tsx:24:9: ERROR: No matching export in "src/pages/scenario/flowgram/nodes/constants.ts" for import "NODE_TYPES"

Comprehensive fixes based on feedback:
1. Fixed zoom: use playgroundTools.zoom for reading, playgroundTools.config.updateZoom for setting
2. Created useAddNode hook following Flowgram pattern for proper node addition
3. Added Minimap component to DemoTools (removed from useEditorProps plugin)
4. Fixed createHistoryNodePlugin to accept opts parameter
5. Updated createPanelManagerPlugin to create custom tools panel
6. Created NodePanel component following Flowgram demo pattern
7. Updated createFreeNodePanelPlugin with renderer parameter
8. All components now follow official Flowgram.ai patterns exactly

Co-authored-by: whyour <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 23, 2025

@copilot

  1. playgroundTools 获取比例是 playgroundTools.zoom,修改缩放是 playgroundTools.config.updateZoom
  2. 添加 node 用的是 useAddNode 参考https://github.com/bytedance/flowgram....

All 6 feedback points addressed in commit eccda4d:

  1. ✅ Zoom API fixed: playgroundTools.zoom for reading, playgroundTools.config.updateZoom() for setting
  2. ✅ Created useAddNode hook following Flowgram pattern with nodePanelService
  3. ✅ Added Minimap component to DemoTools, removed createMinimapPlugin from useEditorProps
  4. ✅ Fixed createHistoryNodePlugin({}) to accept opts parameter
  5. ✅ Updated createPanelManagerPlugin with custom tools factory
  6. ✅ Created NodePanel component, updated createFreeNodePanelPlugin({ renderer: NodePanel })

All components now follow official Flowgram.ai patterns exactly.

Fixed build error:
- Changed import from NODE_TYPES to WorkflowNodeType (actual export name)
- Matches the enum exported from nodes/constants.ts
- Resolves "No matching export" build error

Co-authored-by: whyour <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 23, 2025

@copilot src/pages/scenario/flowgram/plugins/tools-plugin/DemoTools.tsx:24:9:
24 │ import { NODE_TYPES } from '../../nodes/constants';
╵ ~~~~~~~~~~
...

Fixed in commit d22803e. The build error was caused by importing NODE_TYPES when the actual export name is WorkflowNodeType. Updated the import statement to match the enum exported from nodes/constants.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Scenario Mode: Complete visual workflow automation system with flowgram.ai

2 participants