From da77a7c0990257842d31d4e22eadd157240c7ad9 Mon Sep 17 00:00:00 2001 From: Reece Date: Tue, 1 Sep 2026 16:45:29 +0100 Subject: [PATCH] docs(folders): fix the eight clunky ones Two deleted outright: an upload branch and a folder lookup whose comments said what the condition below them said. The rest kept their fact and lost the rest of the sentence. DiskFileCard gets back the constraint that makes it unusual - no stub, so no selection or move. The "Local" tab keeps only the both-halves rule, not the predicate beside it. The disk-subfolder state says it is never persisted rather than restating its type. FolderRecord.kind pointed at folderKind twice over; now the accessor holds the rule and the field points at it. --- .../editor/src/core/components/filesPage/FileGrid.tsx | 5 ++++- .../src/core/components/filesPage/FileManagerView.tsx | 5 ++--- .../editor/src/core/components/filesPage/FilesPage.css | 9 +++------ frontend/editor/src/core/contexts/FolderContext.tsx | 2 +- frontend/editor/src/core/hooks/useLazyThumbnail.ts | 5 +---- frontend/editor/src/core/types/folder.ts | 4 ++-- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/frontend/editor/src/core/components/filesPage/FileGrid.tsx b/frontend/editor/src/core/components/filesPage/FileGrid.tsx index cc308bebd2..8ab5bdbca9 100644 --- a/frontend/editor/src/core/components/filesPage/FileGrid.tsx +++ b/frontend/editor/src/core/components/filesPage/FileGrid.tsx @@ -1647,7 +1647,10 @@ function FileRow({ // Re-export root constant for caller convenience export { ROOT_FOLDER_ID }; -/** A file listed straight off a mounted directory. */ +/** + * No stub behind it, so no selection, move, rename or delete: the disk owns the + * file and the only affordance is adding it to the workspace. + */ function DiskFileCard({ entry, onOpen, diff --git a/frontend/editor/src/core/components/filesPage/FileManagerView.tsx b/frontend/editor/src/core/components/filesPage/FileManagerView.tsx index 0e706d406c..0952732599 100644 --- a/frontend/editor/src/core/components/filesPage/FileManagerView.tsx +++ b/frontend/editor/src/core/components/filesPage/FileManagerView.tsx @@ -322,7 +322,8 @@ export default function FileManagerView() { // Tab overrides folder navigation for Local/Recent/Shared. switch (currentTab) { case "local": - // Local means no server copy AND no folder membership - not both places. + // Both halves: a local file inside a browser folder belongs to that folder, + // not here as well. return allFiles.filter( (f) => f.remoteStorageId == null && (f.folderId ?? null) === null, ); @@ -452,7 +453,6 @@ export default function FileManagerView() { [foldersById], ); - // Read-through: the directory is the source of truth, never ingested to show. const currentFolder = currentFolderId ? folders.foldersById.get(currentFolderId) : undefined; @@ -694,7 +694,6 @@ export default function FileManagerView() { const target = currentTab === "all" || currentTab === "cloud" ? currentFolderId : null; const targetFolder = target ? folders.foldersById.get(target) : undefined; - // A mount's upload writes straight to disk, never through app storage. if (targetFolder && folderKind(targetFolder) === "local") { const { failedCount } = await writeIntoMount( targetFolder.directory, diff --git a/frontend/editor/src/core/components/filesPage/FilesPage.css b/frontend/editor/src/core/components/filesPage/FilesPage.css index 8f32db0cb4..b6e54bb15d 100644 --- a/frontend/editor/src/core/components/filesPage/FilesPage.css +++ b/frontend/editor/src/core/components/filesPage/FilesPage.css @@ -1500,12 +1500,9 @@ } } -/* A disabled destination in the New-folder menu still has to be READ — its - * caption carries the reason it is disabled. Mantine's disabled colour sinks - * below comfortable contrast (worst in dark mode), so the item keeps the - * theme's muted/subtle text tones instead: visibly dimmer than an enabled - * item, but legible. The dropdown renders in a portal, so the selector must - * stand on the item's own class, not a page ancestor. */ +/* A disabled destination still has to be read - its caption carries the reason - and + Mantine's disabled colour drops below comfortable contrast in dark mode. Selector + stands on the item's own class because the dropdown renders in a portal. */ .files-page-new-folder-option[data-disabled] { color: var(--c-text-muted) !important; opacity: 1; diff --git a/frontend/editor/src/core/contexts/FolderContext.tsx b/frontend/editor/src/core/contexts/FolderContext.tsx index 8a9857a925..0c52c4b845 100644 --- a/frontend/editor/src/core/contexts/FolderContext.tsx +++ b/frontend/editor/src/core/contexts/FolderContext.tsx @@ -280,7 +280,7 @@ function shouldStrandedReset( export function FolderProvider({ children }: FolderProviderProps) { const [storedFolders, setFolders] = useState([]); - // Subdirectories found inside mounts, keyed by parent. In memory only. + // Never persisted: a directory is its own record, so a listing rebuilds these. const [diskSubfolders, setDiskSubfolders] = useState< Map >(() => new Map()); diff --git a/frontend/editor/src/core/hooks/useLazyThumbnail.ts b/frontend/editor/src/core/hooks/useLazyThumbnail.ts index 976a1d2238..31d8d94bc2 100644 --- a/frontend/editor/src/core/hooks/useLazyThumbnail.ts +++ b/frontend/editor/src/core/hooks/useLazyThumbnail.ts @@ -82,10 +82,7 @@ export function useLazyThumbnail( return thumb; } -/** - * Keyed by path + mtime + size, so an unchanged file never renders twice and an edited - * one does. - */ +// Keyed by path + mtime + size: an unchanged file never renders twice, an edited one does. const diskThumbCache = new Map(); // Bounded by bytes, not entries: image thumbnails are data URLs that track the // source, so 300 photos would pin gigabytes of strings for the process lifetime. diff --git a/frontend/editor/src/core/types/folder.ts b/frontend/editor/src/core/types/folder.ts index 93ab147d9b..5ac464ed6f 100644 --- a/frontend/editor/src/core/types/folder.ts +++ b/frontend/editor/src/core/types/folder.ts @@ -46,7 +46,7 @@ export type FolderKind = "server" | "virtual" | "local"; /** Persisted folder shape stored in IndexedDB. */ export interface FolderRecord { id: FolderId; - /** Absent means `server`: rows predating kinds are all server folders. */ + /** Read through {@link folderKind}, never directly. */ kind?: FolderKind; name: string; parentFolderId: FolderId | null; @@ -59,7 +59,7 @@ export interface FolderRecord { updatedAt: number; } -/** The folder's kind. Absent means `server`: server DTOs and long-lived cached rows never carry one. */ +/** Absent means `server`: server DTOs and rows predating kinds never carry one. */ export function folderKind(folder: Pick): FolderKind { return folder.kind ?? "server"; }