|
| 1 | +import { promises as fs } from "node:fs"; |
| 2 | +import os from "node:os"; |
| 3 | +import path from "node:path"; |
1 | 4 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 5 |
|
3 | 6 | const noop = () => {}; |
@@ -431,4 +434,34 @@ describe("subagent registry seam flow", () => { |
431 | 434 | }); |
432 | 435 | }); |
433 | 436 | }); |
| 437 | + |
| 438 | + it("removes attachments for killed delete-mode runs", async () => { |
| 439 | + const attachmentsRootDir = await fs.mkdtemp( |
| 440 | + path.join(os.tmpdir(), "openclaw-kill-attachments-"), |
| 441 | + ); |
| 442 | + const attachmentsDir = path.join(attachmentsRootDir, "child"); |
| 443 | + await fs.mkdir(attachmentsDir, { recursive: true }); |
| 444 | + await fs.writeFile(path.join(attachmentsDir, "artifact.txt"), "artifact"); |
| 445 | + |
| 446 | + mod.registerSubagentRun({ |
| 447 | + runId: "run-killed-delete-attachments", |
| 448 | + childSessionKey: "agent:main:subagent:killed-delete-attachments", |
| 449 | + requesterSessionKey: "agent:main:main", |
| 450 | + requesterDisplayKey: "main", |
| 451 | + task: "kill and delete attachments", |
| 452 | + cleanup: "delete", |
| 453 | + attachmentsDir, |
| 454 | + attachmentsRootDir, |
| 455 | + }); |
| 456 | + |
| 457 | + const updated = mod.markSubagentRunTerminated({ |
| 458 | + runId: "run-killed-delete-attachments", |
| 459 | + reason: "manual kill", |
| 460 | + }); |
| 461 | + |
| 462 | + expect(updated).toBe(1); |
| 463 | + await vi.waitFor(async () => { |
| 464 | + await expect(fs.access(attachmentsDir)).rejects.toMatchObject({ code: "ENOENT" }); |
| 465 | + }); |
| 466 | + }); |
434 | 467 | }); |
0 commit comments