Files
homarr/packages
Thomas Camlong f25be7cf1c fix(api): make assistant message ordering iterative and cycle-safe
Addresses two review findings.

The depth-first walk recursed once per message. A conversation is a single
parent chain and getThread loads the whole thread, so a long conversation
could exhaust the call stack; a 30,000 message chain already threw
RangeError. It now uses an explicit stack, pushing siblings in reverse so
the incoming order is preserved.

The cycle fallback appended unvisited messages without walking their
children, so for child -> a, a -> b, b -> a the child came out ahead of its
parent. Each remaining component is now entered at the earliest member of
its cycle in the incoming order and traversed from there, which leaves only
the cycle's own back-edge violating parent-before-child - unavoidable by
definition - instead of arbitrary messages.
2026-08-07 17:49:39 +02:00
..