Page MenuHomePhabricator

Double-posting prevention interacts weirdly with auto-save in DiscussionTools
Open, Needs TriagePublic

Description

If you're using a flaky internet connection, you can experience the following (as noted by @Ryasmeen):

  1. Write a reply in the reply tool and try to post it
  2. The API request reaches the server, and the reply is posted, but the response doesn't reach you, resulting in error message: "Could not connect to the server. Make sure you have a working internet connection and try again."
  3. You try again as instructed, and because the reply was posted, you get this error message: "Comment already posted. Reload the page to see it."
  4. You reload the page as instructed, and because of auto-save, the reply tool opens again. Your new comment is also visible on the page, but it's not highlighted, so you might miss it.
  5. If you try posting the reply again, you'll continue getting the same error message (even if you delete your reply and write completely new text), until you click "Cancel" in the reply tool and open it again.

Video demonstration (using Chromium dev tools to simulate flaky connection):

This happens because auto-save doesn't cooperate with the double-posting prevention (added in T286409).

Instead of displaying the "Comment already posted…" error, we should probably offer a prompt to show and highlight the new comments (including your new comment), similar to what we do in case of someone else replying while you're writing (T250295) – that didn't exist yet when we wrote this feature. Doing this should also clear the internal form token (so that the draft message is considered as a new message, and can be posted without getting that error).