fix(background-agent): delay session error task cleanup
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -908,13 +908,12 @@ export class BackgroundManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.cleanupPendingByParent(task)
|
this.cleanupPendingByParent(task)
|
||||||
this.tasks.delete(task.id)
|
|
||||||
this.clearTaskHistoryWhenParentTasksGone(task.parentSessionID)
|
|
||||||
this.clearNotificationsForTask(task.id)
|
this.clearNotificationsForTask(task.id)
|
||||||
const toastManager = getTaskToastManager()
|
const toastManager = getTaskToastManager()
|
||||||
if (toastManager) {
|
if (toastManager) {
|
||||||
toastManager.removeTask(task.id)
|
toastManager.removeTask(task.id)
|
||||||
}
|
}
|
||||||
|
this.scheduleTaskRemoval(task.id)
|
||||||
if (task.sessionID) {
|
if (task.sessionID) {
|
||||||
SessionCategoryRegistry.remove(task.sessionID)
|
SessionCategoryRegistry.remove(task.sessionID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ describe("task history cleanup", () => {
|
|||||||
managerUnderTest = undefined
|
managerUnderTest = undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
test("#given BackgroundManager with stale tasks for one parent #when pruneStaleTasksAndNotifications() runs #then only that parent's history is removed", () => {
|
test("#given BackgroundManager with stale tasks for one parent #when pruneStaleTasksAndNotifications() runs #then history is preserved until delayed cleanup", () => {
|
||||||
// given
|
// given
|
||||||
const manager = createManager()
|
const manager = createManager()
|
||||||
managerUnderTest = manager
|
managerUnderTest = manager
|
||||||
@@ -136,7 +136,7 @@ describe("task history cleanup", () => {
|
|||||||
pruneStaleTasksAndNotificationsForTest(manager)
|
pruneStaleTasksAndNotificationsForTest(manager)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(manager.taskHistory.getByParentSession("parent-1")).toHaveLength(0)
|
expect(manager.taskHistory.getByParentSession("parent-1")).toHaveLength(1)
|
||||||
expect(manager.taskHistory.getByParentSession("parent-2")).toHaveLength(1)
|
expect(manager.taskHistory.getByParentSession("parent-2")).toHaveLength(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user