Skip to content

Show short mentions and current user mention in MarkdownTextInput with styling #54037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Kicu
Copy link
Member

@Kicu Kicu commented Dec 12, 2024

Explanation of Change

This PR introduces short mentions to the App. These are mentions of style @ + first part of user email (or login), ex: @john.doe, @user123.

We are only highlighting a login (short-mention) for users that we have already interacted with in the app.
The reason is that there is no place other than local Onyx data to get knowledge whether a string like: @some.body is an actual login of Expensify user or just a random string. So a user types in a login of someone he has never interacted with it will not be highlighted.

This PR builds upon (and uses):

Details:

  • we consume the new mention-short tag from ExpensiMark and inside worklet we compare the mention with the actual list of user logins
  • if a user login matches, then we treat it as correct mention and apply styling (mention-user style in LiveMarkdown)
  • if a login doesn't match, we strip any styling from it so we get plain text (just like we would get before this PR)
  • the list of all available user logins are based on Onyx data and can be very long; because of that sharedValue is used to pass the list to a worklet.

IMPORTANT:
this PR should be merged together with this Hybrid bump: https://github.com/Expensify/Mobile-Expensify/pull/13451
no Hybrid changes required

Fixed Issues

$ #38025
PROPOSAL:

Tests

  1. Open composer on any chat
  2. use autocomplete list to mention someone - the short mention should be styled with blue background and work
  3. manually type in any first part of email of a person you know* - it should get blue background
  4. mention yourself and it should have green background
  • we are only able to highlight a short-mention of user that you previously had an interaction in expensify

Offline tests

QA Steps

Same as Tests

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
    • MacOS: Desktop
  • 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 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
rec-mention-andr.mp4
Android: mWeb Chrome
iOS: Native
rec-mention-ios.mp4
iOS: mWeb Safari
rec-mention-ios-web.mp4
MacOS: Chrome / Safari
rec-mention-web.mp4
MacOS: Desktop

@Kicu Kicu force-pushed the kicu/38025-green-mention branch 2 times, most recently from b85d761 to a140a7f Compare December 16, 2024 10:02
@Kicu Kicu force-pushed the kicu/38025-green-mention branch 2 times, most recently from f179eee to 4ddb91e Compare December 31, 2024 09:46
@Kicu Kicu changed the title WIP Show current user mention in MarkdownTextInput with green outline [WIP] Show current user mention in MarkdownTextInput with green outline Dec 31, 2024
@Kicu Kicu force-pushed the kicu/38025-green-mention branch from 4ddb91e to 8a8e5cd Compare December 31, 2024 10:15
@Kicu Kicu force-pushed the kicu/38025-green-mention branch 5 times, most recently from d88cb60 to 43cf3f3 Compare January 9, 2025 13:23
@Kicu
Copy link
Member Author

Kicu commented Jan 9, 2025

This PR is currently awaiting merge and release of: Expensify/expensify-common#824

@Kicu Kicu force-pushed the kicu/38025-green-mention branch from 43cf3f3 to eca0668 Compare January 13, 2025 09:01
@Kicu Kicu changed the title [WIP] Show current user mention in MarkdownTextInput with green outline Show current user mention in MarkdownTextInput with green outline Jan 13, 2025
@Kicu Kicu changed the title Show current user mention in MarkdownTextInput with green outline Show short mentions and current user mention in MarkdownTextInput with styling Jan 13, 2025
@Kicu Kicu force-pushed the kicu/38025-green-mention branch from eca0668 to 508c4a3 Compare January 20, 2025 12:01
@Kicu Kicu force-pushed the kicu/38025-green-mention branch from 508c4a3 to d09c805 Compare February 5, 2025 16:08
@Kicu
Copy link
Member Author

Kicu commented Feb 6, 2025

Update with description how to test this here: #38025 (comment)

@shubham1206agra
Copy link
Contributor

Screen.Recording.2025-02-18.at.1.46.45.PM.mov

@Kicu Can you please check this and verify if we need to change something in clipboard?

@Kicu
Copy link
Member Author

Kicu commented Feb 21, 2025

@shubham1206agra So in this task I focused only on the part of adding styling to short-mentions in the Live markdown input.
As far as I can see, there is some some code that runs on submitting, and all these "short mentions" are change to full version when being send to backend. Check my screen:
Screenshot 2025-02-21 at 14 01 18

So after they're back from backend, we get full emails and that is what we see on your video. I believe everything related to copy-to-clipboard from this point would be working same as before.
Whether this behaviour (highlighting short mention -> but sending full mention to api) is correct or we want to change it I don't know - perhaps @puneetlath can give his opinion?

@puneetlath
Copy link
Contributor

Sending as full mention to the API seems correct to me. That's what the back-end expects. The short mention is just a rendering thing on the client, not something the back-end is aware of.

@Kicu
Copy link
Member Author

Kicu commented Feb 27, 2025

There seems to be some problems with publishing to npm: https://github.com/Expensify/expensify-common/actions/runs/13502875291

I've pinged people on slack and will be waiting till this gets solved. Once the version is published I will make this PR reviewable (probably next week).
Sorry this is taking so long 😅

@puneetlath
Copy link
Contributor

Ah gotcha. Were you able to get the help you needed on the npm publishing issue? Would you mind linking the Slack thread here?

@Kicu
Copy link
Member Author

Kicu commented Mar 4, 2025

@puneetlath yeah the newest version of expensify-common is now published.
I plan to have this PR ready for final review today or tomorrow 🚀

@Kicu Kicu force-pushed the kicu/38025-green-mention branch from d09c805 to 6801386 Compare March 4, 2025 15:27
Copy link
Contributor

github-actions bot commented Mar 4, 2025

⚠️ This PR is possibly changing native code, it may cause problems with HybridApp. Please run an AdHoc build to verify that HybridApp will not break. ⚠️

@puneetlath
Copy link
Contributor

Great!

@Kicu
Copy link
Member Author

Kicu commented Mar 14, 2025

@shubham1206agra I pused a commit fixing the green long mention highlighting.
Here's what I tested:

Screen.Recording.2025-03-14.at.09.43.32.mov

As for the rest minor bugs:

On editing the comment, the short mention expands into full emails

same as on prod

There is a warning

About reanimated warning: I'm not sure what causes it. I asked @tomekzaw who works with reanimated to take a quick look at the code and he didn't see anything wrong with sharedValue usage in this PR. I checked on production and I noticed that we have a similar warning running when you open Search (cmd+k) - which uses similar code. We could probably create an issue to investigate this.

I think these are small enough that we could merge this PR.

I have a lot of work with ReportsView in here: #57508 - so if you find any other bugs then I can only work on them once I'm done with the other task.
Again sorry it's taking so long and thanks!

@shubham1206agra
Copy link
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 tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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: Native
Screen.Recording.2025-03-13.at.7.20.45.PM.mov
Android: mWeb Chrome
Screen.Recording.2025-03-13.at.6.23.51.PM.mov
iOS: Native
Screen.Recording.2025-03-13.at.6.51.53.PM.mov
iOS: mWeb Safari
Screen.Recording.2025-03-13.at.6.14.48.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2025-03-13.at.6.07.07.PM.mov
MacOS: Desktop
Screen.Recording.2025-03-13.at.6.39.54.PM.mov

Copy link
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@melvin-bot melvin-bot bot requested a review from thienlnam March 14, 2025 14:07
thienlnam
thienlnam previously approved these changes Mar 15, 2025
Copy link
Contributor

@thienlnam thienlnam left a comment

Choose a reason for hiding this comment

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

@puneetlath Will leave final approve / merge to you

Copy link
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@Kicu
Copy link
Member Author

Kicu commented Mar 17, 2025

  1. I see some tests failing - tests fixed
  2. please remember that if you want to merge this, then this should be merged alongside https://github.com/Expensify/Mobile-Expensify/pull/13451 merging another PR no longer needed

Copy link
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@mountiny
Copy link
Contributor

Sorry, wrong PR

Copy link
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@puneetlath puneetlath merged commit 4318f0f into Expensify:main Mar 19, 2025
25 checks passed
@OSBotify
Copy link
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.

Copy link
Contributor

🚀 Deployed to staging by https://github.com/puneetlath in version: 9.1.16-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅
🤖🔄 android HybridApp 🤖🔄 success ✅
🍎🔄 iOS HybridApp 🍎🔄 success ✅

Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 9.1.16-4 🚀

platform result
🤖 android 🤖 true ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅
🤖🔄 android HybridApp 🤖🔄 failure ❌
🍎🔄 iOS HybridApp 🍎🔄 failure ❌

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