Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

✨fix: has_more logic in ChatMessageListApi to ensure correct on behavior when no more messages are available. (#24661)

Eric Guoecf74d91e25b
diff --git a/api/controllers/console/app/message.py b/api/controllers/console/app/message.py
index 05b668b8039..fd86191a072 100644
--- a/api/controllers/console/app/message.py
+++ b/api/controllers/console/app/message.py
@@ -95,18 +95,22 @@ class ChatMessageListApi(Resource):
.all()
)
+ # Initialize has_more based on whether we have a full page
if len(history_messages) == args["limit"]:
current_page_first_message = history_messages[-1]
-
- has_more = db.session.scalar(
- select(
- exists().where(
- Message.conversation_id == conversation.id,
- Message.created_at < current_page_first_message.created_at,
- Message.id != current_page_first_message.id,
+ # Check if there are more messages before the current page
+ has_more = db.session.scalar(
+ select(
+ exists().where(
+ Message.conversation_id == conversation.id,
+ Message.created_at < current_page_first_message.created_at,
+ Message.id != current_page_first_message.id,
+ )
)
)
- )
+ else:
+ # If we don't have a full page, there are no more messages
+ has_more = False
history_messages = list(reversed(history_messages))