Compare commits

...

1 Commits

Author SHA1 Message Date
Jiang Bohan
534a5c4b30 fix(views): sort timeline entries after WebSocket append
WebSocket event handlers for comment:created and activity:created
appended new entries to the end of the timeline array without sorting.
When events arrived out of order (e.g. agent replying rapidly), comments
displayed out of chronological order.

Sort the timeline by created_at after each append to maintain correct
chronological ordering.

Closes #1032
2026-04-15 13:01:06 +08:00

View File

@@ -70,7 +70,9 @@ export function useIssueTimeline(issueId: string, userId?: string) {
(old) => {
if (!old) return old;
if (old.some((e) => e.id === comment.id)) return old;
return [...old, commentToTimelineEntry(comment)];
return [...old, commentToTimelineEntry(comment)].sort(
(a, b) => a.created_at.localeCompare(b.created_at),
);
},
);
},
@@ -144,7 +146,9 @@ export function useIssueTimeline(issueId: string, userId?: string) {
(old) => {
if (!old) return old;
if (old.some((e) => e.id === entry.id)) return old;
return [...old, entry];
return [...old, entry].sort(
(a, b) => a.created_at.localeCompare(b.created_at),
);
},
);
},