The best way to control Claude Code, Codex and more from any computer or phone
fix(shared): TypeScript files no longer show as videos (#27372)
maria committed
Oct 30, 2026 at 15:43 UTC
616c426f5f199865e34974777740dff678ffb7f5
5 files changed
+15
-3
packages/shared/src/filePreview.test.ts
+3
@@ -30,6 +30,9 @@ describe("workspace file previews", () => {
30
expect(isWorkspacePreviewEntryPath(`${name}?download=1`)).toBe(false);
31
expect(hostPreviewMimeTypeFromExtension(`.${extension}`)).toBe(mimeType);
32
});
33
+ it("previews a TypeScript file the OS labels as MPEG transport stream as text", () => {
34
+ expect(filePreviewKind({ name: "clamp.ts", mimeType: "video/mp2t" })).toBe("text");
35
+ });
36
it("recognizes compound archives and MIME aliases", () => {
37
expect(filePreviewKind({ name: "archive.tar.gz" })).toBe("archive");
38
expect(filePreviewKind({ name: "download", mimeType: "application/x-gzip" })).toBe("archive");
packages/shared/src/filePreview.ts
+3
-2
@@ -9,6 +9,7 @@ export {
9
mediaKindFromPath,
10
mediaMimeTypeFromExtension,
11
} from "./mediaPreview.ts";
12
+import { GENERIC_MIME_TYPES } from "./image.ts";
13
import { videoMimeType } from "./video.ts";
14
15
export type FilePreviewKind =
@@ -41,7 +42,7 @@ export function filePreviewKind(
42
const mime = file.mimeType?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
43
const name = file.name.toLowerCase();
44
const extension = name.slice(name.lastIndexOf("."));
44
- const generic = !mime || mime === "application/octet-stream" || mime === "text/plain";
45
+ const generic = !mime || GENERIC_MIME_TYPES.has(mime) || mime === "text/plain";
46
const richDocuments = options?.richDocuments !== false;
47
const office = richDocuments ? officePreviewKind(file) : null;
48
if (office) return office;
@@ -61,7 +62,7 @@ export function filePreviewKind(
62
)
63
return "font";
64
if (mime.startsWith("image/")) return "image";
64
- if (mime.startsWith("video/")) return "video";
65
+ if (mime.startsWith("video/") && !generic) return "video";
66
if (mime.startsWith("audio/")) return "audio";
67
if (generic) {
68
if (extension === ".pdf") return "pdf";
packages/shared/src/image.ts
+3
@@ -13,6 +13,9 @@ export const GENERIC_MIME_TYPES = new Set([
13
"application/octet-stream",
14
"binary/octet-stream",
15
"application/unknown",
16
+ // macOS and Windows label TypeScript `.ts` files as MPEG transport streams, which browsers can't play.
17
+ "video/mp2t",
18
+ "video/vnd.dlna.mpeg-tts",
19
]);
20
21
export function isSvgAttachment(attachment: {
packages/shared/src/video.test.ts
+5
@@ -14,4 +14,9 @@ describe("videoMimeType", () => {
14
"video/webm",
15
);
16
});
17
+
18
+ it("does not treat a TypeScript file the OS labels as MPEG transport stream as video", () => {
19
+ expect(videoMimeType({ name: "clamp.ts", mimeType: "video/mp2t" })).toBeNull();
20
+ expect(videoMimeType({ name: "clamp.ts", mimeType: "video/vnd.dlna.mpeg-tts" })).toBeNull();
21
+ });
22
});
packages/shared/src/video.ts
+1
-1
@@ -17,7 +17,7 @@ export function videoMimeType(attachment: {
17
readonly mimeType: string;
18
}): string | null {
19
const mimeType = attachment.mimeType.split(";", 1)[0]?.trim().toLowerCase() ?? "";
20
- if (mimeType.startsWith("video/")) return mimeType;
20
+ if (mimeType.startsWith("video/") && !GENERIC_MIME_TYPES.has(mimeType)) return mimeType;
21
if (mimeType !== "" && !GENERIC_MIME_TYPES.has(mimeType)) return null;
22
const dotIndex = attachment.name.lastIndexOf(".");
23
return dotIndex < 0