Skip to content

Fix terminal "Rerun Task" closing the task without restarting it#320124

Merged
meganrogge merged 2 commits into
mainfrom
copilot/fix-rerun-task-button-issue
Jun 5, 2026
Merged

Fix terminal "Rerun Task" closing the task without restarting it#320124
meganrogge merged 2 commits into
mainfrom
copilot/fix-rerun-task-button-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 5, 2026

Description

The terminal "Rerun Task" button terminated the active task but never restarted it.

_restart() awaits TerminalTaskSystem.terminate() before calling run(), but terminate() resolved its promise solely from the terminal's onExit event. When a task terminal is disposed, TerminalInstance._onProcessExit bails out after await this._flushXtermData() (it hits if (this.isDisposed) return), so onExit never fires — only onDisposed does. The terminate promise never settles, _restart() is stuck awaiting it, and the task is closed but never re-run.

Changes in terminalTaskSystem.ts terminate():

  • Settle on first event — resolve on whichever of onExit/onDisposed fires first, guarded against double-resolution, so the restart flow always proceeds to run().
  • Clear _activeTasks — remove the terminated task from _activeTasks (matching terminateAll()), preventing run() from throwing "There is already a task running" on the stale entry.
const finish = () => {
    if (resolved) { return; }
    resolved = true;
    onExit.dispose();
    onDisposedListener.dispose();
    const terminatedTask = activeTerminal.task;
    if (this._activeTasks[mapKey] === activeTerminal) {
        delete this._activeTasks[mapKey];
    }
    resolve({ success: true, task: terminatedTask });
};
const onDisposedListener = terminal.onDisposed(t => { this._fireTaskEvent(TaskEvent.terminated(task, t.instanceId, t.exitReason)); finish(); });
const onExit = terminal.onExit(() => { /* fire terminated event */ finish(); });
terminal.dispose();

Copilot AI requested review from Copilot and removed request for Copilot June 5, 2026 15:33
Copilot AI linked an issue Jun 5, 2026 that may be closed by this pull request
Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot June 5, 2026 15:51
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
Copilot AI requested a review from meganrogge June 5, 2026 15:52
@meganrogge meganrogge added this to the 1.124.0 milestone Jun 5, 2026
@meganrogge meganrogge marked this pull request as ready for review June 5, 2026 16:19
Copilot AI review requested due to automatic review settings June 5, 2026 16:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 of onExit or onDisposed.
  • Remove the terminated task from _activeTasks during 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

Comment thread src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts
@meganrogge meganrogge enabled auto-merge (squash) June 5, 2026 16:34
@meganrogge meganrogge merged commit c83b87f into main Jun 5, 2026
26 checks passed
@meganrogge meganrogge deleted the copilot/fix-rerun-task-button-issue branch June 5, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal "Rerun Task" button closes the task instead of restarting it

4 participants