fix(background): Wave 2 - fix interrupt status checks, display text, error recovery grace, LSP JSONC

- fix(background): include "interrupt" status in all terminal status checks (3 files)
- fix(background): display "INTERRUPTED" instead of "CANCELLED" for interrupted tasks
- fix(cli): add error recovery grace period in poll-for-completion
- fix(lsp): use JSONC parser for config loading to support comments

All changes verified with tests and typecheck.
This commit is contained in:
YeonGyu-Kim
2026-02-10 19:20:59 +09:00
parent 47595f21a6
commit 73898b88b4
11 changed files with 268 additions and 13 deletions
@@ -0,0 +1,56 @@
import { describe, test, expect, mock } from "bun:test"
import type { BackgroundManager } from "../../features/background-agent"
import { createBackgroundTask } from "./create-background-task"
describe("createBackgroundTask", () => {
const mockManager = {
launch: mock(() => Promise.resolve({
id: "test-task-id",
sessionID: null,
description: "Test task",
agent: "test-agent",
status: "pending",
})),
getTask: mock(),
} as unknown as BackgroundManager
const tool = createBackgroundTask(mockManager)
const testContext = {
sessionID: "test-session",
messageID: "test-message",
agent: "test-agent",
abort: new AbortController().signal,
}
const testArgs = {
description: "Test background task",
prompt: "Test prompt",
agent: "test-agent",
}
test("detects interrupted task as failure", async () => {
//#given
mockManager.launch.mockResolvedValueOnce({
id: "test-task-id",
sessionID: null,
description: "Test task",
agent: "test-agent",
status: "pending",
})
mockManager.getTask.mockReturnValueOnce({
id: "test-task-id",
sessionID: null,
description: "Test task",
agent: "test-agent",
status: "interrupt",
})
//#when
const result = await tool.execute(testArgs, testContext)
//#then
expect(result).toContain("Task entered error state")
expect(result).toContain("test-task-id")
})
})
@@ -79,7 +79,7 @@ export function createBackgroundTask(manager: BackgroundManager): ToolDefinition
}
await delay(WAIT_FOR_SESSION_INTERVAL_MS)
const updated = manager.getTask(task.id)
if (!updated || updated.status === "error") {
if (!updated || updated.status === "error" || updated.status === "cancelled" || updated.status === "interrupt") {
return `Task ${!updated ? "was deleted" : `entered error state`}\.\n\nTask ID: ${task.id}`
}
sessionId = updated?.sessionID