[PR #27803] fix: ensure advanced-chat workflows stop correctly #31868

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

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

State: closed
Merged: Yes


close #27801

Add GraphEngineManager.send_stop_command() to all advanced-chat stop endpoints to match workflow mode behavior. This ensures workflow status is properly recorded as STOPPED when users click the stop button.

Modified files:

  • controllers/console/app/completion.py
  • controllers/console/explore/completion.py
  • controllers/web/completion.py
  • controllers/service_api/app/completion.py

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

The advanced-chat stop APIs were only using the legacy Redis flag mechanism (AppQueueManager.set_stop_flag()), while workflow mode uses both:

  1. Legacy Redis flag mechanism
  2. New GraphEngine command channel mechanism (GraphEngineManager.send_stop_command())

The missing GraphEngineManager.send_stop_command() call in advanced-chat stop endpoints prevents the proper workflow stop event from being recorded.

Affected Endpoints:

/console/api/apps/<app_id>/chat-messages/<task_id>/stop
/api/chat-messages/<task_id>/stop (web)
/v1/chat-messages/<task_id>/stop (service API)
/console/api/installed-apps/<app_id>/chat-messages/<task_id>/stop (explore)

Screenshots

Before After
image 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/27803 **State:** closed **Merged:** Yes --- close #27801 Add GraphEngineManager.send_stop_command() to all advanced-chat stop endpoints to match workflow mode behavior. This ensures workflow status is properly recorded as STOPPED when users click the stop button. Modified files: - controllers/console/app/completion.py - controllers/console/explore/completion.py - controllers/web/completion.py - controllers/service_api/app/completion.py > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #<issue number>`. ## Summary <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> The advanced-chat stop APIs were only using the legacy Redis flag mechanism (AppQueueManager.set_stop_flag()), while workflow mode uses both: 1. Legacy Redis flag mechanism 2. New GraphEngine command channel mechanism (GraphEngineManager.send_stop_command()) The missing GraphEngineManager.send_stop_command() call in advanced-chat stop endpoints prevents the proper workflow stop event from being recorded. Affected Endpoints: /console/api/apps/<app_id>/chat-messages/<task_id>/stop /api/chat-messages/<task_id>/stop (web) /v1/chat-messages/<task_id>/stop (service API) /console/api/installed-apps/<app_id>/chat-messages/<task_id>/stop (explore) ## Screenshots | Before | After | |--------|-------| | <img width="762" height="886" alt="image" src="https://github.com/user-attachments/assets/9d4494a4-67bb-42c1-a00f-10b055dafe43" /> | <img width="744" height="708" alt="image" src="https://github.com/user-attachments/assets/bc0cd907-ac79-4cd6-9549-286668833d22" /> <img width="1660" height="528" alt="image" src="https://github.com/user-attachments/assets/b165ed1b-e06e-4230-bfff-cbaa9b2e1d57" /> | ## 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:50:18 -05:00
yindo closed this issue 2026-02-21 20:50:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31868