Skip to content
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

[HOLD for payment 2024-06-28] [$500] HIGH: [Polish] Editing a comment with a video removes the video #41952

Closed
quinthar opened this issue May 9, 2024 · 64 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@quinthar
Copy link
Contributor

quinthar commented May 9, 2024

Reported by @zsgreenwald here: https://expensify.slack.com/archives/C066HJM2CAZ/p1715280747390969

image

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019eb5f4d74fc52968
  • Upwork Job ID: 1788937751790014464
  • Last Price Increase: 2024-06-27
  • Automatic offers:
    • DylanDylann | Reviewer | 0
Issue OwnerCurrent Issue Owner: @alexpensify
@quinthar quinthar converted this from a draft issue May 9, 2024
@quinthar
Copy link
Contributor Author

quinthar commented May 9, 2024

Optimistically assigning to @tgolen

@tgolen tgolen added Weekly KSv2 Improvement Item broken or needs improvement. Engineering labels May 9, 2024
@tgolen
Copy link
Contributor

tgolen commented May 9, 2024

It looks like this is because we don't support <video> tags in our HTML to markdown conversion.

image

@kidroca Do you agree that we just need to add support for <video> tags, like what you did with the <img /> ones?

@kidroca
Copy link
Contributor

kidroca commented May 10, 2024

It looks like this is because we don't support <video> tags in our HTML to markdown conversion.

@kidroca Do you agree that we just need to add support for <video> tags, like what you did with the <img /> ones?

Yes, this seems to be the problem

We have to convert <video> to ![vid](src.mp4) and back to <video> in order to preserve the correct behaviour

@tgolen tgolen added Bug Something is broken. Auto assigns a BugZero manager. and removed Improvement Item broken or needs improvement. labels May 10, 2024
Copy link

melvin-bot bot commented May 10, 2024

Triggered auto assignment to @laurenreidexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 10, 2024
@tgolen tgolen added the External Added to denote the issue can be worked on by a contributor label May 10, 2024
Copy link

melvin-bot bot commented May 10, 2024

Job added to Upwork: https://www.upwork.com/jobs/~019eb5f4d74fc52968

@melvin-bot melvin-bot bot changed the title HIGH: [Polish] Editing a comment with a video removes the video [$250] HIGH: [Polish] Editing a comment with a video removes the video May 10, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 10, 2024
Copy link

melvin-bot bot commented May 10, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (External)

@tgolen
Copy link
Contributor

tgolen commented May 10, 2024

Great, thanks! Let's get this one worked on by a contributor.

@dominictb
Copy link
Contributor

dominictb commented May 10, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Editing a comment with a video removes the video

What is the root cause of that problem?

We don't support <video> tags in our HTML to markdown conversion, and conversion back from markdown to <video>

What changes do you think we should make in order to solve the problem?

  1. Convert <video> to ![vid](src.mp4), we can add a rule in expensify-common to do this, similar to images.
    Some differences to note:
  • The video will use data-expensify-source, not src like image
  • The video will have closing tags, unlike image which doesn't

So the Regex will need to accommodate those differences

Pseudo-code:

{
    name: 'video',
    regex: /<video[^><]*data-expensify-source\s*=\s*(['"])(\S*?)\1(.*?)>([^><]*)<\/video>*(?![^<][\s\S]*?(<\/pre>|<\/code>))/gi,
    replacement: (match, g1, g2, g3, g4) => {
        if (g4) {
            return `![${g4}](${g2})`;
        }

        return `!(${g2})`;
    },
},

This works well for current use cases but some details might need to be changed based on expectations

  1. Convert video markdown back to <video>, we can add a rule in expensify-common to do this, similar to images. The difference with image is that the src of the video will have a video file extension (like .mp4)

Or we can just modify the rule here to work for both images and videos, based on source file extension

{
    name: 'imageOrVideo',
    regex: MARKDOWN_IMAGE_REGEX,
    replacement: (match, g1, g2) => {
        if (g2.endsWith('.mp4')) { // we should handle other video file extensions too
            return `<video src="${Str.sanitizeURL(g2)}">${g1 ? `${g1}` : ''}<\/video>`
        }
        return `<img src="${Str.sanitizeURL(g2)}"${g1 ? ` alt="${this.escapeAttributeContent(g1)}"` : ''} />`
    },
    // will need to update this similarly
    rawInputReplacement: (match, g1, g2) => `<img src="${Str.sanitizeURL(g2)}"${g1 ? ` alt="${this.escapeAttributeContent(g1)}"` : ''} data-raw-href="${g2}" data-link-variant="${typeof (g1) === 'string' ? 'labeled' : 'auto'}" />`
},

We should take additional references from this PR too to make it work for videos like for images.

What alternative solutions did you explore? (Optional)

NA

Video

It will work fine like this after the fix
https://github.com/Expensify/App/assets/165644294/365b3911-4854-4fa8-830c-ca65c9846119

@dominictb
Copy link
Contributor

dominictb commented May 10, 2024

@tgolen @kidroca To confirm:

  • We have some details in the <video> like data-expensify-width, data-expensify-height, data-expensify-thumbnail-url
    Do they need to be included in the markdown? If yes, what will the markdown look like with those metadata?

  • I assume the vid referred to here is the file name right?

![vid](src.mp4)

Because the format of the html is <video ...>fileName</video>. Or is the [vid] a hardcoding thing to distinguish the video markdown from the image markdown?

(FWIW it's ok for the markdown formats of video and image to be the same, we can distinguish them by the source file extension)

@dominictb
Copy link
Contributor

Proposal updated to include more details

@DylanDylann
Copy link
Contributor

In my opinion, In reality there are not many cases in which users want to update a video/image by updating the video/image link. When users send a video/image with a message, we should only allow the user to edit the message, not the video/image link. It means that when editing the message that is attached to a video/image, we only display the message in the edit composer and exclude the video/image link

@tgolen
Copy link
Contributor

tgolen commented May 13, 2024

@dominictb I think it's OK to use the same markdown for both images and videos and base all logic off of file extensions.

We have some details in the

I think we do need to keep this, yes. Is there anyway to keep this without including it in the markdown syntax? They are fields that shouldn't be edited by the user.

@DylanDylann I think there are quite a few cases where users need to replace or delete a video/image entirely, so I don't think stripping out video/img tags from the editor is an option at this point.

@DylanDylann
Copy link
Contributor

If that, @dominictb's proposal looks promising. Let's me deep dive into it

@DylanDylann
Copy link
Contributor

@dominictb Same question

Is there anyway to keep this without including it in the markdown syntax?

@dominictb
Copy link
Contributor

dominictb commented May 14, 2024

I think we do need to keep this, yes. Is there anyway to keep this without including it in the markdown syntax?

@tgolen @DylanDylann We can store the metadata in a local cache or in Onyx, it will be like an object with the video source as the key, similar to how we cached the thumbnail dimensions

We can initialize the cache when the user starts editing the message, and clear the cache after the user finishes editing

@laurenreidexpensify
Copy link
Contributor

@alexpensify adding you here for parental leave sub. no action required this BZ this week, PR is still in review, but adding you for payment in coming weeks when the fix makes it to prod. Thanks

@alexpensify
Copy link
Contributor

Noted!

@tgolen
Copy link
Contributor

tgolen commented Jun 21, 2024

Weekly Update

Next Steps

  • @dominictb Update App with the new version of expensify-common

ETA

  • Merged by Friday, June 28

@dominictb Have you been able to create the App PR that updates the expensify-common version?

@dominictb
Copy link
Contributor

@tgolen #42463 it's already here.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 21, 2024
@melvin-bot melvin-bot bot changed the title [$250] HIGH: [Polish] Editing a comment with a video removes the video [HOLD for payment 2024-06-28] [$250] HIGH: [Polish] Editing a comment with a video removes the video Jun 21, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 21, 2024
Copy link

melvin-bot bot commented Jun 21, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Jun 21, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.0-9 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-06-28. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jun 21, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@DylanDylann] The PR that introduced the bug has been identified. Link to the PR:
  • [@DylanDylann] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@DylanDylann] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@DylanDylann] Determine if we should create a regression test for this bug.
  • [@DylanDylann] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@alexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@alexpensify alexpensify changed the title [HOLD for payment 2024-06-28] [$250] HIGH: [Polish] Editing a comment with a video removes the video [HOLD for payment 2024-06-28] [$500] HIGH: [Polish] Editing a comment with a video removes the video Jun 27, 2024
Copy link

melvin-bot bot commented Jun 27, 2024

Upwork job price has been updated to $500

@alexpensify
Copy link
Contributor

@DylanDylann and @dominictb - to prepare for the payment date, please apply here:

https://www.upwork.com/jobs/~019eb5f4d74fc52968

Automation failed here and Upwork search is throwing an error. Thanks!

@alexpensify
Copy link
Contributor

alexpensify commented Jun 28, 2024

Payouts due: 2024-06-28

Upwork job is here.

Status: Search was working better today. Please accept the Upwork jobs, and I can complete the process.

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Jun 28, 2024
@alexpensify
Copy link
Contributor

alexpensify commented Jul 1, 2024

There is no update yet; the offers are pending in Upwork. It need to be approved by the contributors. Heads up, I'm OOO this week, but I'm trying to check in sporadically to help finish the required process here. I'll try to check again on Wednesday morning to see if I can complete the next steps for this GH.

@melvin-bot melvin-bot bot removed the Overdue label Jul 1, 2024
@DylanDylann
Copy link
Contributor

@alexpensify I accepted the offer, thanks 🚀

@dominictb
Copy link
Contributor

@alexpensify I accepted it too, ty!

@melvin-bot melvin-bot bot added the Overdue label Jul 3, 2024
Copy link

melvin-bot bot commented Jul 4, 2024

@tgolen, @alexpensify, @DylanDylann, @dominictb Whoops! This issue is 2 days overdue. Let's get this updated quick!

@alexpensify
Copy link
Contributor

Closing - I've completed the payment process in Upwork.

#41952 (comment)

@melvin-bot melvin-bot bot removed the Overdue label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Development

No branches or pull requests

7 participants