[PR #22194] [MERGED] perf: rewrite createMessagesList from recursive to iterative #65400

Closed
opened 2026-05-06 11:12:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22194
Author: @Classic298
Created: 3/3/2026
Status: Merged
Merged: 3/6/2026
Merged by: @tjbck

Base: devHead: perf/iterative-create-messages-list


📝 Commits (1)

  • 653b3b6 perf: rewrite createMessagesList from recursive to iterative

📊 Changes

1 file changed (+11 additions, -11 deletions)

View changed files

📝 src/lib/utils/index.ts (+11 -11)

📄 Description

Replace the recursive spread-based implementation with an iterative push+reverse approach. The recursive version created a new array at each level of recursion via spread, resulting in O(d^2) array copies where d is the conversation depth. The iterative version walks from the target message to the root, pushes each message, and reverses once at the end for O(d) total work.

No behavioral change - same input produces the same output array.

This was tested extensively

No side effects observed even in branched chats and navigating between branches.

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22194 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 3/3/2026 **Status:** ✅ Merged **Merged:** 3/6/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `perf/iterative-create-messages-list` --- ### 📝 Commits (1) - [`653b3b6`](https://github.com/open-webui/open-webui/commit/653b3b6347b7aac48d8fae900f08d1f891190f3c) perf: rewrite createMessagesList from recursive to iterative ### 📊 Changes **1 file changed** (+11 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/utils/index.ts` (+11 -11) </details> ### 📄 Description Replace the recursive spread-based implementation with an iterative push+reverse approach. The recursive version created a new array at each level of recursion via spread, resulting in O(d^2) array copies where d is the conversation depth. The iterative version walks from the target message to the root, pushes each message, and reverses once at the end for O(d) total work. No behavioral change - same input produces the same output array. # This was tested extensively No side effects observed even in branched chats and navigating between branches. ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. --> By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 11:12:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#65400