fix: clear completed tasks from Recently Assigned (set assignee_status=later)
This commit is contained in:
@@ -324,13 +324,28 @@ EVIDENCE: one line why`;
|
||||
if (this.userTaskListGid) {
|
||||
try {
|
||||
const myTasks = await this.asana.getUserTasks(this.userTaskListGid);
|
||||
|
||||
// First: clear completed tasks from "Recently Assigned" by moving to "later"
|
||||
const completedInbox = myTasks.filter((t) => t.completed);
|
||||
if (completedInbox.length > 0) {
|
||||
logger.info("task-loop", `Clearing ${completedInbox.length} completed tasks from Recently Assigned`);
|
||||
for (const task of completedInbox) {
|
||||
try {
|
||||
await this.asana.updateTask(task.gid, { assignee_status: "later" });
|
||||
logger.info("task-loop", `Cleared from Recently Assigned: ${task.name}`);
|
||||
} catch (e: any) {
|
||||
logger.debug("task-loop", `Could not clear task ${task.name}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Then: check incomplete tasks to see if they're already done
|
||||
const incompleteMyTasks = myTasks.filter((t) => !t.completed);
|
||||
|
||||
if (incompleteMyTasks.length > 0) {
|
||||
logger.info("task-loop", `Sweeping ${incompleteMyTasks.length} tasks from My Tasks (Recently Assigned)`);
|
||||
logger.info("task-loop", `Sweeping ${incompleteMyTasks.length} incomplete tasks from My Tasks`);
|
||||
|
||||
for (const task of incompleteMyTasks) {
|
||||
// Skip if already checked in project sweep
|
||||
if (seen.has(task.gid)) continue;
|
||||
|
||||
const check = await this.verifyTaskAlreadyDone(task);
|
||||
@@ -343,7 +358,7 @@ EVIDENCE: one line why`;
|
||||
`✅ Pi Worker sweep: This task is **already completed**.\n\nEvidence:\n${check.evidence}`
|
||||
);
|
||||
|
||||
await this.asana.updateTask(task.gid, { completed: true });
|
||||
await this.asana.updateTask(task.gid, { completed: true, assignee_status: "later" });
|
||||
logger.info("task-loop", `My Tasks sweep: Marked done: ${task.name}`);
|
||||
} else {
|
||||
logger.debug("task-loop", `My Tasks sweep: "${task.name}" not yet done`);
|
||||
|
||||
Reference in New Issue
Block a user