Skip to content

Commit 810e995

Browse files
committed
Guard indicator clear by request context
1 parent 74fcba9 commit 810e995

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/hooks/usePendingConciergeResponse.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {useEffect, useRef} from 'react';
22
import type {OnyxEntry} from 'react-native-onyx';
33
import {clearAgentZeroProcessingIndicator} from '@libs/actions/Report';
44
import {applyPendingConciergeAction, clearPendingFollowupList, discardPendingConciergeAction, hidePendingFollowupList} from '@libs/actions/Report/SuggestedFollowup';
5-
import {MAX_AGE_MS} from '@libs/AgentZeroOptimisticStore';
5+
import AgentZeroOptimisticStore, {MAX_AGE_MS} from '@libs/AgentZeroOptimisticStore';
66
import Log from '@libs/Log';
77
import {rand64} from '@libs/NumberUtils';
88
import type {ConciergeDraftEvent} from '@libs/Pusher/types';
@@ -104,7 +104,12 @@ function usePendingConciergeResponse(reportID: string | undefined) {
104104
}
105105
const html = pendingFollowupAction ? getReportActionHtml(pendingFollowupAction) : '';
106106
const hardClearIndicator = () => {
107-
clearAgentZeroProcessingIndicator(reportID);
107+
// Skip clearing agent thinking indicator when a newer agent request has kicked off.
108+
const optimisticEntry = AgentZeroOptimisticStore.getEntry(reportID);
109+
const hasNewerRequest = !!optimisticEntry && optimisticEntry.startedAt > pendingFollowupList.createdAt;
110+
if (!hasNewerRequest) {
111+
clearAgentZeroProcessingIndicator(reportID);
112+
}
108113
clearPendingFollowupList(reportID);
109114
};
110115
if (parseFollowupsFromHtml(html)?.length) {

0 commit comments

Comments
 (0)