Skip to content

[Payment due @TaduJR] Show Concierge thinking immediately - #106142

Merged
NicolasBonet merged 16 commits into
mainfrom
codex/concierge-immediate-thinking
Dec 1, 2026
Merged

NicolasBonet merged 16 commits into
mainfrom
codex/concierge-immediate-thinking

Conversation

@inimaga

@inimaga inimaga commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

The “Concierge is thinking” indicator can appear late or fail to appear after you send a message. This change shows it as soon as you send a message in a Concierge DM or thread.

App tracks each message separately. A reply or completion clears the indicator for that message, so it stays visible while a newer message is still waiting. It also clears when Concierge won’t respond, when a queued offline message is deleted before send, or when the message fails to send. For messages queued while offline, the 120-second safety window restarts when the request is dispatched after reconnecting, and brief disconnects mid-run preserve active server labels and reasoning history.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/695383
PROPOSAL: N/A

Tests

Note: the Concierge processing update is already merged and deployed.

  1. Open the Concierge DM.
  2. Send "How do I submit an expense?".
  3. Verify "Concierge is thinking..." appears immediately, before the request completes.
  4. Wait for Concierge's reply and verify the indicator clears without a refresh.
  5. Send two questions in quick succession in the same Concierge thread.
  6. Verify the indicator stays visible while Concierge works on the thread and clears once all replies finish.
  7. Send a question, switch to another chat, and come back before Concierge replies.
  8. Verify the indicator is still shown until the reply arrives.
  • Verify that no errors appear in the JS console

Offline tests

  1. Open the Concierge DM and turn off the network (or enable Force offline in Settings → Troubleshoot).
  2. Send a question.
  3. Verify the message shows as pending and the indicator is not shown while offline.
  4. Turn the network back on.
  5. Verify the indicator appears, then clears after Concierge replies.
  6. Go offline again, send a question, delete it while still offline, then reconnect.
  7. Verify "Concierge is thinking..." does not appear for the deleted message.

QA Steps

Repeat the test steps on staging.

  • Verify that no errors appear in the JS console

Query Timings/Plans

N/A

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

MacOS: Chrome / Safari
  1. Immediate "Concierge is thinking..." upon sending:
    Immediate thinking indicator

  2. Concierge reply arrives and clears indicator automatically:
    Reply cleared thinking indicator

  3. Two quick questions in the same Concierge thread:
    Two quick questions thinking

  4. Switching chats and returning preserves the thinking indicator:
    Chat switch preserves thinking

  5. Offline send stays pending with no thinking indicator:
    Offline pending message without thinking indicator

  6. Reconnecting shows the thinking indicator and clears once Concierge replies:
    Reconnected thinking indicator
    Reconnected reply cleared

@inimaga
inimaga requested review from a team as code owners November 5, 2026 19:36
@melvin-bot
melvin-bot Bot requested review from TaduJR and removed request for a team November 5, 2026 19:36
@melvin-bot

melvin-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

@TaduJR Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested a review from trjExpensify November 5, 2026 19:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T13:34:55.674508Z 100a589 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@melvin-bot
melvin-bot Bot removed the request for review from a team November 5, 2026 19:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b92e65d38

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@TaduJR

TaduJR commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Do you need a review here @inimaga?

@inimaga

inimaga commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@TaduJR eventually, yes, when the PR comes off hold

@TaduJR

TaduJR commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Sure I will keep an eye on reviewing the code til then

@TaduJR

TaduJR commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Mac-Chrome.mp4

Pending sends are kept per message with the reply ID the client reserves, so an older reply or completion cannot clear a newer message. The server decision and completion events apply on every tab without waiting for that tab's request queue. The reconnect completion lookup is removed because the reply itself, or the worker's completion event, finishes each message.
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/hooks/useAgentZeroStatusIndicator.ts 97.68% <100.00%> (+0.99%) ⬆️
...s/Middleware/ReconcileConciergeProcessingStatus.ts 100.00% <100.00%> (ø)
src/libs/Middleware/register.ts 100.00% <100.00%> (ø)
src/libs/Network/SequentialQueue.ts 95.69% <100.00%> (+0.06%) ⬆️
src/libs/actions/Report/index.ts 76.93% <100.00%> (+0.02%) ⬆️
src/libs/actions/RequestConflictUtils.ts 99.33% <100.00%> (+<0.01%) ⬆️
src/libs/actions/User.ts 53.56% <100.00%> (+0.28%) ⬆️
src/pages/inbox/AgentZeroStatusContext.tsx 94.25% <100.00%> (+0.13%) ⬆️
src/selectors/ReportAction.ts 95.31% <100.00%> (+0.31%) ⬆️
src/selectors/ReportNameValuePairs.ts 86.84% <100.00%> (+1.12%) ⬆️
... and 1 more
... and 66 files with indirect coverage changes

The escalation notice is saved on the report by the server and comes back on
the next OpenReport, so the 120 second safety clear and the reconnect clear now
leave it in place and only drop the local waiting state. The live label a run
sends is a per-agent map, so a plain string on the report is the saved kind.

Also cover a pregenerated followup creating no waiting state, reuse the store's
fresh-entry lookup, name the reply-matching hook, and explain the move guards.
Keep both new selectors in src/selectors/ReportAction.ts. Main and this branch each added one middleware, so the registration tests now expect 20.
@inimaga inimaga changed the title [HOLD Web-E#58024] Show Concierge thinking immediately Show Concierge thinking immediately Nov 23, 2026
@inimaga

inimaga commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@TaduJR This PR is now ready for review.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 100a589181

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@MelvinBot

MelvinBot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Web test steps verification results: ⚠️ partial

No confirmed regression; web verification remains incomplete. All 72 tests across five focused unit suites passed, with React act() warnings.

Final state with the last question unanswered and thinking remaining

Step Status
Open Concierge DMOpened successfully.
✅
Send “How do I submit an expense?”Question sent and received a substantive reply.
✅
Thinking appears before request completesThinking appeared, but pre-completion timing was not established.
⚠️
Reply clears thinking without refreshAnother question was already pending, so isolated clearing was not verified.
⚠️
Send two questions quickly in the same threadBoth questions were sent before the first reply arrived.
✅
First reply leaves thinking visibleThinking remained for the newer unanswered question.
First follow-up answered while the newer question still shows thinking
✅
Second reply clears thinkingFinal reply did not arrive during a 90-second wait. Deployment of the required backend dependency was not confirmed; this is not attributed to the frontend changes.
Final state with the last question unanswered and thinking remaining
⚠️
Switch chats and return; thinking persists until replyThinking survived leaving and returning. Eventual completion remains unverified.
First follow-up answered while the newer question still shows thinking
⚠️
Open DM and go offlineAvailable browser tooling exposes no offline toggle.
⚠️
Send a question offlineBlocked by unavailable offline setup.
⚠️
Offline message is pending without thinkingBlocked by unavailable offline setup.
⚠️
Reconnect and observe thinkingOffline/reconnect transition could not be established.
⚠️
Reply clears thinking after reconnectBlocked by unavailable offline/reconnect setup.
⚠️
No JavaScript console errorsBrowser-console access was unavailable; absence of errors is unverified.
⚠️
Check for an extra legacy optimistic countNot reproduced; no reachable composer kickoff was identified. The hypothetical mixed-count case in AgentZeroOptimisticStore.ts:136–158 remains unverified, not a confirmed finding.
⚠️

view run · view recording

@TaduJR

TaduJR commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@inimaga

I think the PR description can be updated the WE PR is deployed?

@github-actions

Copy link
Copy Markdown
Contributor

🚧 inimaga has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@TaduJR TaduJR left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @inimaga.

The main flow works: the indicator shows right after send, two quick questions in one thread work, and switching chats keeps it. I left a few inline comments. Two more things:

  1. One reply for several pending messages. With 3 images sent in an existing thread, each file becomes its own turn (Report/index.ts#L1429). Concierge replied once at ~21 s, but "thinking" stayed until ~35 s, when the server finished the other two without a reply. Two quick questions answered in one reply did the same, ~7 s extra. Is that expected from the backend, or can it finish the other messages when it answers them together?

Comment thread src/libs/AgentZeroOptimisticStore.ts Resolved
Comment thread src/libs/actions/Report/index.ts Resolved
*/
function hasPersistedAgentZeroProcessingLabelSelector(reportNameValuePairs: OnyxEntry<ReportNameValuePairs>): boolean {
const indicator = reportNameValuePairs?.agentZeroProcessingRequestIndicator;
return typeof indicator === 'string' && !!indicator.trim();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every live label on staging came as a per-agent map. Does any backend path still write a live label as a plain string? If so, this treats it as saved and it no longer clears locally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed on the backend: No live progress path writes a plain string anymore. All live status updates are sent as a per-agent map. Only the persisted escalation and human-handling notices are written as plain strings, so treating non-empty strings as saved labels won't stop any live label from clearing locally.

Comment thread src/libs/AgentZeroOptimisticStore.ts Resolved
@inimaga

inimaga commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@TaduJR This is ready for another review round! Also added some screenshots for the testing.

Regarding your question:

One reply for several pending messages. With 3 images sent in an existing thread, each file becomes its own turn (Report/index.ts#L1429). Concierge replied once at ~21 s, but "thinking" stayed until ~35 s, when the server finished the other two without a reply. Two quick questions answered in one reply did the same, ~7 s extra. Is that expected from the backend, or can it finish the other messages when it answers them together?

That's expected from the backend today rather than something the client can infer safely.

When multiple messages are batched into the same backend run before it starts, the backend already finishes all of them together when that run completes. However, when extra messages (or the 2nd and 3rd files from a multi-attachment send in an existing thread, since each file is sent as a separate request) arrive after the first run is already in flight, they are queued into a follow-up run. The first run only knows about its own batch, so the extra messages stay pending until that follow-up run checks them and finishes without posting another reply.

Having the client clear all pending turns on a single reply would reintroduce the bug where an older reply prematurely hides the indicator for a genuinely newer question that still needs its own answer.

@inimaga
inimaga requested a review from TaduJR November 30, 2026 15:44

@TaduJR TaduJR left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@expensify-chore-bot

Copy link
Copy Markdown

@NicolasBonet Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot Bot changed the title Show Concierge thinking immediately [Payment due @TaduJR] Show Concierge thinking immediately Dec 1, 2026
@melvin-bot

melvin-bot Bot commented Dec 1, 2026

Copy link
Copy Markdown

🎯 @TaduJR, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - https://www.github.com/Expensify/Expensify/issues/695383.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

@TaduJR

TaduJR commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot

Please create the Payment issue on App side

@MelvinBot

Copy link
Copy Markdown
Contributor

Created Payment issue for TaduJR — Show Concierge thinking immediately review, assigned to TaduJR.

Payment timing and amount remain pending confirmation; the PR is not yet merged.


view run

@NicolasBonet
NicolasBonet merged commit d118405 into main Dec 1, 2026
49 of 51 checks passed
@NicolasBonet
NicolasBonet deleted the codex/concierge-immediate-thinking branch December 1, 2026 14:51
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🚧 NicolasBonet has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@OSBotify

OSBotify commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/NicolasBonet in version: 9.5.57-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR fixes the existing Concierge thinking indicator’s timing and reliability without adding a new workflow or making existing article guidance incorrect.


view run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants