[PR #24822] Fix workflow card toggle logic and implement minimal state UI #30809

Closed
opened 2026-02-21 20:48:16 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/24822

State: closed
Merged: Yes


Summary

Fixed workflow app card toggle logic inconsistencies and implemented minimal state UI for better user experience during workflow initialization. This change addresses issues where cards were incorrectly disabled due to incomplete entry node detection and inconsistent state logic across components.

Changes Made

Core Logic Fixes:

  • Fixed entry node detection to use getWorkflowEntryNode() instead of only checking BlockEnum.Start, now properly detects all trigger types (TriggerSchedule, TriggerWebhook, TriggerPlugin)
  • Unified toggle disabled logic across WebApp, API, and MCP Service cards with consistent variable naming and conditions
  • Standardized logic order: hasInsufficientPermissions || appUnpublished || missingEntryNode

UI Improvements:

  • Implemented minimal card state (48px height) when workflow is unpublished or missing entry nodes
  • Added informative tooltip to WebApp card toggle with "Learn more" documentation link
  • Conditional rendering of card sections based on workflow state

Code Quality:

  • Unified variable naming across components: isWorkflowApp, appUnpublished, hasEntryNode, missingEntryNode, hasInsufficientPermissions
  • Consistent logic implementation between app-card.tsx and mcp-service-card.tsx
  • Added comprehensive unit tests covering all toggle logic scenarios

Technical Details

Before: Cards only checked for Start nodes, causing trigger-based workflows to appear disabled
After: Cards properly detect all entry node types using centralized getWorkflowEntryNode() function

Before: Inconsistent disable logic between WebApp/API cards and MCP cards
After: All cards use identical logic: permissions, publish state, and entry node presence

Before: Cards showed full UI even for uninitialized workflows
After: Progressive disclosure with minimal state until workflow is properly configured

Test Coverage

Added 11 unit tests covering:

  • Entry node detection for all trigger types
  • Published vs unpublished workflow states
  • Permission-based toggle logic (editor vs manager)
  • Combined condition handling
  • Non-workflow app behavior

All tests pass with no regressions detected in existing functionality.

Screenshots(Workflow initialized but empty)

Before After
image image

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/24822 **State:** closed **Merged:** Yes --- ## Summary Fixed workflow app card toggle logic inconsistencies and implemented minimal state UI for better user experience during workflow initialization. This change addresses issues where cards were incorrectly disabled due to incomplete entry node detection and inconsistent state logic across components. ### Changes Made **Core Logic Fixes:** - Fixed entry node detection to use `getWorkflowEntryNode()` instead of only checking `BlockEnum.Start`, now properly detects all trigger types (TriggerSchedule, TriggerWebhook, TriggerPlugin) - Unified toggle disabled logic across WebApp, API, and MCP Service cards with consistent variable naming and conditions - Standardized logic order: `hasInsufficientPermissions || appUnpublished || missingEntryNode` **UI Improvements:** - Implemented minimal card state (48px height) when workflow is unpublished or missing entry nodes - Added informative tooltip to WebApp card toggle with "Learn more" documentation link - Conditional rendering of card sections based on workflow state **Code Quality:** - Unified variable naming across components: `isWorkflowApp`, `appUnpublished`, `hasEntryNode`, `missingEntryNode`, `hasInsufficientPermissions` - Consistent logic implementation between app-card.tsx and mcp-service-card.tsx - Added comprehensive unit tests covering all toggle logic scenarios ### Technical Details **Before:** Cards only checked for Start nodes, causing trigger-based workflows to appear disabled **After:** Cards properly detect all entry node types using centralized `getWorkflowEntryNode()` function **Before:** Inconsistent disable logic between WebApp/API cards and MCP cards **After:** All cards use identical logic: permissions, publish state, and entry node presence **Before:** Cards showed full UI even for uninitialized workflows **After:** Progressive disclosure with minimal state until workflow is properly configured ### Test Coverage Added 11 unit tests covering: - Entry node detection for all trigger types - Published vs unpublished workflow states - Permission-based toggle logic (editor vs manager) - Combined condition handling - Non-workflow app behavior All tests pass with no regressions detected in existing functionality. ## Screenshots(Workflow initialized but empty) | Before | After | |--------|-------| |<img width="457" height="779" alt="image" src="https://github.com/user-attachments/assets/0ffac9c4-e3dc-4d3d-9f5c-4f4d2c4bf400" />|<img width="721" height="782" alt="image" src="https://github.com/user-attachments/assets/ea021ae1-3743-4214-93af-6f668cb6d3cb" />| ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:48:16 -05:00
yindo closed this issue 2026-02-21 20:48:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30809