How to rename theia widgets via context-menu?

Right-clicking a theia widget gives us 4 options- Close, Close others, Close others to the right, Close All. I want to add another option in the context-menu for renaming the widget and persisting with the new name for that particular widget instance. Code snippets appreciated.

[original thread by rhendricks]

If you search Theia codebase for Close you will find this command definition:

After that use code navigation in your IDE to learn how it is used to register in MenuContribution:

You can open a file in your browser by prefixing an URL with to start searching:


Okay, will check this. But how to implement the rename functionality? How to rename the widget and replace the original name? I believe the widget label has to be modified, right? Is there any method similar to renaming a file that can be used to rename the widget itself(for eg: rename ‘output’ widget to ‘Multiple outputs’ or something from the UI) ?

if you want to change a title on creation when you should provide a custom factory which assigns a widget title