Skip to content

Commit 51e677f

Browse files
committed
fix: restore download functionality for text-based attachments
The refactoring in #1237 accidentally broke download links for text-based attachments (txt, csv, json, code files) by returning undefined instead of creating a blob URL. This restores the original behavior where all content types get a blob URL for downloading.
1 parent 770d3da commit 51e677f

File tree

1 file changed

+6
-3
lines changed
  • packages/spotlight/src/ui/telemetry/components/insights/envelopes

1 file changed

+6
-3
lines changed

packages/spotlight/src/ui/telemetry/components/insights/envelopes/Attachment.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export default function Attachment({
2323
const extension = inferExtension(header.content_type as string | null, header.type as string | null);
2424
const name = (header.filename as string) || `untitled.${extension}`;
2525

26-
// Create download URL for binary content types
27-
// Returns: string (success), null (decode error)
26+
// Create download URL for attachment
27+
// Returns: string (success), null (decode error), undefined (not expanded yet)
2828
const downloadUrl = useMemo(() => {
2929
if (!expanded) {
3030
return undefined; // Not needed yet
@@ -34,19 +34,22 @@ export default function Attachment({
3434
let blobData: BlobPart;
3535

3636
if (IMAGE_CONTENT_TYPES.has(contentType) || VIDEO_CONTENT_TYPES.has(contentType)) {
37+
// Binary content types are base64-encoded
3738
const decoded = base64Decode(attachment);
3839
if (!decoded) {
3940
return null; // Decode error
4041
}
4142
blobData = decoded.buffer as BlobPart;
4243
} else if (extension === "bin") {
44+
// Unknown binary files are base64-encoded
4345
const decoded = safeAtob(attachment);
4446
if (decoded === null) {
4547
return null; // Decode error
4648
}
4749
blobData = decoded;
4850
} else {
49-
return undefined; // Not a binary type, no blob URL needed
51+
// Text-based content types (json, txt, csv, code, etc.) - use raw attachment
52+
blobData = attachment;
5053
}
5154

5255
const blob = new Blob([blobData], { type: contentType || "application/octet-stream" });

0 commit comments

Comments
 (0)