dify - ✅(Solved) Fix Streaming output is broken after refreshing chat app [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langgenius/dify#35307Fetched 2026-04-17 08:56:17
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
1
Author
Participants
Assignees
Timeline (top)
cross-referenced ×2assigned ×1renamed ×1

Fix Action

Fixed

PR fix notes

PR #35315: Feat/replayable stream

Description (problem / solution / changelog)

[!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

closes #35307

Screenshots

BeforeAfter
......

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 make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Changed files

  • api/controllers/console/human_input_form.py (modified, +3/-1)
  • api/controllers/web/workflow_events.py (modified, +3/-1)
  • api/core/app/apps/message_based_app_generator.py (modified, +3/-1)
  • api/core/app/apps/message_generator.py (modified, +3/-1)
  • api/core/app/apps/streaming_utils.py (modified, +2/-1)
  • api/extensions/ext_redis.py (modified, +64/-153)
  • api/fields/message_fields.py (modified, +1/-0)
  • api/libs/broadcast_channel/channel.py (modified, +8/-1)
  • api/libs/broadcast_channel/redis/channel.py (modified, +1/-1)
  • api/libs/broadcast_channel/redis/sharded_channel.py (modified, +1/-1)
  • api/libs/broadcast_channel/redis/streams_channel.py (modified, +6/-7)
  • api/services/app_generate_service.py (modified, +2/-1)
  • api/services/workflow_event_snapshot_service.py (modified, +2/-1)
  • web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.spec.tsx (modified, +90/-0)
  • web/app/components/base/chat/chat-with-history/chat-wrapper.tsx (modified, +30/-19)
  • web/app/components/base/chat/chat-with-history/hooks.tsx (modified, +4/-3)
  • web/app/components/base/chat/chat/__tests__/hooks.spec.tsx (modified, +99/-3)
  • web/app/components/base/chat/chat/hooks.ts (modified, +319/-2)
  • web/app/components/base/chat/chat/type.ts (modified, +1/-0)
  • web/app/components/base/chat/embedded-chatbot/__tests__/chat-wrapper.spec.tsx (modified, +47/-0)
  • web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx (modified, +30/-19)
  • web/app/components/base/chat/embedded-chatbot/hooks.tsx (modified, +2/-0)
  • web/app/components/workflow/panel/debug-and-preview/__tests__/hooks/handle-resume.spec.ts (modified, +1/-1)
  • web/app/components/workflow/panel/debug-and-preview/hooks.ts (modified, +4/-2)

PR #35321: feat: replayable message

Description (problem / solution / changelog)

[!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

fixed #35307

The message stream should be replayed on

  • page refreh
  • switching between conversations

Screenshots

BeforeAfter
<img width="1920" height="1298" alt="demo-bad" src="https://github.com/user-attachments/assets/cf2a6b47-0d9d-40c0-b477-2ddae1f80f97" />
<img width="1920" height="1298" alt="demo" src="https://github.com/user-attachments/assets/fba27583-2bf9-49b5-822a-74121147a42e" />

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 make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Changed files

  • api/controllers/web/workflow_events.py (modified, +3/-0)
  • api/core/app/apps/message_based_app_generator.py (modified, +1/-1)
  • api/core/app/apps/message_generator.py (modified, +1/-1)
  • api/core/app/apps/streaming_utils.py (modified, +3/-0)
  • api/fields/message_fields.py (modified, +1/-0)
  • api/libs/broadcast_channel/channel.py (modified, +1/-0)
  • api/libs/broadcast_channel/redis/streams_channel.py (modified, +1/-3)
  • api/services/workflow_event_snapshot_service.py (modified, +23/-0)
  • api/tests/unit_tests/controllers/console/explore/test_message.py (modified, +3/-0)
  • web/app/components/base/chat/chat-with-history/__tests__/chat-wrapper.spec.tsx (modified, +90/-0)
  • web/app/components/base/chat/chat-with-history/chat-wrapper.tsx (modified, +30/-19)
  • web/app/components/base/chat/chat-with-history/hooks.tsx (modified, +4/-3)
  • web/app/components/base/chat/chat/__tests__/hooks.spec.tsx (modified, +99/-3)
  • web/app/components/base/chat/chat/hooks.ts (modified, +319/-2)
  • web/app/components/base/chat/chat/type.ts (modified, +1/-0)
  • web/app/components/base/chat/embedded-chatbot/__tests__/chat-wrapper.spec.tsx (modified, +47/-0)
  • web/app/components/base/chat/embedded-chatbot/chat-wrapper.tsx (modified, +30/-19)
  • web/app/components/base/chat/embedded-chatbot/hooks.tsx (modified, +2/-0)
RAW_BUFFERClick to expand / collapse

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

To reproduce

  1. Start a conversation in chat bot
  2. Prompt the LLM to output long sequence
  3. Refresh the page and enter previous conversation

A possible solution

In message list API, add a workflow_run_id field to each message. The frontend tries to subscribe to last workflow run in the conversation.

In broadcast_channel, expose a boolean field called replay in subscribe APIs. If replay == True, the id used in xread should be 0 instead of $.

Consider using group in order to consume from the beginning.

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.

extent analysis

TL;DR

To resolve the issue with message sequencing in the chat bot, consider modifying the message list API to include a workflow_run_id field and adjusting the broadcast_channel subscribe API to handle replay scenarios.

Guidance

  • Review the message list API to determine the best approach for adding a workflow_run_id field to each message, ensuring it aligns with the existing data structure and backend logic.
  • Investigate the broadcast_channel subscribe API to understand how to expose a replay boolean field and implement the logic for using 0 instead of $ when replay is True.
  • Explore the use of group to consume messages from the beginning, considering how this might impact performance and message ordering.
  • Verify that the proposed solution does not introduce any compatibility issues with existing features or workflows.

Example

No specific code example is provided due to the lack of detailed implementation details in the issue description.

Notes

The solution involves modifying APIs and potentially adjusting how messages are consumed, which could have broader implications on the system's behavior and performance. It's essential to thoroughly test these changes.

Recommendation

Apply the proposed workaround by modifying the message list API and broadcast_channel subscribe API, as it directly addresses the issue described and provides a clear path forward for resolving the problem with message sequencing in the chat bot.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING