App icon indicating copy to clipboard operation
App copied to clipboard

[$175] [Auto] - Concierge - Pre-generated Concierge response does not appears while offline

Open applause-bot[bot] opened this issue 3 weeks ago • 20 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.5.34-0 Reproducible in staging?: Yes Reproducible in production?: No If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/82874198/folder/22315296/83670639/1956441437?sort=%2Bidentifier Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Windows 10/Chrome App Component: Left Hand Navigation (LHN)

Action Performed:

Preconditions: Logged-in user with an active Concierge conversation. (normal account, not using Expensifail) User has sent a question in Concierge: How do I set up QuickBooks? Steps:

  1. Open the Concierge chat room where follow-up buttons with pre-generated answers are visible
  2. Disconnect the device from the internet (enable Airplane Mode or disable Wi-Fi/Data)
  3. Click on one of the suggested follow-up buttons

Expected Result:

  1. Verify the pre-generated Concierge response appears instantly in the chat thread while still offline

Actual Result:

No response from Concierge

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/14e1dee2-3d80-412c-bb53-2141c1e5376b

View all open jobs on GitHub

Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7308158

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Nov 08 '26 17:11 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/74317b20f551fe9709a873964cc9fc3f32c9e28c30ad4c4287c19ea5c923ae41

applause-bot[bot] avatar Nov 08 '26 17:11 applause-bot[bot]

Triggered auto assignment to @Julesssss (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

melvin-bot[bot] avatar Nov 08 '26 17:11 melvin-bot[bot]

💬 A slack conversation has been started in #expensify-open-source

melvin-bot[bot] avatar Nov 08 '26 17:11 melvin-bot[bot]

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

github-actions[bot] avatar Nov 08 '26 17:11 github-actions[bot]

🤖 Web test steps verification results: ⚠️ partial

The QuickBooks question was submitted, but Concierge returned no answer or suggested follow-ups within 30 seconds, preventing reproduction. Offline verification was also blocked because the supported browser interface cannot disconnect networking.

Concierge conversation containing the question but no answer or suggested follow-ups
Step Status
Ask Concierge “How do I set up QuickBooks?”The question was submitted using the provided normal account.
✅
Verify suggested follow-up buttons are visibleNo Concierge answer or suggested follow-ups appeared within 30 seconds. This blocked the reproduction precondition; it does not confirm the reported offline bug.
Concierge conversation containing the question but no answer or suggested follow-ups
❌
Disconnect networking and click a follow-upBlocked: no button was available, and the supported browser interface has no offline control.
⚠️
Verify the answer immediately and after at least 10 seconds offlineBlocked: no offline click occurred.
⚠️
Investigate cached responses and identify the causing PRNo causing PR verified; keep DeployBlockerCash. Do not revert a specific PR on the current evidence.
The deploy-blocker investigator compared staging 9.5.34-0 against production 9.5.33-1: seven directly relevant follow-up parsing, dispatch, scheduling, and rendering files are identical between releases. An indirect regression remains possible.
Leading hypothesis—not confirmed: the visible button lacked a cached answer. The parser accepts questions without responses; when no response exists, the click handler only sends a comment, so it cannot generate a local offline answer. When cached content exists, the handler queues a local response, and the reveal effect has no offline guard.
The expected “instant” response also conflicts with an existing four-second delay, although that cannot explain indefinite absence.
Next diagnostic: capture the affected message’s cached follow-up content and the existing hasPregeneratedResponse telemetry. If true, inspect pending-response state and reveal logs after four seconds; if false, compare staging/production payloads before assigning ownership. The affected payload was unavailable, so neither missing data nor a rendering regression is confirmed.
⚠️

view run

MelvinBot avatar Nov 08 '26 17:11 MelvinBot

Asked for a retest on the revert adhoc here https://github.com/Expensify/App/pull/106333

mountiny avatar Nov 09 '26 03:11 mountiny

I tried testing this locally on the main branch without pulling the latest changes yet (which doesn't include our PR), and I can reproduce the issue.

https://github.com/user-attachments/assets/28a233ac-f068-4c6b-8ee4-8b7cabd180f1

The latest commit is 63acb1ed08949b77fb80f02e8b2d1d6360d0d90b.

bernhardoj avatar Nov 09 '26 16:11 bernhardoj

Triggered auto assignment to Contributor-plus team member for initial proposal review - @daledah (External)

melvin-bot[bot] avatar Nov 09 '26 19:11 melvin-bot[bot]

Thanks sounds like this si not blocker then

mountiny avatar Nov 09 '26 19:11 mountiny

Job added to Upwork: https://www.upwork.com/jobs/~022119878227182546692

melvin-bot[bot] avatar Nov 09 '26 19:11 melvin-bot[bot]

Proposal

What is the root cause of that problem?

There are two interacting root causes:

  1. Target Report ID Mismatch for Threaded Followups (resolveSuggestedFollowup): In ChatActionableButtons.tsx, SuggestedFollowupButtons invokes:

    resolveSuggestedFollowup(
        actionOwnerReport,
        reportID, // passed as notifyReportID
        action,
        followup,
        ...
    );
    

    Where actionOwnerReport is originalReport ?? report. In a Concierge question thread, actionOwnerReport points to the parent Concierge DM (originalReport), while the active thread's report ID is passed as reportID (notifyReportID). However, inside src/libs/actions/Report/SuggestedFollowup.ts:

    function resolveSuggestedFollowup(
        report: OnyxEntry<Report>,
        notifyReportID: string | undefined,
        ...
    ) {
        const reportID = report?.reportID;
    

    reportID is taken strictly from report?.reportID (the parent DM) instead of notifyReportID ?? report?.reportID (the active thread). Consequently:

    • buildOptimisticAddCommentReportAction is stamped with the parent reportID.
    • addOptimisticConciergeActionWithDelay writes to ${ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE}${actionOwnerReport.reportID}.
    • applyPendingConciergeAction commits the action to ${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${actionOwnerReport.reportID}.

    Meanwhile, the user is viewing the thread (notifyReportID). The thread's ReportActionsSkeletonGuard and usePendingConciergeResponse(reportID) listen to the thread's ID, so the optimistic action is never rendered in the thread.

  2. Unnecessary 4000ms Delay & Suppressed Typing Indicator While Offline: In src/libs/actions/Report/SuggestedFollowup.ts, addOptimisticConciergeActionWithDelay sets displayAfter: Date.now() + CONCIERGE_RESPONSE_DELAY_MS (4000ms delay). This delay was introduced for online flows so the server-owned agentZeroProcessingIndicator NVP can render "Concierge is thinking...". When offline:

    • The server NVP is never received.
    • Client typing indicators for Concierge are explicitly suppressed in usePendingConciergeResponse.ts.
    • The response is already pre-generated and locally available in selectedFollowup.response. Imposing a 4000ms delay while offline leaves the UI frozen with zero feedback. If the user navigates away or the view unmounts before 4 seconds, the response timer is cancelled and the action is never committed to REPORT_ACTIONS.

    (Note: Additionally, if a backend payload provides <followup-list> containing only <followup-text> without a <followup-response> child node, selectedFollowup.response is undefined, so resolveSuggestedFollowup correctly falls back to addComment for an online server round-trip).

What changes do you think we should make in order to solve the problem?

  1. In src/libs/actions/Report/SuggestedFollowup.ts:

    • Define const targetReportID = notifyReportID ?? reportID;.
    • Route the optimistic Concierge action, delayed queue, and pending action to targetReportID:
      const targetReportID = notifyReportID ?? reportID;
      const isOffline = getIsOffline();
      
    • When offline (isOffline is true):
      • Build optimisticConciergeAction with reportID: targetReportID and createdOffset: 1.
      • Post the user's comment via addComment.
      • Immediately invoke applyPendingConciergeAction(targetReportID, optimisticConciergeAction.reportAction) instead of waiting 4000ms.
    • When online:
      • Proceed with normal addOptimisticConciergeActionWithDelay(targetReportID, optimisticConciergeAction).
  2. In src/hooks/usePendingConciergeResponse.ts:

    • When isOffline is true and a pending response is detected, immediately commit it via applyPendingConciergeAction(reportID, reportAction) instead of scheduling delayed timers or trickle intervals.
// In src/libs/actions/Report/SuggestedFollowup.ts:
const targetReportID = notifyReportID ?? reportID;
const isOffline = getIsOffline();

if (isOffline) {
    const optimisticConciergeAction = buildOptimisticAddCommentReportAction({
        text: selectedFollowup.response,
        actorAccountID: CONST.ACCOUNT_ID.CONCIERGE,
        createdOffset: 1,
        reportActionID: optimisticConciergeReportActionID,
        reportID: targetReportID,
        isHTML: true,
        currentUserEmail,
        currentUserAccountID,
        delegateAccountIDParam: delegateAccountID,
    });

    addComment({
        report,
        notifyReportID: targetReportID,
        ancestors,
        text: selectedFollowup.text,
        timezoneParam,
        currentUserAccountID,
        shouldPlaySound: false,
        isInSidePanel: false,
        pregeneratedResponseParams: {
            optimisticConciergeReportActionID,
            optimisticConciergeCreated: optimisticConciergeAction.reportAction.created,
            pregeneratedResponse: selectedFollowup.response,
        },
        delegateAccountID,
        conciergeReportID,
    });

    applyPendingConciergeAction(targetReportID, optimisticConciergeAction.reportAction);
} else {
    // Standard online path with delay/trickle
    addOptimisticConciergeActionWithDelay(targetReportID, optimisticConciergeAction);
}

What alternative solutions did you explore? (Optional)

  • Handling offline display only in usePendingConciergeResponse.ts: While this handles the delay, it does not fix the thread routing mismatch (targetReportID). In threads, the action would still be committed to the parent DM rather than the thread. Fixing both in SuggestedFollowup.ts ensures consistent behavior across both root Concierge chats and question threads.

Tests

  1. Open Concierge and ask a question that returns suggested follow-up buttons with pre-generated answers (test both root Concierge chat and inside a thread).
  2. Disconnect the device from the internet (Airplane Mode / DevTools offline).
  3. Click on one of the suggested follow-up buttons.
  4. Verify that:
    • The user's question comment appears immediately.
    • The pre-generated Concierge response appears immediately in the chat thread while still offline.
  5. Reconnect to the internet and verify that report actions sync cleanly with the server without duplicates.
  • [x] Verify that no errors appear in the JS console

Contributor details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

kevinjosh10 avatar Nov 09 '26 20:11 kevinjosh10

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 09 '26 20:11 melvin-bot[bot]

@MelvinBot can you make a proposal on this bug?

mountiny avatar Nov 09 '26 22:11 mountiny

Proposal — preliminary, not ready for implementation

What is the root cause of that problem?

The cause of the missing response is still unconfirmed. I checked the existing proposal, and its missing-optimistic-flags explanation does not hold:

Verified code findings

A visible follow-up button can lack a cached answer. In that case, the handler only queues the question, so no offline answer is possible. That explains the symptom if the affected payload lacks a response, but we have not established that.

What changes do you think we should make in order to solve the problem?

I would not recommend a code change yet. The next reproduction needs to capture:

  1. Whether the clicked follow-up has nonempty cached response content (hasPregeneratedResponse).
  2. If it does, whether the pending response reaches the reveal hook and report-actions list after four seconds.

The existing four-second delay contradicts “instantly,” but removing it alone is not a demonstrated fix for “no response.”

What alternative solutions did you explore? (Optional)

  • Re-add optimistic flags: unnecessary; they already exist.
  • Change visibility caching: unsupported by the traced code.
  • Bypass delay/trickling offline: potentially addresses timing, not the unexplained disappearance.

The two existing targeted test suites passed—all 24 tests—but do not reproduce this failure. Production-log access was unavailable, so the affected payload and reveal events remain the blocker to an implementation-ready proposal.


view run

MelvinBot avatar Nov 09 '26 22:11 MelvinBot

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~013d295f05a578824b

Proposal

Please re-state the problem that we are trying to solve in this issue.

In Concierge chat (specifically inside Concierge question threads or root chats), when a user is offline and clicks on a suggested follow-up button, no response appears from Concierge.

What is the root cause of that problem?

There are two interacting root causes:

  1. Target Report ID Mismatch for Threaded Followups (resolveSuggestedFollowup): In ChatActionableButtons.tsx, SuggestedFollowupButtons invokes:

    resolveSuggestedFollowup(
        actionOwnerReport,
        reportID,
        action,
        followup,
        ...
    );
    

    Where actionOwnerReport is originalReport ?? report. In a Concierge question thread (e.g. route /r/<threadReportID>/?backTo=%2Fr%2F<conciergeReportID>), actionOwnerReport resolves to the parent Concierge DM (originalReport), while the active thread's report ID is passed as reportID (notifyReportID). However, inside src/libs/actions/Report/SuggestedFollowup.ts:

    function resolveSuggestedFollowup(
        report: OnyxEntry<Report>,
        notifyReportID: string | undefined,
        reportAction: OnyxEntry<ReportAction>,
        ...
    ) {
        const reportID = report?.reportID;
    

    reportID is extracted strictly from report?.reportID (actionOwnerReport.reportID, the parent DM) instead of notifyReportID ?? report?.reportID (the active thread). Consequently:

    • buildOptimisticAddCommentReportAction is stamped with reportID = actionOwnerReport.reportID.
    • addOptimisticConciergeActionWithDelay(reportID, optimisticConciergeAction) writes to ${ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE}${actionOwnerReport.reportID}.
    • applyPendingConciergeAction(reportID, reportAction) merges the action into ${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${actionOwnerReport.reportID}.

    Meanwhile, the user is viewing the thread (notifyReportID). The thread's ReportActionsSkeletonGuard and usePendingConciergeResponse(reportID) are subscribed to the thread's ID (notifyReportID). They never receive the pending response or the optimistic report action because it was queued and merged under the parent report.

  2. Unnecessary 4000ms Delay & Suppressed Typing Indicator While Offline: CONCIERGE_RESPONSE_DELAY_MS = 4000 is intended for the online state to delay client display while the server-owned agentZeroProcessingIndicator NVP renders "Concierge is thinking...". When offline:

    • The server NVP is never received.
    • Client-side typing status (REPORT_USER_IS_TYPING) for Concierge is explicitly suppressed in usePendingConciergeResponse.ts.
    • The pre-generated response is already locally available in selectedFollowup.response. Enforcing a 4000ms delay while offline leaves the UI frozen with no feedback, and if the user switches away or the component unmounts, the timer is cleared before display.

    (Note: In addition, if a backend payload returns <followup-list> containing only <followup-text> without <followup-response>, selectedFollowup.response is undefined, so resolveSuggestedFollowup only posts the question comment via addComment; without a pregenerated payload, no offline response is possible).

What changes do you think we should make in order to solve the problem?

  1. Target the Active Thread/Report in src/libs/actions/Report/SuggestedFollowup.ts:

    • Define const targetReportID = notifyReportID ?? report?.reportID;.
    • Use targetReportID for:
      • Building the optimistic Concierge action (reportID: targetReportID).
      • Queueing the delayed response: addOptimisticConciergeActionWithDelay(targetReportID, optimisticConciergeAction).
      • Applying the pending action: applyPendingConciergeAction(targetReportID, reportAction).
      • Marking the followup-list resolved in REPORT_ACTIONS:
        Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
            [reportActionID]: resolvedAction,
        });
        
        (Marking the action resolved on reportID preserves the button state on the owning action, while the new reply lands on targetReportID).
  2. Bypass the 4000ms Delay When Offline:

    • In resolveSuggestedFollowup: If NetworkStore.isOffline(), set createdOffset: 1 and immediately invoke applyPendingConciergeAction(targetReportID, optimisticConciergeAction.reportAction) instead of waiting for CONCIERGE_RESPONSE_DELAY_MS.
    • In src/hooks/usePendingConciergeResponse.ts: If isOffline is true when a pending response is detected, bypass the delay/trickle and immediately commit it via applyPendingConciergeAction(reportID, reportAction).
// In src/libs/actions/Report/SuggestedFollowup.ts:
const targetReportID = notifyReportID ?? reportID;
const isOffline = NetworkStore.isOffline();

if (isOffline) {
    const optimisticConciergeAction = buildOptimisticAddCommentReportAction({
        text: selectedFollowup.response,
        actorAccountID: CONST.ACCOUNT_ID.CONCIERGE,
        createdOffset: 1,
        reportActionID: optimisticConciergeReportActionID,
        reportID: targetReportID,
        isHTML: true,
        currentUserEmail,
        currentUserAccountID,
        delegateAccountIDParam: delegateAccountID,
    });
    addComment({ ... });
    applyPendingConciergeAction(targetReportID, optimisticConciergeAction.reportAction);
} else {
    // Normal online delayed trickle path
    addOptimisticConciergeActionWithDelay(targetReportID, optimisticConciergeAction);
}

What alternative solutions did you explore? (Optional)

  • Only removing CONCIERGE_RESPONSE_DELAY_MS without fixing targetReportID: In Concierge threads, the pre-generated response would still be written to the parent DM's REPORT_ACTIONS instead of the active thread, leaving the thread without a response. Fixing both guarantees immediate and correct placement across both root chats and question threads.

Tests

  1. Navigate to Concierge and ask a question that returns suggested follow-ups with pre-generated responses (e.g., in a thread).
  2. Disconnect the device from the internet (enable Airplane Mode / offline in DevTools).
  3. Tap one of the suggested follow-up buttons.
  4. Verify that:
    • The user's question is added to the active thread immediately.
    • The pre-generated Concierge response appears immediately in the active thread while still offline.
  5. Reconnect to the internet and verify that no duplicate messages or errors occur.

— submitted with Antigravity on the contributor's behalf

HindsightWise avatar Nov 10 '26 01:11 HindsightWise

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 10 '26 01:11 melvin-bot[bot]

@MelvinBot please post a proposal

daledah avatar Nov 10 '26 08:11 daledah

Proposal — root cause not yet verified

What is the root cause of that problem?

The reported disappearance remains unconfirmed. Further investigation ruled out the proposed general thread-routing mismatch:

  • Ordinary thread replies resolve ownership to the thread, not automatically to the parent Concierge DM.
  • A focused offline experiment successfully queued the question and displayed its cached answer in that same thread after four seconds.
  • notifyReportID controls notification, not message destination. Moving only the answer there could separate it from the question and break failure cleanup.
Code evidence

What changes do you think we should make in order to solve the problem?

No implementation-ready change is justified yet. The remaining specific scenario to reproduce is clicking a follow-up on an ancestor message above the thread’s Replies divider: its answer is queued under the ancestor report, while the mounted thread observes a different pending-response key.

To establish whether that explains this issue, capture the clicked action’s owner report, viewed report, cached response, and pending state after four seconds.

The supplied recordings downloaded, but frame extraction was blocked, so their message placement and timing could not be verified.

What alternative solutions did you explore? (Optional)

Re-adding optimistic flags, retargeting only the answer, and removing the delay do not establish a fix for the reported disappearance. Six focused checks and 27 existing tests passed; none reproduced the affected UI failure.


view run

MelvinBot avatar Nov 10 '26 08:11 MelvinBot

@daledah,After investigating the network payloads and tracing the flow locally, this appears to be primarily a Backend (BE) issue rather than a frontend bug.

Key Finding:

  1. Missing Data in the Server Payload: For the question tested ("How do I set up QuickBooks?"), the backend XML returns follow-up suggestions (<followup-text>), but completely omits <followup-response>.
  2. Precondition Not Met: The test case expects a pre-generated answer to appear while offline. However, because the server never sent a pre-generated answer in the payload, the client has no offline text to display and simply queues the user's question to be answered by the server upon reconnection.

The client cannot display a pre-generated answer offline if the backend never provided one in the response payload.

emkhalid avatar Nov 10 '26 13:11 emkhalid

on my list today

daledah avatar Nov 16 '26 04:11 daledah