Skip to content
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

[tasks] Fix execution of Configured tasks #5313

Closed
wants to merge 1 commit into from

Conversation

RomanNikitenko
Copy link
Contributor

@RomanNikitenko RomanNikitenko commented May 30, 2019

  1. Change way of filtering task configurations:
  • 'configured' tasks have higher priority than 'detected' at adding to 'recently used' section
  • do not display 'detected' task for running if 'configured' task is exist with the same label
  1. Do not set ‘source’ of ‘detected’ task for configuration of ‘configured’ task - after saving the task is citizen of tasks.json file, so according to the doc should has corresponding source (path of root folder that the task config comes from)
  2. Do not save '_scope' of 'detected' task at 'configure task' action - this field is not supposed to be used in tasks.json

Related issues: #5064 and #5067

Signed-off-by: Roman Nikitenko rnikiten@redhat.com

@benoitf
Copy link
Contributor

benoitf commented Jun 18, 2019

@elaihau @akosyakov is it fine for you ?

@elaihau
Copy link
Contributor

elaihau commented Jun 18, 2019

@vince-fugnitto this one is related to your work in #5472

@elaihau
Copy link
Contributor

elaihau commented Jun 18, 2019

Sorry for my misleading comments (which has been removed). I am playing with this change in my local env.

Copy link
Contributor

@elaihau elaihau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worked well when I opened one folder as my workspace.

When i tested in the setting where there are multiple folders in the same workspace, the task list looks different from that of vsCode.

In Theia:

Peek 2019-06-18 11-49

And in vsCode:

Peek 2019-06-18 11-54

}

private findConfig(label: string, configs: TaskConfiguration[]): TaskConfiguration | undefined {
return configs.find(task => label === task.label);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the label comparison is enough. What if we have tasks

  • from different sources
  • and with the same label
    ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All configurations from tasks.json file have the same source.
I tried to add a configuration with the same label to tasks.json file and got error:

label_error
Detected tasks from different sources can have the same label - you are right.
I'll try improve this behavior, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, please review

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am testing right now

@RomanNikitenko
Copy link
Contributor Author

Worked well when I opened one folder as my workspace.

When i tested in the setting where there are multiple folders in the same workspace, the task list looks different from that of vsCode.

Maybe it's related to known issue #4919 and it never worked in a multi-root use case.
I'll check on master branch

@RomanNikitenko
Copy link
Contributor Author

@elaihau

Worked well when I opened one folder as my workspace.

When i tested in the setting where there are multiple folders in the same workspace, the task list looks different from that of vsCode.

Hello,
I can see that you have:

  • for Theia case: one recently used, two detected tasks and a few configured
  • for VS Code case: one recently used, two configured tasks and a lot of detected

Looks like the tasks are different for the cases and maybe it's quickly on gif...

I'm trying to reproduce it and catch the difference, could you help me?
Could you share your test project or the main steps?

Thanks in advance!

@elaihau
Copy link
Contributor

elaihau commented Jun 20, 2019

Worked well when I opened one folder as my workspace.
When i tested in the setting where there are multiple folders in the same workspace, the task list looks different from that of vsCode.

Maybe it's related to known issue #4919 and it never worked in a multi-root use case.
I'll check on master branch

i did more testing and looks like the problem i found is different from what i initially thought:

let me use {theia}/packages/task/test-resources to make an example
i copied it and renamed it into test-resources_A and test-resources_B. Here is what happened on the master branch:

Peek 2019-06-20 16-48

As you see, only the names of the folders (instead of full paths) are displayed as the source.

==============

Things started going wrong when i added "detected tasks":

Peek 2019-06-20 17-36

Full paths show up as the source, which is inconsistent.
To reproduce what the 2nd GIF shows, please ensure you have npm extension (from vs code) installed as a Theia plugin.

So this is not a bug introduced by this pull request.

@elaihau
Copy link
Contributor

elaihau commented Jun 20, 2019

I fixed it in #5550

@RomanNikitenko
Copy link
Contributor Author

@elaihau thank you very much for your investigation, this was very helpful!

@elaihau
Copy link
Contributor

elaihau commented Jun 26, 2019

@RomanNikitenko do you want to resolve this comment and merge this PR in near future? I see other PRs dependent on this one. Thanks !

Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
@RomanNikitenko
Copy link
Contributor Author

RomanNikitenko commented Jun 27, 2019

@RomanNikitenko do you want to resolve this comment and merge this PR in near future? I see other PRs dependent on this one. Thanks !

I fixed the comment here.
I guess that tasks.json file can not contain tasks with the same label, so first I’m trying to find configured task by label for ‘recently used’ section. Then I use equals method to find task among detected tasks.

Also I separated changes related to fix task converting, please review.

It should be noted that ‘run task’ items for ‘configured’ tasks don’t look the same as for VS Code, so maybe it makes sense to create the issue and align this behavior.
@akosyakov @elaihau WDYT?
If I’m not mistaken, in master branch they look the same because they are considered not as ‘configured’ here, so 'source' + 'label' are used to name an item.

if (exist) {
filteredRecentTasks.push(recent);
for (const recent of recentTasks) {
const taskConfig = configuredTasks.find(task => recent.label === task.label) || detectedTasks.find(task => TaskConfiguration.equals(task, recent));
Copy link
Contributor

@elaihau elaihau Jun 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like i mentioned in the other comment, using label comparison would cause issues that tasks from different sources are indentified as the same task.

This is what happened with your change:

Peek 2019-06-27 09-38

What i did was running test task from test-resources_A and test-resources_B respectively.
We ended up having only one test task in recently used tasks

============================

For your reference, this is what happened on master branch

Peek 2019-06-27 09-36

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to use TaskConfiguration.equals() which compares the label and _source - I guess you might have a good reason to use the label comparison instead. Could you please explain ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, I'll check mentioned case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to fix the case like:

  1. User runs detected task (the task moves to 'recently used' section)
  2. User configures the task, edits it (adds some args for command, for example) and tries to run the task.
  3. It's expected for me that modified task will be running, not detected task.
    So at first I try to find configured task by label for ‘recently used’ section. Why by label? Because
    according to the doc for configured task source is the root folder, while for a detected task, it is the name of the provider - after configuring the task has another source - so I can not use equals method for this case. Is it correct?
    Then I use equals method to find task among detected tasks.

But you are right, for a multi-root use case it's not working, so we need to improve filtering tasks for 'recently used' section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. You are right: When the detected task is written into the tasks.json, it becomes a configured task. We need a machanism to differentiate the configured detected task from the configured task. And to be honest, I am not sure what is the best way to do.

@RomanNikitenko
Copy link
Contributor Author

The behavior for master branch was changed: after configuring of detected task, this one is not present in configured tasks section.
For more details please see #5747
so I'm closing the PR.

@RomanNikitenko RomanNikitenko deleted the fixConfiguredTasks branch July 19, 2019 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tasks issues related to the task system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants