Skip to content

Commit d99e1b6

Browse files
committed
Drop typing write
1 parent 5f8f5a4 commit d99e1b6

1 file changed

Lines changed: 14 additions & 40 deletions

File tree

src/libs/actions/Report/SuggestedFollowup.ts

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ const CONCIERGE_RESPONSE_DELAY_MS = 4000;
1717
/**
1818
* Resolves a suggested followup by posting the selected question as a comment
1919
* and optimistically updating the HTML to mark the followup-list as resolved.
20-
* If the followup has a pre-generated response, it will show a "Concierge is typing"
21-
* indicator briefly before displaying the response.
20+
* If the followup has a pre-generated response, it will be queued and displayed
21+
* after a short delay. The server-owned agentZeroProcessingIndicator NVP drives
22+
* the "Concierge is thinking..." indicator during that window.
2223
* @param report - The report where the action exists
2324
* @param notifyReportID - The report ID to notify for new actions
2425
* @param reportAction - The report action containing the followup-list
@@ -66,8 +67,7 @@ function resolveSuggestedFollowup(
6667
return;
6768
}
6869

69-
// If there's a pre-generated response, show typing indicator then display response after delay
70-
70+
// If there's a pre-generated response, queue it for delayed display.
7171
const optimisticConciergeReportActionID = rand64();
7272

7373
// Post user's comment immediately
@@ -110,47 +110,26 @@ function resolveSuggestedFollowup(
110110
* when the time arrives, with proper lifecycle cleanup.
111111
*/
112112
function addOptimisticConciergeActionWithDelay(reportID: string, optimisticConciergeAction: OptimisticReportAction) {
113-
Onyx.update([
114-
// Store the pending response for the scheduler to process
115-
{
116-
onyxMethod: Onyx.METHOD.SET,
117-
key: `${ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE}${reportID}`,
118-
value: {
119-
reportAction: optimisticConciergeAction.reportAction,
120-
displayAfter: Date.now() + CONCIERGE_RESPONSE_DELAY_MS,
121-
},
122-
},
123-
// Show "Concierge is typing..." indicator
124-
{
125-
onyxMethod: Onyx.METHOD.MERGE,
126-
key: `${ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING}${reportID}`,
127-
value: {[CONST.ACCOUNT_ID.CONCIERGE]: true},
128-
},
129-
]);
113+
// The "Concierge is thinking..." indicator is driven by the server-owned
114+
// agentZeroProcessingIndicator NVP, so this client-local delayed response
115+
// must not also write REPORT_USER_IS_TYPING for Concierge.
116+
Onyx.set(`${ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE}${reportID}`, {
117+
reportAction: optimisticConciergeAction.reportAction,
118+
displayAfter: Date.now() + CONCIERGE_RESPONSE_DELAY_MS,
119+
});
130120
}
131121

132122
/**
133-
* Discards a stale pending concierge response and clears the typing indicator.
123+
* Discards a stale pending concierge response.
134124
* Called when the response has been pending too long (e.g. app was killed and restarted).
135125
*/
136126
function discardPendingConciergeAction(reportID: string | undefined) {
137-
Onyx.update([
138-
{
139-
onyxMethod: Onyx.METHOD.SET,
140-
key: `${ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE}${reportID}`,
141-
value: null,
142-
},
143-
{
144-
onyxMethod: Onyx.METHOD.MERGE,
145-
key: `${ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING}${reportID}`,
146-
value: {[CONST.ACCOUNT_ID.CONCIERGE]: false},
147-
},
148-
]);
127+
Onyx.set(`${ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE}${reportID}`, null);
149128
}
150129

151130
/**
152131
* Applies a pending concierge response by moving it to REPORT_ACTIONS
153-
* and clearing the pending state and typing indicator.
132+
* and clearing the pending state.
154133
*/
155134
function applyPendingConciergeAction(reportID: string | undefined, reportAction: ReportAction) {
156135
Onyx.update([
@@ -159,11 +138,6 @@ function applyPendingConciergeAction(reportID: string | undefined, reportAction:
159138
key: `${ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE}${reportID}`,
160139
value: null,
161140
},
162-
{
163-
onyxMethod: Onyx.METHOD.MERGE,
164-
key: `${ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING}${reportID}`,
165-
value: {[CONST.ACCOUNT_ID.CONCIERGE]: false},
166-
},
167141
{
168142
onyxMethod: Onyx.METHOD.MERGE,
169143
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,

0 commit comments

Comments
 (0)