Skip to content

feat: derive app-load skeleton gates from the request queue - #96394

Merged
mountiny merged 4 commits into
Expensify:mainfrom
callstack-internal:feat/apploadgate-migrate-consumers
Jul 22, 2026
Merged

mountiny merged 4 commits into
Expensify:mainfrom
callstack-internal:feat/apploadgate-migrate-consumers

Conversation

@BartekObudzinski

@BartekObudzinski BartekObudzinski commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Several full-page and skeleton loaders decide whether the app is still doing its initial load by reading the stored IS_LOADING_APP Onyx flag. That flag is a shadow of the request queue: it is set optimistically when the initial OpenApp request is enqueued and cleared when the request leaves the queue, but a reload or dropped response in between can strand it, leaving the loader up forever with no request running.

This change moves those consumers onto the queue-derived useIsAppLoadPending() hook, which reads directly whether an OpenApp request is currently in the SequentialQueue. The flag was already set and cleared atomically with that request, so healthy-path behavior is identical — the only difference is that a stranded flag can no longer pin a loader.

Scope is the consumers that read the flag as a plain loading gate. Consumers with different semantics (a true/false default that treats "unknown" as loading, completion checks, latches, or non-loader logic) are intentionally left on the flag. The flag, its writers, and the recovery watchdog are untouched — their removal is a separate change. Telemetry reasonAttributes keep their existing isLoadingApp key name (now sourced from the hook) for continuity in Sentry.

Migrated: WorkspaceSelector, DomainsListPage, DynamicNewReportWorkspaceSelectionPage, DynamicReportChangeWorkspacePage, SetDefaultWorkspacePage, ReportActions, MoneyRequestReportView, useReportActionsListModel, ProfilePage, WalletPage.

Fixed Issues

$ #96487
PROPOSAL:

Tests

  1. Cold-start the app. Verify the initial full-page / skeleton loaders show, then the content renders.
  2. Open each migrated screen (Profile, Wallet, Domains list, a workspace selector) during and after the initial load. Verify no endless loader.
  3. Reload the app mid initial-load, then reopen a migrated screen. Verify the loader resolves once OpenApp completes (no stuck loader).
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline, then open the migrated screens. Verify they do not sit on an endless skeleton and offline handling matches today.

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

@codecov

codecov Bot commented Jul 17, 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 54.94% <100.00%> (ø)
...ents/Search/FilterComponents/WorkspaceSelector.tsx 89.65% <100.00%> (ø)
src/hooks/useInFlightRequests.ts 100.00% <100.00%> (ø)
src/hooks/useReportActionsListModel.ts 100.00% <100.00%> (ø)
...c/pages/DynamicNewReportWorkspaceSelectionPage.tsx 86.13% <100.00%> (+0.28%) ⬆️
src/pages/inbox/ReportActions.tsx 100.00% <100.00%> (ø)
src/pages/settings/Profile/ProfilePage.tsx 95.09% <100.00%> (-0.05%) ⬇️
src/pages/DynamicReportChangeWorkspacePage.tsx 0.00% <0.00%> (ø)
src/pages/SetDefaultWorkspacePage.tsx 0.00% <0.00%> (ø)
src/pages/domain/DomainsListPage.tsx 0.00% <0.00%> (ø)
... and 1 more
... and 436 files with indirect coverage changes

@BartekObudzinski
BartekObudzinski marked this pull request as ready for review July 20, 2026 15:36
@BartekObudzinski
BartekObudzinski requested review from a team as code owners July 20, 2026 15:36
@melvin-bot
melvin-bot Bot requested review from DylanDylann and joekaufmanexpensify and removed request for a team July 20, 2026 15:36
@melvin-bot

melvin-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

@DylanDylann 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 review from a team and mountiny and removed request for a team July 20, 2026 15:36
@melvin-bot

melvin-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

@mountiny 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]

@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: 9dc81dff6b

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


if (isLoadingApp) {
const reasonAttributes: SkeletonSpanReasonAttributes = {context: 'WalletPage', isLoadingApp: !!isLoadingApp};
if (isAppLoadPending) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep skeletons gated until OpenApp updates are flushed

When another write follows OpenApp in the sequential queue, this becomes false before the app data is available: SequentialQueue.process() removes the completed request at src/libs/Network/SequentialQueue.ts:199-203, while write response/finally updates are deliberately held until the entire queue is empty and flushed at lines 424-427. This occurs, for example, when clearOnyxAndResetApp() enqueues OpenApp and then restores previously queued writes; a slow or retrying restored write can therefore make Wallet and the other migrated screens render cleared/stale Onyx data for an extended period, whereas IS_LOADING_APP remained true until that flush applied its finallyData.

Useful? React with 👍 / 👎.

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

No product review needed.

@joekaufmanexpensify
joekaufmanexpensify removed their request for review July 20, 2026 20:52
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions
github-actions Bot requested review from luacmartins and tgolen July 21, 2026 07:18
@github-actions

Copy link
Copy Markdown
Contributor

This PR adds a new Onyx.connectWithoutView call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @luacmartins) — a review from any one of them is enough. Please add a link in your PR description to the Slack discussion where the @frontend-performance team approved using connectWithoutView here.

@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

let me validate or prepare other approach

Co-authored-by: Cursor <cursoragent@cursor.com>
@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

I removed it Onyx.connectWithoutView sorry for that 🙏

Comment thread src/hooks/useInFlightRequests.ts Outdated

// HAS_LOADED_APP is committed only after deferred OpenApp updates flush. Combining both existing
// markers covers that gap without trusting an IS_LOADING_APP value stranded after a completed load.
return hasPendingOpenApp || (isLoadingApp === true && hasLoadedApp !== true);

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.

@BartekObudzinski I understand this gap. My question is whether we actually need to handle it at all. Could we drop the IS_LOADING_APP/HAS_LOADED_APP fallback and rely on hasPendingOpenApp only? Do you see any problem with that?

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.

Honestly, I'd like to remove isLoadingApp completely

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.

We can't drop it fully yet, but the reliance is minimal and self limiting.

hasPendingOpenApp goes false the moment OpenApp leaves the queue, which is before its finallyData flushes (the queue holds those writes until it drains). In that window the app data and HAS_LOADED_APP are not committed yet, so a pure hasPendingOpenApp gate would flash cleared or stale data on the migrated screens. That is the P1 Codex flagged.

The isLoadingApp === true && hasLoadedApp !== true term exists only to cover that first load flush window, and it is self healing for the stranded flag case: HAS_LOADED_APP is a permanent latch set only after the flush, so once the app has loaded it stays true and the term is false regardless of a stranded IS_LOADING_APP. A later reload runs ReconnectApp, not OpenApp, so nothing is left pending to strand.

Removing isLoadingApp completely is exactly the goal of the dedicated cleanup PR that deletes the flag and its writers. It can't come out here because these screens still need the flush window cover and other consumers still read it. If you would rather not lean on the markers, we can pair the removal with a different flush signal in that PR.

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.

Correction to my note above: the marker was not fully self healing. An account switch preserves HAS_LOADED_APP true while firing a real OpenApp, and its data plus the IS_LOADING_APP clear are deferred to the queue drain, so gating on HAS_LOADED_APP dropped the skeleton mid flush (the P2 Codex flagged). I replaced the marker with a process session latch keyed on an observed OpenApp instead, which covers that window and still ignores a stranded flag on reload, since a reload runs ReconnectApp not OpenApp so the latch is never set.

@DylanDylann

DylanDylann commented Jul 22, 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
Screen.Recording.2026-07-22.at.15.12.58.mov
Android: mWeb Chrome
Screen.Recording.2026-07-22.at.15.10.48.mov
iOS: HybridApp
Screen.Recording.2026-07-22.at.15.12.35.mov
iOS: mWeb Safari
Screen.Recording.2026-07-22.at.15.09.57.mov
MacOS: Chrome / Safari
Screen.Recording.2026-07-22.at.15.07.19.mov

@DylanDylann

Copy link
Copy Markdown
Contributor

@codex review

@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: 60ef1cc863

ℹ️ 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/hooks/useInFlightRequests.ts Outdated

// HAS_LOADED_APP is committed only after deferred OpenApp updates flush. Combining both existing
// markers covers that gap without trusting an IS_LOADING_APP value stranded after a completed load.
return hasPendingOpenApp || (isLoadingApp === true && hasLoadedApp !== true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep app-load pending through account-switch OpenApp flush

When HAS_LOADED_APP is already true (for example, delegate transitions preserve it while seeding IS_LOADING_APP=true before calling openApp()), this expression stops reporting pending as soon as the OpenApp leaves PERSISTED_ONGOING_REQUESTS. The sequential queue clears the ongoing request before it flushes the queued OpenApp Onyx updates and finallyData, so the newly migrated screens can render against cleared or stale account data instead of the loading skeleton during that gap; keep the post-request IS_LOADING_APP gate for OpenApp instances that were actually observed rather than keying it only on HAS_LOADED_APP.

Useful? React with 👍 / 👎.

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.

I think that's @BartekObudzinski's intention now as explained above

@melvin-bot
melvin-bot Bot requested a review from mountiny July 22, 2026 08:16
@DylanDylann

Copy link
Copy Markdown
Contributor

Let me check the latest update again

@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

thanks there i put and update #96394 (comment)

@DylanDylann

Copy link
Copy Markdown
Contributor

@BartekObudzinski The thing I'd actually want to know before endorsing all of this: how visible is that flash, really? If it's only 1–2 frames and only on cold start, a simpler solution might be acceptable, and this cleverness would be buying us very little

@DylanDylann

Copy link
Copy Markdown
Contributor

The current implementation does ensure the app works well, but it feels a bit over-engineered

@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

@DylanDylann Thanks, I verified both cases directly.

During normal account switches, I did not observe stale data appearing. I also tested a delayed restored write with OpenApp followed by AddComment. After OpenApp was removed, the current latch correctly stayed true while AddComment remained. Using only hasPendingOpenApp returned false too early.

The simpler approach is not equivalent and can remove the skeleton before deferred OpenApp data is flushed. I think we should keep the current implementation.

@DylanDylann

Copy link
Copy Markdown
Contributor

I'll be waiting for the cleanup PR to simplify it if possible 😄

@mountiny mountiny 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.

Are there no docs that need to be updated?

@mountiny
mountiny merged commit 2246df4 into Expensify:main Jul 22, 2026
34 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

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.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.43-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 I reviewed the changes in this PR against the help site content under App/docs/articles.

No help site changes are required, so I did not create a draft PR.

Why: This PR is a purely internal refactor. It migrates several loader consumers from the stored IS_LOADING_APP Onyx flag to the queue-derived useIsAppLoadPending() hook. The description confirms healthy-path behavior is identical — the only observable difference is a bug fix (a stranded flag can no longer pin a loader forever). The diff touches only internal plumbing (hook usage and Sentry reasonAttributes telemetry keys); there are no changes to user-facing copy, src/languages/* strings, UI labels, feature/tab/setting names, buttons, or workflows.

Expensify's help articles document user-facing product features and workflows. Loading skeletons/spinners and their internal trigger mechanism are not documented there, so nothing needs to be updated.

@BartekObudzinski — no linked help site PR was created since no docs changes are needed. If you believe a specific article should be updated as a result of this change, let me know which one and I'll take another look.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.4.43-1 🚀

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

Bundle Size Analysis (Sentry):

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.

7 participants