Files
dify/web/__tests__
crazywoola a1cc7c555e feat: cmd+k /create workflow generator (slim planner-builder)
Restart the natural-language Workflow generator from main with a Prompt-
Generator-shaped UX: cmd+k → /create → pick workflow/chatflow → describe
the task → preview the generated graph → Apply to a new app or overwrite
the current Studio draft.

Backend (slim planner→builder pipeline, ~600 LOC vs. the previous 13.5k):

- core/workflow/generator/: WorkflowGenerator runs PLANNER (high-level
  node plan) then BUILDER (full graph JSON via structured output), with a
  postprocess pass that fills safe defaults, lays nodes out left-to-right
  and runs a final structural sanity check (start/end shape, edge node
  references). Mermaid rendering, graph_builder, validation engine and
  node/edge repair are deferred — re-add when quality demands it.
- services/workflow_generator_service.py: facade owning the ModelManager
  dependency so core.workflow.generator stays pure domain code.
- controllers/console/app/generator.py: new POST /workflow-generate
  endpoint, error envelope identical to /rule-generate so the frontend
  reuses its existing handler.

Frontend (reuses WorkflowPreview verbatim and the Prompt-Generator pattern):

- components/workflow/workflow-generator/: two-pane modal (1140×680),
  zustand store for global open/close, lazy mount via @/next/dynamic,
  sessionStorage version history mirroring use-gen-data, apply.ts wiring
  both "Create new app" (createApp + syncWorkflowDraft + redirect) and
  "Apply to current draft" (syncWorkflowDraft with overwrite confirmation).
- components/goto-anything/actions/commands/create.tsx: submenu slash
  command surfacing Workflow + Chatflow, dispatching create.open through
  the existing command bus.
- (commonLayout)/layout.tsx: mount WorkflowGeneratorMount alongside
  GotoAnything so cmd+k works from anywhere in the app.
- service/debug.ts: typed generateWorkflow() helper.
- i18n/{en-US,zh-Hans}/workflow.json: 19 new workflowGenerator.* keys.

Tests:

- 7 backend unit tests cover happy path for both modes plus planner JSON
  failure, builder exception, structural validation, edge integrity.
- 9 frontend tests cover /create command surface + filtering, and the
  sessionStorage version history hook.

All checks green: pyrefly + mypy, ruff, pnpm tsgo, vitest (86 passing
including the existing 82 goto-anything regression tests).

Closes #29774

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 15:26:25 +08:00
..
2026-05-27 11:58:13 +00:00