#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
Make the file library a view (#7727)
Reece Browne8e2ba4a12461
diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.tomlindex 6c60b30076..d530dd7bf8 100644--- a/frontend/editor/public/locales/en-US/translation.toml+++ b/frontend/editor/public/locales/en-US/translation.toml@@ -4389,7 +4389,6 @@ duplicateFailed = "Could not duplicate file"expand = "Expand sidebar"googleDrive = "Google Drive"googleDriveDisabled = "Google Drive is not configured"-leaveMyFiles = "Leave File library"library = "PDF Library"myFiles = "File library"noFiles = "No files yet"@@ -4509,7 +4508,6 @@ removeVersion = "Remove this version"rename = "Rename"renamed = "Renamed"renameFolder = "Rename folder"-resizeFolderTree = "Resize folder tree (arrow keys, Shift for bigger steps; double-click to auto-fit)"save = "Save"saveToServer = "Save to server"saveToServerDisabledHint = "Saving to the server isn't enabled on this server. Ask your admin to enable it."@@ -4737,9 +4735,6 @@ server = "Server error during folder sync."[filesPage.tabName]local = "Local"-recent = "Recent"-shared = "Shared with me"-sharedByMe = "Shared by me"[filesPage.tabs]all = "All"diff --git a/frontend/editor/src/core/components/filesPage/FileManagerView.tsx b/frontend/editor/src/core/components/filesPage/FileManagerView.tsxindex 3da8f6a202..e7abbc8641 100644--- a/frontend/editor/src/core/components/filesPage/FileManagerView.tsx+++ b/frontend/editor/src/core/components/filesPage/FileManagerView.tsx@@ -23,7 +23,6 @@ import { useMediaQuery } from "@mantine/hooks";import CloseIcon from "@mui/icons-material/Close";import SearchIcon from "@mui/icons-material/Search";import UploadFileIcon from "@mui/icons-material/UploadFile";-import QrCode2Icon from "@mui/icons-material/QrCode2";import GridViewIcon from "@mui/icons-material/GridView";import ViewListIcon from "@mui/icons-material/ViewList";import DeleteIcon from "@mui/icons-material/Delete";@@ -31,14 +30,15 @@ import DriveFileMoveIcon from "@mui/icons-material/DriveFileMove";import OpenInNewIcon from "@mui/icons-material/OpenInNew";import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";import CloudUploadIcon from "@mui/icons-material/CloudUpload";+import RefreshIcon from "@mui/icons-material/Refresh";import KeyboardArrowRightIcon from "@mui/icons-material/KeyboardArrowRight";import MoreHorizIcon from "@mui/icons-material/MoreHoriz";-import RefreshIcon from "@mui/icons-material/Refresh";import { FilesToolbarBulkMenu } from "@app/components/filesPage/FilesToolbarBulkMenu";import { FilesToolbarCount } from "@app/components/filesPage/FilesToolbarCount";import { FilesToolbarFilterMenu } from "@app/components/filesPage/FilesToolbarFilterMenu";import { FilesToolbarSortMenu } from "@app/components/filesPage/FilesToolbarSortMenu";import { NewFolderButton } from "@app/components/filesPage/NewFolderButton";+import { useFileLibraryWorkbenchBarButtons } from "@app/components/filesPage/useFileLibraryWorkbenchBarButtons";import { useAuth } from "@app/auth/UseSession";import { useSharingEnabled } from "@app/hooks/useSharingEnabled";@@ -89,11 +89,8 @@ import { useProcessingFolders } from "@app/hooks/useProcessingFolders";import { FolderProcessingSetup } from "@app/components/policies/FolderProcessingSetup";import { FolderSweepWall } from "@app/components/policies/SweepRunWall";import { RestoreOriginalsDialog } from "@app/components/filesPage/RestoreOriginalsDialog";-import SuperSearch from "@app/components/shared/superSearch/SuperSearch";-import { useEditorSearchScopes } from "@app/hooks/useSuperSearch";import { FileDetailsPanel } from "@app/components/filesPage/FileDetailsPanel";import BulkUploadToServerModal from "@app/components/shared/BulkUploadToServerModal";-import MobileUploadModal from "@app/components/shared/MobileUploadModal";import { useAppConfig } from "@app/contexts/AppConfigContext";import { canPickDirectory } from "@app/services/directoryPicker";import {@@ -102,6 +99,7 @@ import {pickFolderColor,} from "@app/types/folder";import { useNewFolderFlow } from "@app/hooks/useNewFolderFlow";+import { useLibraryRefresh } from "@app/hooks/useLibraryRefresh";import { writeIntoMount } from "@app/services/mountWrites";import {canListDirectory,@@ -133,7 +131,6 @@ export default function FileManagerView() {const navigate = useNavigate();const location = useLocation();const openFolder = useOpenFolder();- const searchScopes = useEditorSearchScopes();// Hide Shared tab when storageSharingEnabled is false.const { sharingEnabled } = useSharingEnabled();@@ -161,8 +158,6 @@ export default function FileManagerView() {const { addFiles } = useFileHandler();const { config: appConfig } = useAppConfig();const isMobile = useIsMobile();- const isMobileUploadAvailable =- Boolean(appConfig?.enableMobileScanner) && !isMobile;// Guests (anonymous sessions) have no server-side storage, so every cloud// action is account-only. Rather than let the click fire a guaranteed 401// (which surfaced as an error toast), we disable the control and explain why@@ -184,7 +179,6 @@ export default function FileManagerView() {"filesPage.saveToServerDisabledHint","Saving to the server isn't enabled on this server. Ask your admin to enable it.",));- const [mobileUploadModalOpen, setMobileUploadModalOpen] = useState(false);const { actions: navActions } = useNavigationActions();const { requestNavigation } = useNavigationGuard();const { setActiveFileId } = useViewer();@@ -501,10 +495,12 @@ export default function FileManagerView() {const [diskEntries, setDiskEntries] = useState<DiskFileEntry[]>([]);const [diskLoading, setDiskLoading] = useState(false);// Bumped when this view writes into the directory, so the listing re-reads.- const [diskRefreshTick, setDiskRefreshTick] = useState(0);+ const { diskRevision, bumpDiskRevision } = filesPage;useEffect(() => {if (!currentLocalDirectory || !canListDirectory) {- setDiskEntries([]);+ // Same array when it is already empty: a refresh outside a mount re-runs this+ // and a fresh one would re-render every reader of the listing for nothing.+ setDiskEntries((prev) => (prev.length > 0 ? [] : prev));// Leaving a mount mid-listing cancels the in-flight reset, so clear the// flag here or the skeleton covers every folder for the rest of the session.setDiskLoading(false);@@ -572,7 +568,7 @@ export default function FileManagerView() {currentFolderId,registerDiskSubfolders,setFolderError,- diskRefreshTick,+ diskRevision,t,]);@@ -949,7 +945,6 @@ export default function FileManagerView() {// ─── upload (drag-from-desktop or button) ───────────────────────────────const fileInputRef = useRef<HTMLInputElement>(null);const [isDraggingExternal, setIsDraggingExternal] = useState(false);- const [refreshing, setRefreshing] = useState(false);const handleNativeUpload = useCallback(async (files: File[]) => {@@ -978,7 +973,7 @@ export default function FileManagerView() {}),);}- setDiskRefreshTick((tick) => tick + 1);+ bumpDiskRevision();return;}// Everywhere else membership is set with the stub rather than by a move that@@ -1383,6 +1378,8 @@ export default function FileManagerView() {const { addLocalFolder } = useNewFolderFlow();// null = New folder actionable; string = disabled tooltip reason.+ const { refreshing, refresh: handleRefresh } = useLibraryRefresh();+const newFolderDisabledReason: string | null = useMemo(() => {// Only All/Cloud render folders, so creating one elsewhere would look inert.if (@@ -1422,137 +1419,102 @@ export default function FileManagerView() {t,]);+ // Stable identities, here and for the controls built below: the bar re-registers+ // whenever what it was given changes, so a value rebuilt per render turns that into+ // an endless register -> render -> register loop.+ const openFilePicker = useCallback(() => fileInputRef.current?.click(), []);++ const newFolderControl = useMemo(+ () => (+ <NewFolderButton+ trigger="icon"+ label={t("filesPage.newFolder", "New folder")}+ disabledReason={newFolderDisabledReason}+ serverDisabledReason={serverFolderDisabledReason}+ currentFolderId={folders.currentFolderId}+ canAddLocalFolder={canPickDirectory}+ onAddLocalFolder={() => void addLocalFolder()}+ onOpenDialog={openNewFolderDialog}+ />+ ),+ [+ t,+ newFolderDisabledReason,+ serverFolderDisabledReason,+ folders.currentFolderId,+ addLocalFolder,+ openNewFolderDialog,+ ],+ );+ // Reads the trail from context, so it takes no props to change. Only the+ // folder-rooted tabs have a trail to show: the rest list files by predicate.+ const path = useMemo(+ () =>+ currentTab === "all" || currentTab === "cloud" ? <Breadcrumbs /> : null,+ [currentTab],+ );++ const libraryActions = useMemo(+ () => (+ <>+ <Tooltip+ label={+ signInRequiredReason ??+ t("filesPage.refresh", "Refresh from server")+ }+ withinPortal+ >+ <ActionIcon+ variant="tertiary"+ size="sm"+ loading={refreshing}+ disabled={refreshing || Boolean(signInRequiredReason)}+ aria-busy={refreshing}+ aria-label={t("filesPage.refresh", "Refresh from server")}+ onClick={handleRefresh}+ >+ <RefreshIcon fontSize="small" />+ </ActionIcon>+ </Tooltip>+ {newFolderControl}+ <Tooltip label={t("filesPage.upload", "Upload")} withinPortal>+ <ActionIcon+ variant="tertiary"+ size="sm"+ aria-label={t("filesPage.upload", "Upload")}+ onClick={openFilePicker}+ >+ <UploadFileIcon fontSize="small" />+ </ActionIcon>+ </Tooltip>+ </>+ ),+ [+ t,+ signInRequiredReason,+ refreshing,+ handleRefresh,+ newFolderControl,+ openFilePicker,+ ],+ );++ // The file sidebar carries these on desktop. Mobile has no sidebar to put them+ // in, so there they go in the bar - the only chrome its layout shows.+ useFileLibraryWorkbenchBarButtons({+ path: isMobile ? path : null,+ actions: isMobile ? libraryActions : null,+ });+return (<div className="files-page" ref={dropZoneRef}>- <header className="files-page-header">- {/* Breadcrumb only for folder-rooted tabs. */}- {(currentTab === "all" || currentTab === "cloud") && <Breadcrumbs />}- {(currentTab === "recent" ||- currentTab === "shared" ||- currentTab === "sharedByMe") && (- <div- style={{- fontSize: "0.95rem",- fontWeight: 600,- padding: "0.25rem 0.5rem",- color: "var(--c-text)",- }}- >- {currentTab === "recent"- ? t("filesPage.tabName.recent", "Recent")- : currentTab === "shared"- ? t("filesPage.tabName.shared", "Shared with me")- : t("filesPage.tabName.sharedByMe", "Shared by me")}- </div>- )}- {(() => {- // Both the inline desktop buttons and the mobile kebab menu need- // these handlers - extract once so we don't drift two copies.- const handleRefresh = async () => {- setRefreshing(true);- try {- // In a mount, refresh means the directory: the listing only re-reads when told.- if (currentLocalDirectory) {- setDiskRefreshTick((tick) => tick + 1);- }- // pullFromServer bumps the folder revision, which the- // FolderProvider's effect reacts to by re-running refresh() -- // no need to await folders.refresh() manually.- const result = await folders.pullFromServer();- if (!result.ok && result.reason !== "endpoint-missing") {- folders.setError(- result.reason === "network"- ? t(- "filesPage.syncError.network",- "Could not reach the server.",- )- : result.reason === "server"- ? t(- "filesPage.syncError.server",- "Server error during folder sync.",- )- : t("filesPage.syncError.client", "Folder sync failed."),- );- }- await refresh();- } finally {- setRefreshing(false);- }- };- return (- <>- <div className="files-page-header-search">- <SuperSearch scopes={searchScopes} />- </div>- <div className="files-page-header-actions">- <Tooltip- label={- signInRequiredReason ??- t("filesPage.refresh", "Refresh from server")- }- withinPortal- >- <ActionIcon- variant="secondary"- size="sm"- loading={refreshing}- disabled={refreshing || Boolean(signInRequiredReason)}- aria-busy={refreshing}- onClick={handleRefresh}- aria-label={t("filesPage.refresh", "Refresh from server")}- >- <RefreshIcon />- </ActionIcon>- </Tooltip>- <NewFolderButton- label={t("filesPage.newFolder", "New folder")}- disabledReason={newFolderDisabledReason}- serverDisabledReason={serverFolderDisabledReason}- currentFolderId={folders.currentFolderId}- canAddLocalFolder={canPickDirectory}- onAddLocalFolder={() => void addLocalFolder()}- onOpenDialog={openNewFolderDialog}- />- <Button- size="sm"- leftSection={<UploadFileIcon fontSize="small" />}- onClick={() => fileInputRef.current?.click()}- >- {t("filesPage.upload", "Upload")}- </Button>- {isMobileUploadAvailable && (- <Tooltip- label={t(- "filesPage.uploadFromMobile",- "Upload from Mobile",- )}- withinPortal- >- <ActionIcon- size="sm"- variant="secondary"- onClick={() => setMobileUploadModalOpen(true)}- aria-label={t(- "filesPage.uploadFromMobile",- "Upload from Mobile",- )}- >- <QrCode2Icon fontSize="small" />- </ActionIcon>- </Tooltip>- )}- <input- ref={fileInputRef}- type="file"- multiple- style={{ display: "none" }}- onChange={onFileInputChange}- />- </div>- </>- );- })()}- </header>+ <input+ ref={fileInputRef}+ type="file"+ multiple+ style={{ display: "none" }}+ onChange={onFileInputChange}+ />{folders.error && (<div@@ -1590,89 +1552,98 @@ export default function FileManagerView() {<div className="files-page-body"><main className="files-page-main">- {/* Tab strip filters the file list; ARIA Tabs keyboard model. */}- {(() => {- const TAB_DEFS = [- { id: "all", label: t("filesPage.tabs.all", "All") },- { id: "recent", label: t("filesPage.tabs.recent", "Recent") },- // Sharing tabs only when sharingEnabled.- ...(sharingEnabled- ? [- {- id: "shared" as const,- label: t("filesPage.tabs.shared", "Shared with me"),- },- {- id: "sharedByMe" as const,- label: t("filesPage.tabs.sharedByMe", "Shared by me"),- },- ]- : []),- ] as const;- const focusTab = (id: string) => {- const el = document.getElementById(`filesPage-tab-${id}`);- el?.focus();- };- return (- <div- className="files-page-tabs"- role="tablist"- aria-label={t("filesPage.tabs.ariaLabel", "File views")}- onKeyDown={(e) => {- const idx = TAB_DEFS.findIndex((t2) => t2.id === currentTab);- if (idx < 0) return;- let next: number;- if (e.key === "ArrowRight")- next = (idx + 1) % TAB_DEFS.length;- else if (e.key === "ArrowLeft")- next = (idx - 1 + TAB_DEFS.length) % TAB_DEFS.length;- else if (e.key === "Home") next = 0;- else if (e.key === "End") next = TAB_DEFS.length - 1;- else return;- e.preventDefault();- const target = TAB_DEFS[next];- setCurrentTab(target.id);- focusTab(target.id);- }}- style={{- display: "flex",- gap: "0.1rem",- padding: "0.2rem 1rem 0.2rem",- }}- >- {TAB_DEFS.map((tab) => (- <button- key={tab.id}- id={`filesPage-tab-${tab.id}`}- role="tab"- type="button"- aria-selected={currentTab === tab.id}- aria-controls="filesPage-tabpanel"- tabIndex={currentTab === tab.id ? 0 : -1}- onClick={() => setCurrentTab(tab.id)}- style={{- background:- currentTab === tab.id- ? "var(--c-hover)"- : "transparent",- border: "none",- borderRadius: "0.3rem",- padding: "0.2rem 0.6rem",- color:- currentTab === tab.id- ? "var(--c-text)"- : "var(--c-text-subtle)",- fontWeight: currentTab === tab.id ? 500 : 400,- fontSize: "0.75rem",- cursor: "pointer",- }}- >- {tab.label}- </button>- ))}- </div>- );- })()}+ {/* Tab strip filters the file list; ARIA Tabs keyboard model. The+ library's path and actions share the row: kept out of the tablist+ itself, which may only contain tabs. */}+ <div className="files-page-tabs-row">+ {(() => {+ const TAB_DEFS = [+ { id: "all", label: t("filesPage.tabs.all", "All") },+ { id: "recent", label: t("filesPage.tabs.recent", "Recent") },+ // Sharing tabs only when sharingEnabled.+ ...(sharingEnabled+ ? [+ {+ id: "shared" as const,+ label: t("filesPage.tabs.shared", "Shared with me"),+ },+ {+ id: "sharedByMe" as const,+ label: t("filesPage.tabs.sharedByMe", "Shared by me"),+ },+ ]+ : []),+ ] as const;+ const focusTab = (id: string) => {+ const el = document.getElementById(`filesPage-tab-${id}`);+ el?.focus();+ };+ return (+ <div+ className="files-page-tabs"+ role="tablist"+ aria-label={t("filesPage.tabs.ariaLabel", "File views")}+ onKeyDown={(e) => {+ const idx = TAB_DEFS.findIndex(+ (t2) => t2.id === currentTab,+ );+ if (idx < 0) return;+ let next: number;+ if (e.key === "ArrowRight")+ next = (idx + 1) % TAB_DEFS.length;+ else if (e.key === "ArrowLeft")+ next = (idx - 1 + TAB_DEFS.length) % TAB_DEFS.length;+ else if (e.key === "Home") next = 0;+ else if (e.key === "End") next = TAB_DEFS.length - 1;+ else return;+ e.preventDefault();+ const target = TAB_DEFS[next];+ setCurrentTab(target.id);+ focusTab(target.id);+ }}+ style={{+ display: "flex",+ gap: "0.1rem",+ padding: "0.2rem 1rem 0.2rem",+ }}+ >+ {TAB_DEFS.map((tab) => (+ <button+ key={tab.id}+ id={`filesPage-tab-${tab.id}`}+ role="tab"+ type="button"+ aria-selected={currentTab === tab.id}+ aria-controls="filesPage-tabpanel"+ tabIndex={currentTab === tab.id ? 0 : -1}+ onClick={() => setCurrentTab(tab.id)}+ style={{+ background:+ currentTab === tab.id+ ? "var(--c-hover)"+ : "transparent",+ border: "none",+ borderRadius: "0.3rem",+ padding: "0.2rem 0.6rem",+ color:+ currentTab === tab.id+ ? "var(--c-text)"+ : "var(--c-text-subtle)",+ fontWeight: currentTab === tab.id ? 500 : 400,+ fontSize: "0.75rem",+ cursor: "pointer",+ }}+ >+ {tab.label}+ </button>+ ))}+ </div>+ );+ })()}+ {!isMobile && (+ <>{path && <div className="files-page-tabs-path">{path}</div>}</>+ )}+ </div><div className="files-page-toolbar"><FilesToolbarCount@@ -2673,16 +2644,6 @@ export default function FileManagerView() {files={saveToServerTarget ?? []}onUploaded={refresh}/>-- <MobileUploadModal- opened={mobileUploadModalOpen}- onClose={() => setMobileUploadModalOpen(false)}- onFilesReceived={(files) => {- if (files.length > 0) {- void addFiles(files);- }- }}- /></div>);}@@ -2776,7 +2737,7 @@ function Breadcrumbs() {<Menu shadow="md" position="bottom-start" withinPortal><Menu.Target><ActionIcon- variant="quiet"+ variant="tertiary"size="sm"className="files-page-breadcrumb-overflow"aria-label={t(diff --git a/frontend/editor/src/core/components/filesPage/FilesPage.css b/frontend/editor/src/core/components/filesPage/FilesPage.cssindex 5df6692b63..3899c3b684 100644--- a/frontend/editor/src/core/components/filesPage/FilesPage.css+++ b/frontend/editor/src/core/components/filesPage/FilesPage.css@@ -8,108 +8,73 @@overflow: hidden;}-.files-page-header {- /* 3-column grid keeps the search bar position-stable regardless of- * breadcrumb length. Left column flexes for the breadcrumb (truncating- * via overflow:hidden), middle column holds the search, right column- * holds the action buttons right-aligned. */- display: grid;- grid-template-columns: minmax(0, 1fr) minmax(min(14rem, 100%), 40rem) minmax(- 0,- 1fr- );- align-items: center;- gap: 1rem;- min-height: 48px;- padding: 0 0.75rem;- border-bottom: 1px solid var(--c-border-subtle);- background: var(--c-bg-raised);- flex-shrink: 0;-}--.files-page-header-actions {- justify-self: end;+/* The library's own row: the tabs, then the folder path. What the library brings+ sits here rather than in the shared bar above, which carries only what every view+ has. */+.files-page-tabs-row {display: flex;align-items: center;gap: 0.5rem;+ min-width: 0;}-.files-page-header-search {+.files-page-tabs-path {+ flex: 1;+ min-width: 0;display: flex;align-items: center;- justify-content: center;- min-width: 0;-}--.files-page-header-search .super-search {- flex: 0 1 24rem;- width: min(100%, 24rem);- max-width: 24rem;-}--.files-page-header-search .super-search input {- background-color: transparent;- padding-top: 4px;- padding-bottom: 4px;- font-size: 12.5px;-}--[data-mantine-color-scheme="dark"]- .files-page-header-search- .super-search- input {- background-color: transparent;+ overflow: hidden;}+/* The folder path. Sized and coloured like the bar's own controls, since on mobile+ that is where it renders. Fixed height and no wrapping: a deep trail would+ otherwise push its row taller, so depth is handled by showing fewer crumbs - see+ the overflow menu. */.files-page-breadcrumbs {display: flex;align-items: center;- gap: 0.25rem;- font-size: 0.8125rem;+ gap: 2px;min-width: 0;- /* Fixed, and never wrapping: the trail shares a row with the search and the- action buttons, and any growth here moves the grid below it. Length is handled- by showing fewer crumbs, not by taking more space. */- height: 2rem;+ height: 24px;flex-wrap: nowrap;overflow: hidden;}+.files-page-breadcrumb {- background: none;+ display: inline-flex;+ align-items: center;+ height: 24px;+ max-width: 12rem;+ min-width: 0;+ padding: 0 6px;border: none;- padding: 0.25rem 0.5rem;- border-radius: 0.375rem;+ border-radius: 8px;+ background: transparent;color: var(--c-text-muted);- cursor: pointer;- font-size: inherit;+ font-size: 13px;font-weight: 500;- transition:- background-color 0.12s ease,- color 0.12s ease;+ cursor: pointer;white-space: nowrap;- max-width: 14rem;- min-width: 0;- height: 1.5rem;- line-height: 1.5rem;- padding: 0 0.375rem;overflow: hidden;text-overflow: ellipsis;-}--/* The parents that don't fit, root included. */-.files-page-breadcrumb-overflow {- flex-shrink: 0;+ transition:+ background-color 0.12s ease,+ color 0.12s ease;}.files-page-breadcrumb:hover,.files-page-breadcrumb.is-current {- background: var(--c-hover);+ background-color: var(--c-hover);color: var(--c-text);}+/* The parents that don't fit, root included. */+.files-page-breadcrumb-overflow {+ flex-shrink: 0;+}+.files-page-breadcrumb-sep {color: var(--c-text-subtle);- font-size: 1rem !important;width: 1rem;height: 1rem;opacity: 0.55;@@ -123,36 +88,6 @@overflow: hidden;}-.files-page-tree {- width: 17rem;- flex-shrink: 0;- border-right: 1px solid var(--c-border-subtle);- background: var(--c-bg-raised);- overflow-y: auto;- display: flex;- flex-direction: column;-}--.files-page-tree[data-collapsed="true"] {- width: 3.25rem;-}--.files-page-tree-header {- display: flex;- align-items: center;- justify-content: space-between;- padding: 0.75rem 0.75rem 0.5rem;- font-size: 0.8rem;- text-transform: uppercase;- letter-spacing: 0.04em;- color: var(--c-text-subtle);-}--/* Tree node styles moved to FolderTreePanel.css - that's where the- .files-page-tree-* elements actually render (the slide-out panel from- HomePage), so the styles need to load whether or not the standalone- /files route is mounted. */-.files-page-main {flex: 1;min-width: 0;@@ -304,20 +239,17 @@}.files-page-tree-list,-.folder-tree-panel-inner,.files-page-details-body {scrollbar-width: thin;scrollbar-color: var(--c-border-subtle) transparent;}.files-page-tree-list::-webkit-scrollbar,-.folder-tree-panel-inner::-webkit-scrollbar,.files-page-details-body::-webkit-scrollbar {width: 0.4rem;}.files-page-tree-list::-webkit-scrollbar-thumb,-.folder-tree-panel-inner::-webkit-scrollbar-thumb,.files-page-details-body::-webkit-scrollbar-thumb {background: var(--c-border-subtle);border-radius: 999px;@@ -1486,24 +1418,15 @@}@media (max-width: 1024px) {- .files-page-tree {- width: 14rem;- }.files-page-details {width: 18rem;}}@media (max-width: 800px) {- /* Tree slot inside the inline layout can't fit at this width - the- tree itself is still reachable via the FolderTreePanel slide-out.- Details panel visibility is controlled by JSX (conditional Drawer)- at this width, not CSS, so we don't blanket-hide .files-page-details- here - that would also hide it when it lives inside the Drawer's- portaled overlay tree. */- .files-page-tree {- display: none;- }+ /* Details panel visibility is controlled by JSX (conditional Drawer) at this+ width, not CSS: blanket-hiding .files-page-details would also hide it when it+ lives inside the Drawer's portaled overlay tree. */.files-page-content {padding: 0.75rem;}@@ -1516,14 +1439,7 @@filter selects + grid/list toggle is too wide to fit. This blockcollapses bulk-action button labels to icon-only, shrinks thefilter selects, and pins the view toggle so it never clips off the- right edge. The header stays in desktop layout here (it has fewer- items and the side panels disappearing actually GIVES it room). */-.files-page-header [data-desktop-hide="true"] {- /* The mobile-only overflow menu trigger. Hidden by default; shown- inside the mobile breakpoint below. Live as inline-flex so it- sits next to the Upload button without breaking the action row. */- display: none;-}+ right edge. */@media (max-width: 1024px) {.files-page-toolbar {/* nowrap so "7 items" + "Select all" sit on the same row as the@@ -1582,64 +1498,9 @@}/* ── Mobile (≤640px) ────────────────────────────────────────────────- Tighten the chrome so the file manager fits inside the mobile- workspace slide. The slide-rail's bottom tab bar already provides- navigation, so the in-header Home/Apps/Close trio is duplicated- and the first to go. Same for "Upload" - the user can use the- centre drop overlay. */-/* ── Mobile + tablet chrome (≤1024px = useIsMobile) ──────────────────- The desktop header is a 3-column grid whose middle track can grow to- 40rem. Below ~1024px that track eats the row: the breadcrumb column- collapsed to ~36px (wrapping "All files" to two lines) and the action- column overflowed, pushing Upload off the right edge. One flex row- instead - breadcrumb and actions keep their intrinsic width and the- search takes whatever is left. Ends at the app's mobile breakpoint so- it matches the layout HomePage is already rendering. */-@media (max-width: 1024px) {- .files-page-header {- display: flex;- flex-wrap: nowrap;- align-items: center;- gap: 0.4rem;- padding: 0.25rem 0.4rem;- overflow-x: hidden;- }- .files-page-header-search {- flex: 1 1 auto;- min-width: 0;- justify-content: flex-start;- }- /* Undo the fixed 24rem basis so the pill tracks the row's spare width. */- .files-page-header-search .super-search {- flex: 1 1 auto;- width: 100%;- max-width: none;- }- .files-page-header-actions {- flex: 0 0 auto;- margin-left: auto;- gap: 0.25rem;- flex-wrap: nowrap;- }- .files-page-breadcrumbs {- flex: 0 1 auto;- font-size: 0.85rem;- flex-wrap: nowrap;- overflow-x: auto;- min-width: 0;- }- /* Icon-only actions: the labels are what pushed Upload past the edge. */- .files-page-header-actions .mantine-Button-root {- padding-left: 0.55rem;- padding-right: 0.55rem;- }- .files-page-header-actions .mantine-Button-section[data-position="left"] {- margin-right: 0;- }- .files-page-header-actions .mantine-Button-label {- display: none;- }-}+ Tighten the chrome so the file manager fits inside the mobile workspace+ slide: the slide-rail's bottom tab bar already carries the navigation, and+ uploads have the centre drop overlay. */@media (max-width: 640px) {/* Grid: single column on very narrow phones; two columns from ~440px */diff --git a/frontend/editor/src/core/components/filesPage/FolderTreePanel.css b/frontend/editor/src/core/components/filesPage/FolderTreePanel.cssdeleted file mode 100644index dd0a42571d..0000000000--- a/frontend/editor/src/core/components/filesPage/FolderTreePanel.css+++ /dev/null@@ -1,205 +0,0 @@-/* Secondary navigator panel that slides out from the main FileSidebar- when the user enters the My Files workbench.-- Pattern:- - Outer panel is a flex item whose `width` transitions. The inner- content keeps a fixed natural width and the outer `overflow: hidden`- clips it during the slide so the user sees the panel grow from the- edge rather than the content shrinking.- - Inner content separately fades + nudges in for an attentive feel.-- Styled to mirror the main FileSidebar - same toolbar background, same- section-header treatment, same icon weight - so the two read as one- unified surface. */--.folder-tree-panel {- width: 0;- flex-shrink: 0;- background: var(--c-bg-raised);- border-right: 0 solid var(--c-border-subtle);- overflow: hidden;- height: 100%;- pointer-events: none;- position: relative;-}--.folder-tree-panel[data-active="true"] {- width: var(--folder-tree-panel-width, 16rem);- border-right-width: 1px;- pointer-events: auto;-}--.folder-tree-panel-inner {- display: flex;- flex-direction: column;- height: 100%;- width: 100%;- overflow-y: auto;- opacity: 0;- transform: translateX(-1rem);- /* Only fade/slide; width is driven by the inline custom property so- * dragging the resizer doesn't animate. */- transition:- opacity 0.18s ease,- transform 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);-}--.folder-tree-panel[data-active="true"] .folder-tree-panel-inner {- opacity: 1;- transform: translateX(0);- transition-delay: 0.04s;-}--/* Drag handle on the right edge. */-.folder-tree-panel-resizer {- position: absolute;- top: 0;- right: -3px;- width: 6px;- height: 100%;- cursor: col-resize;- z-index: 2;- background: transparent;- transition: background-color 0.15s ease;-}--.folder-tree-panel-resizer:hover,-.folder-tree-panel-resizer:focus-visible {- background: color-mix(in srgb, var(--c-primary) 35%, transparent);- outline: none;-}--/* Section header - matches .file-sidebar-section-header in FileSidebar.css */-.folder-tree-panel-header {- display: flex;- align-items: center;- justify-content: space-between;- padding: 12px 18px 6px 18px;- margin-top: 4px;- flex-shrink: 0;-}--.folder-tree-panel-title {- font-size: 13px;- font-weight: 600;- letter-spacing: 0.02em;- color: var(--c-text-subtle);- text-transform: uppercase;-}--/* Tree rows - mirror .file-sidebar-action-row from FileSidebar.css so the- slide-out folder navigator reads as a continuation of the main sidebar's- design language. Same row height, padding, font weight, muted icon- treatment. The hover/active state uses the same --hover-bg pill that- the sidebar's other rows do, with no heavy accent bar. */--.files-page-tree-list {- display: flex;- flex-direction: column;- padding: 4px 0 12px;-}--.files-page-tree-node {- display: flex;- align-items: center;- height: 32px;- padding: 0 14px;- border-radius: 4px;- margin: 0 8px;- cursor: pointer;- user-select: none;- color: var(--c-text-muted);- font-size: 14px;- position: relative;- transition: background-color 0.15s ease;- flex-shrink: 0;-}--.files-page-tree-node:hover {- background: var(--c-hover);-}--.files-page-tree-node.is-active {- background: var(--c-hover);- color: var(--c-text);- font-weight: 500;-}--.files-page-tree-node.is-drop-target {- background: color-mix(in srgb, var(--c-primary) 12%, transparent);- box-shadow: inset 0 0 0 1px var(--c-primary);- color: var(--c-text);-}--.files-page-tree-toggle {- display: inline-flex;- align-items: center;- justify-content: center;- width: 16px;- height: 16px;- color: var(--c-text-subtle);- flex-shrink: 0;-}--.files-page-tree-toggle svg {- font-size: 16px !important;-}--.files-page-tree-spacer {- display: inline-block;- width: 16px;- height: 16px;- flex-shrink: 0;-}--.files-page-tree-icon {- display: inline-flex;- align-items: center;- justify-content: center;- flex-shrink: 0;- color: var(--c-text-subtle);- margin-left: 8px;- font-size: 18px;-}--.files-page-tree-icon svg {- font-size: 18px !important;-}--.files-page-tree-name {- flex: 1;- min-width: 0;- display: flex;- white-space: nowrap;- overflow: hidden;- text-overflow: ellipsis;- margin-left: 12px;-}--/* Head elides, tail is kept whole: together they read as one name broken in the- middle, so both ends stay visible at any column width. */-.files-page-tree-name-head {- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;-}--.files-page-tree-name-tail {- flex-shrink: 0;- white-space: nowrap;-}--.files-page-tree-count {- color: var(--c-text-subtle);- font-size: 12px;- flex-shrink: 0;- margin-left: 8px;-}--@media (max-width: 900px) {- /* Cap the user width on narrow viewports so the tree can't squeeze- * out the file grid. The custom property is still honoured but capped. */- .folder-tree-panel[data-active="true"] {- width: min(var(--folder-tree-panel-width, 14rem), 14rem);- }-}diff --git a/frontend/editor/src/core/components/filesPage/FolderTreePanel.tsx b/frontend/editor/src/core/components/filesPage/FolderTreePanel.tsxdeleted file mode 100644index 76e8757255..0000000000--- a/frontend/editor/src/core/components/filesPage/FolderTreePanel.tsx+++ /dev/null@@ -1,159 +0,0 @@-/** Folder tree navigator panel rendered next to FileSidebar on /files. */--import React, { useCallback, useRef, useState } from "react";-import { useTranslation } from "react-i18next";--import { FolderTreeSidebar } from "@app/components/filesPage/FolderTreeSidebar";-import { useFilesPage } from "@app/contexts/FilesPageContext";-import { useFolders } from "@app/contexts/FolderContext";-import { FileId } from "@app/types/file";-import { FolderId, FolderRecord } from "@app/types/folder";-import {- MIN_WIDTH,- MAX_WIDTH,- clamp,- computeAutoFitWidth,- loadPersistedWidth,- savePersistedWidth,-} from "@app/components/filesPage/folderTreeWidth";--import "@app/components/filesPage/FolderTreePanel.css";--interface FolderTreePanelProps {- active: boolean;-}--export function FolderTreePanel({ active }: FolderTreePanelProps) {- const { t } = useTranslation();- const {- fileCountsByFolder,- openNewFolderDialog,- openRenameFolderDialog,- promptDeleteFolder,- moveFilesTo,- } = useFilesPage();- const folders = useFolders();- const rootLabel = t("filesPage.allFiles", "All files");-- const [width, setWidth] = useState<number>(() => {- const persisted = loadPersistedWidth();- return persisted ?? 256;- });- // The width is the user's, never the content's: a folder with a long name- // truncates in the row rather than widening the column it sits in.-- const dragStateRef = useRef<{- startX: number;- startWidth: number;- } | null>(null);-- const onMouseMove = useCallback((e: MouseEvent) => {- const state = dragStateRef.current;- if (!state) return;- const next = clamp(state.startWidth + (e.clientX - state.startX));- setWidth(next);- }, []);-- const onMouseUp = useCallback(() => {- const state = dragStateRef.current;- if (!state) return;- dragStateRef.current = null;- document.removeEventListener("mousemove", onMouseMove);- document.removeEventListener("mouseup", onMouseUp);- document.body.style.removeProperty("cursor");- document.body.style.removeProperty("user-select");- setWidth((current) => {- savePersistedWidth(current);- return current;- });- }, [onMouseMove]);-- const onMouseDown = useCallback(- (e: React.MouseEvent) => {- e.preventDefault();- dragStateRef.current = { startX: e.clientX, startWidth: width };- document.addEventListener("mousemove", onMouseMove);- document.addEventListener("mouseup", onMouseUp);- document.body.style.cursor = "col-resize";- document.body.style.userSelect = "none";- },- [onMouseMove, onMouseUp, width],- );-- const onKeyDown = useCallback(- (e: React.KeyboardEvent) => {- const step = e.shiftKey ? 32 : 8;- let next: number | null = null;- if (e.key === "ArrowLeft") next = clamp(width - step);- else if (e.key === "ArrowRight") next = clamp(width + step);- else if (e.key === "Home") next = MIN_WIDTH;- else if (e.key === "End") next = MAX_WIDTH;- if (next === null) return;- e.preventDefault();- setWidth(next);- savePersistedWidth(next);- },- [width],- );-- return (- <div- className="folder-tree-panel"- data-active={String(active)}- aria-hidden={!active}- style={- active- ? ({- "--folder-tree-panel-width": `${width}px`,- } as React.CSSProperties)- : undefined- }- >- <div className="folder-tree-panel-inner">- <div className="folder-tree-panel-header">- <span className="folder-tree-panel-title">- {t("fileSidebar.myFiles", "File library")}- </span>- </div>-- <FolderTreeSidebar- fileCounts={fileCountsByFolder}- onRequestNewFolder={openNewFolderDialog}- onRenameFolder={(folder: FolderRecord) =>- openRenameFolderDialog(folder)- }- onDeleteFolder={promptDeleteFolder}- onMoveFilesIntoFolder={async (- targetId: FolderId | null,- fileIds: FileId[],- ) => {- if (fileIds.length === 0) return;- await moveFilesTo(fileIds, targetId);- }}- />- </div>- {active && (- <div- className="folder-tree-panel-resizer"- role="separator"- aria-orientation="vertical"- aria-valuemin={MIN_WIDTH}- aria-valuemax={MAX_WIDTH}- aria-valuenow={width}- aria-label={t(- "filesPage.resizeFolderTree",- "Resize folder tree (arrow keys, Shift for bigger steps)",- )}- tabIndex={0}- onMouseDown={onMouseDown}- onKeyDown={onKeyDown}- onDoubleClick={() => {- const auto = computeAutoFitWidth(folders.folders, rootLabel);- setWidth(auto);- savePersistedWidth(auto);- }}- />- )}- </div>- );-}diff --git a/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.css b/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.cssnew file mode 100644index 0000000000..cc1f118564--- /dev/null+++ b/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.css@@ -0,0 +1,106 @@+/* Folder tree rows. They sit in the file sidebar's Folders section, so they take the+ same row height, padding and muted icon treatment as .file-sidebar-action-row, and+ the same hover pill rather than an accent bar. */++.files-page-tree-list {+ display: flex;+ flex-direction: column;+ padding: 4px 0 12px;+}++.files-page-tree-node {+ display: flex;+ align-items: center;+ height: 32px;+ padding: 0 14px;+ border-radius: 4px;+ margin: 0 8px;+ cursor: pointer;+ user-select: none;+ color: var(--c-text-muted);+ font-size: 14px;+ position: relative;+ transition: background-color 0.15s ease;+ flex-shrink: 0;+}++.files-page-tree-node:hover {+ background: var(--c-hover);+}++.files-page-tree-node.is-active {+ background: var(--c-hover);+ color: var(--c-text);+ font-weight: 500;+}++.files-page-tree-node.is-drop-target {+ background: color-mix(in srgb, var(--c-primary) 12%, transparent);+ box-shadow: inset 0 0 0 1px var(--c-primary);+ color: var(--c-text);+}++.files-page-tree-toggle {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 16px;+ height: 16px;+ color: var(--c-text-subtle);+ flex-shrink: 0;+}++.files-page-tree-toggle svg {+ font-size: 16px !important;+}++.files-page-tree-spacer {+ display: inline-block;+ width: 16px;+ height: 16px;+ flex-shrink: 0;+}++.files-page-tree-icon {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ flex-shrink: 0;+ color: var(--c-text-subtle);+ margin-left: 8px;+ font-size: 18px;+}++.files-page-tree-icon svg {+ font-size: 18px !important;+}++.files-page-tree-name {+ flex: 1;+ min-width: 0;+ display: flex;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ margin-left: 12px;+}++/* Head elides, tail is kept whole: together they read as one name broken in the+ middle, so both ends stay visible at any column width. */+.files-page-tree-name-head {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.files-page-tree-name-tail {+ flex-shrink: 0;+ white-space: nowrap;+}++.files-page-tree-count {+ color: var(--c-text-subtle);+ font-size: 12px;+ flex-shrink: 0;+ margin-left: 8px;+}diff --git a/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.tsx b/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.tsxindex e95c0d6d50..b59b0994f9 100644--- a/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.tsx+++ b/frontend/editor/src/core/components/filesPage/FolderTreeSidebar.tsx@@ -28,6 +28,7 @@ import {serialiseFilesPageDragPayload,} from "@app/components/filesPage/dragDrop";import { useDropTarget } from "@app/components/filesPage/useDropTarget";+import "@app/components/filesPage/FolderTreeSidebar.css";import { useOpenFolder } from "@app/components/filesPage/useOpenFolder";/**@@ -56,14 +57,9 @@ interface FolderTreeSidebarProps {) => Promise<void> | void;}-// This component is always rendered inside FolderTreePanel, which supplies-// its own <aside> chrome and "New folder at root" toolbar control. An-// earlier `embed` prop selected between an embedded list and a standalone-// aside+header layout; the standalone layout was unused and its "New-// folder at root" ActionIcon was not gated by `serverReachable`, so if-// anyone re-wired the component into a non-embed surface they'd ship an-// always-enabled mutation button against a possibly-offline server.-// Deleted to remove the trap.+// A list, not a surface: the section around it owns the heading, and root-level+// folder mutations belong there too - they need a serverReachable gate that a bare+// list has no way to apply./*** A name that gives way in the middle when the row is too narrow for it, keeping both* ends readable - folder names tend to differ at the end, where a plain end-ellipsisdiff --git a/frontend/editor/src/core/components/filesPage/NewFolderButton.test.tsx b/frontend/editor/src/core/components/filesPage/NewFolderButton.test.tsxnew file mode 100644index 0000000000..6ee20a327d--- /dev/null+++ b/frontend/editor/src/core/components/filesPage/NewFolderButton.test.tsx@@ -0,0 +1,142 @@+import { describe, expect, it, vi } from "vitest";+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { MantineProvider } from "@mantine/core";+import { NewFolderButton } from "@app/components/filesPage/NewFolderButton";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({+ t: (_key: string, fallback?: string) => fallback ?? _key,+ }),+}));++function renderButton(props: Partial<Parameters<typeof NewFolderButton>[0]>) {+ const onOpenDialog = vi.fn();+ const onAddLocalFolder = vi.fn();+ render(+ <MantineProvider>+ <NewFolderButton+ label="New folder"+ currentFolderId={null}+ canAddLocalFolder={false}+ onAddLocalFolder={onAddLocalFolder}+ onOpenDialog={onOpenDialog}+ {...props}+ />+ </MantineProvider>,+ );+ return { onOpenDialog, onAddLocalFolder };+}++describe("NewFolderButton", () => {+ it("offers both destinations from the icon trigger where a directory can be mounted", async () => {+ const { onAddLocalFolder } = renderButton({+ trigger: "icon",+ canAddLocalFolder: true,+ });++ await userEvent.click(screen.getByRole("button", { name: "New folder" }));+ await userEvent.click(await screen.findByText("Add local folder"));++ expect(onAddLocalFolder).toHaveBeenCalled();+ });++ it("goes straight to the server where there is nowhere else to put a folder", async () => {+ const { onOpenDialog } = renderButton({ trigger: "icon" });++ await userEvent.click(screen.getByRole("button", { name: "New folder" }));++ expect(onOpenDialog).toHaveBeenCalledWith(null, "server");+ });+});++describe("NewFolderButton in the sidebar", () => {+ it("offers both destinations from the row where a directory can be mounted", async () => {+ const onAddLocalFolder = vi.fn();+ render(+ <MantineProvider>+ <NewFolderButton+ label="New folder"+ trigger="row"+ currentFolderId={null}+ canAddLocalFolder+ onAddLocalFolder={onAddLocalFolder}+ onOpenDialog={vi.fn()}+ />+ </MantineProvider>,+ );++ await userEvent.click(screen.getByRole("button", { name: "New folder" }));+ await userEvent.click(await screen.findByText("Add local folder"));++ expect(onAddLocalFolder).toHaveBeenCalled();+ });++ it("marks the row disabled with its reason", () => {+ render(+ <MantineProvider>+ <NewFolderButton+ label="New folder"+ trigger="row"+ disabledReason="Sign in to use cloud storage."+ currentFolderId={null}+ canAddLocalFolder+ onAddLocalFolder={vi.fn()}+ onOpenDialog={vi.fn()}+ />+ </MantineProvider>,+ );++ expect(screen.getByRole("button", { name: "New folder" })).toHaveAttribute(+ "aria-disabled",+ "true",+ );+ });+});++describe("NewFolderButton keyboard access", () => {+ it("opens the row's menu from the keyboard", async () => {+ const onAddLocalFolder = vi.fn();+ render(+ <MantineProvider>+ <NewFolderButton+ label="New folder"+ trigger="row"+ currentFolderId={null}+ canAddLocalFolder+ onAddLocalFolder={onAddLocalFolder}+ onOpenDialog={vi.fn()}+ />+ </MantineProvider>,+ );++ screen.getByRole("button", { name: "New folder" }).focus();+ await userEvent.keyboard("{Enter}");++ await userEvent.click(await screen.findByText("Add local folder"));+ expect(onAddLocalFolder).toHaveBeenCalled();+ });+});++describe("NewFolderButton single-destination row", () => {+ it("opens the dialog from the keyboard where the server is the only place", async () => {+ const onOpenDialog = vi.fn();+ render(+ <MantineProvider>+ <NewFolderButton+ label="New folder"+ trigger="row"+ currentFolderId={null}+ canAddLocalFolder={false}+ onAddLocalFolder={vi.fn()}+ onOpenDialog={onOpenDialog}+ />+ </MantineProvider>,+ );++ screen.getByRole("button", { name: "New folder" }).focus();+ await userEvent.keyboard(" ");++ expect(onOpenDialog).toHaveBeenCalledWith(null, "server");+ });+});diff --git a/frontend/editor/src/core/components/filesPage/NewFolderButton.tsx b/frontend/editor/src/core/components/filesPage/NewFolderButton.tsxindex 79de32b013..fdc39eec06 100644--- a/frontend/editor/src/core/components/filesPage/NewFolderButton.tsx+++ b/frontend/editor/src/core/components/filesPage/NewFolderButton.tsx@@ -6,12 +6,19 @@ import CreateNewFolderIcon from "@mui/icons-material/CreateNewFolder";import DriveFolderUploadIcon from "@mui/icons-material/DriveFolderUpload";import { useTranslation } from "react-i18next";+import { ActionIcon } from "@app/ui/ActionIcon";import { Button } from "@app/ui/Button";import type { FolderId, FolderKind } from "@app/types/folder";export interface NewFolderButtonProps {label: string;size?: "sm" | "md";+ /** "icon" matches the workbench bar's controls; "row" the file sidebar's. */+ trigger?: "labelled" | "icon" | "row";+ /** Row trigger only: the sidebar is a rail, so the label goes. */+ collapsed?: boolean;+ /** Row trigger only, for the tests and callers that look the row up. */+ testId?: string;/** Set when a folder cannot be created here at all; also the tooltip. */disabledReason?: string | null;/** Set when only the server destination is unavailable; also its tooltip. */@@ -32,6 +39,9 @@ export interface NewFolderButtonProps {export function NewFolderButton({label,size = "sm",+ trigger = "labelled",+ collapsed = false,+ testId,disabledReason,serverDisabledReason,currentFolderId,@@ -40,21 +50,77 @@ export function NewFolderButton({onOpenDialog,}: NewFolderButtonProps): ReactNode {const { t } = useTranslation();+ const iconOnly = trigger === "icon";+ const asRow = trigger === "row";++ /** The sidebar's own action-row markup, so the row reads as one of its own.+ * `nativeTitle` for the menu shape, which Menu.Target's clone leaves no room to+ * wrap in a Tooltip. */+ const row = (onClick?: () => void, nativeTitle = false) => (+ <div+ className={`file-sidebar-action-row${disabledReason ? " disabled" : ""}`}+ data-testid={testId}+ role="button"+ tabIndex={disabledReason ? -1 : 0}+ aria-disabled={Boolean(disabledReason)}+ aria-label={label}+ title={nativeTitle && collapsed ? label : undefined}+ onClick={disabledReason ? undefined : onClick}+ // Not onClick: in the menu shape the click handler belongs to Menu.Target,+ // which binds the pointer only. A div has no native Enter/Space either way.+ onKeyDown={(e) => {+ if (disabledReason) return;+ if (e.key === "Enter" || e.key === " ") {+ e.preventDefault();+ e.currentTarget.click();+ }+ }}+ >+ <span className="file-sidebar-action-icon">+ <CreateNewFolderIcon />+ </span>+ {!collapsed && (+ <span className="file-sidebar-action-label sidebar-content-fade">+ {label}+ </span>+ )}+ </div>+ );if (disabledReason) {return (- <Tooltip label={disabledReason} withinPortal multiline w={260}>+ <Tooltip+ label={disabledReason}+ withinPortal+ multiline+ w={260}+ position={asRow ? "right" : undefined}+ >{/* Wrapped so the tooltip still opens while the button is disabled. */}- <span style={{ display: "inline-flex" }}>- <Button- variant="secondary"- size={size}- leftSection={<CreateNewFolderIcon fontSize="small" />}- disabled- style={{ pointerEvents: "auto" }}- >- {label}- </Button>+ <span style={{ display: asRow ? "block" : "inline-flex" }}>+ {asRow ? (+ row()+ ) : iconOnly ? (+ <ActionIcon+ variant="tertiary"+ size="sm"+ disabled+ aria-label={label}+ style={{ pointerEvents: "auto" }}+ >+ <CreateNewFolderIcon fontSize="small" />+ </ActionIcon>+ ) : (+ <Button+ variant="secondary"+ size={size}+ leftSection={<CreateNewFolderIcon fontSize="small" />}+ disabled+ style={{ pointerEvents: "auto" }}+ >+ {label}+ </Button>+ )}</span></Tooltip>);@@ -63,6 +129,34 @@ export function NewFolderButton({// Inside a folder the kind is inherited, and on the web the server is the only// place a folder can go.if (currentFolderId !== null || !canAddLocalFolder) {+ const open = () =>+ currentFolderId !== null ? onOpenDialog() : onOpenDialog(null, "server");+ if (asRow) {+ return (+ <Tooltip+ label={label}+ position="right"+ withinPortal+ disabled={!collapsed}+ >+ {row(open)}+ </Tooltip>+ );+ }+ if (iconOnly) {+ return (+ <Tooltip label={label} withinPortal>+ <ActionIcon+ variant="tertiary"+ size="sm"+ aria-label={label}+ onClick={open}+ >+ <CreateNewFolderIcon fontSize="small" />+ </ActionIcon>+ </Tooltip>+ );+ }return (<Buttonvariant="secondary"@@ -82,14 +176,24 @@ export function NewFolderButton({return (<Menu shadow="md" position="bottom-end" withinPortal><Menu.Target>- <Button- variant="secondary"- size={size}- leftSection={<CreateNewFolderIcon fontSize="small" />}- rightSection={<ArrowDropDownIcon fontSize="small" />}- >- {label}- </Button>+ {asRow ? (+ row(undefined, true)+ ) : iconOnly ? (+ <Tooltip label={label} withinPortal>+ <ActionIcon variant="tertiary" size="sm" aria-label={label}>+ <CreateNewFolderIcon fontSize="small" />+ </ActionIcon>+ </Tooltip>+ ) : (+ <Button+ variant="secondary"+ size={size}+ leftSection={<CreateNewFolderIcon fontSize="small" />}+ rightSection={<ArrowDropDownIcon fontSize="small" />}+ >+ {label}+ </Button>+ )}</Menu.Target><Menu.Dropdown><Menu.Itemdiff --git a/frontend/editor/src/core/components/filesPage/folderTreeWidth.ts b/frontend/editor/src/core/components/filesPage/folderTreeWidth.tsdeleted file mode 100644index a88b0e7f11..0000000000--- a/frontend/editor/src/core/components/filesPage/folderTreeWidth.ts+++ /dev/null@@ -1,83 +0,0 @@-import { FolderRecord } from "@app/types/folder";--const STORAGE_KEY = "stirling-folder-tree-width";-export const MIN_WIDTH = 210;-export const MAX_WIDTH = 480;-const DEFAULT_WIDTH = 272;--const ROW_FONT =- '14px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';-const COUNT_FONT =- '12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';-/** Per-row chrome: left padding + toggle + icon + name margin + count margin + right padding. */-const ROW_CHROME = 14 + 16 + 18 + 8 + 12 + 8 + 14;-const INDENT_PER_LEVEL = 16;--function loadCanvas(): CanvasRenderingContext2D | null {- if (typeof document === "undefined") return null;- const canvas = document.createElement("canvas");- return canvas.getContext("2d");-}--function depthOf(- folder: FolderRecord,- byId: Map<string, FolderRecord>,-): number {- let depth = 0;- let cursor: FolderRecord | undefined = folder;- while (cursor && cursor.parentFolderId) {- depth += 1;- cursor = byId.get(cursor.parentFolderId);- if (depth > 50) break;- }- return depth;-}--/** Width needed to fit the longest folder row, clamped to [MIN, MAX]. */-export function computeAutoFitWidth(- folders: FolderRecord[],- rootLabel: string,-): number {- const ctx = loadCanvas();- if (!ctx) return DEFAULT_WIDTH;- const byId = new Map(folders.map((f) => [f.id as string, f]));- let maxName = 0;- let maxDepth = 0;- ctx.font = ROW_FONT;- const measure = (name: string) => Math.ceil(ctx.measureText(name).width);- maxName = Math.max(maxName, measure(rootLabel));- for (const f of folders) {- const w = measure(f.name);- const d = depthOf(f, byId);- if (w > maxName) maxName = w;- if (d > maxDepth) maxDepth = d;- }- ctx.font = COUNT_FONT;- // 4 digits covers typical counts (9999).- const countWidth = Math.ceil(ctx.measureText("9999").width);- const width = ROW_CHROME + maxDepth * INDENT_PER_LEVEL + maxName + countWidth;- return clamp(width);-}--export function clamp(width: number): number {- if (Number.isNaN(width)) return DEFAULT_WIDTH;- return Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, Math.round(width)));-}--export function loadPersistedWidth(): number | null {- if (typeof window === "undefined") return null;- const raw = window.localStorage?.getItem(STORAGE_KEY);- if (raw == null) return null;- const parsed = Number(raw);- if (!Number.isFinite(parsed)) return null;- return clamp(parsed);-}--export function savePersistedWidth(width: number): void {- if (typeof window === "undefined") return;- try {- window.localStorage?.setItem(STORAGE_KEY, String(clamp(width)));- } catch {- // localStorage can throw in private mode or when over quota; ignore.- }-}diff --git a/frontend/editor/src/core/components/filesPage/useFileLibraryWorkbenchBarButtons.tsx b/frontend/editor/src/core/components/filesPage/useFileLibraryWorkbenchBarButtons.tsxnew file mode 100644index 0000000000..98c73fa5e6--- /dev/null+++ b/frontend/editor/src/core/components/filesPage/useFileLibraryWorkbenchBarButtons.tsx@@ -0,0 +1,50 @@+import { useMemo, type ReactNode } from "react";+import {+ useWorkbenchBarButtons,+ type WorkbenchBarButtonWithAction,+} from "@app/hooks/useWorkbenchBarButtons";++export interface FileLibraryWorkbenchBarButtonsOptions {+ /** Names the folder being shown. Null where the library places it itself. */+ path: ReactNode;+ /** The library's own actions. Null where the library places them itself. */+ actions: ReactNode;+}++/**+ * Puts the library's chrome in the bar every other view uses, for the layouts with+ * nowhere else to put it. Rendered whole rather than as icons and handlers: which+ * controls appear, and the menus behind them, are the library's business.+ */+export function useFileLibraryWorkbenchBarButtons({+ path,+ actions,+}: FileLibraryWorkbenchBarButtonsOptions): void {+ const buttons = useMemo<WorkbenchBarButtonWithAction[]>(+ () => [+ ...(path+ ? [+ {+ id: "fileLibraryPath",+ section: "bar-lead" as const,+ order: 10,+ render: () => path,+ },+ ]+ : []),+ ...(actions+ ? [+ {+ id: "fileLibraryActions",+ section: "bar" as const,+ order: 20,+ render: () => actions,+ },+ ]+ : []),+ ],+ [path, actions],+ );++ useWorkbenchBarButtons(buttons);+}diff --git a/frontend/editor/src/core/components/layout/Workbench.tsx b/frontend/editor/src/core/components/layout/Workbench.tsxindex 0cac20e574..22691486b8 100644--- a/frontend/editor/src/core/components/layout/Workbench.tsx+++ b/frontend/editor/src/core/components/layout/Workbench.tsx@@ -88,12 +88,13 @@ export default function Workbench() {const activeCustomView = customWorkbenchViews.find((v) => v.workbenchId === currentView,);- const topControlsAvailable =- currentView !== "myFiles" && !activeCustomView?.hideTopControls;+ const topControlsAvailable = !activeCustomView?.hideTopControls;const hasWorkbenchContent =hasFiles ||fileIds.length > 0 ||!isBaseWorkbench(currentView) ||+ // The library browses stored files, so it has content of its own with none open.+ currentView === "myFiles" ||// Shared signing drives the viewer from the sidebar with no file in context.(currentView === "viewer" && !!signingOverlay?.file);// Reading hides the bar; the rail's Reader entry is the way back.diff --git a/frontend/editor/src/core/components/session/WorkbenchSessionPersistence.test.tsx b/frontend/editor/src/core/components/session/WorkbenchSessionPersistence.test.tsxindex b05928a93e..71658a5e01 100644--- a/frontend/editor/src/core/components/session/WorkbenchSessionPersistence.test.tsx+++ b/frontend/editor/src/core/components/session/WorkbenchSessionPersistence.test.tsx@@ -238,7 +238,7 @@ describe("restore", () => {expect(mocks.restoreWorkbench).toHaveBeenCalledWith("fileEditor");});- it("leaves a URL-owned view to the return path", async () => {+ it("leaves a path-seeded view to the return path", async () => {sessionStorage.setItem(SESSION_KEY,JSON.stringify({diff --git a/frontend/editor/src/core/components/session/WorkbenchSessionPersistence.tsx b/frontend/editor/src/core/components/session/WorkbenchSessionPersistence.tsxindex 86bf72502c..cb500ae827 100644--- a/frontend/editor/src/core/components/session/WorkbenchSessionPersistence.tsx+++ b/frontend/editor/src/core/components/session/WorkbenchSessionPersistence.tsx@@ -116,7 +116,12 @@ export function WorkbenchSessionPersistence() {const { user, loading: authLoading } = useAuth();// Login/signup mount the editor's providers too. Nothing there is the user's workbench, so this// records nothing and restores nothing - otherwise signing out rebuilds it on the login screen.- const onAuthRoute = isAuthRoute(useLocation().pathname);+ const { pathname } = useLocation();+ const onAuthRoute = isAuthRoute(pathname);+ // The file library is the one view its path names, so arriving on /files is the user+ // asking for it. A recorded document view must not displace that; the files it records+ // are still reopened underneath.+ const pathOwnsView = pathname.startsWith("/files");const userId = user?.id != null ? String(user.id) : null;// Fingerprinted, never stored raw - see fingerprintOwner. Computed asynchronously, so writes// hold off until it lands rather than stamping the record "nobody's" and then failing its own@@ -238,7 +243,10 @@ export function WorkbenchSessionPersistence() {.filter((stub): stub is StirlingFileStub => stub !== undefined);if (stubs.length > 0) {- const view = isSeedableView(saved.workbench) ? saved.workbench : null;+ const view =+ !pathOwnsView && isSeedableView(saved.workbench)+ ? saved.workbench+ : null;if (view) held = beginRestoredView();// The same entry point My Files uses, so a restored file is governed by the same rules as// any other file entering the workbench - including whether a policy has already run on it.@@ -295,6 +303,7 @@ export function WorkbenchSessionPersistence() {authLoading,userId,onAuthRoute,+ pathOwnsView,]);return null;diff --git a/frontend/editor/src/core/components/shared/FileSidebar.css b/frontend/editor/src/core/components/shared/FileSidebar.cssindex 96ff38f1d5..f7a5273037 100644--- a/frontend/editor/src/core/components/shared/FileSidebar.css+++ b/frontend/editor/src/core/components/shared/FileSidebar.css@@ -281,6 +281,34 @@margin-top: 4px;}+/* A refresh in progress, on a row that has no room for a spinner beside its label. */+.file-sidebar-spin {+ animation: file-sidebar-refresh-spin 0.9s linear infinite;+}++@keyframes file-sidebar-refresh-spin {+ to {+ transform: rotate(360deg);+ }+}++@media (prefers-reduced-motion: reduce) {+ .file-sidebar-spin {+ animation-duration: 2s;+ }+}++/* Folder navigation fills the box the file list would: in the library it is what the+ sidebar is for, and a deep tree scrolls within it. */+.file-sidebar-folders-section {+ flex: 1;+ min-height: 0;+ display: flex;+ flex-direction: column;+ overflow-y: auto;+ margin-top: 4px;+}+.file-sidebar-file-list {flex: 1;min-height: 0;diff --git a/frontend/editor/src/core/components/shared/FileSidebar.tsx b/frontend/editor/src/core/components/shared/FileSidebar.tsxindex bade67a600..096c31af17 100644--- a/frontend/editor/src/core/components/shared/FileSidebar.tsx+++ b/frontend/editor/src/core/components/shared/FileSidebar.tsx@@ -12,7 +12,6 @@ import { NavSurface } from "@app/ui/NavSurface";import { Button } from "@app/ui/Button";import { Icon } from "@app/ui/Icon";import { useTranslation } from "react-i18next";-import { useNavigate } from "react-router-dom";import { useFileState, useFileActions } from "@app/contexts/file/fileHooks";import { useAppConfig } from "@app/contexts/AppConfigContext";import { useGoogleDrivePicker } from "@app/hooks/useGoogleDrivePicker";@@ -34,7 +33,6 @@ import {import { GoogleDriveIcon } from "@app/components/shared/CloudStorageIcons";import { SidebarHeader } from "@app/components/shared/SidebarHeader";import type { StirlingFileStub } from "@app/types/fileContext";-import FolderOpenIcon from "@mui/icons-material/FolderOpen";import FolderSpecialIcon from "@mui/icons-material/FolderSpecial";import UploadFileIcon from "@mui/icons-material/UploadFile";import AddIcon from "@mui/icons-material/Add";@@ -75,6 +73,9 @@ import {clearWatchedFolderDraggedFileIds,} from "@app/components/watchedFolders/watchedFolderDragState";import { WATCHED_FOLDERS_ENABLED } from "@app/constants/featureFlags";+import { FolderTreeSidebar } from "@app/components/filesPage/FolderTreeSidebar";+import { useFilesPage } from "@app/contexts/FilesPageContext";+import type { FolderId, FolderRecord } from "@app/types/folder";import { useToolWorkflow } from "@app/contexts/ToolWorkflowContext";import { useToolEligibleFileIds } from "@app/contexts/ToolFileEligibilityContext";import "@app/components/shared/FileSidebar.css";@@ -102,23 +103,22 @@ export interface FileSidebarProps {onOpenSettings?: () => void;/** The quick nav rail owns the account control, so the footer drops its own row. */accountHoisted?: boolean;- /** Accessible name override for the collapse toggle. */- toggleAriaLabel?: string;- /** Icon override for the collapse toggle (e.g. back-arrow on /files). */- toggleIcon?: React.ReactNode;/** Override the Open-from-computer handler (e.g. upload to /files folder). */onUploadFiles?: (files: File[]) => void | Promise<void>;/** Override the Google Drive handler. */onPickGoogleDriveFiles?: (files: File[]) => void | Promise<void>;- /** Extra action row inserted under Open-from-computer (e.g. New folder). */- extraAction?: {+ /** Action rows inserted under Open-from-computer (New folder, Refresh). A+ * control with more than one destination renders itself instead, given the+ * collapse state the row would have used. */+ extraActions?: Array<{icon: React.ReactNode;label: string;onClick: () => void;disabled?: boolean;disabledTooltip?: string;testId?: string;- };+ render?: (ctx: { collapsed: boolean }) => React.ReactNode;+ }>;}/**@@ -153,6 +153,41 @@ function BulkAddProgressRow() {);}+/**+ * The library's folder tree, as a section of the file sidebar. Separate so the+ * subscription to the library's state belongs to the only part that reads it: that+ * state changes on every keystroke in the library's filter, and the sidebar renders+ * in every view.+ */+function FolderTreeSection() {+ const { t } = useTranslation();+ const filesPage = useFilesPage();+ return (+ <div className="file-sidebar-folders-section sidebar-content-fade">+ <div className="file-sidebar-section-header">+ <span className="file-sidebar-section-label">+ {t("filesPage.tree", "Folders")}+ </span>+ </div>+ <FolderTreeSidebar+ fileCounts={filesPage.fileCountsByFolder}+ onRequestNewFolder={filesPage.openNewFolderDialog}+ onRenameFolder={(folder: FolderRecord) =>+ filesPage.openRenameFolderDialog(folder)+ }+ onDeleteFolder={filesPage.promptDeleteFolder}+ onMoveFilesIntoFolder={async (+ targetId: FolderId | null,+ fileIds: FileId[],+ ) => {+ if (fileIds.length === 0) return;+ await filesPage.moveFilesTo(fileIds, targetId);+ }}+ />+ </div>+ );+}+const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(function FileSidebar({@@ -160,11 +195,9 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(onToggleCollapse,onOpenSettings,accountHoisted = false,- toggleAriaLabel,- toggleIcon,onUploadFiles,onPickGoogleDriveFiles,- extraAction,+ extraActions,},ref,) {@@ -180,7 +213,6 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(null,);- const navigate = useNavigate();const { config } = useAppConfig();const {isEnabled: isGoogleDriveEnabled,@@ -962,8 +994,6 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(<SidebarHeadercollapsed={collapsed}onToggleCollapse={onToggleCollapse}- toggleAriaLabel={toggleAriaLabel}- toggleIcon={toggleIcon}/>{/* Box 1 — top controls (open / my files / cloud). No title. File@@ -1031,88 +1061,61 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(</div></Tooltip>- {extraAction && (- <Tooltip- label={extraAction.disabledTooltip ?? extraAction.label}- position="right"- withinPortal- // Only force a wide multiline box when the long disabled- // reason is shown; the short label fits one line.- multiline={Boolean(- extraAction.disabled && extraAction.disabledTooltip,- )}- w={- extraAction.disabled && extraAction.disabledTooltip- ? 220- : undefined- }- disabled={- !collapsed &&- !(extraAction.disabled && extraAction.disabledTooltip)- }- >- <div- className={`file-sidebar-action-row${extraAction.disabled ? " disabled" : ""}`}- data-testid={extraAction.testId}- onClick={() => {- if (extraAction.disabled) return;- extraAction.onClick();- }}- role="button"- tabIndex={extraAction.disabled ? -1 : 0}- aria-disabled={extraAction.disabled}- aria-label={extraAction.label}- onKeyDown={(e) => {- if (extraAction.disabled) return;- if (e.key === "Enter" || e.key === " ") {- e.preventDefault();- extraAction.onClick();+ {extraActions?.map((action) => (+ <React.Fragment key={action.label}>+ {action.render ? (+ action.render({ collapsed })+ ) : (+ <Tooltip+ label={action.disabledTooltip ?? action.label}+ position="right"+ withinPortal+ // Only force a wide multiline box when the long disabled+ // reason is shown; the short label fits one line.+ multiline={Boolean(+ action.disabled && action.disabledTooltip,+ )}+ w={+ action.disabled && action.disabledTooltip+ ? 220+ : undefined}- }}- >- <span className="file-sidebar-action-icon">- {extraAction.icon}- </span>- {!collapsed && (- <span className="file-sidebar-action-label sidebar-content-fade">- {extraAction.label}- </span>- )}- </div>- </Tooltip>- )}-- <Tooltip- label={t("fileSidebar.myFiles", "File library")}- position="right"- withinPortal- disabled={!collapsed}- >- <div- className="file-sidebar-action-row"- data-testid="my-files-button"- onClick={() => {- if (collapsed && onToggleCollapse) onToggleCollapse();- navigate("/files");- }}- role="button"- tabIndex={0}- aria-label={t("fileSidebar.myFiles", "File library")}- onKeyDown={(e) => {- if (e.key === "Enter" || e.key === " ") {- e.preventDefault();- navigate("/files");- }- }}- >- <FolderOpenIcon className="file-sidebar-action-icon" />- {!collapsed && (- <span className="file-sidebar-action-label sidebar-content-fade">- {t("fileSidebar.myFiles", "File library")}- </span>+ disabled={+ !collapsed && !(action.disabled && action.disabledTooltip)+ }+ >+ <div+ className={`file-sidebar-action-row${action.disabled ? " disabled" : ""}`}+ data-testid={action.testId}+ onClick={() => {+ if (action.disabled) return;+ action.onClick();+ }}+ role="button"+ tabIndex={action.disabled ? -1 : 0}+ aria-disabled={action.disabled}+ aria-label={action.label}+ onKeyDown={(e) => {+ if (action.disabled) return;+ if (e.key === "Enter" || e.key === " ") {+ e.preventDefault();+ action.onClick();+ }+ }}+ >+ <span className="file-sidebar-action-icon">+ {action.icon}+ </span>+ {!collapsed && (+ <span className="file-sidebar-action-label sidebar-content-fade">+ {action.label}+ </span>+ )}+ </div>+ </Tooltip>)}- </div>- </Tooltip>+ </React.Fragment>+ ))}{!shouldHideGoogleDrive && (<Tooltip@@ -1194,8 +1197,15 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>({/* Box 2 — the file tree (this box scrolls). */}<NavSurface className="file-sidebar-files-box"><div className="file-sidebar-scroll">- {/* Files section - always visible when expanded */}- {!collapsed && (+ {/* The library browses folders, so there the box carries the tree the+ file list would otherwise fill: one sidebar, its contents following+ the view. */}+ {!collapsed && currentWorkbench === "myFiles" && (+ <FolderTreeSection />+ )}++ {/* Files section - visible when expanded, outside the library */}+ {!collapsed && currentWorkbench !== "myFiles" && (<div className="file-sidebar-files-section sidebar-content-fade"><div className="file-sidebar-section-header"><span className="file-sidebar-section-label">@@ -1205,7 +1215,7 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(<ActionIconvariant="quiet"className="file-sidebar-section-btn file-sidebar-section-btn-external"- onClick={() => navigate("/files")}+ onClick={() => navActions.setWorkbench("myFiles")}title={t("fileSidebar.openFileManager","Browse all files & folders",@@ -1306,7 +1316,7 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(fullWidthjustify="between"className="file-sidebar-view-all"- onClick={() => navigate("/files")}+ onClick={() => navActions.setWorkbench("myFiles")}rightSection={<KeyboardArrowRightIconsx={{ fontSize: "1rem" }}diff --git a/frontend/editor/src/core/components/shared/SidebarHeader.tsx b/frontend/editor/src/core/components/shared/SidebarHeader.tsxindex 1a2befa074..89a0fc32ff 100644--- a/frontend/editor/src/core/components/shared/SidebarHeader.tsx+++ b/frontend/editor/src/core/components/shared/SidebarHeader.tsx@@ -4,8 +4,6 @@ import { SidebarToggleButton } from "@app/components/shared/SidebarToggleButton"export interface SidebarHeaderProps {collapsed?: boolean;onToggleCollapse?: () => void;- toggleAriaLabel?: string;- toggleIcon?: React.ReactNode;className?: string;}@@ -13,8 +11,6 @@ export interface SidebarHeaderProps {export function SidebarHeader({collapsed,onToggleCollapse,- toggleAriaLabel,- toggleIcon,className,}: SidebarHeaderProps) {return (@@ -24,8 +20,6 @@ export function SidebarHeader({<SidebarToggleButtoncollapsed={collapsed}onToggle={onToggleCollapse}- ariaLabel={toggleAriaLabel}- icon={toggleIcon}/>)}</div>diff --git a/frontend/editor/src/core/components/shared/SidebarToggleButton.tsx b/frontend/editor/src/core/components/shared/SidebarToggleButton.tsxindex 3a1345360b..9dde141bab 100644--- a/frontend/editor/src/core/components/shared/SidebarToggleButton.tsx+++ b/frontend/editor/src/core/components/shared/SidebarToggleButton.tsx@@ -5,16 +5,12 @@ import { SidebarToggleIcon } from "@app/components/shared/SidebarToggleIcon";export interface SidebarToggleButtonProps {collapsed?: boolean;onToggle: () => void;- ariaLabel?: string;- icon?: React.ReactNode;}-/** Opens and closes the sidebar; on /files the caller swaps in a back arrow. */+/** Opens and closes the sidebar. */export function SidebarToggleButton({collapsed,onToggle,- ariaLabel,- icon,}: SidebarToggleButtonProps) {const { t } = useTranslation();return (@@ -24,13 +20,12 @@ export function SidebarToggleButton({className="file-sidebar-collapse-toggle"onClick={() => onToggle()}aria-label={- ariaLabel ??- (collapsed+ collapsed? t("fileSidebar.expand", "Expand sidebar")- : t("fileSidebar.collapse", "Collapse sidebar"))+ : t("fileSidebar.collapse", "Collapse sidebar")}>- {icon ?? <SidebarToggleIcon size={18} />}+ <SidebarToggleIcon size={18} /></ActionIcon>);}diff --git a/frontend/editor/src/core/components/shared/WorkbenchBar.css b/frontend/editor/src/core/components/shared/WorkbenchBar.cssindex 6523a03816..0c6b1c985d 100644--- a/frontend/editor/src/core/components/shared/WorkbenchBar.css+++ b/frontend/editor/src/core/components/shared/WorkbenchBar.css@@ -22,6 +22,17 @@}/* ---- View switcher (left) ---- */+/* Follows the view switcher, which claims order 1 in the bar's reflow. */+.workbench-bar-lead {+ order: 2;+ display: flex;+ align-items: center;+ gap: 2px;+ min-width: 0;+ overflow: hidden;+ height: 38px;+}+.workbench-bar-views {order: 1;flex-shrink: 0;diff --git a/frontend/editor/src/core/components/shared/WorkbenchBar.tsx b/frontend/editor/src/core/components/shared/WorkbenchBar.tsxindex 4e0e3976f7..7d2390ca18 100644--- a/frontend/editor/src/core/components/shared/WorkbenchBar.tsx+++ b/frontend/editor/src/core/components/shared/WorkbenchBar.tsx@@ -168,6 +168,24 @@ export default function WorkbenchBar({return selectedFileIds.length;}, [currentView, pageEditorSelectedCount, selectedFileIds.length]);+ // Registered into the bar's own row rather than the tool row below it. Already+ // sorted by order when registered.+ const barRowButtons = useMemo(+ () =>+ buttons.filter((btn) => btn.section === "bar" && (btn.visible ?? true)),+ [buttons],+ );++ // Beside the view switcher rather than among the actions: what the view is showing+ // reads as part of the view, not as something to do to it.+ const barLeadButtons = useMemo(+ () =>+ buttons.filter(+ (btn) => btn.section === "bar-lead" && (btn.visible ?? true),+ ),+ [buttons],+ );+const sectionsWithButtons = useMemo(() => {return SECTION_ORDER.map((section) => {const sectionButtons = buttons.filter(@@ -334,7 +352,9 @@ export default function WorkbenchBar({// stay in step; each renders the same actions in its own shape.const globalActionProps: WorkbenchBarActionsProps = {currentView,- isCustomView,+ // Save, Save As and Close act on an open document. The library has none: it+ // lists files, and opening one is what the other views are for.+ showsFileActions: !isCustomView && currentView !== "myFiles",actionsDisabled,policyEnforcing,downloadLabel: downloadTooltip,@@ -525,7 +545,9 @@ export default function WorkbenchBar({<div className="workbench-bar-divider" /></>)}- {(hasFiles || isCustomView) && (+ {/* Not in the library: it browses files rather than showing one, and the+ rail is what moves between surfaces. */}+ {currentView !== "myFiles" && (hasFiles || isCustomView) && (<SegmentedControl<WorkbenchType>className="workbench-bar-views"size="sm"@@ -543,6 +565,16 @@ export default function WorkbenchBar({}))}/>)}+ {barLeadButtons.map((btn) => {+ const content = renderButton(btn);+ if (!content) return null;+ return (+ <div className="workbench-bar-lead" key={btn.id}>+ <div className="workbench-bar-divider" />+ {content}+ </div>+ );+ })}</div>{/* Global super search - always present, even on the homepage */}@@ -598,6 +630,19 @@ export default function WorkbenchBar({{/* Right: Global buttons - export group left, close anchored right */}<div className="workbench-bar-globals">+ {/* A view's own controls, ahead of the globals every view shares. */}+ {barRowButtons.map((btn) => {+ const content = renderButton(btn);+ if (!content) return null;+ return (+ <div key={btn.id} className="workbench-bar-action-wrapper">+ {content}+ </div>+ );+ })}+ {barRowButtons.length > 0 && (+ <div className="workbench-bar-divider workbench-bar-globals-sep" />+ )}{/* Share (viewer only; opens the same modal as My Files "Manage sharing") */}{currentView === "viewer" && sharingEnabled && (<ViewerShareButton disabled={actionsDisabled} />diff --git a/frontend/editor/src/core/components/shared/quickNav/QuickNavHostBridge.tsx b/frontend/editor/src/core/components/shared/quickNav/QuickNavHostBridge.tsxindex ca9af1a22b..424febf85b 100644--- a/frontend/editor/src/core/components/shared/quickNav/QuickNavHostBridge.tsx+++ b/frontend/editor/src/core/components/shared/quickNav/QuickNavHostBridge.tsx@@ -19,11 +19,13 @@ import type { ToolId } from "@app/types/toolId";export interface QuickNavHostBridgeProps {portalAccess?: boolean;readerMode?: boolean;+ fileLibrary?: boolean;onSetReaderMode?: (on: boolean) => void;requestNavigation?: (go: () => void) => void;onGoToDefaultState?: () => void;onSelectTool?: (toolId: ToolId) => void;activeTool?: ToolId | null;+ onShowFileLibrary?: () => void;/** Merged over the reasons worked out here, for what only the app can see. */toolReasons?: QuickNavToolReasons;}@@ -32,10 +34,12 @@ export interface QuickNavHostBridgeProps {export function QuickNavHostBridge({portalAccess = false,readerMode = false,+ fileLibrary = false,onSetReaderMode,requestNavigation,onSelectTool,activeTool = null,+ onShowFileLibrary,onGoToDefaultState,toolReasons,}: QuickNavHostBridgeProps) {@@ -64,6 +68,7 @@ export function QuickNavHostBridge({signingBadge,portalAccess,readerMode,+ fileLibrary,activeTool,notificationsOpen,toolReasons: mergedToolReasons,@@ -72,6 +77,7 @@ export function QuickNavHostBridge({requestNavigation,selectTool: onSelectTool,setReaderMode: onSetReaderMode,+ showFileLibrary: onShowFileLibrary,goToDefaultState: onGoToDefaultState,toggleNotifications: () => setNotificationsOpen((open) => !open),onBrandFlourish: brandFlourish.trigger,diff --git a/frontend/editor/src/core/components/shared/quickNav/QuickNavRailHost.tsx b/frontend/editor/src/core/components/shared/quickNav/QuickNavRailHost.tsxindex c3d8741843..c62e8ddb08 100644--- a/frontend/editor/src/core/components/shared/quickNav/QuickNavRailHost.tsx+++ b/frontend/editor/src/core/components/shared/quickNav/QuickNavRailHost.tsx@@ -47,12 +47,14 @@ export function QuickNavRailHost() {};// Guarded where the app supplies a guard, so leaving mid-edit still prompts.- const go = (to: string) => {+ const guarded = (leave: () => void) => {const guard = host?.actions.current?.requestNavigation;- if (guard) guard(() => navigate(to));- else navigate(to);+ if (guard) guard(leave);+ else leave();};+ const go = (to: string) => guarded(() => navigate(to));+// Through the app where possible: its route only selects a tool on a fresh mount.const openTool = (toolId: ToolId, route: string) => {const select = host?.actions.current?.selectTool;@@ -97,7 +99,8 @@ export function QuickNavRailHost() {) : (<LocalIcon icon="edit-outline-rounded" width={SIZE} height={SIZE} />),- current: inEditor,+ // The library is a place of its own, not the editor with a different centre.+ current: inEditor && !host?.fileLibrary,onClick: () => {if (inEditor) {returnHome();@@ -145,7 +148,19 @@ export function QuickNavRailHost() {icon: (<LocalIcon icon="folder-outline-rounded" width={SIZE} height={SIZE} />),- onClick: () => go("/files"),+ current: Boolean(host?.fileLibrary),+ // Through the app where possible: the library is a view, not a route. From the+ // processor there is no editor to ask, so the path carries it and HomePage seeds+ // the view on arrival. Unwrapped: setting the view runs the app's own+ // unsaved-changes check, and asking twice leaves the second ask nowhere to+ // prompt.+ onClick: () => {+ const show = host?.actions.current?.showFileLibrary;+ // Unwrapped: setting the view runs the app's own unsaved-changes check, and+ // asking twice leaves the second ask with nowhere to prompt.+ if (show) show();+ else go("/files");+ },},{id: "automate",diff --git a/frontend/editor/src/core/components/shared/workbenchBar/WorkbenchBarDesktopActions.tsx b/frontend/editor/src/core/components/shared/workbenchBar/WorkbenchBarDesktopActions.tsxindex e2070d6711..64fe416810 100644--- a/frontend/editor/src/core/components/shared/workbenchBar/WorkbenchBarDesktopActions.tsx+++ b/frontend/editor/src/core/components/shared/workbenchBar/WorkbenchBarDesktopActions.tsx@@ -21,7 +21,7 @@ interface WorkbenchBarDesktopActionsProps extends WorkbenchBarActionsProps {*/export default function WorkbenchBarDesktopActions({currentView,- isCustomView,+ showsFileActions,actionsDisabled,policyEnforcing,downloadLabel,@@ -64,8 +64,8 @@ export default function WorkbenchBarDesktopActions({tooltipFor(t("workbenchBar.print", "Print PDF")),)}- {/* Download (file-level action — not relevant in custom views) */}- {!isCustomView &&+ {/* Saving, and closing what was saved: only where a document is open. */}+ {showsFileActions &&renderWithTooltip(<ActionIconvariant="tertiary"@@ -80,7 +80,7 @@ export default function WorkbenchBarDesktopActions({tooltipFor(downloadLabel),)}- {!isCustomView &&+ {showsFileActions &&saveAsIconName &&renderWithTooltip(<ActionIcon@@ -97,12 +97,12 @@ export default function WorkbenchBarDesktopActions({)}{/* Separator: export group | close */}- {!isCustomView && (+ {showsFileActions && (<div className="workbench-bar-divider workbench-bar-globals-sep" />)}{/* Close (context-aware: close all / close viewer file / close page editor) */}- {!isCustomView &&+ {showsFileActions &&renderWithTooltip(<ActionIconvariant="tertiary"diff --git a/frontend/editor/src/core/components/shared/workbenchBar/WorkbenchBarMobileActions.tsx b/frontend/editor/src/core/components/shared/workbenchBar/WorkbenchBarMobileActions.tsxindex 7675c37e33..c3859ea86a 100644--- a/frontend/editor/src/core/components/shared/workbenchBar/WorkbenchBarMobileActions.tsx+++ b/frontend/editor/src/core/components/shared/workbenchBar/WorkbenchBarMobileActions.tsx@@ -13,7 +13,7 @@ import { WorkbenchBarActionsProps } from "@app/components/shared/workbenchBar/ty*/export default function WorkbenchBarMobileActions({currentView,- isCustomView,+ showsFileActions,actionsDisabled,policyEnforcing,downloadLabel,@@ -26,7 +26,7 @@ export default function WorkbenchBarMobileActions({const { t } = useTranslation();const exportDisabled = actionsDisabled || policyEnforcing;const showPrint = currentView === "viewer";- const showFileActions = !isCustomView;+ const showFileActions = showsFileActions;// Custom workbench views own their content, so none of these apply. The// desktop cluster renders nothing at all in that case; without this thediff --git a/frontend/editor/src/core/components/shared/workbenchBar/types.ts b/frontend/editor/src/core/components/shared/workbenchBar/types.tsindex 7ec30c5cec..9348ce25ff 100644--- a/frontend/editor/src/core/components/shared/workbenchBar/types.ts+++ b/frontend/editor/src/core/components/shared/workbenchBar/types.ts@@ -5,7 +5,9 @@ import { WorkbenchType } from "@app/types/workbench";export interface WorkbenchBarActionsProps {currentView: WorkbenchType;/** Custom workbench views own their content, so file actions don't apply. */- isCustomView: boolean;+ /** Whether the view has a document for the file-level actions to act on: a custom+ * view brings its own canvas, and the library lists files rather than opening one. */+ showsFileActions: boolean;/** No files to act on, or the bar is globally locked out. */actionsDisabled: boolean;/** A policy run is enforcing on a file the export would touch. */diff --git a/frontend/editor/src/core/contexts/FilesPageContext.tsx b/frontend/editor/src/core/contexts/FilesPageContext.tsxindex c64a9f1a54..ac03a475b6 100644--- a/frontend/editor/src/core/contexts/FilesPageContext.tsx+++ b/frontend/editor/src/core/contexts/FilesPageContext.tsx@@ -79,6 +79,10 @@ interface FilesPageContextValue {fileCountsByFolder: Map<FolderId | null, number>;loading: boolean;refresh: () => Promise<void>;+ /** Bumped to re-read a mounted directory, which is listed from disk rather than+ * from storage and so has nothing to react to when its contents change. */+ diskRevision: number;+ bumpDiskRevision: () => void;// SelectionselectedFileIds: Set<FileId>;@@ -169,6 +173,9 @@ export function FilesPageProvider({ children }: { children: React.ReactNode }) {const setFoldersError = folders.setError;const storageEnabled = appConfig?.storageEnabled === true;const shareLinksEnabled = appConfig?.storageShareLinksEnabled === true;+ const [diskRevision, setDiskRevision] = useState(0);+ const bumpDiskRevision = useCallback(() => setDiskRevision((n) => n + 1), []);+const refresh = useCallback(async () => {const gen = ++refreshGenRef.current;setLoading(true);@@ -711,6 +718,8 @@ export function FilesPageProvider({ children }: { children: React.ReactNode }) {fileCountsByFolder,loading,refresh,+ diskRevision,+ bumpDiskRevision,selectedFileIds,setSelectedFileIds,clearSelection,@@ -753,6 +762,8 @@ export function FilesPageProvider({ children }: { children: React.ReactNode }) {fileCountsByFolder,loading,refresh,+ diskRevision,+ bumpDiskRevision,selectedFileIds,clearSelection,viewMode,diff --git a/frontend/editor/src/core/contexts/NavigationContext.tsx b/frontend/editor/src/core/contexts/NavigationContext.tsxindex f158991378..fed0daebb8 100644--- a/frontend/editor/src/core/contexts/NavigationContext.tsx+++ b/frontend/editor/src/core/contexts/NavigationContext.tsx@@ -116,6 +116,10 @@ export interface NavigationContextActions {) => void;unregisterNavigationWarningHandlers: () => void;navigationWarningHandlersRef: React.RefObject<NavigationWarningHandlers | null>;+ /** The path a view was last derived from. Lives here rather than in the page so a+ * remount (a share link, a login bounce, a Suspense boundary resolving) does not+ * read an unchanged path as a fresh arrival and re-derive over the user's choice. */+ viewDerivedFromPathRef: React.RefObject<string | null>;}// Context state values@@ -151,6 +155,7 @@ export const NavigationProvider: React.FC<{const [state, dispatch] = useReducer(navigationReducer, initialState);const { allTools: toolRegistry } = useToolRegistry();const unsavedChangesCheckerRef = React.useRef<(() => boolean) | null>(null);+ const viewDerivedFromPathRef = useRef<string | null>(null);const navigationWarningHandlersRef = useRef<NavigationWarningHandlers | null>(null,);@@ -424,6 +429,7 @@ export const NavigationProvider: React.FC<{registerNavigationWarningHandlers,unregisterNavigationWarningHandlers,navigationWarningHandlersRef,+ viewDerivedFromPathRef,}),[setWorkbench,@@ -518,5 +524,6 @@ export const useNavigationGuard = () => {unregisterNavigationWarningHandlers:actions.unregisterNavigationWarningHandlers,navigationWarningHandlersRef: actions.navigationWarningHandlersRef,+ viewDerivedFromPathRef: actions.viewDerivedFromPathRef,};};diff --git a/frontend/editor/src/core/contexts/QuickNavHostContext.tsx b/frontend/editor/src/core/contexts/QuickNavHostContext.tsxindex 8aa113c3f4..f68dc67ff1 100644--- a/frontend/editor/src/core/contexts/QuickNavHostContext.tsx+++ b/frontend/editor/src/core/contexts/QuickNavHostContext.tsx@@ -24,6 +24,8 @@ export interface QuickNavHostData {signingBadge: number;portalAccess: boolean;readerMode: boolean;+ /** The library is a view of the editor app, and the rail marks it as its own place. */+ fileLibrary: boolean;activeTool: ToolId | null;/** The app owns the panel; the rail's bell only reports its state. */notificationsOpen: boolean;@@ -35,6 +37,7 @@ export interface QuickNavHostActions {/** The editor reads its tool from the URL only on mount. */selectTool?: (toolId: ToolId) => void;setReaderMode?: (on: boolean) => void;+ showFileLibrary?: () => void;toggleNotifications?: () => void;goToDefaultState?: () => void;requestNavigation?: (go: () => void) => void;@@ -65,6 +68,7 @@ const EMPTY_DATA: QuickNavHostData = {signingBadge: 0,portalAccess: false,readerMode: false,+ fileLibrary: false,activeTool: null,notificationsOpen: false,};@@ -94,6 +98,7 @@ export function QuickNavHostProvider({ children }: { children: ReactNode }) {merged.signingBadge === prev.signingBadge &&merged.portalAccess === prev.portalAccess &&merged.readerMode === prev.readerMode &&+ merged.fileLibrary === prev.fileLibrary &&merged.activeTool === prev.activeTool &&merged.notificationsOpen === prev.notificationsOpen &&merged.identity?.displayName === prev.identity?.displayName &&@@ -147,6 +152,7 @@ export function useRegisterQuickNavHost(signingBadge,portalAccess,readerMode,+ fileLibrary,activeTool,notificationsOpen,toolReasons,@@ -158,6 +164,7 @@ export function useRegisterQuickNavHost(signingBadge: signingBadge ?? 0,portalAccess: portalAccess ?? false,readerMode: readerMode ?? false,+ fileLibrary: fileLibrary ?? false,// Cleared, not omitted as toolReasons is: a stale tool marks an entry.activeTool: activeTool ?? null,notificationsOpen: notificationsOpen ?? false,@@ -172,6 +179,7 @@ export function useRegisterQuickNavHost(signingBadge,portalAccess,readerMode,+ fileLibrary,activeTool,notificationsOpen,toolReasons,diff --git a/frontend/editor/src/core/hooks/useLibraryRefresh.ts b/frontend/editor/src/core/hooks/useLibraryRefresh.tsnew file mode 100644index 0000000000..8cec0a3c84--- /dev/null+++ b/frontend/editor/src/core/hooks/useLibraryRefresh.ts@@ -0,0 +1,47 @@+import { useCallback, useState } from "react";+import { useTranslation } from "react-i18next";++import { useFilesPage } from "@app/contexts/FilesPageContext";+import { useFolders } from "@app/contexts/FolderContext";++/**+ * Pull the server's folders and files again. Shared by every surface that offers+ * it, so a refresh from one is the same work as a refresh from another.+ */+export function useLibraryRefresh(): {+ refreshing: boolean;+ refresh: () => Promise<void>;+} {+ const { t } = useTranslation();+ const folders = useFolders();+ const { refresh, bumpDiskRevision } = useFilesPage();+ const [refreshing, setRefreshing] = useState(false);++ const run = useCallback(async () => {+ setRefreshing(true);+ try {+ // pullFromServer bumps the folder revision, which the FolderProvider's effect+ // reacts to by re-running refresh() - no need to await folders.refresh() here.+ const result = await folders.pullFromServer();+ if (!result.ok && result.reason !== "endpoint-missing") {+ folders.setError(+ result.reason === "network"+ ? t("filesPage.syncError.network", "Could not reach the server.")+ : result.reason === "server"+ ? t(+ "filesPage.syncError.server",+ "Server error during folder sync.",+ )+ : t("filesPage.syncError.client", "Folder sync failed."),+ );+ }+ // A mount is listed from the disk, which no amount of server syncing re-reads.+ bumpDiskRevision();+ await refresh();+ } finally {+ setRefreshing(false);+ }+ }, [folders, refresh, bumpDiskRevision, t]);++ return { refreshing, refresh: run };+}diff --git a/frontend/editor/src/core/pages/HomePage.tsx b/frontend/editor/src/core/pages/HomePage.tsxindex 6e201b4908..47fbe57cd2 100644--- a/frontend/editor/src/core/pages/HomePage.tsx+++ b/frontend/editor/src/core/pages/HomePage.tsx@@ -27,7 +27,6 @@ import { isApplyingRestoredView } from "@app/services/workbenchSession";import { useViewer } from "@app/contexts/ViewerContext";import { useLocation, useNavigate } from "react-router-dom";import AppsIcon from "@mui/icons-material/AppsRounded";-import ArrowBackIcon from "@mui/icons-material/ArrowBack";import CreateNewFolderIcon from "@mui/icons-material/CreateNewFolder";import RightSidebar from "@app/components/tools/RightSidebar";@@ -58,8 +57,14 @@ import { useFolders } from "@app/contexts/FolderContext";import { folderKind } from "@app/types/folder";import { useServerFolderBlock } from "@app/hooks/useServerFolderBlock";import { useNewFolderFlow } from "@app/hooks/useNewFolderFlow";+import { NewFolderButton } from "@app/components/filesPage/NewFolderButton";+import MobileUploadModal from "@app/components/shared/MobileUploadModal";+import { useLibraryRefresh } from "@app/hooks/useLibraryRefresh";+import { useAuth } from "@app/auth/UseSession";+import RefreshIcon from "@mui/icons-material/Refresh";+import QrCode2Icon from "@mui/icons-material/QrCode2";+import { canPickDirectory } from "@app/services/directoryPicker";import { useFileHandler } from "@app/hooks/useFileHandler";-import { FolderTreePanel } from "@app/components/filesPage/FolderTreePanel";import type { FileSidebarProps } from "@app/components/shared/FileSidebar";import { Button } from "@app/ui/Button";@@ -128,10 +133,8 @@ export default function HomePage() {const isProgrammaticScroll = useRef(false);const otherApp = useOtherAppSwitch();const location = useLocation();- // Persisted user preference for the FileSidebar collapsed state. Auto-- // collapse on /files is layered on top in the transition effect below and- // doesn't write to storage, so deep-linking to /files won't overwrite what- // the user actually chose last time.+ // The user's preference, and the only thing that decides it: reading mode forces+ // the sidebar shut without writing, so leaving reading restores this.const [fileSidebarCollapsed, setFileSidebarCollapsed] = useState(// Reader mode outlives this page (settings swaps it out and back), and it// collapses the sidebar without persisting that, so it wins on mount too.@@ -194,56 +197,47 @@ export default function HomePage() {// Clean slate: no tool, out of the file library and reading.const goToDefaultState = useCallback(() => {handleBackToTools();- if (location.pathname.startsWith("/files")) navigate(EDITOR_BASENAME);actions.setWorkbench(getDefaultWorkbenchForFileCount(activeFiles.length));- }, [- handleBackToTools,- location.pathname,- navigate,- actions,- activeFiles.length,- ]);+ }, [handleBackToTools, actions, activeFiles.length]);++ // The library is a view like the viewer and the file editor: which view is on screen+ // is state, the path says which folder you are in. Each side moves the other on a+ // transition only: asserting either on every render lets the path re-impose+ // "myFiles" a render after anything else has set a view.- // Sync the /files* URL into the workbench state so the file manager view- // takes over the workbench area when the user lands on it. This is the- // only state-of-truth for the active workbench, so keep the URL pinned.+ // Path moved, so the path is the cause: arrival, back/forward, or a deliberate+ // navigate. Mount included, which is what seeds a deep link.+ const derivedFromPath = actions.viewDerivedFromPathRef;useEffect(() => {+ if (derivedFromPath.current === location.pathname) return;if (location.pathname.startsWith("/files")) {if (navigationState.workbench !== "myFiles") {actions.setWorkbench("myFiles");}- } else if (- navigationState.workbench === "myFiles" &&- !isApplyingRestoredView()- ) {- // The URL no longer supports the file manager - drop back to a sensible default. Stays a- // state check rather than a transition one: HomePage remounts without NavigationContext- // (a share link, a login bounce), and the view has to be corrected on arrival too.- // Skipped mid-restore, which is reopening a recorded view onto files still loading.- actions.setWorkbench(activeFiles.length > 1 ? "fileEditor" : "viewer");+ } else if (navigationState.workbench === "myFiles") {+ // A restore is reopening a recorded view onto files still loading. Leave the+ // path unmarked so the correction runs once those files land.+ if (isApplyingRestoredView()) return;+ actions.setWorkbench(getDefaultWorkbenchForFileCount(activeFiles.length));}- }, [- location.pathname,- navigationState.workbench,- actions,- activeFiles.length,- ]);+ derivedFromPath.current = location.pathname;+ // Deliberately not keyed on the workbench: this reacts to the path only.+ }, [location.pathname, actions, derivedFromPath, activeFiles.length]);- // Auto-collapse the FileSidebar while on /files; restore the user's persisted- // preference on leave. Auto-collapse doesn't write to storage so deep-linking- // to /files won't overwrite what the user actually chose.- const prevWorkbenchRef = useRef(navigationState.workbench);+ // View moved, so the path follows. Pushed, not replaced, so Back leaves the library.+ const wasInLibraryRef = useRef(navigationState.workbench === "myFiles");useEffect(() => {- const prev = prevWorkbenchRef.current;- const curr = navigationState.workbench;- if (curr === "myFiles" && prev !== "myFiles") {- if (!fileSidebarCollapsed) setFileSidebarCollapsed(true);- } else if (curr !== "myFiles" && prev === "myFiles") {- setFileSidebarCollapsed(readPersistedSidebarCollapsed());+ const inLibrary = navigationState.workbench === "myFiles";+ if (inLibrary === wasInLibraryRef.current) return;+ wasInLibraryRef.current = inLibrary;+ const onFilesPath = location.pathname.startsWith("/files");+ if (inLibrary && !onFilesPath) {+ navigate("/files");+ } else if (!inLibrary && onFilesPath) {+ navigate(EDITOR_BASENAME);}- prevWorkbenchRef.current = curr;- // fileSidebarCollapsed read as snapshot on transition only.- }, [navigationState.workbench]);+ }, [navigationState.workbench, location.pathname, navigate]);+// Imperative, so the toggle still works while reading. Never persisted: not a preference.const prevReaderModeRef = useRef(readerMode);useEffect(() => {@@ -322,18 +316,14 @@ export default function HomePage() {return reasons;}, [toolRegistry, toolAvailability, config?.premiumEnabled, t]);- // Shared with the sidebar's own toggle. On /files it leaves rather than collapses.+ // The collapse is a preference, so it is written as one; every view reads it back.const handleSidebarToggle = useCallback(() => {- if (navigationState.workbench === "myFiles") {- navigate(EDITOR_BASENAME);- return;- }setFileSidebarCollapsed((c) => {const next = !c;writePersistedSidebarCollapsed(next);return next;});- }, [navigationState.workbench, navigate]);+ }, []);const [showSwipeHint, setShowSwipeHint] = useState(() => !readSwipeHintSeen(),@@ -365,10 +355,8 @@ export default function HomePage() {[dismissSwipeHint],);- // The /files URL pins the workbench to myFiles, so changing view while the- // file manager is open does nothing until we navigate off it. Desktop leaves- // via the sidebar's back arrow; mobile renders no sidebar, so without this the- // bottom bar could not get out of My Files at all.+ // Mobile's bottom bar sets no view of its own, so leaving the library is the path+ // moving; the reconciliation effect takes the view with it.const leaveMyFiles = useCallback(() => {if (navigationState.workbench === "myFiles") navigate(EDITOR_BASENAME);}, [navigationState.workbench, navigate]);@@ -492,10 +480,12 @@ export default function HomePage() {portalAccess={Boolean(otherApp)}requestNavigation={requestNavigation}readerMode={readerMode}+ fileLibrary={navigationState.workbench === "myFiles"}onSetReaderMode={setReaderMode}onGoToDefaultState={goToDefaultState}onSelectTool={handleToolSelect}activeTool={selectedToolKey}+ onShowFileLibrary={() => actions.setWorkbench("myFiles")}toolReasons={quickNavToolReasons}/><FilesPageProvider>@@ -504,10 +494,9 @@ export default function HomePage() {className="mobile-layout"data-files-mode={navigationState.workbench === "myFiles"}>- {/* On /files the FileManagerView already has its own Back +- breadcrumb + tabs chrome - the tools/workspace toggle would- just duplicate vertical space. Keep the toggle on every- other route. */}+ {/* The library brings its own tabs and folder path, so the+ tools/workspace toggle would only cost it vertical space. Every+ other view keeps the toggle. */}{navigationState.workbench !== "myFiles" && (<div className="mobile-toggle"><div className="mobile-brand">@@ -680,27 +669,12 @@ export default function HomePage() {<MyFilesAwareFileSidebarref={quickAccessRef}accountHoisted- toggleAriaLabel={- navigationState.workbench === "myFiles"- ? t("fileSidebar.leaveMyFiles", "Leave File library")- : undefined- }- toggleIcon={- navigationState.workbench === "myFiles" ? (- <ArrowBackIcon />- ) : undefined- }active={navigationState.workbench === "myFiles"}- // Forced: a deep link to /files has no transition to collapse on.- collapsed={- navigationState.workbench === "myFiles" ||- fileSidebarCollapsed- }+ collapsed={fileSidebarCollapsed}onToggleCollapse={handleSidebarToggle}onOpenSettings={openSettings}/></div>- <FolderTreePanel active={navigationState.workbench === "myFiles"} /><Workbench />{!hideToolPanel && <RightSidebar />}<FileManager selectedTool={selectedTool} />@@ -715,7 +689,7 @@ interface MyFilesAwareFileSidebarProps extends FileSidebarProps {active: boolean;}-/** Wraps FileSidebar with /files-aware overrides when `active`. */+/** Wraps FileSidebar with the library's overrides while the library is on screen. */const MyFilesAwareFileSidebar = forwardRef<HTMLDivElement,MyFilesAwareFileSidebarProps@@ -733,8 +707,20 @@ const MyFilesSidebarOverrides = forwardRef<HTMLDivElement, FileSidebarProps>(const filesPage = useFilesPage();const folders = useFolders();const { addFiles } = useFileHandler();- const { createFolderHere, createFolderHereBlockedReason } =+ const { addLocalFolder, createFolderHere, createFolderHereBlockedReason } =useNewFolderFlow();+ const { refreshing, refresh: refreshLibrary } = useLibraryRefresh();+ const { isAnonymous } = useAuth();+ const { config: appConfig } = useAppConfig();+ const [mobileUploadOpen, setMobileUploadOpen] = useState(false);+ const isMobileViewport = useIsMobile();+ // The scanner sends files from a phone to this screen, so it is a desktop+ // affordance: on a phone you are already where the files are.+ const mobileUploadAvailable =+ Boolean(appConfig?.enableMobileScanner) && !isMobileViewport;+ const signInRequired = isAnonymous+ ? t("filesPage.signInRequired", "Sign in to use cloud storage.")+ : null;const handleUpload = useCallback(async (files: File[]) => {@@ -766,20 +752,73 @@ const MyFilesSidebarOverrides = forwardRef<HTMLDivElement, FileSidebarProps>(: createFolderHereBlockedReason;return (- <FileSidebar- ref={ref}- {...props}- onUploadFiles={handleUpload}- onPickGoogleDriveFiles={handleUpload}- extraAction={{- icon: <CreateNewFolderIcon />,- label: t("filesPage.newFolder", "New folder"),- onClick: createFolderHere,- disabled: newFolderDisabledReason !== null,- disabledTooltip: newFolderDisabledReason ?? undefined,- testId: "files-rail-new-folder",- }}- />+ <>+ <FileSidebar+ ref={ref}+ {...props}+ onUploadFiles={handleUpload}+ onPickGoogleDriveFiles={handleUpload}+ extraActions={[+ {+ icon: <CreateNewFolderIcon />,+ label: t("filesPage.newFolder", "New folder"),+ onClick: createFolderHere,+ disabled: newFolderDisabledReason !== null,+ disabledTooltip: newFolderDisabledReason ?? undefined,+ testId: "files-rail-new-folder",+ // The same control the library's other surfaces use, so one row+ // cannot offer less than another: where a folder can go decides+ // its shape.+ render: ({ collapsed }) => (+ <NewFolderButton+ trigger="row"+ collapsed={collapsed}+ testId="files-rail-new-folder"+ label={t("filesPage.newFolder", "New folder")}+ disabledReason={newFolderDisabledReason}+ serverDisabledReason={serverFolderBlock ?? undefined}+ currentFolderId={folders.currentFolderId}+ canAddLocalFolder={canPickDirectory}+ onAddLocalFolder={() => void addLocalFolder()}+ onOpenDialog={filesPage.openNewFolderDialog}+ />+ ),+ },+ {+ icon: (+ <RefreshIcon+ className={refreshing ? "file-sidebar-spin" : undefined}+ />+ ),+ label: t("filesPage.refresh", "Refresh from server"),+ onClick: () => void refreshLibrary(),+ disabled: refreshing || signInRequired !== null,+ disabledTooltip: signInRequired ?? undefined,+ testId: "files-rail-refresh",+ },+ ...(mobileUploadAvailable+ ? [+ {+ icon: <QrCode2Icon />,+ label: t(+ "filesPage.uploadFromMobile",+ "Upload from Mobile",+ ),+ onClick: () => setMobileUploadOpen(true),+ testId: "files-rail-mobile-upload",+ },+ ]+ : []),+ ]}+ />+ <MobileUploadModal+ opened={mobileUploadOpen}+ onClose={() => setMobileUploadOpen(false)}+ onFilesReceived={(files) => {+ if (files.length > 0) void handleUpload(files);+ }}+ />+ </>);},);diff --git a/frontend/editor/src/core/services/workbenchSession.test.ts b/frontend/editor/src/core/services/workbenchSession.test.tsindex 0258b83623..8e931ba9ae 100644--- a/frontend/editor/src/core/services/workbenchSession.test.ts+++ b/frontend/editor/src/core/services/workbenchSession.test.ts@@ -188,8 +188,8 @@ describe("views the restore may reopen", () => {expect(isSeedableView("pageEditor")).toBe(true);});- it("leaves URL-owned and tool-owned views alone", () => {- // HomePage pins myFiles to /files and bounces it elsewhere; custom views belong to a tool.+ it("leaves path-seeded and tool-owned views alone", () => {+ // The library arrives with the path that names the folder; custom views belong to a tool.expect(isSeedableView("myFiles")).toBe(false);expect(isSeedableView("custom:compare")).toBe(false);expect(isSeedableView(undefined)).toBe(false);diff --git a/frontend/editor/src/core/services/workbenchSession.ts b/frontend/editor/src/core/services/workbenchSession.tsindex 2f23db8655..8783f35386 100644--- a/frontend/editor/src/core/services/workbenchSession.ts+++ b/frontend/editor/src/core/services/workbenchSession.ts@@ -125,8 +125,9 @@ export function clearWorkbenchSession(): void {}}-/** Views a restore may seed directly. "myFiles" is URL-owned (HomePage pins it to /files) and a- * custom view belongs to its tool - the editor return path restores those instead. */+/** Views a restore may seed directly. The library arrives with the path that names the+ * folder, and a custom view belongs to its tool - the editor return path restores those+ * instead. */const SEEDABLE_VIEWS = ["viewer", "fileEditor", "pageEditor"];// Raised while a restore is applying its recorded view, so writers that pick a default view fromdiff --git a/frontend/editor/src/core/tests/stubbed/file-actions-menu.spec.ts b/frontend/editor/src/core/tests/stubbed/file-actions-menu.spec.tsindex cafc188462..6e62cd810e 100644--- a/frontend/editor/src/core/tests/stubbed/file-actions-menu.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/file-actions-menu.spec.ts@@ -114,7 +114,10 @@ const cards = (page: Page) => page.locator(".files-page-card:not(.is-folder)");/** Upload a file, cross to My Files, and open the card's kebab. */async function openCardKebab(page: Page): Promise<void> {await uploadFiles(page, SAMPLE);- await page.getByTestId("my-files-button").click();+ await page+ .getByRole("navigation", { name: /Quick navigation/i })+ .getByRole("button", { name: /^File library$/i })+ .click();const card = cards(page).filter({ hasText: "sample.pdf" }).first();await expect(card).toBeVisible();await card.getByRole("button", { name: /File actions/i }).click();diff --git a/frontend/editor/src/core/tests/stubbed/file-library-view.spec.ts b/frontend/editor/src/core/tests/stubbed/file-library-view.spec.tsnew file mode 100644index 0000000000..c24b6e9cf7--- /dev/null+++ b/frontend/editor/src/core/tests/stubbed/file-library-view.spec.ts@@ -0,0 +1,121 @@+import path from "path";+import { test, expect } from "@app/tests/helpers/stub-test-base";+import { dismissTourTooltip, uploadFiles } from "@app/tests/helpers/ui-helpers";++const SAMPLE_PDF = path.join(+ import.meta.dirname,+ "../test-fixtures/sample.pdf",+);++/**+ * The file library is a view, not a route: which view is on screen is state, and the+ * path follows it. These pin the direction of that, because the reverse - the path+ * imposing the view on every render - makes anything else set on /files revert a+ * render later.+ */+test.describe("The file library behaves like the other views", () => {+ const railButton = (page: import("@playwright/test").Page, name: RegExp) =>+ page+ .getByRole("navigation", { name: /Quick navigation/i })+ .getByRole("button", { name });++ test("reading mode leaves the library instead of being reverted by it", async ({+ page,+ }) => {+ await page.goto("/editor");++ await railButton(page, /^File library$/i).click();+ await expect(page).toHaveURL(/\/files/);+ // The path leads the view by a render, so wait for the library itself: clicking+ // the next control before it mounts races its own arrival.+ await expect(page.getByRole("tree", { name: /Folders/i })).toBeVisible({+ timeout: 15_000,+ });++ // Reader sets the viewer workbench. The path leaving /files is that view change+ // reaching the URL - which is what the old reconciler undid.+ await railButton(page, /^Reader$/i).click();+ await expect(page).not.toHaveURL(/\/files/);+ await expect(railButton(page, /^Reader$/i)).toHaveAttribute(+ "aria-pressed",+ "true",+ );+ });++ test("the rail marks the library, not the editor it sits in", async ({+ page,+ }) => {+ await page.goto("/editor");+ const library = railButton(page, /^File library$/i);+ await expect(library).toBeVisible({ timeout: 15_000 });+ await expect(library).not.toHaveAttribute("aria-current", "true");++ await library.click();+ await expect(page.getByRole("tree", { name: /Folders/i })).toBeVisible({+ timeout: 15_000,+ });+ await expect(library).toHaveAttribute("aria-current", "true");++ // The editor entry pairs off with the processor, so a build without one ships+ // neither: where it is on screen, the library takes the marker off it.+ const editor = railButton(page, /^Editor$/i);+ if ((await editor.count()) > 0) {+ await expect(editor).not.toHaveAttribute("aria-current", "true");+ }+ });++ test("going back from the library returns to the editor", async ({+ page,+ }) => {+ await page.goto("/editor");++ await railButton(page, /^File library$/i).click();+ await expect(page).toHaveURL(/\/files/);++ await page.goBack();+ await expect(page).not.toHaveURL(/\/files/);+ });++ test("a deep link to /files opens the library and keeps it", async ({+ page,+ }) => {+ await page.goto("/files");+ const tree = page.getByRole("tree", { name: /Folders/i });+ await expect(tree).toBeVisible({ timeout: 15_000 });++ // Arriving is the easy half. The view also has to survive the renders that+ // follow, which is where a second opinion about which view belongs on screen+ // would replace it - leaving the path saying library and the screen not.+ await page.waitForTimeout(500);+ await expect(page).toHaveURL(/\/files/);+ await expect(tree).toBeVisible();+ });++ /** The library is a view, so reaching it runs the same unsaved-changes check a view+ * switch runs. Asking a second time around that one leaves the confirm with nothing+ * to act on: the prompt closes and the click is swallowed. */+ test("discarding unsaved changes opens the library on the first ask", async ({+ page,+ }) => {+ test.setTimeout(180_000);+ await page.goto("/editor", { waitUntil: "domcontentloaded" });+ await uploadFiles(page, SAMPLE_PDF);+ await dismissTourTooltip(page);+ await page.getByText("PDF Multi Tool", { exact: true }).first().click();+ const firstPage = page.locator("[data-page-id]").first();+ await expect(firstPage).toBeVisible({ timeout: 60_000 });+ await firstPage.hover();+ await firstPage.getByRole("button", { name: "Rotate Right" }).click();++ await railButton(page, /^File library$/i).click();+ await expect(page.getByTestId("unsaved-discard")).toBeVisible({+ timeout: 10_000,+ });+ await page.getByTestId("unsaved-discard").click();++ await expect(page.getByRole("tree", { name: /Folders/i })).toBeVisible({+ timeout: 15_000,+ });+ await expect(page).toHaveURL(/\/files/);+ });+});diff --git a/frontend/editor/src/core/tests/stubbed/file-state-across-tools.spec.ts b/frontend/editor/src/core/tests/stubbed/file-state-across-tools.spec.tsindex 09708bbb0a..458bfdf0cc 100644--- a/frontend/editor/src/core/tests/stubbed/file-state-across-tools.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/file-state-across-tools.spec.ts@@ -22,20 +22,30 @@ test.describe("File state persists across tool navigation", () => {await uploadFiles(page, SAMPLE_PDF);// Sanity: My Files page lists the upload- await page.getByTestId("my-files-button").click();- await expect(page.getByText(/sample\.pdf/i).first()).toBeVisible({- timeout: 5_000,- });+ await page+ .getByRole("navigation", { name: /Quick navigation/i })+ .getByRole("button", { name: /^File library$/i })+ .click();+ // The library's grid, which loads its own listing: in the library the sidebar+ // shows folders, not files, so nothing answers this sooner.+ await expect(+ page.locator(".files-page-card").filter({ hasText: /sample\.pdf/i }),+ ).toBeVisible({ timeout: 15_000 });// Navigate to /splitawait page.goto("/split");await page.waitForLoadState("domcontentloaded");// Re-open My Files - sample.pdf must still be there (persisted across tools)- await page.getByTestId("my-files-button").click();- await expect(page.getByText(/sample\.pdf/i).first()).toBeVisible({- timeout: 5_000,- });+ await page+ .getByRole("navigation", { name: /Quick navigation/i })+ .getByRole("button", { name: /^File library$/i })+ .click();+ // The library's grid, which loads its own listing: in the library the sidebar+ // shows folders, not files, so nothing answers this sooner.+ await expect(+ page.locator(".files-page-card").filter({ hasText: /sample\.pdf/i }),+ ).toBeVisible({ timeout: 15_000 });});test("file uploaded on /merge survives an in-app tool-link navigation", async ({@@ -65,9 +75,12 @@ test.describe("File state persists across tool navigation", () => {// The upload must still be listed after the tool switch. A "no files"// empty state here would mean the client-side nav silently dropped it.- await page.getByTestId("my-files-button").click();- await expect(page.getByText(/sample\.pdf/i).first()).toBeVisible({- timeout: 10_000,- });+ await page+ .getByRole("navigation", { name: /Quick navigation/i })+ .getByRole("button", { name: /^File library$/i })+ .click();+ await expect(+ page.locator(".files-page-card").filter({ hasText: /sample\.pdf/i }),+ ).toBeVisible({ timeout: 15_000 });});});diff --git a/frontend/editor/src/core/tests/stubbed/files-page.spec.ts b/frontend/editor/src/core/tests/stubbed/files-page.spec.tsindex 5b20234bb1..a4e6620309 100644--- a/frontend/editor/src/core/tests/stubbed/files-page.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/files-page.spec.ts@@ -902,48 +902,13 @@ test.describe("Files page", () => {});});- test.describe("Folder tree panel resize", () => {- test.use({ autoGoto: false });-- test("Resize handle is present and keyboard-adjustable", async ({- page,- }) => {- await stubStorageApis(page);- await seedFiles(page, [- { id: "alpha", name: "alpha.pdf", remoteStorageId: null },- ]);- await gotoFilesPage(page);- const handle = page.locator(".folder-tree-panel-resizer").first();- await expect(handle).toBeVisible();- const before = await page.evaluate(() => {- const el = document.querySelector(- ".folder-tree-panel[data-active='true']",- ) as HTMLElement | null;- return el?.getBoundingClientRect().width ?? 0;- });- await handle.focus();- await page.keyboard.press("ArrowRight");- await page.keyboard.press("ArrowRight");- await page.keyboard.press("ArrowRight");- await page.keyboard.press("ArrowRight");- const after = await page.evaluate(() => {- const el = document.querySelector(- ".folder-tree-panel[data-active='true']",- ) as HTMLElement | null;- return el?.getBoundingClientRect().width ?? 0;- });- // Four 8px steps = +32px.- expect(after).toBeGreaterThanOrEqual(before + 24);- });- });-test.describe("Folder chrome stability", () => {const CHROME_FOLDER = "11111111-2222-4333-8444-555555555561";test.use({ autoGoto: false });- /** The column is sized by the user, not by its contents: a long name has to give- * way inside the row rather than push the panel wider. */- test("a long folder name does not widen the tree panel", async ({+ /** The sidebar is sized by the user, not by its contents: a long name has to give+ * way inside the row rather than push the sidebar wider. */+ test("a long folder name does not widen the file sidebar", async ({page,}) => {await stubStorageApis(page);@@ -959,16 +924,16 @@ test.describe("Files page", () => {);await gotoFilesPage(page);- const panel = page.locator('.folder-tree-panel[data-active="true"]');- await expect(panel).toBeVisible({ timeout: 10_000 });+ const sidebar = page.locator(".file-sidebar");+ await expect(sidebar).toBeVisible({ timeout: 10_000 });await expect(page.getByRole("treeitem", { name: /Quarterly/i }),).toBeVisible();- const width = await panel.evaluate(+ const width = await sidebar.evaluate((el) => el.getBoundingClientRect().width,);- expect(width).toBeLessThanOrEqual(280);+ expect(width).toBeLessThanOrEqual(320);// Clipped inside the row rather than laid out at full length.const clipped = await page.locator(".files-page-tree-name-head")@@ -1003,7 +968,7 @@ test.describe("Files page", () => {);await gotoFilesPage(page);- const header = page.locator(".files-page-header");+ const header = page.locator(".files-page-tabs-row");const atRoot = await header.evaluate((el) => el.getBoundingClientRect().height,);@@ -1042,7 +1007,7 @@ test.describe("Files page", () => {);await gotoFilesPage(page);- const header = page.locator(".files-page-header");+ const header = page.locator(".files-page-tabs-row");const atRoot = await header.evaluate((el) => el.getBoundingClientRect().height,);@@ -1059,6 +1024,79 @@ test.describe("Files page", () => {});});+ test.describe("Library chrome placement", () => {+ test.use({ autoGoto: false });++ /** The path sits on the library's own row with the tabs; its actions live in the+ * file sidebar, and the shared bar above carries only what every view has. */+ test("the path is on the tabs row and the actions are in the sidebar", async ({+ page,+ }) => {+ const NESTED = "11111111-2222-4333-8444-555555555581";+ const PARENT = "11111111-2222-4333-8444-555555555580";+ await stubStorageApis(page);+ await seedFiles(+ page,+ [{ id: "b-1", name: "b-1.pdf", remoteStorageId: null }],+ [+ { id: PARENT, name: "Engagements" },+ { id: NESTED, name: "Signed originals", parentFolderId: PARENT },+ ],+ );+ await gotoFilesPage(page);++ const bar = page.locator(".workbench-bar");+ await expect(bar).toBeVisible({ timeout: 10_000 });+ const row = page.locator(".files-page-tabs-row");+ // On the library's row, and not in the bar above it.+ await expect(+ row.getByRole("navigation", { name: /Folder path/i }),+ ).toBeVisible();+ await expect(+ row.getByRole("button", { name: /New folder/i }),+ ).toHaveCount(0);+ await expect(+ page.locator('[data-testid="files-rail-new-folder"]'),+ ).toBeVisible();+ await expect(+ page.locator('[data-testid="files-rail-refresh"]'),+ ).toBeVisible();+ await expect(+ bar.getByRole("navigation", { name: /Folder path/i }),+ ).toHaveCount(0);++ const tree = page.getByRole("tree", { name: /Folders/i });+ await tree.getByRole("treeitem", { name: /Engagements/i }).click();+ await expect(page).toHaveURL(new RegExp(PARENT), { timeout: 5_000 });+ await tree.getByRole("treeitem", { name: /Signed originals/i }).click();+ await expect(page).toHaveURL(new RegExp(NESTED), { timeout: 5_000 });++ // Two crumbs whatever the depth, and the bar stays one row tall.+ await expect(page.locator(".files-page-breadcrumb")).toHaveCount(2);+ await expect(bar).toHaveAttribute("data-wrapped", "false");+ });+ });++ test.describe("Document actions in the library", () => {+ test.use({ autoGoto: false });++ /** Save, Save As and Close act on an open document, and the library has none.+ * Desktop is where this shows: two save glyphs sit side by side there. */+ test("saving and closing are absent from the library", async ({ page }) => {+ await stubStorageApis(page);+ await seedFiles(page, [+ { id: "d-a", name: "d-a.pdf", remoteStorageId: null },+ ]);+ await gotoFilesPage(page);++ const bar = page.locator(".workbench-bar");+ await expect(bar).toBeVisible({ timeout: 10_000 });+ for (const name of [/^Save$/i, /Save As/i, /Close (All|PDF)/i]) {+ await expect(bar.getByRole("button", { name })).toHaveCount(0);+ }+ });+ });+test.describe("Folder navigation", () => {const FOLDER_ID = "11111111-2222-4333-8444-555555555555";test.beforeEach(async ({ page }) => {diff --git a/frontend/editor/src/core/tests/stubbed/super-search.spec.ts b/frontend/editor/src/core/tests/stubbed/super-search.spec.tsindex ed7621f207..d91e074bae 100644--- a/frontend/editor/src/core/tests/stubbed/super-search.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/super-search.spec.ts@@ -140,8 +140,8 @@ test.describe("Super search — bar basics", () => {// router never sees — the sink must leave /files through the router or// the myFiles workbench swallows the selection (and "/" is a role router// on processor-shipping builds, so the exit must target the editor home).- await expect(page.locator(".files-page-header-search")).not.toBeVisible({- timeout: 5000,+ await expect(page.locator(".files-page")).toHaveCount(0, {+ timeout: 5_000,});await expect(page).toHaveURL(/\/merge/);});diff --git a/frontend/editor/src/core/types/workbenchBar.ts b/frontend/editor/src/core/types/workbenchBar.tsindex 523aaab681..83e086c1ff 100644--- a/frontend/editor/src/core/types/workbenchBar.ts+++ b/frontend/editor/src/core/types/workbenchBar.ts@@ -1,6 +1,15 @@import React from "react";-export type WorkbenchBarSection = "top" | "middle" | "bottom" | "tool-panel";+/** "bar-lead" follows the view switcher, for content naming what the view is showing;+ * "bar" renders among the bar's own actions on the right; top/middle/bottom are lanes+ * of the retractable tool row beneath it. */+export type WorkbenchBarSection =+ | "bar-lead"+ | "bar"+ | "top"+ | "middle"+ | "bottom"+ | "tool-panel";export type WorkbenchBarAction = () => void;