Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix: download name (#1504)

gbirmanbb885a827384
diff --git a/js/app/packages/core/util/currentBlockDocumentName.ts b/js/app/packages/core/util/currentBlockDocumentName.ts
index b405c2e820..335ff26cb0 100644
--- a/js/app/packages/core/util/currentBlockDocumentName.ts
+++ b/js/app/packages/core/util/currentBlockDocumentName.ts
@@ -36,11 +36,14 @@ export const useBlockDocumentName = (defaultName?: string) => {
export const useBlockDocumentDownloadName = (defaultName?: string) => {
const documentName = useBlockDocumentName(defaultName);
+ const [metadata] = blockMetadataSignal;
return () => {
let current = documentName();
if (!current) current = 'download';
- const fileType = blockMetadataSignal()?.fileType;
- return formatDocumentName(current, fileType);
+ const fileType = metadata()?.fileType;
+ return formatDocumentName(current, fileType, {
+ caseInsensitiveSuffix: true,
+ });
};
};
diff --git a/js/app/packages/service-clients/service-storage/util/filename.ts b/js/app/packages/service-clients/service-storage/util/filename.ts
index 83a066bdac..c43fd592d2 100644
--- a/js/app/packages/service-clients/service-storage/util/filename.ts
+++ b/js/app/packages/service-clients/service-storage/util/filename.ts
@@ -62,10 +62,20 @@ export const reverseFormatDocumentName = (
return name.substring(0, name.length - suffix.length);
};
+/**
+ * Appends the file type extension to a document name if it's not already present.
+ * @param originalName - The document name to format.
+ * @param fileType - The file extension to append (e.g. "mp4", "mov").
+ * @param options.fullyQualifiedBlockName - When true, only appends the extension for block types in the fully qualified list (e.g. "unknown", "code").
+ * @param options.caseInsensitiveSuffix - When true, treats existing suffixes as matching regardless of case (e.g. "abc.MOV" won't get ".mov" appended).
+ */
export const formatDocumentName = (
originalName: string,
fileType?: string | null,
- options?: { fullyQualifiedBlockName?: boolean }
+ options?: {
+ fullyQualifiedBlockName?: boolean;
+ caseInsensitiveSuffix?: boolean;
+ }
) => {
if (!fileType) return originalName;
@@ -81,5 +91,12 @@ export const formatDocumentName = (
return originalName;
}
+ if (
+ options?.caseInsensitiveSuffix &&
+ originalName.toLowerCase().endsWith(suffix.toLowerCase())
+ ) {
+ return originalName;
+ }
+
return `${originalName}.${fileType}`;
};