fix(web): order session messages by creation time#17149
fix(web): order session messages by creation time#17149ShenAC-SAC wants to merge 4 commits intoanomalyco:devfrom
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Adding a quick note on the split with #17010:
So the two PRs are meant to be complementary:
Both are needed when the browser and opencode server run on different machines and therefore do not share a reliable global clock for message ID generation. |
|
We adopted this PR's |
Thanks — that’s helpful context.
|
Issue for this PR
Closes #17012
Follow-up to #17010.
Type of change
What does this PR do?
This fixes the web frontend side of the cross-machine message ordering bug.
#17010fixed the backend/prompt loop logic by avoiding assumptions based on message ID ordering. The frontend still had several places where it implicitly treatedmessage.idas a chronological key.That breaks when user message IDs are generated on the client, assistant message IDs are generated on the server, and those machines are not using the same clock source. In that setup, message IDs can be lexically out of order even when
time.createdis correct.This PR updates the web UI to:
time.createdparentIDinstead of relying on array position after ID sortingmessage.idcomparisonsHow did you verify your code works?
I verified this locally in the fork workspace with:
cd packages/util && bun test src/message.test.tscd packages/util && bun run typecheckcd packages/ui && bun run typecheckcd packages/app && bun run typecheckI also reproduced the issue scenario conceptually by using the case where the browser and opencode server run on different machines, so client-generated user IDs and server-generated assistant IDs no longer share a reliable global time source.
Screenshots / recordings
Not included. This change is focused on the message ordering and rendering logic that determines whether assistant replies appear at all in cross-machine web sessions.
Checklist