Repository navigation
fix(chat): import branch threads parents-before-children on refresh - #13113
Merged
mahiatlinux merged 4 commits intoOct 9, 2026
Merged
mahiatlinux merged 4 commits into
mahiatlinux merged 4 commits into
Conversation
A branched thread lost its forks on refresh: an edited user message is written after its reply, so the reply's createdAt predates its user parent, and assistant-ui's import() throws on a child that precedes its parent. The write path already ordered rows parents-first; the read path never did, so the import aborted. Reorder the read path's rows with the shared orderParentsFirst (message-order.ts). headId comes from the saved-branch head (unslothai#13109), which always resolves to a leaf, so import won't drop the head's descendants. Adds regression tests through a real MessageRepository.import(); save-temporary-chat injects the shared helper. Full frontend suite: 11110 pass / 0 fail; typecheck clean.
CelesteHeartsong
force-pushed
the
fix/chat-branch-import-order-on-refresh
branch
from
October 9, 2026 02:34
b485584 to
18a02c4
Compare
Contributor
Author
|
Rebased onto main to resolve a conflict with #13109, which touched the same load() block. The changes compose: messages now use the orderParentsFirst reorder (the actual fix, #13109 still maps in createdAt order and would throw), and headId uses #13109's savedBranchHead, which I verified always resolves to a leaf so import() won't drop descendants. Test updated to exercise resolveSavedBranchHead. 11110 pass / 0 fail. |
mahiatlinux
approved these changes
Oct 9, 2026
mahiatlinux
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Ready to merge, all manually checked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A branched thread lost its forks on refresh: an edited user message is written after its reply, so the reply's createdAt predates its user parent, and assistant-ui's import() throws on a child that precedes its parent.
The write path already ordered rows parents-first; the read path never did, so the import aborted. Reorder the read path's rows with the shared orderParentsFirst (message-order.ts). headId comes from the saved-branch head (#13109), which always resolves to a leaf, so import won't drop the head's descendants.
Adds regression tests through a real MessageRepository.import(); save-temporary-chat injects the shared helper.
Full frontend suite: 11110 pass / 0 fail; typecheck clean.