Fixes #90125 - Add a task instancePolicy to task runOptions#90914
Fixes #90125 - Add a task instancePolicy to task runOptions#90914alpalla wants to merge 2 commits into
Conversation
…ce of a task once the instanceLimit has been reached.
|
@alexr00 any updates regarding anything I can do to move forward with this PR? 😃 |
|
need this feature |
| }, | ||
| instancePolicy: { | ||
| type: 'string', | ||
| enum: ['terminateNewest', 'terminateOldest', 'prompt', 'warn', 'silent'], |
There was a problem hiding this comment.
Can you add an enum description for this?
|
I haven't had a chance to do a full review yet, but I hope to next week. Can you resolve the conflicts? |
|
Sure! I'll resolve the conflicts and add that enum description 👍 |
|
@alexr00 I can't resolve the conflicts and test the resulting code locally because it seems like a couple of things are broken in the latest build. The main issues are:
I can resolve the conflicts via GitHub without testing the resulting code first but I'm a little hesitant to do so. Let me know how I should proceed, thanks! |
|
Is this feature dead in the water? Would be a great addition. |
|
Closing in favor of the newer one: #117129 |
Summary
Fixes #90125. Added an
instancePolicytorunOptions. TheinstancePolicyis applied when creating a new instance of a task once theinstanceLimithas been reached.The
instancePolicyis as follows:terminateNewest: the newest instance is terminatedterminateOldest: the oldest instance is terminatedprompt: the QuickPick is shown and the user picks an instance to restart (this is the default option)warn: do nothing (do not terminate an existing instance or create a new one) and show a warning that indicates that theinstanceLimithas been reachedsilent: do nothingImplementation notes
instancePolicyis effectively restartedTerminalTaskSystemgetLastInstance()method has been expanded in scope and is now calledgetNthInstance. As the name suggests it returns the Nth instance of a task given a number. If no index is given, it returns the last instance by default. I used aforloop instead of doing aforEachonObject.keysso that I could exit early once the right instance was foundidso as to avoid cases in which an instance of an instance was being created and theidwould be appended with|<COUNTER>multiple timesTesting changes
Create a
tasks.jsonand set theinstancLimitandinstancePolicyproperties. Here is an example configuration:{ "version": "2.0.0", "tasks": [ { "label": "echo", "type": "shell", "command": "sleep 20 && echo Hello", "runOptions": { "instanceLimit": 2, "instancePolicy": "terminateOldest" } } ] }Ensure that once the
instanceLimitis reached, the choseninstancePolicybehaves as described at the beginning of this PR.P.S.
I would suggest not having the
promptoption as the default option simply because in the default case whereinstanceLimit == 1, the user would be shown the QuickPick which would contain only one entry since there is only one active instance. Personally, I think it would make more sense to have anotherinstancePolicyoption which would ask the user to terminate or restart the last instance. This would maintain the current behavior and use the current terminate/restart notification, while I think being the least confusing option in the case whererunOptionsis set to all default settings.