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.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user