My general plan for this is to have an option for how the user wants to mark notifications read with 3 choices:
I want to mark all notifications read manually (default)
Automatically mark all notifications read whenever I view the page
Automatically mark notifications read when I interact with them (voting, replying, clicking Link or Parent)
1 and 2 are the existing options, so only the third would be something new. It will probably be implemented by having both the voting and replying endpoints also mark comments read, and then Link and Parent will probably need to use a non-async ajax request to mark the comment read before leaving the page: https://api.jquery.com/jQuery.ajax/ (async=false)
That's not great (will freeze the browser while the ajax request completes), but I don't think there's a much better method of making sure the request completes before the user leaves the page.
The "mark as read" button will still need to be kept on the page for people set to option 3 as well, in case they want to mark one read without interacting with it.
The above code would not work if the user has disabled JS, but that doesn't seem unreasonable given that the current proposed solution also requires JS.
We have the functionality of marking notifications read automatically when voting/labeling/etc. now, but it would still be nice to have them marked read when you click Link or Parent.