@devries-cameron20 / t3code-1 / commits / 48e73f6ca9
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix: honor generic MIME aliases in attachment previews (#29360)

Johan Vaz committed Nov 4, 2026 at 07:23 UTC 48e73f6ca905f87e3432b19112c704d68fe9319c
2 files changed +22 -4
packages/shared/src/filePreview.test.ts
+20 -2
@@ -24,7 +24,16 @@ describe("workspace file previews", () => {
24 ["db", "sqlite", "application/vnd.sqlite3"],
25 ])("recognizes binary preview %s", (extension, kind, mimeType) => {
26 const name = `files#draft/sample.${extension.toUpperCase()}`;
27 - expect(filePreviewKind({ name, mimeType: "application/octet-stream" })).toBe(kind);
27 + for (const genericMime of [
28 + "",
29 + "application/octet-stream",
30 + "binary/octet-stream",
31 + "application/unknown",
32 + " APPLICATION/UNKNOWN ; charset=utf-8",
33 + "text/plain",
34 + ]) {
35 + expect(filePreviewKind({ name, mimeType: genericMime })).toBe(kind);
36 + }
37 expect(filePreviewKind({ name: "download", mimeType })).toBe(kind);
38 expect(isWorkspacePreviewEntryPath(name)).toBe(true);
39 expect(isWorkspacePreviewEntryPath(`${name}?download=1`)).toBe(false);
@@ -79,7 +88,16 @@ describe("workspace file previews", () => {
88 ["analysis.ipynb", "ipynb", "application/x-ipynb+json"],
89 ])("recognizes Office assets at literal path %s", (name, kind, mimeType) => {
90 expect(officePreviewKind({ name })).toBe(kind);
82 - expect(filePreviewKind({ name, mimeType: "application/octet-stream" })).toBe(kind);
91 + for (const genericMime of [
92 + "",
93 + "application/octet-stream",
94 + "binary/octet-stream",
95 + "application/unknown",
96 + " APPLICATION/UNKNOWN ; charset=utf-8",
97 + "text/plain",
98 + ]) {
99 + expect(filePreviewKind({ name, mimeType: genericMime })).toBe(kind);
100 + }
101 expect(isWorkspacePreviewEntryPath(name)).toBe(true);
102 expect(hostPreviewMimeTypeFromExtension(`.${kind}`)).toBe(mimeType);
103 expect(filePreviewKind({ name: "download", mimeType })).toBe(kind);
packages/shared/src/filePreview.ts
+2 -2
@@ -126,7 +126,7 @@ export function binaryPreviewKind(file: {
126 ].includes(mime)
127 )
128 return "archive";
129 - if (mime && mime !== "application/octet-stream" && mime !== "text/plain") return null;
129 + if (mime && !GENERIC_MIME_TYPES.has(mime) && mime !== "text/plain") return null;
130 const extension = file.name.slice(file.name.lastIndexOf(".")).toLowerCase();
131 const inferred = BINARY_MIME_TYPES.get(extension);
132 return inferred === "application/vnd.sqlite3" ? "sqlite" : inferred ? "archive" : null;
@@ -158,7 +158,7 @@ export function officePreviewKind(file: {
158 if (mime === OFFICE_MIME_TYPES[kind]) return kind;
159 if (
160 (!mime ||
161 - mime === "application/octet-stream" ||
161 + GENERIC_MIME_TYPES.has(mime) ||
162 mime === "text/plain" ||
163 (kind === "ipynb" && mime === "application/json")) &&
164 file.name.toLowerCase().endsWith(`.${kind}`)