Compare commits

...

1 Commits

Author SHA1 Message Date
Naiyuan Qing
1b8dfb9540 fix(realtime): update issue in-place on WS event to prevent inbox loading flash
When viewing an issue in the inbox, issue:updated WS events triggered a
full useIssueStore.fetch() that replaced the entire issues array. This
caused all consumers to re-render, producing a loading flash. Now
issue:updated events use the WS payload to surgically update the single
affected issue via updateIssue(), avoiding array replacement.

Other issue events (created/deleted) still use full refetch.
WS reconnect recovery path is unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 18:46:07 +08:00

View File

@@ -74,6 +74,20 @@ export function useRealtimeSync(ws: WSClient | null) {
logger.debug("skipping self-event", msg.type);
return;
}
// issue:updated — update in-place using WS payload instead of full
// refetch. Replacing the entire issues array causes every consumer
// (including IssueDetail in the inbox) to re-render, which can flash
// a loading state. The payload already contains the full issue object
// so a surgical merge is safe.
if (msg.type === "issue:updated") {
const { issue } = (msg.payload ?? {}) as IssueUpdatedPayload;
if (issue?.id) {
useIssueStore.getState().updateIssue(issue.id, issue);
}
return;
}
const prefix = msg.type.split(":")[0] ?? "";
const refresh = refreshMap[prefix];
if (refresh) debouncedRefresh(prefix, refresh);