mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-09 08:37:17 +00:00
refactor: track visited ids when resolving a chat's current message
`delete_message_from_history` follows `childrenIds` down to the deepest leaf without recording where it has been. Record it.
This commit is contained in:
parent
29541cbb52
commit
2bd7f24d21
1 changed files with 3 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue