From 5a19986c92201536a626335dd6bddb19b1ba90d9 Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 3 Jun 2026 15:16:06 +0800 Subject: [PATCH 1/3] feat(ui): add high-fidelity skeleton loading screens and local uploading file cards --- .../components/file-browser/file-browser.tsx | 54 ++++-- .../webui/components/loading-skeletons.tsx | 169 ++++++++++++++++++ .../projects/$projectId/files/$fileId.tsx | 3 +- .../projects/$projectId/folders/$folderId.tsx | 5 +- .../routes/projects/$projectId/index.tsx | 5 +- .../projects/$projectId/recently-deleted.tsx | 5 +- .../projects/$projectId/shares/$shareId.tsx | 5 +- packages/webui/routes/share/$shareId.tsx | 4 +- 8 files changed, 226 insertions(+), 24 deletions(-) create mode 100644 packages/webui/components/loading-skeletons.tsx diff --git a/packages/webui/components/file-browser/file-browser.tsx b/packages/webui/components/file-browser/file-browser.tsx index 19e12ffa..24854576 100644 --- a/packages/webui/components/file-browser/file-browser.tsx +++ b/packages/webui/components/file-browser/file-browser.tsx @@ -125,6 +125,14 @@ export function FileBrowser({ const queryClient = useQueryClient() const navigate = useNavigate() + const [localUploadingFiles, setLocalUploadingFiles] = useState([]) + + const displayedFiles = useMemo(() => { + const existingIds = new Set(files.map((f) => f.id)) + const filteredLocal = localUploadingFiles.filter((f) => !existingIds.has(f.id)) + return [...filteredLocal, ...files] + }, [files, localUploadingFiles]) + const { data: shareLinksData } = useQuery({ queryKey: ['shares', teamId, projectId], queryFn: async () => { @@ -320,7 +328,7 @@ export function FileBrowser({ projectId, assetId, folders, - files, + files: displayedFiles, selectedIds, }) @@ -349,6 +357,24 @@ export function FileBrowser({ return (await res.json()) as InferResponseType }, onSuccess: async (data) => { + const newLocalFiles: AssetInfo[] = filesToUpload.map((f) => { + const urlInfo = ( + data.presignedUrls as { id?: string; url?: string; fileId?: string }[] | undefined + )?.find((p) => p.id === f.id) + return { + id: urlInfo?.fileId || f.id, + name: f.file.name, + sizeByte: f.file.size, + fileCount: 0, + type: 'file', + status: 'uploading', + mediaType: f.file.type || null, + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), + } + }) + setLocalUploadingFiles((prev) => [...newLocalFiles, ...prev]) + // The RPC client returns an object that we cast to the expected type // eslint-disable-next-line @typescript-eslint/no-explicit-any await uploadFiles(filesToUpload, data.presignedUrls as any, data.taskId!) @@ -392,7 +418,7 @@ export function FileBrowser({ }, [filesInView, hasNextFilesPage, isFetchingNextFilesPage, fetchNextFilesPage]) const foldersSize = folders.reduce((acc, f) => acc + (f.sizeByte || 0), 0) - const filesSize = files.reduce((acc, f) => acc + (f.sizeByte || 0), 0) + const filesSize = displayedFiles.reduce((acc, f) => acc + (f.sizeByte || 0), 0) const formatCount = (count: number, isFile: boolean) => { const isNameFilter = filterConditions?.some( @@ -496,7 +522,7 @@ export function FileBrowser({ folders.find((item) => item.id === id), ).length const selectedFiles = Array.from(selectedIds).filter((id) => - files.find((item) => item.id === id), + displayedFiles.find((item) => item.id === id), ).length const handleUploadFilesClick = () => { @@ -565,9 +591,6 @@ export function FileBrowser({ errorMessage: `upload failed with status: ${resp.status}`, }, }) - queryClient.invalidateQueries({ - queryKey: ['search', teamId, assetId], - }) return } } catch (error) { @@ -579,13 +602,14 @@ export function FileBrowser({ errorMessage: `upload failed with error: ${error instanceof Error ? error.message : String(error)}`, }, }) - queryClient.invalidateQueries({ - queryKey: ['search', teamId, assetId], - }) return } } finally { decrementUploading() + setLocalUploadingFiles((prev) => prev.filter((f) => f.id !== uploadInfo.fileId)) + queryClient.invalidateQueries({ + queryKey: ['search', teamId, assetId], + }) } } } @@ -764,7 +788,7 @@ export function FileBrowser({ {displayStyle === 'list' ? ( @@ -856,7 +880,9 @@ export function FileBrowser({ variant="ghost" size="sm" onClick={() => - handleDownload([...folders, ...files].filter((i) => selectedIds.has(i.id!))) + handleDownload( + [...folders, ...displayedFiles].filter((i) => selectedIds.has(i.id!)), + ) } className="gap-2" > @@ -871,7 +897,7 @@ export function FileBrowser({ item={contextMenuItem} selectedIds={selectedIds} folders={folders} - files={files} + files={displayedFiles} onRename={handleRename} onDelete={handleDelete} onDownload={handleDownload} diff --git a/packages/webui/components/loading-skeletons.tsx b/packages/webui/components/loading-skeletons.tsx new file mode 100644 index 00000000..43c8016b --- /dev/null +++ b/packages/webui/components/loading-skeletons.tsx @@ -0,0 +1,169 @@ +import { Skeleton } from '@/ui/components/ui/skeleton' + +export function ProjectFolderSkeleton() { + return ( +
+ {/* Top navigation/breadcrumbs placeholder */} +
+
+ + / + +
+
+ + +
+
+ +
+ {/* Sidebar (Folder tree placeholder) */} +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ + {/* File Browser area */} +
+ {/* File browser toolbar */} +
+
+ + +
+
+ + + +
+
+ + {/* Cards Grid */} +
+
+ +
+
+ {Array.from({ length: 10 }).map((_, i) => ( +
+ +
+ +
+ + +
+
+
+ ))} +
+
+
+
+
+ ) +} + +export function FileDetailSkeleton() { + return ( +
+ {/* Top navigation */} +
+
+ + / + + / + +
+
+ +
+
+ +
+ {/* Left Pane (Version stack) */} +
+ +
+ {Array.from({ length: 4 }).map((_, i) => ( +
+ +
+ + +
+
+ ))} +
+
+ + {/* Center Pane (Viewer area) */} +
+
+ +
+
+
+ + +
+ +
+
+ + {/* Right Pane (Metadata and Comments) */} +
+ {/* Metadata Section */} +
+ +
+ {Array.from({ length: 3 }).map((_, i) => ( +
+ + +
+ ))} +
+
+ + {/* Comments Section */} +
+ +
+ {Array.from({ length: 3 }).map((_, i) => ( +
+ +
+
+ + +
+ + +
+
+ ))} +
+
+
+
+
+ ) +} diff --git a/packages/webui/routes/projects/$projectId/files/$fileId.tsx b/packages/webui/routes/projects/$projectId/files/$fileId.tsx index 33c485f8..48be52aa 100644 --- a/packages/webui/routes/projects/$projectId/files/$fileId.tsx +++ b/packages/webui/routes/projects/$projectId/files/$fileId.tsx @@ -3,6 +3,7 @@ import { FileViewer } from '@/ui/components/file-viewer' import { FileViewerLeftSidebar } from '@/ui/components/file-viewer-left-sidebar' import { FileViewerRightSidebar } from '@/ui/components/file-viewer-right-sidebar' import { ResizeHandle } from '@/ui/components/resize-handle' +import { FileDetailSkeleton } from '@/ui/components/loading-skeletons' import { useMemberStore } from '@/ui/stores/members' import { useTeamContextStore } from '@/ui/stores/team-context' import { useTopNavStore } from '@/ui/stores/top-nav' @@ -171,7 +172,7 @@ function FileViewPage() { ]) if (isLoading && !fileData) { - return
Loading...
+ return } if (isError || !fileData || !projectInfo || !teamId) { diff --git a/packages/webui/routes/projects/$projectId/folders/$folderId.tsx b/packages/webui/routes/projects/$projectId/folders/$folderId.tsx index c8073a43..f3ed6d16 100644 --- a/packages/webui/routes/projects/$projectId/folders/$folderId.tsx +++ b/packages/webui/routes/projects/$projectId/folders/$folderId.tsx @@ -1,5 +1,6 @@ import { client } from '@/ui/api/client' import FileSystemManager from '@/ui/components/file-system-manager' +import { ProjectFolderSkeleton } from '@/ui/components/loading-skeletons' import { useTeamContextStore } from '@/ui/stores/team-context' import { useQuery, useSuspenseQuery } from '@tanstack/react-query' import { createFileRoute } from '@tanstack/react-router' @@ -41,7 +42,7 @@ function FolderPage() { }) if (!teamId || !rootFolderId || !rootFolder) { - return
Loading project...
+ return } return ( @@ -59,5 +60,5 @@ export const Route = createFileRoute('/projects/$projectId/folders/$folderId')({ component: FolderPage, loader: ({ context: { queryClient }, params: { projectId } }) => queryClient.ensureQueryData(projectInfoQueryOptions(projectId)), - pendingComponent: () =>
Loading project...
, + pendingComponent: () => , }) diff --git a/packages/webui/routes/projects/$projectId/index.tsx b/packages/webui/routes/projects/$projectId/index.tsx index 3d7ea4a3..85753960 100644 --- a/packages/webui/routes/projects/$projectId/index.tsx +++ b/packages/webui/routes/projects/$projectId/index.tsx @@ -1,5 +1,6 @@ import { client } from '@/ui/api/client' import FileSystemManager from '@/ui/components/file-system-manager' +import { ProjectFolderSkeleton } from '@/ui/components/loading-skeletons' import { useTeamContextStore } from '@/ui/stores/team-context' import { useQuery, useSuspenseQuery } from '@tanstack/react-query' import { createFileRoute } from '@tanstack/react-router' @@ -41,7 +42,7 @@ function ProjectPage() { }) if (!teamId || !rootFolderId || !rootFolder) { - return
Loading project...
+ return } return ( @@ -59,5 +60,5 @@ export const Route = createFileRoute('/projects/$projectId/')({ component: ProjectPage, loader: ({ context: { queryClient }, params: { projectId } }) => queryClient.ensureQueryData(projectInfoQueryOptions(projectId)), - pendingComponent: () =>
Loading project...
, + pendingComponent: () => , }) diff --git a/packages/webui/routes/projects/$projectId/recently-deleted.tsx b/packages/webui/routes/projects/$projectId/recently-deleted.tsx index ccb4256e..fc00fd08 100644 --- a/packages/webui/routes/projects/$projectId/recently-deleted.tsx +++ b/packages/webui/routes/projects/$projectId/recently-deleted.tsx @@ -1,5 +1,6 @@ import { client } from '@/ui/api/client' import FileSystemManager from '@/ui/components/file-system-manager' +import { ProjectFolderSkeleton } from '@/ui/components/loading-skeletons' import { useTeamContextStore } from '@/ui/stores/team-context' import { useQuery, useSuspenseQuery } from '@tanstack/react-query' import { createFileRoute } from '@tanstack/react-router' @@ -41,7 +42,7 @@ function RecentlyDeletedPage() { }) if (!teamId || !rootFolderId || !rootFolder) { - return
Loading project...
+ return } return ( @@ -59,5 +60,5 @@ export const Route = createFileRoute('/projects/$projectId/recently-deleted')({ component: RecentlyDeletedPage, loader: ({ context: { queryClient }, params: { projectId } }) => queryClient.ensureQueryData(projectInfoQueryOptions(projectId)), - pendingComponent: () =>
Loading project...
, + pendingComponent: () => , }) diff --git a/packages/webui/routes/projects/$projectId/shares/$shareId.tsx b/packages/webui/routes/projects/$projectId/shares/$shareId.tsx index 49aa8455..2f255dbd 100644 --- a/packages/webui/routes/projects/$projectId/shares/$shareId.tsx +++ b/packages/webui/routes/projects/$projectId/shares/$shareId.tsx @@ -1,5 +1,6 @@ import { client } from '@/ui/api/client' import ShareManager from '@/ui/components/share-manager' +import { ProjectFolderSkeleton } from '@/ui/components/loading-skeletons' import { useTeamContextStore } from '@/ui/stores/team-context' import { useQuery, useSuspenseQuery } from '@tanstack/react-query' import { createFileRoute } from '@tanstack/react-router' @@ -41,7 +42,7 @@ function SharePage() { }) if (!teamId || !rootFolderId || !rootFolder) { - return
Loading project...
+ return } return ( @@ -59,5 +60,5 @@ export const Route = createFileRoute('/projects/$projectId/shares/$shareId')({ component: SharePage, loader: ({ context: { queryClient }, params: { projectId } }) => queryClient.ensureQueryData(projectInfoQueryOptions(projectId)), - pendingComponent: () =>
Loading share link...
, + pendingComponent: () => , }) diff --git a/packages/webui/routes/share/$shareId.tsx b/packages/webui/routes/share/$shareId.tsx index 31e1e68e..fd8689ca 100644 --- a/packages/webui/routes/share/$shareId.tsx +++ b/packages/webui/routes/share/$shareId.tsx @@ -1,4 +1,5 @@ import { client } from '@/ui/api/client' +import { ProjectFolderSkeleton } from '@/ui/components/loading-skeletons' import { useQuery } from '@tanstack/react-query' import { createFileRoute, Outlet } from '@tanstack/react-router' @@ -20,7 +21,8 @@ function ShareLayout() { }, }) - if (isLoading) return
Loading...
+ if (isLoading) return + if (error || !shareInfo) return (
From eba4801dc78a3a45235c2c5100cfc0c74b617161 Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 3 Jun 2026 15:23:10 +0800 Subject: [PATCH 2/3] fix(ui): resolve upload error mapping and completeness race condition --- .../components/file-browser/file-browser.tsx | 9 +++++--- .../components/file-browser/file-card.tsx | 22 +++++++++++++++---- .../file-browser/file-list-item.tsx | 6 +++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/packages/webui/components/file-browser/file-browser.tsx b/packages/webui/components/file-browser/file-browser.tsx index 24854576..8c9e1750 100644 --- a/packages/webui/components/file-browser/file-browser.tsx +++ b/packages/webui/components/file-browser/file-browser.tsx @@ -361,13 +361,14 @@ export function FileBrowser({ const urlInfo = ( data.presignedUrls as { id?: string; url?: string; fileId?: string }[] | undefined )?.find((p) => p.id === f.id) + const hasUrl = !!urlInfo && !!urlInfo.url return { id: urlInfo?.fileId || f.id, name: f.file.name, sizeByte: f.file.size, fileCount: 0, type: 'file', - status: 'uploading', + status: hasUrl ? 'uploading' : 'error', mediaType: f.file.type || null, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), @@ -606,10 +607,12 @@ export function FileBrowser({ } } finally { decrementUploading() - setLocalUploadingFiles((prev) => prev.filter((f) => f.id !== uploadInfo.fileId)) - queryClient.invalidateQueries({ + await queryClient.invalidateQueries({ queryKey: ['search', teamId, assetId], }) + setLocalUploadingFiles((prev) => + prev.filter((f) => f.id !== uploadInfo.fileId && f.id !== file.id), + ) } } } diff --git a/packages/webui/components/file-browser/file-card.tsx b/packages/webui/components/file-browser/file-card.tsx index fee6794c..69c246c4 100644 --- a/packages/webui/components/file-browser/file-card.tsx +++ b/packages/webui/components/file-browser/file-card.tsx @@ -238,11 +238,25 @@ export function FileCard({
{displayItem.status === 'uploading' || displayItem.status === 'processing' || - displayItem.status === 'uploaded' ? ( + displayItem.status === 'uploaded' || + displayItem.status === 'error' ? (
- - - {displayItem.status === 'uploaded' ? 'Processing' : displayItem.status} + {displayItem.status !== 'error' && ( + + )} + + {displayItem.status === 'uploaded' + ? 'Processing' + : displayItem.status === 'error' + ? 'Failed to upload' + : displayItem.status}
) : ( diff --git a/packages/webui/components/file-browser/file-list-item.tsx b/packages/webui/components/file-browser/file-list-item.tsx index 692792dd..19412e16 100644 --- a/packages/webui/components/file-browser/file-list-item.tsx +++ b/packages/webui/components/file-browser/file-list-item.tsx @@ -216,6 +216,12 @@ export function FileListItem({ disabled={!isEditing} className="h-auto p-0 text-sm font-medium text-foreground truncate" /> + {displayItem.status === 'error' && ( + + (Failed to upload) + + )} + {displayItem.versionStack && ( v From fbd3630916e03f042d26700454759c7471d99aa5 Mon Sep 17 00:00:00 2001 From: yiling Date: Wed, 3 Jun 2026 15:30:47 +0800 Subject: [PATCH 3/3] fix(ui): gate local uploading cards to current folder uploads --- .../components/file-browser/file-browser.tsx | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/packages/webui/components/file-browser/file-browser.tsx b/packages/webui/components/file-browser/file-browser.tsx index 8c9e1750..8da10b5a 100644 --- a/packages/webui/components/file-browser/file-browser.tsx +++ b/packages/webui/components/file-browser/file-browser.tsx @@ -356,25 +356,29 @@ export function FileBrowser({ if (!res.ok) throw new Error('Failed to create upload task') return (await res.json()) as InferResponseType }, - onSuccess: async (data) => { - const newLocalFiles: AssetInfo[] = filesToUpload.map((f) => { - const urlInfo = ( - data.presignedUrls as { id?: string; url?: string; fileId?: string }[] | undefined - )?.find((p) => p.id === f.id) - const hasUrl = !!urlInfo && !!urlInfo.url - return { - id: urlInfo?.fileId || f.id, - name: f.file.name, - sizeByte: f.file.size, - fileCount: 0, - type: 'file', - status: hasUrl ? 'uploading' : 'error', - mediaType: f.file.type || null, - createdAt: new Date().toISOString(), - updatedAt: new Date().toISOString(), - } - }) - setLocalUploadingFiles((prev) => [...newLocalFiles, ...prev]) + onSuccess: async (data, variables) => { + const isCurrentFolderUpload = variables.json.parentId === assetId + + if (isCurrentFolderUpload) { + const newLocalFiles: AssetInfo[] = filesToUpload.map((f) => { + const urlInfo = ( + data.presignedUrls as { id?: string; url?: string; fileId?: string }[] | undefined + )?.find((p) => p.id === f.id) + const hasUrl = !!urlInfo && !!urlInfo.url + return { + id: urlInfo?.fileId || f.id, + name: f.file.name, + sizeByte: f.file.size, + fileCount: 0, + type: 'file', + status: hasUrl ? 'uploading' : 'error', + mediaType: f.file.type || null, + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), + } + }) + setLocalUploadingFiles((prev) => [...newLocalFiles, ...prev]) + } // The RPC client returns an object that we cast to the expected type // eslint-disable-next-line @typescript-eslint/no-explicit-any