mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-27 07:54:55 -06:00
refactor: track visited ids when resolving a chat's current message (#28035)
`delete_message_from_history` follows `childrenIds` down to the deepest leaf without recording where it has been. Record it.
This commit is contained in:
@@ -902,8 +902,10 @@ class ChatTable:
|
||||
if current_id is None
|
||||
else messages.get(current_id, {}).get('childrenIds', [])
|
||||
)
|
||||
while child_ids:
|
||||
visited_ids = set()
|
||||
while child_ids and child_ids[-1] not in visited_ids:
|
||||
current_id = child_ids[-1]
|
||||
visited_ids.add(current_id)
|
||||
child_ids = messages.get(current_id, {}).get('childrenIds', [])
|
||||
history['currentId'] = current_id if current_id in messages else None
|
||||
return deleted_ids
|
||||
|
||||
Reference in New Issue
Block a user