fix(tasks): Make every background task cancellable, queued or running (#177)

Background tasks often couldn't be cancelled, or cancelling didn't stop them:
- A cancel that arrived before the backend registered the request was dropped (build while saving files, multi-repository fetch/pull between repositories). The host now remembers early cancels (bounded, 2 min), and request ids start at a random value per page.
- There was no queue and no common cancel path: backend-reported tasks (LSP progress, deployment transfers) couldn't be cancelled, and tool installs, VCS operations and update checks had no cancel button in Background Tasks.
- Only the direct child process was killed, and JDK / tool archives were extracted without checking for cancellation.

Tool installs and JDK downloads now share a downloads queue; cancelling a queued task removes it without starting any work. Every task cancels through one path that shows "Cancelling…" and then removes it; tasks that can't be interrupted show a disabled cancel button with the reason. IdeEvent::Task carries `cancellable` with a cancel_task command, cancellable LSP progress sends window/workDoneProgress/cancel, installers, curl and tar run in their own process group and are killed as a group, and extraction checks for cancellation between entries.

Claude-Session: https://claude.ai/code/session_01Dq6jQQn8ZhRfkkyj3PRutA
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-10-29 09:05:12 +08:00
1 джерело c6621c5c36
коміт 1c46a1cd04
40 files changed
+888 -148

No files matched your search

+3 -1
Переглянути файл
@@ -34,7 +34,9 @@ export function isCancelled(e: unknown): boolean {
return e instanceof IpcError && e.kind === "cancelled";
}
let nextId = 1;
// Ids are shared by every window of the backend and outlive a reload there (a cancel that
// arrives before its request began is remembered), so each page starts at a random point.
let nextId = 1 + Math.floor(Math.random() * 0x7000_0000);
/** Allocates an id for a cancellable request (see `commands.cancelRequest`). */
export function nextRequestId(): RequestId {
return nextId++ as RequestId;
+1
Переглянути файл
@@ -66,6 +66,7 @@
"app.update.installed": "OpenIDEA {version} is installed",
"app.update.installedBody": "It is used after OpenIDEA restarts.",
"app.update.installingMessage": "Installing…",
"app.update.installUncancellable": "The update is being installed; this step can't be cancelled",
"app.update.none": "OpenIDEA {version} is up to date",
"app.update.progress": "{done} MB of {total} MB",
"app.update.progressUnknown": "{done} MB",
+6 -1
Переглянути файл
@@ -4644,5 +4644,10 @@
"Couldn't copy the task": "无法复制任务",
"Copy to a New Task From Here": "从此处复制为新任务",
"Run Again From Here": "从此处重新运行",
"The messages after this one are replaced. Files the agent changed stay as they are.": "这条之后的消息会被替换。Agent 改动过的文件保持不变。"
"The messages after this one are replaced. Files the agent changed stay as they are.": "这条之后的消息会被替换。Agent 改动过的文件保持不变。",
"Cancelling…": "正在取消…",
"Code insight needs the index; it can't be stopped": "代码洞察依赖索引,无法停止",
"Waiting for other tasks": "正在等待其他任务",
"This task can't be cancelled": "此任务无法取消",
"Cancelled": "已取消"
}
+1
Переглянути файл
@@ -66,6 +66,7 @@
"app.update.installed": "OpenIDEA {version} 已安装",
"app.update.installedBody": "重启 OpenIDEA 后生效。",
"app.update.installingMessage": "正在安装…",
"app.update.installUncancellable": "正在安装更新,此步骤无法取消",
"app.update.none": "OpenIDEA {version} 已是最新版本",
"app.update.progress": "{done} MB / {total} MB",
"app.update.progressUnknown": "{done} MB",