Page MenuHomePhabricator

Allow minor (<small>-wrapped) comments to be saved via the reply link without duplicate signature
Closed, ResolvedPublic

Description

Experienced users using the reply tool sometimes want to save a tangential/aside/minor/off-topic comment. In the normal wikitext editor, it's customary to do that by wrapping the comment in <small></small> tags. However, doing so in the reply tool doesn't include the signature; and if the signature is typed and wrapped, the tool adds a duplicate signature.

Original bug report

Hello,

I'm an experienced user using the reply link almost every other day. Sometimes, I feel the need to save a "minor" comment, such as https://cs.wikipedia.org/w/index.php?title=Wikipedie:N%C3%A1st%C4%9Bnka_spr%C3%A1vc%C5%AF&diff=19193453&oldid=19193303&diffmode=source. I do that by wrapping the comment into <small></small> tags. However, that doesn't include the signature (I'd have to bypass reply link entriely to do that). Would it make sense to add a "minor comment" checkbox under the advanced settings, which would purely make the comment look smaller?

At least at cswiki, smaller font is used frequently for things that should be said, but doesn't need to be big as the rest of the discussion.

What do you think about this idea?

References

  • "I've had this same issue. It's not a huge deal, as generally when I'm using small it's because I'm making some sort of joke or tangential remark, but still it would be nice to be able to use the tool instead of having to go into source." via @Valereee on mediawiki.org: Topic:Wp1z9zz8s0rc53k7
  • "I would like to be able to type something in small, including the signature..." via @He3nry at de.wiki: https://w.wiki/4L7n

Event Timeline

My workaround would be simply wrapping the text AND my signature <small>Text... --~~~~</small> but the reply tool also appends another signature because it isn't at the end...

matmarex subscribed.

Task T267663 complains about a similar problem (although it proposes a different solution, so I'm not sure if we should mark this one as duplicate).

My workaround would be simply wrapping the text AND my signature <small>Text... --~~~~</small> but the reply tool also appends another signature because it isn't at the end...

Right, we add a signature unless we detect that you've typed a signature exactly at the end of the comment. We've actually considered detecting signatures anywhere, in T255738#6321426 and https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/607091, but that fails in some interesting cases – the specific counterexample was this, which would make the new tool look particularly silly:

"In this tool you don't need to type <nowiki>~~~~</nowiki> anymore!"

Another potential problem was that this could result in comments ending in the middle of a paragraph, which could behave weirdly when replying, but since then we've changed how the parser works, so this can't happen any more.

We've now had several people requesting this, so maybe we should reconsider.

“Recognizing signatures anywhere in the middle” and “allowing some closing HTML tags” is not the same—if you look it at DOM level, you can translate this request to “the signature is at the end of the .innerText of the signature node”. I don’t know where the signature recognition happens, but if you analyze wikitext, can’t you just parse it into DOM (probably replacing all occurrences of ~~~~ with some special value beforehand) and determine if it’s at the end of the .innerText? (If you analyze the DOM, it’s even easier.) The ability to make comments small would be really useful indeed.

Yes, we should probably think about doing it that way…

Currently, when you post in wikitext mode, we don't actually convert that wikitext to HTML, we just directly insert it into the Parsoid HTML – so I was still thinking about doing everything on wikitext. You're right that it gets easier if we parse it to HTML and then deal with the HTML DOM. On the other hand, that requires doing a API request to parse it, which makes things slower. (And we'd also have to wait for that operation when generating the preview.) Maybe there's some clever way to do this.

Replacing all occurrences of ~~~~ with some special value would actually be tricky, since we'd also have to handle that <nowiki> case somehow – but instead, we can just parse it, and then run our signature detector on the result and see where the signature is. (Hmm, we do a similar thing for switching from wikitext to visual mode, and it actually doesn't work well for this case.)

(Sorry if this isn't making much sense, I'm just writing it out to remember it when I come back to this.)

Checking "is at the end of a HTML element" can have it's own corner cases as well. For instance, consider the following:

This is an invisible signature: <span style="display: none">--~~~~</span>. As you can see, you don't see it.

How would we differentiate between "the whole message is in a HTML element, and signature is at its end" and "the user added a signature in a HTML element, and the post itself is not signed" at the DOM level?

What about just removing everything that looks like a HTML element (incl pseudo elements like nowiki or poem) via a preg_replace or something, and doing the comparement then? It should save us a parse, AFAICS.

How about a simpler option - just add a "don't append a signature" button to the advanced panel?

Would work as well. I'd hoverer prefer a solution with a checkbox "Minor
comment", which could also mark the edit as minor.

This comment was removed by dmehus.
Esanders renamed this task from Allow minor comments to be saved via the reply link to Allow minor (<small>-wrapped) comments to be saved via the reply link.Apr 8 2021, 3:41 PM

Not sure if the sig is being picked out via a regex, some kind of wildcard match or a simple string comp, but that same method could very easily be used to recognize, for example, a signature wrapped in <nowiki></nowiki> tags.

If should be pretty easy to do a regex match to find any tags at the very end of the user input, temporarily strip those out to check for a valid signature and then add them back in before saving as well.

But I agree that a more elegant solution would be giving the user control. There is always the possibility of unforeseen edge cases, and I can imagine a few situations where a someone might not put their signature at the end of their edit, as well. (prior to this tool, I used to see <small>(Please ping me as I'm not watching this page)</small> appended after signatures, quite a bit.

Change 759841 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/DiscussionTools@master] Improve detecting already signed comments

https://gerrit.wikimedia.org/r/759841

Since the more general task was closed, can this be expanded? That is, the fix shouldn't be specific the to "small" tag only. Even more general than relationship to other tags is, why autosign if there is already a magic signature text in the reply at all?

@matmarex - so this task seems to be a feature request to add a new "minor" flag to the interface; the problem in T302257 that you merged is that autosign is running when it probably shouldn't. Is this task going to be for that more general problem?

Since the more general task was closed, can this be expanded? That is, the fix shouldn't be specific the to "small" tag only.

The proposed patch would work for any tag (although I haven't seen any requests to support other tags, it makes sense to implement it that way)

Even more general than relationship to other tags is, why autosign if there is already a magic signature text in the reply at all?

To ensure that when you save a comment with the reply tool, someone else will be able to reply to it correctly using the reply tool. The main situation where it's necessary to add a signature, even if the user typed one, is when they're adding a multi-line comment but sign somewhere else than the last line (e.g. if they add a lengthy postscript).

There may be some other edge cases where we can't detect the signature, and we thought that when we can't handle the situation perfectly, it's better to add an unnecessary extra signature, than to fail to add a necessary one. I think that's still true, and this this task is just about handling more situations perfectly.

@matmarex - so this task seems to be a feature request to add a new "minor" flag to the interface; the problem in T302257 that you merged is that autosign is running when it probably shouldn't. Is this task going to be for that more general problem?

Sorry, I forgot the bug report was so specific, we were indeed thinking about the more general problem and I rephrased the task now. We're hoping to solve it by just doing the right thing when the user types a signature in <small> tags, rather than adding more flags to the interface (especially not ones that would be easily confused with "minor edit" checkbox).

matmarex renamed this task from Allow minor (<small>-wrapped) comments to be saved via the reply link to Allow minor (<small>-wrapped) comments to be saved via the reply link without duplicate signature.Feb 25 2022, 12:06 AM

Change 759841 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Improve detecting already signed comments

https://gerrit.wikimedia.org/r/759841

<small> wrapped comments can be saved via the reply link without duplicate signature. See

Screenshot 2022-03-08 at 16.18.21.png (684×2 px, 186 KB)