From 004714a86bd5fb559604d21afca2e2c07cc2e6a2 Mon Sep 17 00:00:00 2001
From: Mahesh Sanikommu
Date: Thu, 4 Jun 2026 01:16:06 -0700
Subject: [PATCH] ENG-712: Accept JSON uploads in Nova + fix file-size display
- Accept .json / application/json files in the add-document uploader.
- Show file sizes in B/KB/MB instead of always '0.00 MB' for small files.
---
apps/web/components/add-document/file.tsx | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/apps/web/components/add-document/file.tsx b/apps/web/components/add-document/file.tsx
index beb31878d..a766bcf05 100644
--- a/apps/web/components/add-document/file.tsx
+++ b/apps/web/components/add-document/file.tsx
@@ -8,7 +8,7 @@ import { useHotkeys } from "react-hotkeys-hook"
import { toast } from "sonner"
export const FILE_ACCEPT =
- "image/*,.pdf,.doc,.docx,.xls,.xlsx,.csv,.txt,.md,.mdx,text/markdown"
+ "image/*,.pdf,.doc,.docx,.xls,.xlsx,.csv,.txt,.md,.mdx,.json,text/markdown,application/json"
export type FileQueueItemStatus = "pending" | "uploading" | "success" | "error"
@@ -46,10 +46,12 @@ function isAcceptedFile(file: File): boolean {
".txt",
".md",
".mdx",
+ ".json",
])
if (allowedExt.has(ext)) return true
if (file.type.startsWith("image/")) return true
if (file.type === "text/markdown") return true
+ if (file.type === "application/json") return true
return false
}
@@ -57,6 +59,18 @@ function fileQueueKey(file: File): string {
return `${file.name}:${file.size}:${file.lastModified}`
}
+function formatFileSize(bytes: number): string {
+ if (bytes < 1024) return `${bytes} B`
+ const units = ["KB", "MB", "GB", "TB"]
+ let size = bytes / 1024
+ let i = 0
+ while (size >= 1024 && i < units.length - 1) {
+ size /= 1024
+ i++
+ }
+ return `${size.toFixed(size < 10 ? 1 : 0)} ${units[i]}`
+}
+
export function FileContent({
data,
onDataChange,
@@ -284,7 +298,7 @@ export function FileContent({
{item.file.name}
- {(item.file.size / 1024 / 1024).toFixed(2)} MB
+ {formatFileSize(item.file.size)}
{item.status === "error" && item.errorMessage ? (