Perf: create derived TODOS - #81188
Conversation
…to perf/span-open-report-todos
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.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da76cf224d
ℹ️ 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".
|
I can start reviewing this immediately. |
|
@codex review |
|
@Krishna2323 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] |
|
I haven’t found any blocking issues so far and am working on the checklist. |
| [CONST.SEARCH.SEARCH_KEYS.SUBMIT]: buildData(todosReports?.reportsToSubmit), | ||
| [CONST.SEARCH.SEARCH_KEYS.APPROVE]: buildData(todosReports?.reportsToApprove), | ||
| [CONST.SEARCH.SEARCH_KEYS.PAY]: buildData(todosReports?.reportsToPay), | ||
| [CONST.SEARCH.SEARCH_KEYS.EXPORT]: buildData(todosReports?.reportsToExport), |
There was a problem hiding this comment.
With this approach, we're still building the data in the hook. Would it be better to store the built data in the derived value?
There was a problem hiding this comment.
The comment above is NAB since this already introduces significant gains in performance. That said, let me know what you think of it.
There was a problem hiding this comment.
I already tried to put this also inside DERIVED.TODOS but it creates a huge object (like 5x bigger) which cause onyx internal kills all gains from it. There was like additional 300ms spend on recomputing that derived value. Right know this hook is used in single place (context)
There was a problem hiding this comment.
Ah I see. Thanks for the context
There was a problem hiding this comment.
I shared some more context in issue, as it was my first idea #77173 (comment)
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid_native.mp4Android: mWeb Chromeandroid_chrome.mp4iOS: HybridAppios_native.mp4iOS: mWeb Safariios_safari.mp4MacOS: Chrome / Safariweb_chrome_offline.mp4web_chrome.mp4 |
|
There are some Onyx console errors. I’m checking whether they also exist on main. errors_onyx.mp4 |
|
Can reproduce these errors ^ on main also, asked in open source channel. |
Krishna2323
left a comment
There was a problem hiding this comment.
Code looks good to me and works well in both online and offline modes. 🚀
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
@LukasMod we have conflicts |
|
No product review needed |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
…to perf/span-open-report-todos
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.3.13-1 🚀
|
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.3.15-0 🚀
|
|
@vincdargento Looks like its proper behavior based on #81355 |
|
🚀 Deployed to production by https://github.com/lakchote in version: 9.3.15-10 🚀
|
Explanation of Change
Move reusable categorization logic (categorizing reports into submit/approve/pay/export buckets) from the
useTodoshook into an Onyx derived value atONYXKEYS.DERIVED.TODOS. This derived value computes only the categorized report arrays and transaction mappings at the Onyx level. Components can then use selectors to extract just the report counts from the derived value, avoiding the heavy search results data construction entirely. TheuseTodoshook subscribes to this derived value and builds the full search results data structure only when required by SearchContext, ensuring the expensive computation runs fewer times.Fixed Issues
$ #81353
Tests
Offline tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android-native.mov
Android: mWeb Chrome
android-web.mov
iOS: Native
ios-native.mov
iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
web.chrome.mov