-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[plugin] Cache command arguments to safely pass the command over JSON-RPC #5961
Conversation
fixes eclipse-che/che#13956 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only commenting, because I just did a code review.
* Convert to a command that can be safely passed over JSON-RPC. | ||
*/ | ||
toSafeCommand(command: theia.Command, disposables: DisposableCollection): theia.Command { | ||
if (!this.isCommandRegistered) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"isSafeCommandRegistered" would make it clear it's not the command that is being converted that needs to be registered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@vinokurig is there an issue this PR fixes? I can't find a reference in the PR description. |
|
@@ -34,10 +35,16 @@ export class CommandRegistryImpl implements CommandRegistryExt { | |||
private readonly commands = new Set<string>(); | |||
private readonly handlers = new Map<string, Handler>(); | |||
private readonly argumentProcessors: ArgumentProcessor[]; | |||
private readonly commandsConverter: CommandsConverter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CommandRegistryImpl never does anything with the "commandsConverter". IMO, the converter should be owned by
"TreeViewExtImpl", not the command registry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be used by other APIs.
@olexii4 Does your approve means that changes looks good and you tested that it behaves well? Please provide such comments to make it clear for other committers that PR is well reviewed already. 🙏 We included it in review guidelines for such reasons: https://github.com/theia-ide/theia/blob/master/doc/pull-requests.md#justifiying-approve |
@vinokurig If @tsmaeder is fine with changes and @olexii4 approve means #5961 (comment) you can proceed |
I cannot verify, it fails for me:
I don't think that it is caused by this PR. It seems to be something broken with plugin systems generally now. The same issue were observed in my Monaco PR and in #5967 |
I will do a PR promptly, found an issue. |
@vinokurig please review #6002, after that we can rebase your PR and test it |
@akosyakov Re-based the branch. |
I see, please put it the description of #6007 as well. |
@vinokurig I'm trying but clicking on the label item does not do anything. Where should it appear? |
It only works if i click |
Fixed, it was a bug in the |
@akosyakov |
@@ -141,13 +141,14 @@ export class PluginTree extends TreeImpl { | |||
}, update); | |||
} | |||
if (TreeViewNode.is(node)) { | |||
return Object.assign(node, update); | |||
return Object.assign(node, update, { command: item.command }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vinokurig command cannot be applied to composite elements? just checking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, according to previous logic that was lost, command is set to fileNode
:
https://github.com/theia-ide/theia/blob/93205109fa4017286ec0a441b0250b74b36c6495/packages/plugin-ext/src/main/browser/view/tree-views-main.tsx#L206-L218
bit is not set to folderNode
:
https://github.com/theia-ide/theia/blob/93205109fa4017286ec0a441b0250b74b36c6495/packages/plugin-ext/src/main/browser/view/tree-views-main.tsx#L189-L204
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant whether it should be set on the composite according to VS Code expectations? If so it would be nice to adjust it as well. It could be done separately, but needs an issue at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raised an issue with question #6025
changes should be tested to be approved and a comment should be provided about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check it with https://github.com/microsoft/vscode-extension-samples/tree/master/tree-view-sample as well.
I'm trying, but nothing happens:
- I've installed an extension.
- And then click on items in dependency tree.
- I thought that a notification should appear for each item, but nothing is shown.
- Refresh and reload does not help.
Tested it with VS Code as well, let me try again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've managed to get it work, fault on my side!
…-RPC Signed-off-by: Igor Vinokur <ivinokur@redhat.com>
@vinokurig please merge, let's tackle remaining 2 issues separately |
I tested these changes inside Eclipse CHE I built the new image "olexii4dockerid/che-theia:next"
and push it to upstream. |
What it does
Currently tree item command doesn't provide arguments at all, they are overwritten to
id
:https://github.com/theia-ide/theia/blob/f718cb3461eaf1a7de90c679d31cdbeafe485708/packages/plugin-ext/src/plugin/tree/tree-views.ts#L247-L249
The converter caches the command in the plugin side so the tree-view passes the command with id in arguments. This prevents
JSON circular structure
error and real arguments are available when the command is executed in the plugin side.How to test
Clone sample plugin: https://github.com/vinokurig/Test.git and compile it
Start the plugin as a Hosted Plugin
Open the tree-view (list icon on the left panel):
click the
label
itemSee A message from argument's field is shown.
The argument object contains a reference to itself: https://github.com/vinokurig/Test/blob/cdd7548fd1d1d3f22ba263017a80ef8a6192ac52/src/nodeDependencies.ts#L18-L20
so the command was safely converted and passed over JSON-RPC without an error.
Review checklist
Reminder for reviewers