fix: stabilize live activity updates

This commit is contained in:
wuyang6
2026-05-26 11:58:13 +08:00
parent 902c9c86c2
commit 20c1946a3c
2 changed files with 50 additions and 8 deletions
@@ -2079,12 +2079,14 @@ const ActivityChainSummary: FC<{
setElapsedMs(storedElapsedMs);
return;
}
const explicitStartedAt =
metadataRunStartedAtMs ?? contentRunStartedAtMs ?? messageCreatedAtMs;
if (explicitStartedAt !== null) {
liveStartedAtRef.current = explicitStartedAt;
const authoritativeStartedAt =
metadataRunStartedAtMs ?? contentRunStartedAtMs;
if (authoritativeStartedAt !== null) {
liveStartedAtRef.current = authoritativeStartedAt;
} else if (liveStartedAtRef.current === null && storedElapsedMs !== null) {
liveStartedAtRef.current = Date.now() - storedElapsedMs;
} else if (liveStartedAtRef.current === null && messageCreatedAtMs !== null) {
liveStartedAtRef.current = messageCreatedAtMs;
}
const startedAt = liveStartedAtRef.current;
if (startedAt === null) {