Skip to content

Commit da799d5

Browse files
committed
refactor: dedupe startup recovery candidate listing in TaskService.initialize
Extract the awaiting_report/running candidate filters used by the startup inactive-workflow-owner recovery pass into a single listStartupRecoveryCandidates closure, mirroring the existing listQueuedTasks pattern, so the initial computation and the post-interrupt refresh reuse the exact same status filters. Behavior-preserving cleanup of #3594.
1 parent 5b38705 commit da799d5

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

src/node/services/taskService.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,12 +1592,22 @@ export class TaskService {
15921592

15931593
let config = this.config.loadConfigOrDefault();
15941594
let taskIndex = this.buildAgentTaskIndex(config);
1595-
let awaitingReportTasks = this.listAgentTaskWorkspaces(config).filter(
1596-
(t) => t.taskStatus === "awaiting_report"
1597-
);
1598-
let runningTasks = this.listAgentTaskWorkspaces(config).filter(
1599-
(t) => t.taskStatus === "running"
1600-
);
1595+
// Recompute the startup recovery candidate lists from a config snapshot. Hoisted into a
1596+
// closure so the post-interrupt refresh below reuses the exact same status filters.
1597+
const listStartupRecoveryCandidates = (
1598+
sourceConfig: ProjectsConfig
1599+
): {
1600+
awaitingReportTasks: AgentTaskWorkspaceEntry[];
1601+
runningTasks: AgentTaskWorkspaceEntry[];
1602+
} => ({
1603+
awaitingReportTasks: this.listAgentTaskWorkspaces(sourceConfig).filter(
1604+
(t) => t.taskStatus === "awaiting_report"
1605+
),
1606+
runningTasks: this.listAgentTaskWorkspaces(sourceConfig).filter(
1607+
(t) => t.taskStatus === "running"
1608+
),
1609+
});
1610+
let { awaitingReportTasks, runningTasks } = listStartupRecoveryCandidates(config);
16011611

16021612
let interruptedInactiveWorkflowOwnerAtStartup = false;
16031613
for (const task of [...awaitingReportTasks, ...runningTasks]) {
@@ -1619,10 +1629,7 @@ export class TaskService {
16191629
// blocked by a child that this startup pass just interrupted.
16201630
config = this.config.loadConfigOrDefault();
16211631
taskIndex = this.buildAgentTaskIndex(config);
1622-
awaitingReportTasks = this.listAgentTaskWorkspaces(config).filter(
1623-
(t) => t.taskStatus === "awaiting_report"
1624-
);
1625-
runningTasks = this.listAgentTaskWorkspaces(config).filter((t) => t.taskStatus === "running");
1632+
({ awaitingReportTasks, runningTasks } = listStartupRecoveryCandidates(config));
16261633
}
16271634

16281635
let resumedAwaitingReportCount = 0;

0 commit comments

Comments
 (0)