From 8e2410f1a041e4ae6be2bf4bae00f83bbb1eb5e8 Mon Sep 17 00:00:00 2001 From: Jeremy Gollehon Date: Thu, 15 Jan 2026 10:53:08 -0800 Subject: [PATCH] refactor(background-agent): rename registerExternalTask to trackTask Update BackgroundManager to rename the method for tracking external tasks, improving clarity and consistency in task management. Adjust related tests to reflect the new method name. --- src/features/background-agent/manager.test.ts | 8 ++++---- src/features/background-agent/manager.ts | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/features/background-agent/manager.test.ts b/src/features/background-agent/manager.test.ts index ab6e8acc7..304cf99dd 100644 --- a/src/features/background-agent/manager.test.ts +++ b/src/features/background-agent/manager.test.ts @@ -960,7 +960,7 @@ describe("BackgroundManager.tryCompleteTask", () => { }) }) -describe("BackgroundManager.registerExternalTask", () => { +describe("BackgroundManager.trackTask", () => { let manager: BackgroundManager beforeEach(() => { @@ -985,8 +985,8 @@ describe("BackgroundManager.registerExternalTask", () => { } // #when - await manager.registerExternalTask(input) - await manager.registerExternalTask(input) + await manager.trackTask(input) + await manager.trackTask(input) // #then const concurrencyManager = getConcurrencyManager(manager) @@ -1010,7 +1010,7 @@ describe("BackgroundManager.resume concurrency key", () => { test("should re-acquire using external task concurrency key", async () => { // #given - const task = await manager.registerExternalTask({ + const task = await manager.trackTask({ taskId: "task-1", sessionID: "session-1", parentSessionID: "parent-session", diff --git a/src/features/background-agent/manager.ts b/src/features/background-agent/manager.ts index 408701900..6959f7b45 100644 --- a/src/features/background-agent/manager.ts +++ b/src/features/background-agent/manager.ts @@ -248,10 +248,10 @@ export class BackgroundManager { } /** - * Register an external task (e.g., from sisyphus_task) for notification tracking. - * This allows tasks created by external tools to receive the same toast/prompt notifications. + * Track a task created elsewhere (e.g., from sisyphus_task) for notification tracking. + * This allows tasks created by other tools to receive the same toast/prompt notifications. */ - async registerExternalTask(input: { + async trackTask(input: { taskId: string sessionID: string parentSessionID: string @@ -419,11 +419,11 @@ export class BackgroundManager { existingTask.error = errorMessage existingTask.completedAt = new Date() - // Release concurrency on error to prevent slot leaks - if (existingTask.concurrencyKey) { - this.concurrencyManager.release(existingTask.concurrencyKey) - existingTask.concurrencyKey = undefined - } + // Release concurrency on error to prevent slot leaks + if (existingTask.concurrencyKey) { + this.concurrencyManager.release(existingTask.concurrencyKey) + existingTask.concurrencyKey = undefined + } this.markForNotification(existingTask) this.notifyParentSession(existingTask).catch(err => { log("[background-agent] Failed to notify on resume error:", err)