Skip to content

Show Concierge thinking indicator on expense reports and threads - #97363

Open
chiragsalian wants to merge 8 commits into
mainfrom
chirag-concierge-thinking-expense-reports
Open

Show Concierge thinking indicator on expense reports and threads#97363
chiragsalian wants to merge 8 commits into
mainfrom
chirag-concierge-thinking-expense-reports

Conversation

@chiragsalian

@chiragsalian chiragsalian commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

The backend already emits Concierge status updates for expense reports — shouldEmitConciergeStatusUpdates in ProcessAgentZeroRequest.cpp includes isMoneyRequestReportWithTransactions, and the labels reach Onyx correctly. Nothing on the client rendered them. Two independent blockers:

  • AgentZeroStatusProvider only mounted for Concierge DMs, #admins rooms and custom-agent chats. It re-derived "does an agent respond here?" from chat type and had drifted from the server's rule, so candidateAgentIDs stayed empty on expense reports and threads.
  • The /search/r/<reportID> tree (MoneyRequestReportView) mounted neither the status context nor the indicator at all, so that screen showed nothing even once the gate allowed it.

Changes:

  • Mount the gate whenever the agentZeroProcessingRequestIndicator NVP names an active agent, so the client stops re-deriving where agents respond. The chat-type arms stay, since they mount the reasoning Pusher subscription before the first NVP lands.
  • Wrap both MoneyRequestReportView feed branches in AgentZeroStatusProvider and fill the unified list's already-supported listFooterComponent slot. That list is not inverted, so the footer is the bottom of the message feed — the same position the indicator occupies in the inverted ReportActionsList.

Note: reasoning summaries ("Concierge is thinking" expandable details) were absent from my local run because the LLM returned no reasoningSummary entries for it, not because of a gate. emitConciergeReasoning is governed by the same shouldEmitConciergeStatusUpdates that was already true. With the UI fixed, reasoning should render whenever the model produces it.

Fixed Issues

$ #97378
PROPOSAL:

Tests

  1. Open a new expense report. Add 2-3 expenses to it.
  2. Then i opened the report and left a message like @concierge@expensify.com can you list how many expenses categorized advertising are there?
  3. Confirmed i saw "Concierge is thinking".
Google Chrome 2026-07-29 12 19 23
  1. Confirmed, I saw Concierge tool call status messages.
Google Chrome 2026-07-29 12 19 33
  1. Confirmed, Concierge responded to me.
image
  • Verify that no errors appear in the JS console

Offline tests

None

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

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 followed proper code patterns (see Reviewing the code)
    • 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 followed the guidelines as stated in the Review Guidelines
  • 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 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 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.
  • 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

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

The provider only mounted for Concierge DMs, #admins rooms and custom-agent
chats, so candidateAgentIDs stayed empty everywhere else and the thinking
bubble never rendered — even though Auth already emits status updates for
expense reports with transactions and the labels reached Onyx.

Mount the gate whenever the processing-indicator NVP names an active agent,
so the client stops re-deriving where agents respond. The chat-type arms stay
for the eager reasoning subscription before the first NVP arrives.
The /search/r/<reportID> tree mounted neither the AgentZero status context nor
the indicator itself, so mentioning Concierge on an expense report showed
nothing even once the gate allows it.

Wrap both feed branches in AgentZeroStatusProvider and fill the unified list's
already-supported listFooterComponent slot. No draft guard is needed here: that
tree has no ConciergeDraftProvider, so no Concierge reply streams into it.
Three of these fail without the gate change; the 'stays inert' case is the
negative control that must keep passing so the gate doesn't start mounting for
every report.
@chiragsalian
chiragsalian requested review from a team as code owners July 29, 2026 17:52
@chiragsalian chiragsalian self-assigned this Jul 29, 2026
@melvin-bot
melvin-bot Bot requested review from ChavdaSachin and joekaufmanexpensify and removed request for a team July 29, 2026 17:52
@melvin-bot

melvin-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

@ChavdaSachin 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 removed the request for review from a team July 29, 2026 17:52
@chiragsalian
chiragsalian requested a review from Copilot July 29, 2026 17:52

Copilot AI 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.

Pull request overview

This PR enables the existing “Concierge is thinking…” / AgentZero processing indicator UI to appear on money request expense reports and their threads (e.g. /search/r/<reportID>), aligning the client’s gating logic with the server’s shouldEmitConciergeStatusUpdates by keying off the processing-indicator NVP the backend already writes.

Changes:

  • Extend AgentZeroStatusProvider’s guard logic to mount whenever the server’s agentZeroProcessingRequestIndicator names active agent(s), not only for specific chat types.
  • Wrap MoneyRequestReportView’s feed area in AgentZeroStatusProvider so the status context is available on expense report/search views.
  • Render ConciergeThinkingMessage at the bottom of the non-inverted unified list via listFooterComponent in MoneyRequestReportActionsList.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/unit/AgentZeroStatusContextTest.ts Adds unit coverage for server-driven gating on expense reports/threads and indicator clearing behavior.
src/pages/inbox/AgentZeroStatusContext.tsx Mounts status gate when server indicates processing; passes server agent IDs into the gate to avoid duplicate subscription logic.
src/components/MoneyRequestReportView/MoneyRequestReportView.tsx Wraps both feed branches with AgentZeroStatusProvider so the indicator context exists on money request report views.
src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx Adds ConciergeThinkingMessage as a unified list footer for the non-inverted list variant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@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: a4ec38f3ec

ℹ️ 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".

Comment thread src/pages/inbox/AgentZeroStatusContext.tsx
@chiragsalian chiragsalian changed the title Show Concierge thinking indicator on expense reports and threads [WIP] Show Concierge thinking indicator on expense reports and threads Jul 29, 2026
Returning bare children for inert reports meant the false-to-true flip on the
indicator NVP inserted the gate above an already-mounted feed, remounting
MoneyRequestReportActionsList/ReportActionsList and dropping scroll position
exactly as the indicator appeared.

Always mount the gate and make it inert instead, so children keep a stable
position. The inert gate skips the reasoning subscription and keys its
report-actions read off nothing, so non-AgentZero reports stay as cheap as before.
The indicator renders in the list footer, outside the FlashList data that
scrollToBottom targets, and this list is not inverted and sets no
autoscrollToBottomThreshold — so a user at the bottom got the bubble just below
the viewport. The inverted ReportActionsList gets this for free, which is why
only the money-request view needs it.

Scroll only when already at the bottom, and only once per appearance, so a user
reading history further up is never yanked back down.
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
.../MoneyRequestReportView/MoneyRequestReportView.tsx 55.43% <100.00%> (+0.48%) ⬆️
src/pages/inbox/AgentZeroStatusContext.tsx 93.44% <100.00%> (-1.48%) ⬇️
...equestReportView/MoneyRequestReportActionsList.tsx 59.80% <53.84%> (-0.27%) ⬇️
... and 11 files with indirect coverage changes

@chiragsalian chiragsalian changed the title [WIP] Show Concierge thinking indicator on expense reports and threads Show Concierge thinking indicator on expense reports and threads Jul 29, 2026
@mkhutornyi

Copy link
Copy Markdown
Contributor

@chiragsalian
chiragsalian requested review from mkhutornyi and removed request for ChavdaSachin July 29, 2026 20:03
@chiragsalian

Copy link
Copy Markdown
Contributor Author

David has a webinar tomorrow and asked me if i could get this reviewed/merged and CP'd to staging soon. Hopefully to improve the demo experience.

@mkhutornyi

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 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
    • 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
    • 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 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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 8c5f9403d7

ℹ️ 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

Copy link
Copy Markdown
Contributor

Review: Show Concierge thinking indicator on expense reports and threads

Verdict: Looks solid and well-reasoned. The two-blocker framing is correct, the fix is minimal, and the comments explain why rather than what. All CI is green (typecheck, ESLint, React Compiler compliance, unit tests). No blocking issues found — a few minor observations below.

What it does

  • Reworks AgentZeroStatusProvider to gate on the processing-indicator NVP (isServerProcessing) in addition to the chat-type arms, so the client stops re-deriving Auth's shouldEmitConciergeStatusUpdates rule. Keeps the chat-type arms so the reasoning Pusher subscription is live before the first NVP lands.
  • Switches the gate from an early return children to an always-mounted isActive flag, so a report flipping to "processing" mid-session doesn't remount the feed (proven by the new keeps children mounted test).
  • Wraps both MoneyRequestReportView feed branches in the provider and fills the non-inverted list's listFooterComponent slot.

Strengths

  • The always-mounted gate + isActive gating of the reasoning subscription, the newestReportAction key, and the candidate set is the right call — it avoids the remount-the-whole-feed problem cleanly.
  • Reading serverAgentIDs once in the provider and passing it down avoids a duplicate Onyx subscription in the gate.
  • Test coverage for the new arm is genuinely good: server-named agent on expense report + thread, inert state (asserts nothing subscribes), clear-on-NVP-clear, and mount stability.

Minor observations (non-blocking)

  1. Scroll-to-end effect relies on reportScrollManager being referentially stable. In MoneyRequestReportActionsList, the effect schedules a setTimeout and cleans it up on re-run. useReportScrollManager returns a fresh object literal each call, so if React Compiler ever failed to memoize it, a re-render within the 100ms window would clearTimeout and then bail early on hasScrolledForThinkingIndicatorRef, so scrollToEnd() would never fire. It works today (Compiler memoizes it, and existing effects in this file already depend on reportScrollManager), just flagging the fragility — a ref-based guard would be immune.
  2. Provider and footer source reportID differently. The provider is keyed on report.reportID while the footer's ConciergeThinkingMessage reportID={reportIDFromRoute} and its useAgentZeroStatusIndicator read the route param. These are equal in practice, so candidateAgentIDs (from report.reportID's NVP) and the per-agent status (from reportIDFromRoute) always agree — but worth a mental note since a divergence would silently mismatch.
  3. Transient gap on activation. When isActive flips false→true, the newestReportAction Onyx key switches from undefined to reportID; for the render before it hydrates, the ADDCOMMENT-suppression can't run, so a bubble could flash for a beat even if the reply already landed. Very low impact and self-corrects.

Test coverage

The context-level behavior is well covered. Not covered (and hard to unit test): the footer actually rendering in MoneyRequestReportActionsList, and the scroll-to-end behavior. Given the manual test screenshots in the PR body, that's acceptable.

@MelvinBot

Copy link
Copy Markdown
Contributor

Regression hunt

Verdict: no correctness regressions found. Previously-working AgentZero chats (Concierge DMs, #admins rooms, custom-agent DMs) behave byte-for-byte the same, and the widest-blast-radius change (the gate now always mounts) is adequately bounded. A few low-impact notes below, none blocking.

Biggest blast radius — verified safe

The refactor swaps the provider's early return children for an always-mounted AgentZeroStatusGate with an isActive flag. Because AgentZeroStatusProvider wraps every inbox report (not just expense reports), this now runs for every report you open. The net-new work per plain non-agent report is small and inert:

Agent-chat parity — no regression

For isActive === true, the candidate seed, Concierge/custom-agent add, current-user removal, ADDCOMMENT suppression, and sort all collapse to their pre-PR form; serverAgentIDs is read with the same key + selector, just hoisted into the provider. A Concierge DM stays isActive via isConciergeChat even as isServerProcessing toggles, so the new isActive dep causes no extra subscribe/unsubscribe cycle.

No double-provider in the search tree

MoneyRequestReportView's new provider only serves the /search/r/ tree — the inbox renders MoneyRequestReportActionsList directly under ReportScreen's existing provider, and ReportActionsList mounts no provider of its own. So no report gets two providers (which would double the reasoning subscription).

Low-impact notes (not regressions)

  1. Global kickoff subscription: every mounted gate now subscribes to the global CONCIERGE_THINKING_KICKOFF scalar, so a kickoff re-renders all mounted gates. Negligible — typically one ReportScreen is mounted.
  2. Transient bubble flash: only on the new server-driven arm, at the isActive false→true edge newestReportAction is briefly undefined before it hydrates, so ADDCOMMENT-suppression can miss for a sub-frame. This path had no bubble at all before the PR, so it's new behavior, not a regression — bounded by cached report-actions latency.
  3. Scroll-to-end effect (repeating from my earlier review): the footer scroll effect depends on reportScrollManager being referentially stable — fine today via React Compiler, but a re-render inside the 100ms window would clearTimeout and then bail on hasScrolledForThinkingIndicatorRef, silently dropping the scroll. A ref guard would be immune.

CI is fully green (typecheck, ESLint, React Compiler compliance, unit tests), and the new tests cover the server-driven arm, inert state, NVP-clear, and mount stability.

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.

4 participants