-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[$250] @-mentions don't work in the same message as an inline code block or a multi-line code block #52214
Comments
Triggered auto assignment to @stephanieelliott ( |
Triggered auto assignment to @MonilBhavsar ( |
Edited by proposal-police: This proposal was edited at 2024-11-08 08:59:32 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.@-mentions don't work if backtick or code block appeared anywhere after @-mentions What is the root cause of that problem?When submitting a comment, we invoke buildOptimisticAddCommentReportAction in addActions, followed by getParsedComment, and then Lines 4262 to 4271 in c658375
There is an issue with Line 2983 in c658375
Apparently, this regex (?![^\`]*`) is used to exclude As a result, mention like ''@ra-md `code` or @ra-md `" will prevent the mention from working correctly. What changes do you think we should make in order to solve the problem?Modify the regex like this: SHORT_MENTION: new RegExp("(?<!`)@[\\w\\-\\+\\'#@]+(?:\\.[\\w\\-\\'\\+]+)*(?!`)", 'gim'), This regex excludes mention only if it’s inside a code block, but it won't exclude the mention if there’s a backtick or code block anywhere later in the string after the mention. What alternative solutions did you explore? (Optional) |
This can be worked externally. Exporting... |
Job added to Upwork: https://www.upwork.com/jobs/~021854839507953800276 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rayane-djouah ( |
@rayane-djouah could you please take a look at this proposal when you have a moment please #52214 (comment) |
Reviewing 👀 |
ProposalPlease re-state the problem that we are trying to solve in this issue.@-mentions don't work in the same message as an inline code block or a multi-line code block What is the root cause of that problem?Our short mention regex doesn't allow any backtick after the mention Line 2984 in 533aed6
What changes do you think we should make in order to solve the problem?What we should check for in the regex is whether the short mention is inside a backtick pair. The short mention will only be overridden by the code block if there are odd number of backticks to the left of the mention (considering consecutive backticks as one as the other duplicate backticks will only be inserted into the code block) there shouldn't be any backtick after the mention so we should update the regex accordingly
In short what the regex checks is whether the mention is not preceded by an odd sets of backticks (which would mean there is an opened backtick before it waiting to convert the mention into code block if it gets any backtick after) or there are no one backtick after the mention. What alternative solutions did you explore? (Optional) |
Asked for a volunteer: https://expensify.slack.com/archives/C02NK2DQWUX/p1731515957295929 |
Taking this one over (slack), please assign me here @MonilBhavsar |
I was able to reproduce this one, please note that this is reproducible only for private domains (i.e. Short mentions ).
Lets hold assignment for a bit @MonilBhavsar 🎀👀🎀 C+ reviewed |
Current assignee @MonilBhavsar is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new. |
@FitseTLT sorry, but i found your proposal over-engineered, if you observed something in @ra-md 's proposal which will still keep this bug from happening please mention it as well. I tried to think of all possible P&C's for short mentions and their proposal fits probably all cases (unless you prove otherwise)! do let us know if you have a say here, open to feedback, but as such @ra-md 's proposal should fix this issue ! |
Nope @allgandalf you are choosing the wrong proposal. The proposal is allowing short mentions if it is not immediately preceded by and followed by a backtick but what we are to achieve is more complex than that I have already stated what is expected and how we are going to handle it so please copy my regex and deep test to check that it works perfect. Some of the cases to test with
|
You are showing me a bug. On 1, 3 it shouldn't have been a long mention but the short mention regex passed it therefore we concatinated the domain before sending it to the BE but the BE turned it to a code block with the long mention. The right result should be the short mention inside block. Did u get me? |
Ahh, okay i tested on staging now. @MonilBhavsar please hold off assignment for a bit. @FitseTLT your regex is still very complex, can you maybe try to update the regex to make it more optimised ? Updating a regex is a really complex tax in general, there are always chances of breaking other things when trying to fix one |
BTW the core structure of the regex is exactly the same as the original one. My regex have two parts separated by or (
Part 1 :
Part 2:
The Core part that is used untouched for both parts:
Let me explain the two part of the regex a bit: Finally, Consecutive backticks are considered as one, that's why you see + signs after the backtick characters in my regex. This is the simplest possible regex that correctly handles all the cases, any simpler approach that deals with this issue only is not going to fix the problem from the root cause and we will end up having similar issues as this forever :) all we can do is a deep deep test 👍 |
📣 @allgandalf 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
@MonilBhavsar what do you think of @FitseTLT 's proposal ? IMO, updating to such lengthly regex is not really ideal scenario unless there is no other way to work on this, but interested to hear what your opinion is :)) |
@allgandalf the proposal makes sense to me. But if we can optimise it, let's do it. I didn't look at the ways to optimise it yet |
@MonilBhavsar The complexity is due to the task we are aiming to achieve, I already have broken down what every peace of the regex is doing and if we exclude any we end up with recreating similar issues. I think the way to go here is to deep deep test 👍 |
Okay, that should be fine! @allgandalf what do you think? Let's add automated tests to test simple and edge cases, and test within app too |
Yes please, tests would be good to have! let's go with @FitseTLT 's proposal 🎀👀🎀 C+ reviewed |
Current assignee @MonilBhavsar is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new. |
📣 @FitseTLT 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
Let's do it! @FitseTLT more automated tests are always good. Please add them as much as you can since we're modifying the main regex 😄 |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.59-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @rafecolton
Slack conversation (hyperlinked to channel name): ts_external_expensify_quality
Action Performed:
Expected Result:
@mention highlighted with blue or green along with the inline code block message
Actual Result:
@mention not highlighted properly when composed with a inline code block message
Workaround:
Can the user still use Expensify without this being fixed? Have you informed them of the workaround?
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @stephanieelliottThe text was updated successfully, but these errors were encountered: