Page MenuHomePhabricator

[SPIKE] Define work to be done before discussion-specific ToC is production ready
Closed, ResolvedPublic

Description

This task is about defining the additional work that will need to be done before the discussion-specific-version of the new ToC can be deployed to production.

Work to be done

The requirements that are informing the questions/work to be done described in this section can be found in T303634.

Issue/Technical Need
Deployment Blocker (Y/N)
Potential solution
Next step(s)
Sometimes the new Vector TOC doesn't display at all
Yes
Already fixed (T305123)

Metadata within ToC cannot be updated without reloading page
Yes
1. Add ToC data to the action=parse action API output (or confirm that the existing action=parse&prop=sections output is sufficient)
2. Create a JavaScript API for updating the ToC based on this data, and add it to mediawiki.util
Editing + Web engineering to scope this work in T307251 and its sub-tasks (e.g.T307480)
Improve how ToC is rendered to allow adding discussion enhancements
TBD
1. Add a PHP hook in SkinComponentTableOfContents to allow DiscussionTools to add HTML fragments to each ToC line
2. Modify Vector to output this
3. Modify the JavaScript API from the previous item to also support this
Define necessity + agree on an approach. This work will happen in T307823.

Open question(s)

  • 1. What work would need to be done in order to adapt the ToC proof of concept @Jdlrobson implemented in T299246#7805640 so that the metadata presented within the ToC updates dynamically based on the state of the discussions present on the page which the ToC appears?
    • @matmarex was able to define and do the work necessary to adapt the ToC proof of concept so that the metadata presented within it reflects the state of the discussions present on the page the ToC appears on. //Note: the prototype will be implemented in T305655.

Background

Knowing the work that is required to make the ToC proof of concept functional, will help the Editing Team decide how to create prototypes for the designs created in T299814 for use in the usability testing that will happen in T293520.

Done

  • Answers to all ===Open question(s) are documented on this ticket
  • The technical work that will need to be done before the Editing Team can implement the requirements T303634 lists are documented in this task's === Work to be done section

Related Objects

Event Timeline

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

[mediawiki/extensions/DiscussionTools@master] [POC] Enhance vector-2022 table of contents

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

I was able to build on top of that proof of concept to make it display the real numbers. That's probably good enough if we wanted to include it in a prototype, but there are a few issues that'd need to be solved before we could have this in production.

  • Sometimes the new Vector TOC doesn't display at all. This would happen seemingly randomly as I was testing. It also happens almost every time on the next page load after saving an edit. In my opinion this is a blocker to deployment.
  • There's no way to get the HTML for the new Vector TOC from the action=parse API, which means we can't update the TOC after a page is edited, unless we reload the whole page. This affects VisualEditor as well, but it's less severe there since you don't always add/remove/change headings when editing normal pages. With DiscussionTools, you always add a heading, or add a reply, which are counted in the TOC.
  • We might need a new hook to improve how we render the TOC. Currently, we can only alter the data used to render the TOC using the 'ParserAfterTidy' hook. While we could render our own HTML at this point, I think a better approach would be to render it later (when Vector renders), and we would need a new hook for that. This is because it would allow us to make the rendering adapt to the skin (currently only Vector would be affected, but I understand that other skins may be changed to work the same way in the future), it would allow us to include machine-readable data in the action=parse&prop=sections output, and it would allow us to avoid splitting the parser cache on user language (currently rendering the TOC already splits it, but it seems to me like this could be changed in the future).

Sometimes the new Vector TOC doesn't display at all. This would happen seemingly randomly as I was testing. It also happens almost every time on the next page load after saving an edit. In my opinion this is a blocker to deployment.

It sounds like you are describing T305123.

There's no way to get the HTML for the new Vector TOC from the action=parse API, which means we can't update the TOC after a page is edited

Yes there is no API for updating table of contents. We'd likely need to add one to mediawiki.util if this is needed.

We might need a new hook to improve how we render the TOC. Currently, we can only alter the data used to render the TOC using the 'ParserAfterTidy' hook

Could you elaborate on exactly what you want to do here? From my perspective, it's important that Vector controls the final look and feel for the table of contents. If you wanted to add machine readable data e.g. data attributes, I'd suggest we update the data model for table of contents https://github.com/wikimedia/mediawiki/blob/master/includes/skins/components/SkinComponentTableOfContents.php#L57 to have html-attributes. Vector would then be modified to output this. A Hook could be added inside SkinComponentTableOfContents if necessary to extend the html-attributes property which would default to ''.

META

I was able to build on top of that proof of concept to make it display the real numbers. That's probably good enough if we wanted to include it in a prototype...

Understood. Let's use T305655 to define the scope of how we'll implement the discussion pages-specific version for the prototype .

...but there are a few issues that'd need to be solved before we could have this in production.

Considering you and @Jdlrobson are already using this ticket to name/discuss the issues that would need to be resolved with the ToC before it is "production ready," I'm going to alter the scope of this task and merge T305663 into it.

ppelberg renamed this task from [SPIKE] Investigate feasibility of adapting ToC proof of concept to update dynamically to [SPIKE] Define work to be done before discussion-specific ToC is production ready.Apr 8 2022, 10:41 PM
ppelberg added a subscriber: Johnuniq.

Sometimes the new Vector TOC doesn't display at all. This would happen seemingly randomly as I was testing. It also happens almost every time on the next page load after saving an edit. In my opinion this is a blocker to deployment.

It sounds like you are describing T305123.

Thanks, glad to see it's fixed.

There's no way to get the HTML for the new Vector TOC from the action=parse API, which means we can't update the TOC after a page is edited

Yes there is no API for updating table of contents. We'd likely need to add one to mediawiki.util if this is needed.

We might need a new hook to improve how we render the TOC. Currently, we can only alter the data used to render the TOC using the 'ParserAfterTidy' hook

Could you elaborate on exactly what you want to do here? From my perspective, it's important that Vector controls the final look and feel for the table of contents. If you wanted to add machine readable data e.g. data attributes, I'd suggest we update the data model for table of contents https://github.com/wikimedia/mediawiki/blob/master/includes/skins/components/SkinComponentTableOfContents.php#L57 to have html-attributes. Vector would then be modified to output this. A Hook could be added inside SkinComponentTableOfContents if necessary to extend the html-attributes property which would default to ''.

That sounds good to me.

T305576#7846028

With the task description's ===Work to be done section now updated (thank you, @matmarex), @Jdlrobson can you please give it a quick read and let me know if you think anything needs adjusting before I file tickets for the work described in rows two and three of the table?

ppelberg added a subscriber: matmarex.

T305576#7846142

Great.

Next step is for me to create tickets for rows two and three of the task description's ===Work to be done table.

Test wiki created on Patch demo by JKlein (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/65d33f5a9f/w/

ppelberg updated the task description. (Show Details)

T305576#7846142

Great.

Next step is for me to create tickets for rows two and three of the task description's ===Work to be done table.

Done. See: T307823, T307251, and T307480.

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

[mediawiki/extensions/DiscussionTools@master] [POC] Enhance vector-2022 table of contents

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

Test wiki on Patch demo by JKlein (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/65d33f5a9f/w/