fix: infer later user turn media types

This commit is contained in:
Shakker
2026-05-26 00:11:12 +01:00
committed by Shakker
parent 662e5b67d5
commit 6510aecfb4
2 changed files with 14 additions and 1 deletions

View File

@@ -83,6 +83,19 @@ describe("user turn transcript persistence", () => {
]);
});
it("does not reuse singular media type for later media paths", () => {
expect(
buildPersistedUserTurnMediaInputsFromFields({
MediaPath: "/tmp/a.png",
MediaPaths: ["/tmp/a.png", "/tmp/report.pdf"],
MediaType: "image/png",
}),
).toEqual([
{ path: "/tmp/a.png", contentType: "image/png" },
{ path: "/tmp/report.pdf", contentType: "application/pdf" },
]);
});
it("resolves staged relative media paths against the media workspace", () => {
const workspaceDir = createTempDir("openclaw-user-turn-media-");

View File

@@ -250,7 +250,7 @@ export function buildPersistedUserTurnMediaInputsFromFields(
...(mediaPath ? { path: mediaPath } : {}),
...(url ? { url } : {}),
contentType: resolveTranscriptMediaType({
explicitType: types[index] ?? singleType,
explicitType: types[index] ?? (index === 0 ? singleType : undefined),
mediaPath,
mediaUrl: url,
}),