Refresh work item children after add_child quick actions

What does this MR do and why?

Fixes the work item hierarchy (Child items) widget not updating after /add_child or /remove_child quick actions until a page refresh.

Why it happens: WorkItemUpdated (and the main work item query) includes hierarchy counts (rolledUpCountsByType) but not the children connection. That connection lives only on workItemTreeQuery, so the count in the widget can change while the list stays stale. This was investigated in #498118 (comment 2529232465); @kushalpandya agreed that refetching workItemTreeQuery when the counts change is the right short-term fix (restoring a hierarchy subscription was previously removed for performance/UX).

What this MR does:

  1. After a successful /add_child or /remove_child note, refetch workItemTreeQuery. This mirrors the existing time-tracking quick action refetch in work_item_add_note.vue. The command is detected from the note text, not from the internationalized success message (see @ramistry's review on !171817 (merged)). Each active tree query is refetched, so a list expanded past the first 50 children with "Load more" reloads from its first page. That pagination reset is an accepted trade-off for this short-term fix, and cross-tab updates are out of scope.

How this differs from previous attempts:

  • !213577 (closed) updated Apollo cache counts on the add/create/remove child form and experimented with injecting reloadWorkItem. @anastasia.khom and @deepika.guliani found that the form path already worked on production, asked not to refetch all children when adding or removing one via the form, and noted that MR did not fix the quick-action bug in #498118 (closed). This MR does not touch the form path.
  • !216407 (closed) (draft) refetched the work item from onNoteUpdate when the success message contained "Child item". That string-matching approach would have the same i18n problem called out on !171817 (merged). This MR keys off the command name and refetches only workItemTreeQuery, not the entire work item.
  • !171817 (merged) remains the model for “quick action should refresh a widget”: refetch after a successful command, identified by command name.

Closes #498118 (closed)

References

Screenshots or screen recordings

Before After
After /add_child or /remove_child, the child list is stale until refresh (count may already update). The Child items list updates as soon as the quick action succeeds in the tab that posted the comment. Cross-tab updates are out of scope.

How to set up and validate locally

  1. Open a work item that supports children (for example an Issue or Epic) and note the Child items list.
  2. In a comment, run /add_child <iid> for another work item. After the note is posted, the new child should appear in the hierarchy widget without refreshing the page.
  3. Run /remove_child <iid> for that child. It should disappear from the list without a refresh.
  4. Optional: expand the tree past 50 children with "Load more", then run /add_child. The list reloads from its first page, which is expected.

An integration test in ee/spec/frontend/integration/work_items/details/children_spec.js posts /add_child from the comment form and asserts workItemTreeQuery is refetched while workItemNotesByIid is not.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Priyanshu Jha

Merge request reports

Loading
Loading