Page MenuHomePhabricator

Design: Provide a design proposal for function call block clipboard dialog
Closed, ResolvedPublic

Description

Overview

For this hypothesis we will build a copy-paste feature so that, when editing an object in the Wikifunctions Default UI (particularly when creating or editing composition implementations or tests), a user should be able to copy a block so that they can reuse it in other parts of the object.

Main use cases

use case 1: wrap an existing function call with another one

In order to debug my composition, I would like to use the "Add debug to function call/Z854" function wrapping an existing complex composition.
To do this without discarding the existing composition, I would like to do:

  • select the function call that I want to wrap and choose "copy"
  • now edit the function call and select "Add debug..." function
  • for the first argument of the "Add debug..." function, select "paste" option
  • navigate the clipboard and choose the block I copied before
  • copy the block and publish it safely, knowing that I've not altered it in any way

use case 2: reuse an existing implementation to build another one

I want to build a new declension table following the same construction as the "build whole table" implementation for "German noun declension table": https://www.wikifunctions.org/view/en/Z28604
To do this successfully without having to replicate one by one every single function call, I would like to do:

  • in the original composition (edit), click on the menu beside "composition" and click "copy"
  • in a new tab (or the same one) create a new implementation for my function, and select composition
  • click on the menu beside "composition" and click "paste"
  • navigate the clipboard and choose the block I copied before
  • make any changes needed to adapt this composition to my use case
  • publish it safely

Additional information

Decisions and Assumptions

These are some assumptions and decisions made while building the initial POC. As such, they can be either sustained or challenged.

  • The copy/paste feature will be displayed in the options menu (marked with an ellipsis icon) on the right side of every key. This menu contains options to modify the shape of its value, and to perform other contextual actions such as moving the item up/down a list or deleting the item from it. This menu appears only in "edit" mode, which means that it will not be possible to "copy" the blocks in "read" mode.

Screenshot from 2026-01-09 12-25-31.png (503×545 px, 59 KB)

  • The block is displayed in the clipboard using the ZObjectToString component, which renders an inline view of the value.
  • The blocks are either valid or not valid for copying into the selected key. This depends on whether the type of the block matches the expected type for the key. This is signaled inside the clipboard with a disabled (grey background) state and a disabled action (it cannot be selected).
only the first block is enabled for pastingthe first and third block are enabled, the second is disabled
Screenshot from 2026-01-09 10-41-12.png (579×428 px, 52 KB)
Screenshot from 2026-01-09 11-45-18.png (562×397 px, 48 KB)
  • The copied blocks are stored along with the name of the key they originally belonged to. In case the value for the key is copied twice (or two keys have identical label), an index number is added to the name.
  • Additionally to the block "name" and the block value, we also display the type of the value (top right corner of each clipboard block), to enrich the information available to the user.
Challenges

challenge 1: The copied block can be extremely complex and large

In situations like the one described for use case 2, the block copied to the clipboard is very complex. This makes it difficult to navigate through all items stored in the clipboard, identify them and select them successfully.

Screenshot from 2026-01-09 12-18-01.png (592×949 px, 255 KB)


Acceptance criteria

Create a viable design proposal for the clipboard dialog so that editors can navigate, understand and successfully choose the block they want to paste in a given slot


Completion checklist
Before closing this task, review one by one the checklist available here: https://www.mediawiki.org/wiki/Abstract_Wikipedia_team/Definition_of_Done#Design_task_completion_checklist

Event Timeline

@Jdforrester-WMF: not resolved yet.

Update 2026-03-03
After design review from @JSengupta-WMF here's a list of improvements and design tweaks:

  • Change placeholder string from "Filter by [...]" to “Search by [...]”
  • When clipboard is empty, hide filter and button bar.
  • Show clipboard items with the latest copied one on top. We may think of toggle sequence later.
  • Add opacity (0.6?) to not applicable items on the clipboard.
  • Display max 3 lines of item content. Add view more link to display the full content inline.

Change #1247622 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] Style fixes for copy-paste feature

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

Thanks! Do we also want a tooltip message for disabled clipboard items that explains that they can't be used because they're the wrong Type?

Thanks! Do we also want a tooltip message for disabled clipboard items that explains that they can't be used because they're the wrong Type?

That's a good idea! I'll make a quick exploration.

Change #1247622 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Style fixes for copy-paste feature

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

Change #1247635 had a related patch set uploaded (by Jforrester; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@wmf/1.46.0-wmf.18] Style fixes for copy-paste feature

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

Change #1247635 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@wmf/1.46.0-wmf.18] Style fixes for copy-paste feature

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

Mentioned in SAL (#wikimedia-operations) [2026-03-03T17:31:55Z] <jforrester@deploy2002> Started scap sync-world: Backport for [[gerrit:1247635|Style fixes for copy-paste feature (T414072)]]

Mentioned in SAL (#wikimedia-operations) [2026-03-03T17:51:46Z] <jforrester@deploy2002> jforrester: Backport for [[gerrit:1247635|Style fixes for copy-paste feature (T414072)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-03-03T18:04:49Z] <jforrester@deploy2002> Finished scap sync-world: Backport for [[gerrit:1247635|Style fixes for copy-paste feature (T414072)]] (duration: 32m 54s)