fix(media): keep one skipped entry per platform on the card

A job that recovers after a crash runs again and reports the same
skipped platforms; the newest reason per platform now replaces the
earlier one instead of listing it twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u
This commit is contained in:
Claude 2026-10-05 09:57:39 +00:00
parent 45856b1af9
commit 9407482903
No known key found for this signature in database
2 changed files with 28 additions and 1 deletions

View File

@ -335,6 +335,25 @@ describePostgres("media job runtime (PostgreSQL, fake operations)", () => {
expect(existsSync(tempDir)).toBe(false);
});
it("keeps one skipped entry per platform when a job reports it again", async () => {
const tooLong = { code: "too_long", maxMs: 600_000, actualMs: 700_000 } as const;
const tooShort = { code: "too_short", minMs: 3_000, actualMs: 1_000 } as const;
const ctx = await setup({
run: async (context) => {
await context.addSkipped({ platform: "tiktok", issues: [tooLong] });
await context.addSkipped({ platform: "tiktok", issues: [tooShort] });
await context.addSkipped({ platform: "youtube", issues: [tooShort] });
return { summary: "Skipped." };
},
});
const { jobId } = await ctx.start({ prompt: "fox" });
await ctx.runtime.runJob(jobId);
expect((await ctx.card(jobId)).skipped).toEqual([
{ platform: "tiktok", issues: [tooShort] },
{ platform: "youtube", issues: [tooShort] },
]);
});
it("refuses outputs outside the temp dir and sources of another user", async () => {
const other = await setup();
const foreign = await other.sourceArtifact();

View File

@ -370,7 +370,15 @@ export function createMediaRuntime(
if (!message) return { exists: false, outputs: appended };
const previous = mediaBlockOf(message.blocks, job.id);
const outputs = [...(previous?.outputs ?? []), ...appended];
const skipped = [...(previous?.skipped ?? []), ...(added.skipped ?? [])];
// A recovered job runs again, so the newest reason per platform replaces an earlier one.
const skipped = [
...new Map(
[...(previous?.skipped ?? []), ...(added.skipped ?? [])].map((entry) => [
entry.platform,
entry,
]),
).values(),
];
const next = cardBlock(job, outputs, skipped);
const current = Array.isArray(message.blocks) ? (message.blocks as MessageBlock[]) : [];
const blocks = previous