fix: hard-abort clears queues on /stop
This commit is contained in:
27
src/auto-reply/reply/queue/cleanup.ts
Normal file
27
src/auto-reply/reply/queue/cleanup.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { resolveEmbeddedSessionLane } from "../../../agents/pi-embedded.js";
|
||||
import { clearCommandLane } from "../../../process/command-queue.js";
|
||||
import { clearFollowupQueue } from "./state.js";
|
||||
|
||||
export type ClearSessionQueueResult = {
|
||||
followupCleared: number;
|
||||
laneCleared: number;
|
||||
keys: string[];
|
||||
};
|
||||
|
||||
export function clearSessionQueues(keys: Array<string | undefined>): ClearSessionQueueResult {
|
||||
const seen = new Set<string>();
|
||||
let followupCleared = 0;
|
||||
let laneCleared = 0;
|
||||
const clearedKeys: string[] = [];
|
||||
|
||||
for (const key of keys) {
|
||||
const cleaned = key?.trim();
|
||||
if (!cleaned || seen.has(cleaned)) continue;
|
||||
seen.add(cleaned);
|
||||
clearedKeys.push(cleaned);
|
||||
followupCleared += clearFollowupQueue(cleaned);
|
||||
laneCleared += clearCommandLane(resolveEmbeddedSessionLane(cleaned));
|
||||
}
|
||||
|
||||
return { followupCleared, laneCleared, keys: clearedKeys };
|
||||
}
|
||||
Reference in New Issue
Block a user