[PR #11175] fix: dialogue_count incorrect in chatflow when there's... #27104

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

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

State: closed
Merged: Yes


...regenerated message.

Summary

In the Chatflow App, the dialogue_count system variable becomes inaccurate when messages are regenerated. This variable is stored in the conversations table of the database and is incremented each time a message is sent. However, with the introduction of the message regeneration feature, this method is no longer suitable for cases involving regenerated messages.

This PR changes the calculation method for the dialogue_count system variable. It now dynamically calculates the value based on the thread messages of the conversation.

Screenshots

Before: After:

Caveats

The dialogue_count column in the conversation table should no longer be necessary. However, this pull request does not include a migration script to remove this column.

Checklist

Important

Please review the checklist below before submitting your pull request.

  • 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/11175 **State:** closed **Merged:** Yes --- ...regenerated message. # Summary In the Chatflow App, the `dialogue_count` system variable becomes inaccurate when messages are regenerated. This variable is stored in the `conversations` table of the database and is incremented each time a message is sent. However, with the introduction of the [`message regeneration`](https://github.com/langgenius/dify/pull/7661#issuecomment-2350967411) feature, this method is no longer suitable for cases involving regenerated messages. This PR changes the calculation method for the `dialogue_count` system variable. It now dynamically calculates the value based on the thread messages of the conversation. # Screenshots <table> <tr> <td>Before: </td> <td>After: </td> </tr> <tr> <td><video src="https://github.com/user-attachments/assets/91642e0c-1051-47c6-a0b3-8709b394990d" /></td> <td><video src="https://github.com/user-attachments/assets/6be2512a-ea0c-4af7-a7a7-75d7229aa1dc" /></td> </tr> </table> # Caveats The `dialogue_count` column in the `conversation` table should no longer be necessary. However, this pull request does not include a migration script to remove this column. # Checklist > [!IMPORTANT] > Please review the checklist below before submitting your pull request. - [ ] 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:40:52 -05:00
yindo closed this issue 2026-02-21 20:40:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#27104