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:
Classic298
2026-08-17 09:13:51 +02:00
committed by GitHub
parent f100edb708
commit b933292d63
+3 -1
View File
@@ -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