At English wikipedia, we have a consensus to have the Mediawiki software automatically sign talkpage posts. The talk page edit window would receive a new "sign this post" checkbox which would be default checked for new users. Magic words such as DISCUSSIONPAGE or NOTDISCUSSIONPAGE could be used to enable or disable this on particular pages. Consensus is here: https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_%28proposals%29&diff=688119609&oldid=688119555
Description
Event Timeline
Don't think this is possible without making talk pages properly structured (there are extensions which do this) or parsing a talk page format in some way (not going to happen).
And how are you going to detect a post? You're dealing with unstructured text. Is me adding a template to the top of the page a post that needs signing?
There would be a checkbox labeled "sign this post". If that box is checked, Mediawiki would add the four tildes at the end. Someone adding a template or fixing typos or something can simply uncheck the box, and it won't add the tildes.
A user preference would let users choose whether they want the box pre-checked or not. Probably makes sense for existing users to default to non-checked and new users to default to checked.
This stuff was already covered in the discussion at English Wikipedia.
I think you're still overestimating the triviality of this change. It's clear that everybody wants a talk page solution that doesn't require users to type in ~~~~ (I could have told you this without holding a vote ;) ); if it was so easy to implement, someone probably would have done this already.
The solution you're proposing would only work in the case of the user adding a single comment at the very end of a page (or section). But that's not what usually happens. What if…
- They add a comment in the middle? https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(proposals)&diff=688185261&oldid=688184462
- They amend a different comment at the same time? https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(proposals)&diff=688239553&oldid=688228992
- They (accidentally?) change some unrelated whitespace? https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(proposals)&diff=688188216&oldid=688187748
(All of these diffs are from the most recent history of "Wikipedia:Village pump (proposals)"; this is not uncommon.)
And then, what happens if the user asks for automatic signature, and the software fails to detect where their comment begins and ends? Should we throw an error in their face (annoying for the user) or not sign (annoying for everybody else). The user now has to either guess what to do to make the algorithm work, or find out how to sign comments manually.
People also can add more than one comment at once with discussion pages, presumably in this case we'd not try to autosign. If the autosignature is the default, we should probably try to detect this automatically. What if the software thinks this is the case, but is wrong? You probably get an unsigned comments and everyone is annoyed again.
You're probably aware of Echo's "mention" functionality, which has a simpler goal of detecting already inserted signatures and then notifying everyone "mentioned" in the message. People are constantly filing bugs about it not working in some corner case, which is obviously very annoying. I'm afraid this feature would be more annoying than useful, or just not useful enough if we limit what it tries to handle too much.
All of those problems you just mention are essentially solved. Over at English 'pedia, Sinebot succesfully signs 100s of posts per day with almost no problems at all. Essentially it would be nothing more than adapting this already existing code and putting it into the core Mediawiki software.