Describe the bug
In WebChat, when using slash commands (e.g. /memory, /plan), the command output sometimes appears at the wrong position in the timeline — above the previous message instead of below it.
To Reproduce
- Complete a normal chat turn (send a message, wait for AI response)
- Immediately send a slash command (e.g.
/memory status)
- Observe that the slash command output may appear above the previous AI response
Expected behavior
Slash command output should always appear in chronological order at the bottom of the conversation.
Root Cause
Event-stream race condition: when slash command output messages arrive before the previous turn's final flush events, the sync data array contains messages in the wrong order. The messages memo in model.ts and the createTimelineProjection call in message-timeline.tsx both use the unsorted sync array directly.
Proposed Fix
model.ts: sort messages by time.created in the messages memo
message-timeline.tsx: add orderedMessages memo as defensive layer
Describe the bug
In WebChat, when using slash commands (e.g.
/memory,/plan), the command output sometimes appears at the wrong position in the timeline — above the previous message instead of below it.To Reproduce
/memory status)Expected behavior
Slash command output should always appear in chronological order at the bottom of the conversation.
Root Cause
Event-stream race condition: when slash command output messages arrive before the previous turn's final flush events, the sync data array contains messages in the wrong order. The
messagesmemo inmodel.tsand thecreateTimelineProjectioncall inmessage-timeline.tsxboth use the unsorted sync array directly.Proposed Fix
model.ts: sort messages bytime.createdin the messages memomessage-timeline.tsx: addorderedMessagesmemo as defensive layer