fix(background-agent): refresh stale todo state
This commit is contained in:
@@ -345,6 +345,47 @@ describe("BackgroundManager pollRunningTasks", () => {
|
|||||||
expect(task.status).toBe("completed")
|
expect(task.status).toBe("completed")
|
||||||
expect(todoCallCount).toBe(0)
|
expect(todoCallCount).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("#when cached incomplete todos become complete before idle polling #then refreshes todos and completes", async () => {
|
||||||
|
//#given
|
||||||
|
let todoCallCount = 0
|
||||||
|
const manager = createManagerWithClient({
|
||||||
|
status: async () => ({ data: { "ses-idle-stale-todos": { type: "idle" } } }),
|
||||||
|
todo: async () => {
|
||||||
|
todoCallCount += 1
|
||||||
|
return {
|
||||||
|
data: [
|
||||||
|
{ content: "compile result", status: "completed", priority: "high" },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const task = createRunningTask("ses-idle-stale-todos")
|
||||||
|
injectTask(manager, task)
|
||||||
|
|
||||||
|
manager.handleEvent({
|
||||||
|
type: "message.part.updated",
|
||||||
|
properties: { sessionID: "ses-idle-stale-todos", type: "text" },
|
||||||
|
})
|
||||||
|
manager.handleEvent({
|
||||||
|
type: "todo.updated",
|
||||||
|
properties: {
|
||||||
|
sessionID: "ses-idle-stale-todos",
|
||||||
|
todos: [
|
||||||
|
{ content: "compile result", status: "in_progress", priority: "high" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
//#when
|
||||||
|
const poll = manager["pollRunningTasks"]
|
||||||
|
await poll.call(manager)
|
||||||
|
manager.shutdown()
|
||||||
|
|
||||||
|
//#then
|
||||||
|
expect(task.status).toBe("completed")
|
||||||
|
expect(todoCallCount).toBe(1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("#given a running task whose session status is busy", () => {
|
describe("#given a running task whose session status is busy", () => {
|
||||||
|
|||||||
@@ -1220,8 +1220,8 @@ The fallback retry session is now created and can be inspected directly.
|
|||||||
|
|
||||||
private async checkSessionTodos(sessionID: string): Promise<boolean> {
|
private async checkSessionTodos(sessionID: string): Promise<boolean> {
|
||||||
const observedIncompleteTodos = this.observedIncompleteTodosBySession.get(sessionID)
|
const observedIncompleteTodos = this.observedIncompleteTodosBySession.get(sessionID)
|
||||||
if (observedIncompleteTodos !== undefined) {
|
if (observedIncompleteTodos === false) {
|
||||||
return observedIncompleteTodos
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user