perf: share scans across useShortMentionsList instances - #96617
Conversation
Every mounted useShortMentionsList instance scanned the entire personal details collection and re-ran it on every personal details write. The scan now lives in a module-level memoized function shared by all instances, subscribed via a useOnyx selector so consumers only re-render when the username list content actually changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
…licit Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@ZhenjaHorbach 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] |
|
#96500 needs to go first |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5b25984b0
ℹ️ 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".
The domain-wide mention list must not shrink to the people appearing in search results when the hook renders inside SearchScopeProvider. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Addressed AI feedbacks. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp2026-07-22.15.49.28.movAndroid: mWeb Chrome2026-07-22.15.49.28.moviOS: HybridApp2026-07-22.15.49.28.moviOS: mWeb Safari2026-07-22.15.49.28.movMacOS: Chrome / Safari2026-07-22.15.44.41.mov |
|
LGTM! |
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.43-0 🚀
|
|
🤖 I reviewed the changes in this PR and no help site documentation updates are required. Why: This is a pure performance refactor of the internal There is no change to any user-facing behavior, feature name, UI label, tab, setting, or flow — short mentions (typing No draft PR was created. @adhorodyski, if you believe any user-facing behavior changed that should be documented, let me know and I'll create the help site PR. |
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.4.43-1 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
useShortMentionsListscans the whole personal details collection (about 50k entries on large accounts) to build the list of usernames on the current user's private email domain. The hook mounts once per composer input and once per short mention in every visible message. Each instance ran its own scan, and every personal details write (avatar, presence, display name) re-ran all of them.This PR moves the scan into one shared cached function, so all instances reuse a single result per personal details update. The scan itself is now a single loop instead of a map plus filter pass, and it drops a redundant public-domain check per entry (once the current user's domain is known to be private, a matching domain must be private too).
The hook reads the data through
useOnyxwith a selector, which compares the small output list by value. Components re-render only when the username list really changes, for example when someone joins the domain. The current user's email comes from auseOnyx(ONYXKEYS.SESSION)selector, so the list also recomputes when the signed-in user changes. A unit test covers that switch.Consumers (
RNMarkdownTextInput,ShortMentionRenderer) are unchanged and the hook returns the same shape.Follow-up to #96500 (same issue) but independent of it: no shared files, branched from
main.Fixed Issues
$ #96612
PROPOSAL:
Tests
@coworker(without the domain) in the composer. Verify it is highlighted as a mention while typing.@coworker. Verify the rendered message styles it as a user mention, and@yourshortnameis styled as a self-mention.@nosuchuser. Verify it renders as plain text.Offline tests
Same as Tests. Mention highlighting is computed from locally cached personal details and works offline.
QA Steps
Same as Tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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.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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari