mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Fix conversation sorting and pagination (#6014)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
parent
1ddf398a81
commit
a6d392322a
@ -68,7 +68,6 @@ class FileConversationStore(ConversationStore):
|
||||
num_conversations = len(conversation_ids)
|
||||
start = page_id_to_offset(page_id)
|
||||
end = min(limit + start, num_conversations)
|
||||
conversation_ids = conversation_ids[start:end]
|
||||
conversations = []
|
||||
for conversation_id in conversation_ids:
|
||||
try:
|
||||
@ -79,6 +78,8 @@ class FileConversationStore(ConversationStore):
|
||||
exc_info=True,
|
||||
stack_info=True,
|
||||
)
|
||||
conversations.sort(key=_sort_key, reverse=True)
|
||||
conversations = conversations[start:end]
|
||||
next_page_id = offset_to_page_id(end, end < num_conversations)
|
||||
return ConversationMetadataResultSet(conversations, next_page_id)
|
||||
|
||||
@ -92,3 +93,10 @@ class FileConversationStore(ConversationStore):
|
||||
async def get_instance(cls, config: AppConfig, token: str | None):
|
||||
file_store = get_file_store(config.file_store, config.file_store_path)
|
||||
return FileConversationStore(file_store)
|
||||
|
||||
|
||||
def _sort_key(conversation: ConversationMetadata) -> str:
|
||||
last_updated_at = conversation.last_updated_at
|
||||
if last_updated_at:
|
||||
return last_updated_at.isoformat() # YYYY-MM-DDTHH:MM:SS for sorting
|
||||
return ''
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user