fix: avoid same-column task move errors and keep durable agents active

This commit is contained in:
gsxdsm
2026-05-14 19:26:58 -07:00
parent 5e1a5a55bb
commit 07d0d8f3d5
4 changed files with 13 additions and 5 deletions

View File

@@ -362,6 +362,12 @@ describe("TaskStore", () => {
await expect(store.moveTask(task.id, "todo")).resolves.toMatchObject({ id: task.id, column: "todo" });
});
it("treats same-column moves as a no-op", async () => {
const task = await store.createTask({ description: "same column no-op", column: "todo" });
await expect(store.moveTask(task.id, "todo")).resolves.toMatchObject({ id: task.id, column: "todo" });
});
});

View File

@@ -3760,8 +3760,8 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
task = this.archiveEntryToTask(archived, false);
}
if (task.column === "done" && toColumn === "done") {
if (this.clearDoneTransientFields(task)) {
if (task.column === toColumn) {
if (toColumn === "done" && this.clearDoneTransientFields(task)) {
task.updatedAt = new Date().toISOString();
await this.atomicWriteTaskJson(dir, task);
if (this.isWatching) this.taskCache.set(id, { ...task });

View File

@@ -277,10 +277,12 @@ export class EphemeralWorkerManager {
this.pendingDeletions.add(agentId);
}
const effectiveTerminalState = reason === "error" && !ephemeral ? "active" : terminalState;
try {
await this.agentStore.updateAgentState(agentId, terminalState);
await this.agentStore.updateAgentState(agentId, effectiveTerminalState);
} catch (err) {
this.log.warn(`Failed to update agent ${agentId} to ${terminalState} (${reason}): ${this.formatError(err)}`);
this.log.warn(`Failed to update agent ${agentId} to ${effectiveTerminalState} (${reason}): ${this.formatError(err)}`);
}
try {
await this.agentStore.syncExecutionTaskLink(agentId, undefined);

View File

@@ -921,7 +921,7 @@ describe("InProcessRuntime", () => {
await vi.advanceTimersByTimeAsync(5000);
const updated = await store.getAgent(durable.id);
expect(updated?.state).toBe("error");
expect(updated?.state).toBe("active");
expect(updated?.taskId).toBeUndefined();
expect(deleteAgentSpy).not.toHaveBeenCalledWith(durable.id);
} finally {