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

Support 'onTaskType' activation event #12431

Merged
merged 3 commits into from
Apr 25, 2023
Merged

Conversation

alvsan09
Copy link
Contributor

@alvsan09 alvsan09 commented Apr 18, 2023

What it does

Provides support for onTaskType activation event

see #4199 (comment)

This brings the following benefits:

  1. Activates specific plugins rather than all task provider plugins. This is achieved by presenting the 'provided' task types to the user and upon selection activate only the provider(s) for that specific selected task type.
  2. The above avoids startup delays, and reduces the memory footprint on the extension host by only loading the task provider plugins which are selected.
  3. Enables the use of plugins which support onTaskType e.g. 'Gulp', 'Grunt', 'Jake'.

NOTE: The above apply to extensions that have stopped using activation by the command workbench.action.tasks.runTask in favor of onTaskType activation. For backward compatibility the activation
by the command mentioned above is still supported.

Additionally, Selecting the option to configure tasks (e.g., Terminal/Configure tasks...) requires and triggers activation
of all tasks providers.

The solution introduces two pick levels for 'provided' tasks,one for the selection of the task type and the second one to resolve and show the corresponding tasks to the selected type which the user can then pick from.

The following scenarios are impacted:

  1. Terminal/Run Task (for a specific task type)
    a) Long resolution (e.g., many provided tasks)
    b) quick resolution (e.g., small number of provided tasks)
  2. Terminal/Configure Tasks...
  3. Command palette Quick Access (e.g. ?Task)

How to test

Prerequisites:

  1. Install Gulp CLI (Used by the Gulp builtin extension)

npm install gulp-cli -g

  1. Install Jake CLI (Optionally, Used by the Jake builtin extension)

npm install -g jake

  1. Activate Auto Detect preference for Gulp to on
    From the:
    Command palette -> type 'open user settings' -> click and then -> Navigate to (Extensions -> Gulp) and change 'Auto Detect' to 'on'

  2. Activate Auto Detect preference for Jake to on
    From the:
    Command palette -> type 'open user settings' -> click and then -> Navigate to (Extensions -> Jake) and change 'Auto Detect' to 'on'

  3. Use a clone of 'vscode' as the project to test theia with

gh repo clone microsoft/vscode

  • edit .vscode/settings.json to delete the line:
    "gulp.autoDetect": "off"
  • edit .vscode/tasks.json to remove the only "gulp" task
    this to prevent early activation of gulp.
  • Copy a valid Jakefile.js under the root folder.
    Example test content:
desc('Default Task');
task('default', function () {
 console.log('Hello, Jake!');
});

desc('Test Task');
task('test', function () {
  console.log('This is a test task.');
});

Steps to test:

  1. Debug theia and open the cloned vscode repository mentioned above.
  2. Under the debugging IDE open the DEBUG CONSOLE using the filter load
    • Make sure that neither of the following extensions supporting onTaskType activation has been loaded/activated i.e. gulp, jake, grunt
  3. On the theia instance run a gulp task i.e. Terminal / Run Task... => Select gulp => wait for it to populate the plugin provided tasks on a second quick pick and select a task to run e.g. the vscode-api-test
    • On the DEBUG CONSOLE observe that gulp was the only loaded / activated plugin.
  4. If Jake was installed, test the same as above but Run a Jake task.
  5. Run `Terminal/Configure tasks...
    • Configuring tasks need to activate all tasks providers, therefore grunt must have been activated with this action.
  6. Run tasks via Quick Access i.e., From the command palette, type ? and then select task
    • Make sure that the two quick pick levels work for provided tasks e.g. gulp, jake (First selecting type, secondly selecting a provided task).
  7. Stop Debugging and start it again to repeat the options above in different order e.g. Running Configure Task... first and then again running Quick Access first.

See test example video:
https://user-images.githubusercontent.com/76971376/232908518-580d56ce-fea2-4eac-b6ac-b018fbb33d20.mp4

Review checklist

Reminder for reviewers

@alvsan09 alvsan09 changed the title Asl/on task type activation Support 'onTaskType' activation event Apr 18, 2023
@msujew msujew added tasks issues related to the task system plug-in system issues related to the plug-in system vscode issues related to VSCode compatibility and removed plug-in system issues related to the plug-in system labels Apr 19, 2023
@alvsan09 alvsan09 requested a review from msujew April 19, 2023 16:39
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

The functionality looks quite good, I only have some minor comments 👍


I noticed some improvements that can be made in follow-up pull-requests:

  • display a + Configure Task entry when no tasks are configured (above contributed items)
  • add Show All Tasks... entry at the bottom of the list
  • improve ordering of entries in a multiroot (sort by root then tasks)
  • add Go back ↩ functionality

packages/plugin-ext/src/hosted/browser/hosted-plugin.ts Outdated Show resolved Hide resolved
packages/task/src/browser/provided-task-configurations.ts Outdated Show resolved Hide resolved
packages/plugin-ext/src/plugin/type-converters.ts Outdated Show resolved Hide resolved
1) To pass unresolved 'picks' promise to the monaco 'esm'.
Resolving picks before calling monaco 'esm' results in a delay to
show the quick pick widget (Giving no feedback to the user during the
delay).

2) Update the signature of 'QuickInputService#pick' to handle
'QuickPickInput' picks as per latest monaco 'esm'.

Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
This brings the following benefits:

1) Activates specific plugins rather than all task provider plugins.
   This is achieved by presenting the 'provided' task types to the
   user and upon selection activate only the provider(s) for that
   specific selected task type.
2) The above avoids startup delays, and reduces the memory footprint
   on the extension host by only loading the task provider plugins
   which are selected.
3) Enables the use of plugins which support 'onTaskType'
   e.g. 'Gulp', 'Grunt', 'Jake'.

NOTE: The above apply to extensions that have stopped using
activation by the command 'workbench.action.tasks.runTask' in favor
of 'onTaskType' activation. For backward compatibility the activation
by the command mentioned  above is still supported.

Additionally, Selecting the option to configure tasks
(e.g., Terminal/Configure tasks...) requires and triggers  activation
of all tasks providers.

The solution introduces two pick levels for 'provided' tasks,
one for the selection of the task type and the second one to resolve
and show the corresponding tasks to the selected type which the user
can then pick from.

The following scenarios are impacted:

1) Terminal/Run Task (for a specific task type)
	a) Long resolution (e.g., many provided tasks)
	b) quick resolution (e.g., small number of provided tasks)
2) Terminal/Configure Tasks...
3) Command palette Quick Access (e.g. ?Task)

Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
The 'vscode.api' for creation of tasks has two constructors, one of
them deprecated which does not require the 'scope' parameter.
Some extensions (e.g., Jake) still use the deprecated api and
therefore it is possible to receive 'Task's where 'scope' is
undefined and causes an exception in 'Theia' which prevents the use
of the related tasks.

This change fixes it by using 'TaskScope.Workspace' as a default
in such cases.

Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

LGTM 👍
I confirmed that:

  • contributed tasks are now displayed
  • contributed tasks work well, and show progress when loading (ex: gulp)
  • plugins support onTaskType properly
  • the quick-access menu works for tasks
  • configure task... works well, and displays the loaded tasks (ex: gulp)

@alvsan09 alvsan09 merged commit 76466cc into master Apr 25, 2023
@alvsan09 alvsan09 deleted the asl/onTaskType-activation branch April 25, 2023 19:15
@github-actions github-actions bot added this to the 1.37.0 milestone Apr 25, 2023
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 vscode issues related to VSCode compatibility
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants