mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:50:43 +00:00
fix(ui): fall back for generic transcript image MIME
This commit is contained in:
committed by
Peter Steinberger
parent
501a68a69b
commit
3cb142ff2e
@@ -83,7 +83,13 @@ function getFileExtension(url: string): string | undefined {
|
||||
|
||||
function isImageTranscriptMediaPath(path: string, mediaType: unknown): boolean {
|
||||
if (typeof mediaType === "string" && mediaType.trim()) {
|
||||
return mediaType.trim().toLowerCase().startsWith("image/");
|
||||
const normalized = mediaType.trim().toLowerCase();
|
||||
if (normalized.startsWith("image/")) {
|
||||
return true;
|
||||
}
|
||||
if (normalized !== "application/octet-stream") {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const ext = getFileExtension(path);
|
||||
return (
|
||||
|
||||
@@ -946,6 +946,34 @@ describe("chat view", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps transcript images visible when MIME falls back to application/octet-stream", () => {
|
||||
const container = document.createElement("div");
|
||||
|
||||
renderGroupedMessage(
|
||||
container,
|
||||
{
|
||||
id: "user-history-image-octet-stream",
|
||||
role: "user",
|
||||
content: "",
|
||||
MediaPath: "/tmp/openclaw/user-upload.png",
|
||||
MediaType: "application/octet-stream",
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
"user",
|
||||
{
|
||||
showToolCalls: false,
|
||||
basePath: "/openclaw",
|
||||
assistantAttachmentAuthToken: "session-token",
|
||||
localMediaPreviewRoots: ["/tmp/openclaw"],
|
||||
},
|
||||
);
|
||||
|
||||
const image = container.querySelector<HTMLImageElement>(".chat-message-image");
|
||||
expect(image?.getAttribute("src")).toBe(
|
||||
"/openclaw/__openclaw__/assistant-media?source=%2Ftmp%2Fopenclaw%2Fuser-upload.png&token=session-token",
|
||||
);
|
||||
});
|
||||
|
||||
it("skips non-image transcript media paths after history reload", () => {
|
||||
const container = document.createElement("div");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user