Fix terminal "Rerun Task" closing the task without restarting it#320124
Merged
Conversation
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix terminal 'Rerun Task' button behavior
Fix terminal "Rerun Task" closing the task without restarting it
Jun 5, 2026
meganrogge
approved these changes
Jun 5, 2026
Yoyokrazy
approved these changes
Jun 5, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression in the task “Rerun Task” flow where terminating a task could dispose the terminal without ever firing onExit, causing TerminalTaskSystem.terminate() to never resolve and preventing the task from being restarted.
Changes:
- Update
TerminalTaskSystem.terminate()to resolve termination on the first ofonExitoronDisposed. - Remove the terminated task from
_activeTasksduring termination to avoid stale “already running” state on rerun.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts | Adjusts task termination to settle on onExit/onDisposed (whichever happens first) and clears _activeTasks so rerun can proceed. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
meganrogge
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The terminal "Rerun Task" button terminated the active task but never restarted it.
_restart()awaitsTerminalTaskSystem.terminate()before callingrun(), butterminate()resolved its promise solely from the terminal'sonExitevent. When a task terminal is disposed,TerminalInstance._onProcessExitbails out afterawait this._flushXtermData()(it hitsif (this.isDisposed) return), soonExitnever fires — onlyonDisposeddoes. The terminate promise never settles,_restart()is stuck awaiting it, and the task is closed but never re-run.Changes in
terminalTaskSystem.tsterminate():onExit/onDisposedfires first, guarded against double-resolution, so the restart flow always proceeds torun()._activeTasks— remove the terminated task from_activeTasks(matchingterminateAll()), preventingrun()from throwing "There is already a task running" on the stale entry.