#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
Dedicated reader view (#8025)
Reece Browneb230ca2ce0d0
diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.tomlindex f18b06d768..cfc63406af 100644--- a/frontend/editor/public/locales/en-US/translation.toml+++ b/frontend/editor/public/locales/en-US/translation.toml@@ -4483,7 +4483,6 @@ dropToAdd = "Drop files to add"duplicateFailed = "Could not duplicate file"expand = "Expand sidebar"googleDrive = "Google Drive"-googleDriveDisabled = "Google Drive is not configured"library = "PDF Library"myFiles = "File library"noFiles = "No files yet"@@ -4534,7 +4533,6 @@ breadcrumbsOverflow = "Show parent folders"bulkActions = "Actions"cancel = "Cancel"classification = "Classification"-clearSelection = "Clear selection"closeDetails = "Close details"create = "Create"cycleBlocked = "Can't move a folder into one of its own subfolders."@@ -10386,6 +10384,19 @@ reader = "Reader"[read]tags = "view,open,display,read,viewer,PDF viewer,PDF reader,open PDF,view PDF,display PDF,preview,browse"+[reader.rail]+addDocument = "Add file"+bookmarks = "Bookmarks"+close = "Close document"+comment = "Comments"+label = "Reading tools"+readAloud = "Read aloud"+rotateLeft = "Rotate left"+rotateRight = "Rotate right"+search = "Find in document"+switchDocument = "Switch document"+thumbnails = "Pages"+[redact]submit = "Redact"tags = "Redact,Hide,black out,black,marker,hidden,auto redact,manual redact"@@ -12041,8 +12052,6 @@ ZIP = "a ZIP archive"[toolPanel]alpha = "Alpha"backToAllTools = "Back to all tools"-collapse = "Collapse panel"-expand = "Expand panel"goBack = "Go back"pdfTools = "PDF Tools"placeholder = "Choose a tool to get started"@@ -12529,6 +12538,7 @@ bookmarkTitle = "Bookmark title"bookmarkTitleRequired = "Bookmark title is required"closeSidebar = "Close bookmarks sidebar"collapseAll = "Collapse all bookmarks"+editorOnly = "This document's bookmarks can only be edited in the editor."empty = "No bookmarks in this document"expandAll = "Expand all bookmarks"searchPlaceholder = "Search bookmarks"diff --git a/frontend/editor/src-tauri/tauri.conf.port5174.json b/frontend/editor/src-tauri/tauri.conf.port5174.jsonnew file mode 100644index 0000000000..c05c3dd669--- /dev/null+++ b/frontend/editor/src-tauri/tauri.conf.port5174.json@@ -0,0 +1,7 @@+{+ "identifier": "stirling.pdf.dev.procfolders",+ "build": {+ "devUrl": "http://localhost:5174",+ "beforeDevCommand": "npx vite --mode desktop --port 5174 --strictPort"+ }+}diff --git a/frontend/editor/src/core/components/filesPage/FileGrid.tsx b/frontend/editor/src/core/components/filesPage/FileGrid.tsxindex 45ebf1ddb8..297e1cd0bd 100644--- a/frontend/editor/src/core/components/filesPage/FileGrid.tsx+++ b/frontend/editor/src/core/components/filesPage/FileGrid.tsx@@ -1,10 +1,4 @@-import React, {- useCallback,- useEffect,- useMemo,- useRef,- useState,-} from "react";+import React, { useCallback, useMemo, useRef } from "react";import { useTranslation } from "react-i18next";import { Checkbox, Loader, Menu, Tooltip } from "@mantine/core";import { Button } from "@app/ui/Button";@@ -44,6 +38,7 @@ import { FolderProcessingTag } from "@app/components/filesPage/FolderProcessingTimport { FolderOriginBadge } from "@app/components/filesPage/FolderOriginBadge";import { DiskLinkBadge } from "@app/components/filesPage/DiskLinkBadge";import { FolderThumbnail } from "@app/components/filesPage/FolderThumbnail";+import { useProcessingFolderCounts } from "@app/components/filesPage/processingFolderCounts";import { findFolderIcon } from "@app/components/filesPage/folderIcons";import { FolderAppearancePicker } from "@app/components/filesPage/FolderAppearancePicker";import {@@ -835,36 +830,21 @@ const FolderCard = React.memo(function FolderCard({});/**- * A working folder's live per-state counts on its card. Light polling: a handful of- * processing folders at most, and the numbers are the card's whole story.+ * A working folder's live per-state counts, wherever the folder is drawn. `compact`+ * is the list's shape: the same numbers on one line, in a row that may not change+ * height.*/function ProcessingFolderStats({recordId,listFiles,+ compact = false,}: {recordId: string;listFiles: (recordId: string) => Promise<{ state: string }[]>;+ compact?: boolean;}) {const { t } = useTranslation();- const [counts, setCounts] = useState<Record<string, number> | null>(null);- useEffect(() => {- let cancelled = false;- const tick = async () => {- const files = await listFiles(recordId).catch(() => []);- if (cancelled) return;- const next: Record<string, number> = {};- for (const file of files) {- next[file.state] = (next[file.state] ?? 0) + 1;- }- setCounts(next);- };- void tick();- const timer = setInterval(() => void tick(), 5000);- return () => {- cancelled = true;- clearInterval(timer);- };- }, [recordId, listFiles]);+ const counts = useProcessingFolderCounts(recordId, listFiles);if (!counts) return null;const parts = ([@@ -876,10 +856,15 @@ function ProcessingFolderStats({).filter(([state]) => (counts[state] ?? 0) > 0);if (parts.length === 0) return null;return (- <div className="files-page-folder-stats">+ <div+ className={`files-page-folder-stats${compact ? " is-compact" : ""}`}+ title={parts+ .map(([state, label]) => `${counts[state]} ${label}`)+ .join(" · ")}+ >{parts.map(([state, label]) => (<span key={state} className={`files-page-folder-stat is-${state}`}>- {counts[state]} {label}+ {counts[state]} {compact ? "" : label}</span>))}</div>@@ -1642,6 +1627,7 @@ const FolderRow = React.memo(function FolderRow({disable: disableProcessing,remove: removeProcessingFolder,sweep: sweepProcessing,+ listFiles: listProcessingFiles,} = useProcessingFolders();const processing = processingStateFor(folder);// Each action surfaces its own failure the way a failed drop does; the@@ -1689,7 +1675,14 @@ const FolderRow = React.memo(function FolderRow({parentPath={parentPath}status={processing ? (- <FolderProcessingTag enabled={processing.enabled} />+ <>+ <FolderProcessingTag enabled={processing.enabled} />+ <ProcessingFolderStats+ recordId={processing.id}+ listFiles={listProcessingFiles}+ compact+ />+ </>) : undefined}trailing={diff --git a/frontend/editor/src/core/components/filesPage/FileManagerView.tsx b/frontend/editor/src/core/components/filesPage/FileManagerView.tsxindex 4fd8b7a740..93390d3e69 100644--- a/frontend/editor/src/core/components/filesPage/FileManagerView.tsx+++ b/frontend/editor/src/core/components/filesPage/FileManagerView.tsx@@ -1954,7 +1954,7 @@ export default function FileManagerView() {<>{selectedFiles.length > 0 &&(() => {- // Bulk-action labels; CSS collapses to icon-only below 900px.+ // Icon-only, as the folder-level strip is; the label is the tooltip.const addLabel =selectedFiles.length === 1? t("filesPage.addToWorkspace", "Add to workspace")@@ -1969,19 +1969,17 @@ export default function FileManagerView() {// wrap="nowrap" keeps the row single-line.<Group gap="xs" wrap="nowrap"><Tooltip label={addLabel} withinPortal>- <Button+ <ActionIconsize="sm"- leftSection={- <Icon name="external-link" size={20} />- }+ variant="secondary"onClick={() =>handleAddToWorkspace(selectedFiles)}aria-label={addLabel}data-testid="add-to-workspace">- {addLabel}- </Button>+ <Icon name="external-link" size={20} />+ </ActionIcon></Tooltip>{/* Save to server; shown whenever local-only files areselected. When storage is off it stays visible but@@ -1996,12 +1994,9 @@ export default function FileManagerView() {multiline={Boolean(saveToServerDisabledReason)}w={saveToServerDisabledReason ? 240 : undefined}>- <Button+ <ActionIconsize="sm"variant="secondary"- leftSection={- <Icon name="cloud-upload" size={20} />- }disabled={Boolean(saveToServerDisabledReason)}onClick={() =>setSaveToServerTarget(localOnlySelectedStubs)@@ -2017,8 +2012,8 @@ export default function FileManagerView() {"Save to server",)}>- {t("filesPage.saveToServer", "Save to server")}- </Button>+ <Icon name="cloud-upload" size={20} />+ </ActionIcon></Tooltip>)}{/* Show details button on compact viewports. */}@@ -2031,62 +2026,38 @@ export default function FileManagerView() {)}withinPortal>- <Button+ <ActionIconsize="sm"variant="secondary"- leftSection={<Icon name="info" size={20} />}onClick={() => setMobileDetailsOpen(true)}aria-label={t("filesPage.showDetails","Show details",)}>- {t("filesPage.showDetails", "Show details")}- </Button>+ <Icon name="info" size={20} />+ </ActionIcon></Tooltip>)}<Tooltip label={moveLabel} withinPortal>- <Button+ <ActionIconsize="sm"variant="secondary"- leftSection={- <Icon name="folder-input" size={20} />- }onClick={() => promptMoveFiles(selectedFiles)}aria-label={moveLabel}>- {moveLabel}- </Button>+ <Icon name="folder-input" size={20} />+ </ActionIcon></Tooltip><Tooltip label={removeLabel} withinPortal>- <Button+ <ActionIconsize="sm"accent="danger"variant="secondary"- leftSection={<Icon name="trash" size={20} />}onClick={() => handleRemoveFiles(selectedFiles)}aria-label={removeLabel}>- {removeLabel}- </Button>- </Tooltip>- <Tooltip- label={t(- "filesPage.clearSelection",- "Clear selection",- )}- withinPortal- >- <ActionIcon- variant="tertiary"- size="md"- onClick={() => clearSelection()}- aria-label={t(- "filesPage.clearSelection",- "Clear selection",- )}- >- ×+ <Icon name="trash" size={20} /></ActionIcon></Tooltip></Group>diff --git a/frontend/editor/src/core/components/filesPage/FilesPage.css b/frontend/editor/src/core/components/filesPage/FilesPage.cssindex 156cafb913..b5c16949d9 100644--- a/frontend/editor/src/core/components/filesPage/FilesPage.css+++ b/frontend/editor/src/core/components/filesPage/FilesPage.css@@ -600,6 +600,17 @@margin-top: 0.3rem;}+/* In a row the counts share one line with the tag beside them, and the row's height+ is fixed: they never wrap, and the full labels live in the title. */+.files-page-folder-stats.is-compact {+ display: inline-flex;+ flex-wrap: nowrap;+ gap: 0.3rem;+ margin-top: 0;+ margin-left: 0.4rem;+ vertical-align: middle;+}+.files-page-folder-stat {display: inline-flex;align-items: center;diff --git a/frontend/editor/src/core/components/filesPage/NewFolderButton.tsx b/frontend/editor/src/core/components/filesPage/NewFolderButton.tsxindex 826c3edd02..508caedbbb 100644--- a/frontend/editor/src/core/components/filesPage/NewFolderButton.tsx+++ b/frontend/editor/src/core/components/filesPage/NewFolderButton.tsx@@ -12,8 +12,6 @@ export interface NewFolderButtonProps {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. */@@ -42,7 +40,6 @@ export function NewFolderButton({label,size = "sm",trigger = "labelled",- collapsed = false,testId,disabledReason,serverDisabledReason,@@ -58,10 +55,8 @@ export function NewFolderButton({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) => (+ /** The sidebar's own action-row markup, so the row reads as one of its own. */+ const row = (onClick?: () => void) => (<divclassName={`file-sidebar-action-row${disabledReason ? " disabled" : ""}`}data-testid={testId}@@ -69,7 +64,6 @@ export function NewFolderButton({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.@@ -84,11 +78,9 @@ export function NewFolderButton({<span className="file-sidebar-action-icon"><Icon name="folder-plus" /></span>- {!collapsed && (- <span className="file-sidebar-action-label sidebar-content-fade">- {label}- </span>- )}+ <span className="file-sidebar-action-label sidebar-content-fade">+ {label}+ </span></div>);@@ -135,16 +127,7 @@ export function NewFolderButton({const open = () =>currentFolderId !== null ? onOpenDialog() : onOpenDialog(null, "server");if (asRow) {- return (- <Tooltip- label={label}- position="right"- withinPortal- disabled={!collapsed}- >- {row(open)}- </Tooltip>- );+ return row(open);}if (iconOnly) {return (@@ -185,7 +168,7 @@ export function NewFolderButton({><Menu.Target>{asRow ? (- row(undefined, true)+ row()) : iconOnly ? (<Tooltip label={label} withinPortal><ActionIcon variant="tertiary" size="sm" aria-label={label}>diff --git a/frontend/editor/src/core/components/filesPage/processingFolderCounts.test.tsx b/frontend/editor/src/core/components/filesPage/processingFolderCounts.test.tsxnew file mode 100644index 0000000000..5e2fac4f32--- /dev/null+++ b/frontend/editor/src/core/components/filesPage/processingFolderCounts.test.tsx@@ -0,0 +1,33 @@+import { act, render } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";++/**+ * The hook holds module-level state, so each case imports its own copy.+ */+async function loadHook() {+ vi.resetModules();+ return (await import("@app/components/filesPage/processingFolderCounts"))+ .useProcessingFolderCounts;+}++describe("useProcessingFolderCounts", () => {+ it("reads once for a mounted folder, however many times it renders", async () => {+ const useProcessingFolderCounts = await loadHook();+ const listFiles = vi.fn(async () => [{ state: "done" }]);++ function Row() {+ const counts = useProcessingFolderCounts("folder-1", listFiles);+ return <span>{counts ? Object.keys(counts).join() : "none"}</span>;+ }++ render(<Row />);+ // Each settled read notifies subscribers, so a renewed subscription would+ // read again on the render that follows: several turns is enough to tell a+ // single read from a loop.+ for (let turn = 0; turn < 10; turn += 1) {+ await act(async () => {});+ }++ expect(listFiles).toHaveBeenCalledTimes(1);+ });+});diff --git a/frontend/editor/src/core/components/filesPage/processingFolderCounts.ts b/frontend/editor/src/core/components/filesPage/processingFolderCounts.tsnew file mode 100644index 0000000000..63bb208c89--- /dev/null+++ b/frontend/editor/src/core/components/filesPage/processingFolderCounts.ts@@ -0,0 +1,71 @@+import { useCallback, useSyncExternalStore } from "react";++export type ProcessingCounts = Record<string, number>;++type Lister = (recordId: string) => Promise<{ state: string }[]>;++const POLL_MS = 5000;++const counts = new Map<string, ProcessingCounts>();+const subscribers = new Map<string, Set<() => void>>();+let timer: ReturnType<typeof setInterval> | null = null;+let lister: Lister | null = null;++async function read(recordId: string): Promise<void> {+ if (!lister) return;+ const files = await lister(recordId).catch(() => []);+ const next: ProcessingCounts = {};+ for (const file of files) next[file.state] = (next[file.state] ?? 0) + 1;+ counts.set(recordId, next);+ for (const notify of subscribers.get(recordId) ?? []) notify();+}++/** One pass over every folder on screen, rather than one timer each. */+function tick(): void {+ for (const recordId of subscribers.keys()) void read(recordId);+}++function subscribe(recordId: string, notify: () => void): () => void {+ const forRecord = subscribers.get(recordId) ?? new Set<() => void>();+ forRecord.add(notify);+ subscribers.set(recordId, forRecord);+ void read(recordId);+ timer ??= setInterval(tick, POLL_MS);+ return () => {+ forRecord.delete(notify);+ // The numbers outlive the last subscriber, so a row the list windows out and+ // back paints what it had while the next read is in flight.+ if (forRecord.size === 0) subscribers.delete(recordId);+ if (subscribers.size === 0 && timer) {+ clearInterval(timer);+ timer = null;+ }+ };+}++/**+ * Live per-state counts for a processing folder. The numbers are shared, so a folder+ * shown as a card and as a row - or the same row remounted by the list's windowing -+ * costs one request per interval rather than one per component.+ *+ * One lister serves every subscriber, so callers must pass equivalent ones: the most+ * recent call's lister is the one the polling uses, for all records.+ */+export function useProcessingFolderCounts(+ recordId: string,+ listFiles: Lister,+): ProcessingCounts | null {+ lister = listFiles;+ // Both are held across renders: useSyncExternalStore resubscribes whenever the+ // subscribe function's identity changes, and resubscribing reads, which+ // notifies, which renders - a loop that never reaches the poll interval.+ const subscribeToRecord = useCallback(+ (notify: () => void) => subscribe(recordId, notify),+ [recordId],+ );+ const readCounts = useCallback(+ () => counts.get(recordId) ?? null,+ [recordId],+ );+ return useSyncExternalStore(subscribeToRecord, readCounts, () => null);+}diff --git a/frontend/editor/src/core/components/layout/Workbench.tsx b/frontend/editor/src/core/components/layout/Workbench.tsxindex ba3a06a9d7..0686ccf6c7 100644--- a/frontend/editor/src/core/components/layout/Workbench.tsx+++ b/frontend/editor/src/core/components/layout/Workbench.tsx@@ -51,10 +51,8 @@ export default function Workbench() {const {previewFile,pageEditorFunctions,- sidebarsVisible,setPreviewFile,setPageEditorFunctions,- setSidebarsVisible,customWorkbenchViews,readerMode,} = useToolWorkflow();@@ -156,8 +154,6 @@ export default function Workbench() {if (currentView === "viewer" && signingOverlay?.file) {return (<Viewer- sidebarsVisible={sidebarsVisible}- setSidebarsVisible={setSidebarsVisible}previewFile={signingOverlay.file}signaturePreviews={signingOverlay.signaturePreviews}signaturePreviewsReadOnly={signingOverlay.signaturePreviewsReadOnly}@@ -210,12 +206,7 @@ export default function Workbench() {case "viewer":return (- <Viewer- sidebarsVisible={sidebarsVisible}- setSidebarsVisible={setSidebarsVisible}- previewFile={previewFile}- onClose={handlePreviewClose}- />+ <Viewer previewFile={previewFile} onClose={handlePreviewClose} />);case "pageEditor":diff --git a/frontend/editor/src/core/components/shared/FileSidebar.css b/frontend/editor/src/core/components/shared/FileSidebar.cssindex 6ed016c21a..3af15cc149 100644--- a/frontend/editor/src/core/components/shared/FileSidebar.css+++ b/frontend/editor/src/core/components/shared/FileSidebar.css@@ -9,28 +9,15 @@height: 100%;position: relative;/* Above the workbench column (also z-10, but later in the DOM, so it would- otherwise paint over us). The brand switcher's menu is wider than the- collapsed rail and has to spill across that boundary intact. */+ otherwise paint over us), so the brand switcher's menu spills across that+ boundary intact. */z-index: var(--z-dropdown);flex-shrink: 0;- /* Slide the rail between collapsed/expanded. The delayed content-fade- (sidebar-content-in, 0.18s) is timed against this 0.22s so labels resolve- only after the width has settled — no squashed text mid-animation. */- transition:- width var(--motion-spring),- min-width var(--motion-spring),- max-width var(--motion-spring);/* Gap around the floating boxes. */padding: var(--nav-gutter);gap: var(--nav-gutter);}-@media (prefers-reduced-motion: reduce) {- .file-sidebar {- transition: none;- }-}-.file-sidebar-inner {display: flex;flex-direction: column;@@ -46,7 +33,58 @@border-radius: 0;}-/* ---- Header row (wordmark + collapse toggle) ---- */+/* Transform only, and out of flow while the wing leaves, so the workbench holds+ its reading width throughout instead of reflowing twice. */+[data-wings] {+ position: relative;+}++[data-wings="leaving"] .workspace-frame {+ position: absolute;+ inset-block: 0;+ inset-inline-start: 0;+ z-index: var(--z-dropdown);+ animation: file-sidebar-leave var(--wings-ms) ease-in both;+}++[data-wings="returning"] .workspace-frame {+ animation: file-sidebar-return var(--wings-ms) ease-out both;+}++@keyframes file-sidebar-leave {+ to {+ transform: translateX(-100%);+ opacity: 0;+ }+}++@keyframes file-sidebar-return {+ from {+ transform: translateX(-100%);+ opacity: 0;+ }+ to {+ transform: translateX(0);+ opacity: 1;+ }+}++/* The wing sits on the trailing edge in RTL, so it leaves by that one. */+[dir="rtl"] [data-wings="leaving"] .workspace-frame {+ animation-name: tool-panel-leave;+}++[dir="rtl"] [data-wings="returning"] .workspace-frame {+ animation-name: tool-panel-return;+}++@media (prefers-reduced-motion: reduce) {+ [data-wings] .workspace-frame {+ animation: none;+ }+}++/* ---- Header row ---- */.file-sidebar-header {display: flex;align-items: center;@@ -60,15 +98,6 @@flex-shrink: 0;}-/* Collapsed the row holds only the toggle, so centre it. */-.file-sidebar[data-collapsed="true"] .file-sidebar-header {- justify-content: center;- padding: 0;-}-.file-sidebar[data-collapsed="true"] .file-sidebar-collapse-toggle {- margin-left: 0;-}-/* ---- Three floating nav-surface boxes (controls / files / footer) ---- *//* Horizontal padding is 0 so row highlights bleed to the surface edges; eachrow's own inner padding keeps its text/icon indented. */@@ -87,27 +116,6 @@/* The footer is the shared <NavFooter>: it brings its own boxes and padding,so this class only positions it in the column. */-/* Collapsed rail: the file tree isn't rendered, so hide its (empty) box and- let the boxes stack at the top — controls, then the settings footer right- after — instead of the files box stretching to fill. */-.file-sidebar[data-collapsed="true"] .file-sidebar-controls {- padding: 0.25rem;-}-.file-sidebar[data-collapsed="true"] .file-sidebar-files-box {- display: none;-}-.file-sidebar[data-collapsed="true"] .file-sidebar-inner {- flex: 0 0 auto;-}-/* Centre each row's icon in the narrow rail (no side padding/margin to shove- it off the edge). */-.file-sidebar[data-collapsed="true"] .file-sidebar-action-row,-.file-sidebar[data-collapsed="true"] .file-sidebar-cloud-row {- justify-content: center;- padding-inline: 0;- margin: 0;-}-/* ---- Native file drag-and-drop ---- */.file-sidebar[data-file-drag-over] {outline: 2px dashed var(--mantine-color-blue-6, var(--c-primary));@@ -608,9 +616,8 @@margin-left: 0;}-/* ---- Sidebar content fade (for collapsed state) ---- */-/* Elements are conditionally rendered so use animation (not transition) to fade in from 0.- Delay until the width animation is nearly done (0.18s of 0.22s) to avoid squashed-text effect. */+/* Rows are conditionally rendered, so they fade in with an animation rather than+ a transition, which has nothing to run from. */@keyframes sidebar-content-in {from {opacity: 0;@@ -623,9 +630,3 @@.sidebar-content-fade {animation: sidebar-content-in 0.12s ease 0.18s both;}--.file-sidebar[data-collapsed="true"] .sidebar-content-fade {- opacity: 0;- pointer-events: none;- animation: none;-}diff --git a/frontend/editor/src/core/components/shared/FileSidebar.tsx b/frontend/editor/src/core/components/shared/FileSidebar.tsxindex c15428a184..96ad7313c4 100644--- a/frontend/editor/src/core/components/shared/FileSidebar.tsx+++ b/frontend/editor/src/core/components/shared/FileSidebar.tsx@@ -74,8 +74,7 @@ import { useToolEligibleFileIds } from "@app/contexts/ToolFileEligibilityContextimport "@app/components/shared/FileSidebar.css";// Shared with the processor sidebar via tokens, so the two cannot drift.-const COLLAPSED_WIDTH = "var(--sidebar-collapsed-w)";-const EXPANDED_WIDTH = "var(--sidebar-w)";+const SIDEBAR_WIDTH = "var(--sidebar-w)";// Inlined to avoid a circular import with WatchedFoldersRegistration.const WATCHED_FOLDER_VIEW_ID = "watchedFolder";@@ -91,8 +90,6 @@ const NO_POLICIES: never[] = [];const BULK_ADD_INDICATOR_MIN = 8;export interface FileSidebarProps {- collapsed?: boolean;- onToggleCollapse?: () => void;onOpenSettings?: () => void;/** The quick nav rail owns the account control, so the footer drops its own row. */accountHoisted?: boolean;@@ -103,8 +100,7 @@ export interface FileSidebarProps {/** Override the Google Drive handler. */onPickGoogleDriveFiles?: (files: File[]) => void | Promise<void>;/** 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. */+ * control with more than one destination renders itself instead. */extraActions?: Array<{icon: React.ReactNode;label: string;@@ -112,7 +108,7 @@ export interface FileSidebarProps {disabled?: boolean;disabledTooltip?: string;testId?: string;- render?: (ctx: { collapsed: boolean }) => React.ReactNode;+ render?: () => React.ReactNode;}>;}@@ -186,8 +182,6 @@ function FolderTreeSection() {const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(function FileSidebar({- collapsed = false,- onToggleCollapse,onOpenSettings,accountHoisted = false,onUploadFiles,@@ -241,20 +235,13 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>([allFolders],);- const openWatchedFolders = useCallback(() => {- if (collapsed && onToggleCollapse) onToggleCollapse();- setCustomWorkbenchViewData(WATCHED_FOLDER_VIEW_ID, { folderId: null });- navActions.setWorkbench(WATCHED_FOLDER_WORKBENCH_ID);- }, [collapsed, onToggleCollapse, setCustomWorkbenchViewData, navActions]);-// Clicking a file's membership dot jumps straight into that folder.const openWatchedFolder = useCallback((folderId: string) => {- if (collapsed && onToggleCollapse) onToggleCollapse();setCustomWorkbenchViewData(WATCHED_FOLDER_VIEW_ID, { folderId });navActions.setWorkbench(WATCHED_FOLDER_WORKBENCH_ID);},- [collapsed, onToggleCollapse, setCustomWorkbenchViewData, navActions],+ [setCustomWorkbenchViewData, navActions],);// In Watched Folders view, sidebar files can be dragged onto a folder card / drop@@ -866,10 +853,6 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>([ingestFiles],);- const shouldHideGoogleDrive =- !isGoogleDriveEnabled && config?.hideDisabledToolsGoogleDrive;-- const width = collapsed ? COLLAPSED_WIDTH : EXPANDED_WIDTH;const eligibleFileIds = useToolEligibleFileIds();// Render one file row (shared by the flat list and the grouped SaaS layout).@@ -972,8 +955,11 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(<divref={ref}className="file-sidebar"- style={{ width, minWidth: width, maxWidth: width }}- data-collapsed={collapsed}+ style={{+ width: SIDEBAR_WIDTH,+ minWidth: SIDEBAR_WIDTH,+ maxWidth: SIDEBAR_WIDTH,+ }}data-sidebar="file-sidebar"data-tour="quick-access-bar"data-file-drag-over={isFileDragOver || undefined}@@ -985,18 +971,13 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>({isFileDragOver && (<div className="file-sidebar-drop-overlay" aria-hidden="true"><Icon name="file-up" className="file-sidebar-drop-overlay-icon" />- {!collapsed && (- <span className="file-sidebar-drop-overlay-text">- {t("fileSidebar.dropToAdd", "Drop files to add")}- </span>- )}+ <span className="file-sidebar-drop-overlay-text">+ {t("fileSidebar.dropToAdd", "Drop files to add")}+ </span></div>)}<div className="file-sidebar-inner">- <SidebarHeader- collapsed={collapsed}- onToggleCollapse={onToggleCollapse}- />+ <SidebarHeader /><inputref={nativeFileInputRef}@@ -1010,55 +991,16 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(data-testid="file-input"/>- {/* Global actions live in quick navigation while expanded. Library-only- actions still belong here; the collapsed rail retains all controls. */}+ {/* Open from computer lives in quick navigation; what is left here is+ the library's own actions, so the box goes when it has none. */}<NavSurfaceclassName="file-sidebar-controls"- hidden={!collapsed && !extraActions?.length}+ hidden={!extraActions?.length}>- {collapsed && (- <Tooltip- label={t("fileSidebar.openFromComputer", "Open from computer")}- position="right"- withinPortal- disabled={!collapsed}- >- <div- className="file-sidebar-action-row"- data-testid="files-rail-button"- onClick={() => {- // "Open from computer" goes straight to the native OS file- // picker. The full file manager (recent + drives + folders)- // is reachable via "File library" below.- nativeFileInputRef.current?.click();- }}- role="button"- tabIndex={0}- aria-label={t(- "fileSidebar.openFromComputer",- "Open from computer",- )}- onKeyDown={(e) => {- if (e.key === "Enter" || e.key === " ") {- e.preventDefault();- nativeFileInputRef.current?.click();- }- }}- >- <Icon name="file-up" className="file-sidebar-action-icon" />- {!collapsed && (- <span className="file-sidebar-action-label sidebar-content-fade">- {t("fileSidebar.openFromComputer", "Open from computer")}- </span>- )}- </div>- </Tooltip>- )}-{extraActions?.map((action) => (<React.Fragment key={action.label}>{action.render ? (- action.render({ collapsed })+ action.render()) : (<Tooltiplabel={action.disabledTooltip ?? action.label}@@ -1074,9 +1016,9 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(? 220: undefined}- disabled={- !collapsed && !(action.disabled && action.disabledTooltip)- }+ // The row carries its own label, so the tooltip is only+ // there to say why it cannot be used.+ disabled={!(action.disabled && action.disabledTooltip)}><divclassName={`file-sidebar-action-row${action.disabled ? " disabled" : ""}`}@@ -1100,98 +1042,14 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(<span className="file-sidebar-action-icon">{action.icon}</span>- {!collapsed && (- <span className="file-sidebar-action-label sidebar-content-fade">- {action.label}- </span>- )}+ <span className="file-sidebar-action-label sidebar-content-fade">+ {action.label}+ </span></div></Tooltip>)}</React.Fragment>))}-- {collapsed && !shouldHideGoogleDrive && (- <Tooltip- label={- !isGoogleDriveEnabled- ? t(- "fileSidebar.googleDriveDisabled",- "Google Drive is not configured",- )- : t("fileSidebar.googleDrive", "Open from Google Drive")- }- position="right"- withinPortal- disabled={!collapsed}- >- <div- className={`file-sidebar-cloud-row${!isGoogleDriveEnabled ? " disabled" : ""}`}- onClick={handleGoogleDriveClick}- role="button"- tabIndex={isGoogleDriveEnabled ? 0 : -1}- aria-disabled={!isGoogleDriveEnabled}- aria-label={- !isGoogleDriveEnabled- ? t(- "fileSidebar.googleDriveDisabled",- "Google Drive is not configured",- )- : t("fileSidebar.googleDrive", "Open from Google Drive")- }- >- <div className="file-sidebar-cloud-icon-wrapper">- <Icon- name="googledrive"- colorless- size={18}- className="file-sidebar-cloud-icon-gray"- />- {isGoogleDriveEnabled && (- <Icon- name="googledrive"- size={18}- className="file-sidebar-cloud-icon-color"- />- )}- </div>- {!collapsed && (- <span className="file-sidebar-action-label sidebar-content-fade">- {t("fileSidebar.googleDrive", "Google Drive")}- </span>- )}- </div>- </Tooltip>- )}-- {/* Watched Folders entry */}- {collapsed && WATCHED_FOLDERS_ENABLED && (- <div- className="file-sidebar-action-row"- data-testid="watchedFolders-button"- data-active={isWatchedFoldersActive}- onClick={openWatchedFolders}- role="button"- tabIndex={0}- onKeyDown={(e) => e.key === "Enter" && openWatchedFolders()}- aria-label={t("watchedFolders.sidebarTitle", "Watched Folders")}- style={- isWatchedFoldersActive- ? { backgroundColor: "var(--c-active)" }- : undefined- }- >- <Icon- name="folder-bookmark"- className="file-sidebar-action-icon"- />- {!collapsed && (- <span className="file-sidebar-action-label sidebar-content-fade">- {t("watchedFolders.sidebarTitle", "Watched Folders")}- </span>- )}- </div>- )}</NavSurface>{/* Box 2 — the file tree (this box scrolls). */}@@ -1200,12 +1058,9 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>({/* The library browses folders, so there the box carries the tree thefile list would otherwise fill: one sidebar, its contents followingthe view. */}- {!collapsed && currentWorkbench === "myFiles" && (- <FolderTreeSection />- )}+ {currentWorkbench === "myFiles" && <FolderTreeSection />}- {/* Files section - visible when expanded, outside the library */}- {!collapsed && currentWorkbench !== "myFiles" && (+ {currentWorkbench !== "myFiles" && (<div className="file-sidebar-files-section sidebar-content-fade"><div className="file-sidebar-section-header"><span className="file-sidebar-section-label">@@ -1370,7 +1225,7 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>({/* Offer to process a folder of files (e.g. Downloads), beneath thefiles section. Empty in builds without a policy engine. */}- <SidebarProcessingSlot collapsed={collapsed} />+ <SidebarProcessingSlot /></div>{/* Kebab "Save to cloud" upload modal (one file at a time). */}@@ -1406,7 +1261,7 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(/>{/* Getting-started checklist, floating above the footer (SaaS only). */}- <SidebarChecklistSlot collapsed={collapsed} />+ <SidebarChecklistSlot />{/* Box 3 — the shared footer: credits, plan, and the account row unless hoisted. */}<NavFooter@@ -1417,7 +1272,6 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(showAccount={!accountHoisted}credits={credits}onOpenPlan={openPlan ?? undefined}- collapsed={collapsed}/></div>);diff --git a/frontend/editor/src/core/components/shared/SidebarChecklistSlot.tsx b/frontend/editor/src/core/components/shared/SidebarChecklistSlot.tsxindex d9844123d6..29037a7590 100644--- a/frontend/editor/src/core/components/shared/SidebarChecklistSlot.tsx+++ b/frontend/editor/src/core/components/shared/SidebarChecklistSlot.tsx@@ -1,13 +1,8 @@-export interface SidebarChecklistSlotProps {- /** Whether the sidebar is collapsed to its narrow rail. */- collapsed?: boolean;-}-/*** Extension point for a getting-started checklist that floats above the* sidebar footer. Core renders nothing; builds that offer onboarding (SaaS)* shadow this file to provide the real checklist.*/-export function SidebarChecklistSlot(_props: SidebarChecklistSlotProps) {+export function SidebarChecklistSlot() {return null;}diff --git a/frontend/editor/src/core/components/shared/SidebarHeader.tsx b/frontend/editor/src/core/components/shared/SidebarHeader.tsxindex 89a0fc32ff..ed997db70d 100644--- a/frontend/editor/src/core/components/shared/SidebarHeader.tsx+++ b/frontend/editor/src/core/components/shared/SidebarHeader.tsx@@ -1,27 +1,14 @@import { Logo } from "@app/ui/Logo";-import { SidebarToggleButton } from "@app/components/shared/SidebarToggleButton";export interface SidebarHeaderProps {- collapsed?: boolean;- onToggleCollapse?: () => void;className?: string;}-/** The wordmark and the collapse toggle; the brand mark sits in the rail beside it. */-export function SidebarHeader({- collapsed,- onToggleCollapse,- className,-}: SidebarHeaderProps) {+/** The wordmark; the brand mark sits in the rail beside it. */+export function SidebarHeader({ className }: SidebarHeaderProps) {return (<div className={`file-sidebar-header${className ? ` ${className}` : ""}`}>- {!collapsed && <Logo variant="textOnly" textHeight="1.3rem" />}- {onToggleCollapse && (- <SidebarToggleButton- collapsed={collapsed}- onToggle={onToggleCollapse}- />- )}+ <Logo variant="textOnly" textHeight="1.3rem" /></div>);}diff --git a/frontend/editor/src/core/components/shared/SidebarProcessingSlot.tsx b/frontend/editor/src/core/components/shared/SidebarProcessingSlot.tsxindex f69ce6d6d8..7dbc39386d 100644--- a/frontend/editor/src/core/components/shared/SidebarProcessingSlot.tsx+++ b/frontend/editor/src/core/components/shared/SidebarProcessingSlot.tsx@@ -1,11 +1,7 @@-export interface SidebarProcessingSlotProps {- collapsed?: boolean;-}-/*** Extension point for a processing-folder offer in the sidebar's controls box. Core has* no policy engine to run one; builds that ship processing folders shadow this file.*/-export function SidebarProcessingSlot(_props: SidebarProcessingSlotProps) {+export function SidebarProcessingSlot() {return null;}diff --git a/frontend/editor/src/core/components/shared/SidebarToggleIcon.tsx b/frontend/editor/src/core/components/shared/SidebarToggleIcon.tsxindex 5559cf2f76..8df211863e 100644--- a/frontend/editor/src/core/components/shared/SidebarToggleIcon.tsx+++ b/frontend/editor/src/core/components/shared/SidebarToggleIcon.tsx@@ -7,9 +7,8 @@ interface SidebarToggleIconProps {}/**- * "Toggle sidebar" glyph — a rounded panel with a divided-off left rail —- * shared by the editor FileSidebar and the processor Sidebar so their- * collapse/expand controls read identically. Inherits colour via currentColor.+ * "Toggle sidebar" glyph — a rounded panel with a divided-off left rail — for+ * the processor sidebar's collapse control. Inherits colour via currentColor.*/export function SidebarToggleIcon({size = 18,diff --git a/frontend/editor/src/core/components/shared/quickNav/QuickNavRailHost.tsx b/frontend/editor/src/core/components/shared/quickNav/QuickNavRailHost.tsxindex 5a92f0ee44..ffa0c33c7f 100644--- a/frontend/editor/src/core/components/shared/quickNav/QuickNavRailHost.tsx+++ b/frontend/editor/src/core/components/shared/quickNav/QuickNavRailHost.tsx@@ -71,14 +71,15 @@ export function QuickNavRailHost() {return { disabled: Boolean(reason), reason };};- // The apps you switch between. Reader is a mode over the editor rather- // than a place of its own, but it leads the group because it is where most- // visits start.+ // Reading is a surface of its own rather than a tool inside the editor, and it+ // leads the group because it is where most visits start.const reader: QuickNavEntry = {id: "reader",label: t("quickNav.reader", "Reader"),icon: <Icon name="book-open" size={SIZE} />,- pressed: Boolean(host?.readerMode),+ // Current means the surface you are on, not a switch left on: reader mode set+ // from the processor does not count until you are in the editor.+ current: inEditor && Boolean(host?.readerMode),// From the processor there is no editor to toggle - see pendingReaderMode.onClick: () => {const setMode = host?.actions.current?.setReaderMode;@@ -95,8 +96,9 @@ export function QuickNavRailHost() {id: "editor",label: t("quickNav.editor", "Editor"),icon: <Icon name="pencil" size={SIZE} filled={inEditor} />,- // The library is a place of its own, not the editor with a different centre.- current: inEditor && !host?.fileLibrary,+ // The library and reading are places of their own, not the editor with a+ // different centre.+ current: inEditor && !host?.fileLibrary && !host?.readerMode,onClick: () => {if (inEditor) {returnHome();@@ -128,8 +130,8 @@ export function QuickNavRailHost() {};// The processor is additive: dropping the editor with it left a lone reader- // toggle in builds without a portal, with no way back out of reader mode.- const apps: QuickNavEntry[] = [+ // entry in builds without a portal, with no way back out of reading.+ const surfaces: QuickNavEntry[] = [reader,editor,...(HAS_PORTAL ? [processor] : []),@@ -227,7 +229,7 @@ export function QuickNavRailHost() {return (<QuickNavRailContainer- groups={[apps, within]}+ groups={[surfaces, within]}onReturnHome={returnHome}identity={host?.identity ?? null}onOpenAccount={openAccount}diff --git a/frontend/editor/src/core/components/tools/RightSidebar.tsx b/frontend/editor/src/core/components/tools/RightSidebar.tsxindex 7db8be8258..98e49217d9 100644--- a/frontend/editor/src/core/components/tools/RightSidebar.tsx+++ b/frontend/editor/src/core/components/tools/RightSidebar.tsx@@ -1,18 +1,13 @@-import { useMemo, useState } from "react";+import { useState } from "react";import { useTranslation } from "react-i18next";import { useToolWorkflow } from "@app/contexts/ToolWorkflowContext";import { useSidebarContext } from "@app/contexts/SidebarContext";import { useIsMobile } from "@app/hooks/useIsMobile";import ToolPanel from "@app/components/tools/ToolPanel";-import { useFavoriteToolItems } from "@app/hooks/tools/useFavoriteToolItems";-import { useToolSections } from "@app/hooks/useToolSections";-import type { SubcategoryGroup } from "@app/hooks/useToolSections";import { ToolIcon } from "@app/components/shared/ToolIcon";import { ToolPanelHeader } from "@app/components/shared/ToolPanelHeader";-import { Tooltip as AppTooltip } from "@app/components/shared/Tooltip";import { ActionIcon } from "@app/ui/ActionIcon";import { withViewTransition } from "@app/utils/viewTransition";-import { SidebarToggleIcon } from "@app/components/shared/SidebarToggleIcon";import CloseIcon from "@mui/icons-material/Close";import { ToolId } from "@app/types/toolId";import type { ToolRegistryEntry } from "@app/data/toolsTaxonomy";@@ -24,11 +19,9 @@ import { useToolPanelGeometry } from "@app/hooks/tools/useToolPanelGeometry";import "@app/components/tools/ToolPanel.css";/**- * Right-side rail wrapping the tool panel.- *- * Owns the rail-level concerns: collapse/expand chrome and the collapsed strip- * (favourite/recommended icon shortcuts). Fullscreen takeover lives in- * FullscreenToolPanel.+ * Right-side rail wrapping the tool panel, which is fixed open: what the rail+ * owns is the panel's own chrome (the header and its back/close control).+ * Fullscreen takeover lives in FullscreenToolPanel.*/export default function RightSidebar() {const { t } = useTranslation();@@ -38,19 +31,11 @@ export default function RightSidebar() {const {leftPanelView,- isPanelVisible,- filteredTools,toolRegistry,setSearchQuery,selectedToolKey,handleToolSelect,handleBackToTools,- setLeftPanelView,- setReaderMode,- setSidebarsVisible,- sidebarsVisible,- readerMode,- favoriteTools,} = useToolWorkflow();const fullscreenExpanded = useIsFullscreenExpanded();@@ -60,18 +45,6 @@ export default function RightSidebar() {quickAccessRef,});- const handleExpand = () => {- withViewTransition(() => {- if (readerMode) setReaderMode(false);- if (leftPanelView === "hidden") setLeftPanelView("toolPicker");- if (!sidebarsVisible) setSidebarsVisible(true);- });- };-- const handleCollapse = () => {- withViewTransition(() => setLeftPanelView("hidden"));- };-const [allToolsView, setAllToolsView] = useState(false);const handleShowAllTools = () => {@@ -110,38 +83,6 @@ export default function RightSidebar() {const expandedWidth = "18.5rem";- const computedWidth = () => {- if (isMobile) return "100%";- if (!isPanelVisible) return "var(--nav-rail-w)";- return expandedWidth;- };-- // Collapsed rail: show favourites + recommended tools as icons.- const favoriteToolItems = useFavoriteToolItems(favoriteTools, toolRegistry);- const { sections: collapsedSections } = useToolSections(filteredTools);- const collapsedQuickSection = useMemo(- () => collapsedSections.find((s) => s.key === "quick"),- [collapsedSections],- );- const collapsedRecommendedItems = useMemo(() => {- if (!collapsedQuickSection) return [];- const items: Array<{ id: ToolId; tool: ToolRegistryEntry }> = [];- collapsedQuickSection.subcategories.forEach((sc: SubcategoryGroup) =>- sc.tools.forEach((entry) =>- items.push({ id: entry.id, tool: entry.tool }),- ),- );- return items;- }, [collapsedQuickSection]);- const collapsedRailItems = useMemo(() => {- const map = new Map<ToolId, ToolRegistryEntry>();- favoriteToolItems.forEach(({ id, tool }) => map.set(id, tool));- collapsedRecommendedItems.forEach(({ id, tool }) => {- if (!map.has(id)) map.set(id, tool);- });- return Array.from(map, ([id, tool]) => ({ id, tool }));- }, [favoriteToolItems, collapsedRecommendedItems]);-return (<divref={toolPanelRef}@@ -149,61 +90,12 @@ export default function RightSidebar() {data-tour={fullscreenExpanded ? undefined : "tool-panel"}className={`tool-panel flex flex-col ${fullscreenExpanded ? "tool-panel--fullscreen-active" : "overflow-hidden"} ${isMobile || fullscreenExpanded ? "border-l border-[var(--c-border-subtle)]" : "tool-panel--floating"} transition-all duration-300 ease-out ${isMobile ? "h-full border-r-0" : fullscreenExpanded ? "h-screen" : ""} ${fullscreenExpanded ? "tool-panel--fullscreen" : ""}`}style={{- width: computedWidth(),+ width: isMobile ? "100%" : expandedWidth,padding: "0",}}>- {!fullscreenExpanded && !isPanelVisible && !isMobile && (- <div className="tool-panel__collapsed-strip">- <div className="tool-panel__collapsed-top">- <ActionIcon- aria-label={t("toolPanel.expand", "Expand panel")}- variant="secondary"- accent="neutral"- size="md"- shape="circle"- className="tool-panel__expand-btn tool-panel__toggle-vt"- onClick={handleExpand}- >- <SidebarToggleIcon size={18} mirrored />- </ActionIcon>- </div>- <div className="tool-panel__collapsed-divider" />- <div className="tool-panel__collapsed-tools">- {collapsedRailItems.map(({ id, tool }) => (- <AppTooltip- key={id}- content={tool.name}- position="left"- arrow- // No delay: collapsed to icons, the tooltip is the only label.- delay={0}- >- <ActionIcon- aria-label={tool.name}- variant="tertiary"- className="tool-panel__collapsed-tool-btn"- data-selected={selectedToolKey === id}- onClick={() => {- handleExpand();- handleToolSelectWithTransition(id);- }}- >- <ToolIcon icon={tool.icon} marginRight="0" />- </ActionIcon>- </AppTooltip>- ))}- </div>- </div>- )}-- {!fullscreenExpanded && isPanelVisible && (+ {!fullscreenExpanded && (<div- /* Fixed width matches the expanded panel width so the inner content is- laid out at its final size from the moment it mounts. The outer- .tool-panel clips it (overflow-hidden) while it animates from the- collapsed rail width — text/icons stay put and just come into view- instead of jiggling as space becomes available. */style={{opacity: 1,transition: "opacity 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94)",@@ -235,42 +127,28 @@ export default function RightSidebar() {: t("toolPanel.goBack", "Go back")}/>- ) : showCloseButton || !isMobile ? (- /* Without a back button this header is just the collapse control,- which has no meaning on mobile - the slider switches panes. Drop- it there so the tool list starts under the tabs. */+ ) : showCloseButton ? (+ /* Closing a tool, not the panel: the panel itself is fixed open, so+ with nothing to leave there is no header to show. */<div className="tool-panel__compact-header"><span className="tool-panel__compact-title">{t("toolPanel.pdfTools", "PDF Tools")}</span><div className="tool-panel__compact-header-actions">- {showCloseButton ? (- <ActionIcon- variant="tertiary"- size="md"- shape="circle"- onClick={handleHeaderBack}- aria-label={- inToolView- ? t("toolPanel.backToAllTools", "Back to all tools")- : t("toolPanel.goBack", "Go back")- }- className="tool-panel__expand-btn"- >- <CloseIcon sx={{ fontSize: "1.1rem" }} />- </ActionIcon>- ) : (- <ActionIcon- variant="secondary"- size="md"- shape="circle"- onClick={handleCollapse}- aria-label={t("toolPanel.collapse", "Collapse panel")}- className="tool-panel__expand-btn tool-panel__toggle-vt"- >- <SidebarToggleIcon size={18} mirrored />- </ActionIcon>- )}+ <ActionIcon+ variant="tertiary"+ size="md"+ shape="circle"+ onClick={handleHeaderBack}+ aria-label={+ inToolView+ ? t("toolPanel.backToAllTools", "Back to all tools")+ : t("toolPanel.goBack", "Go back")+ }+ className="tool-panel__expand-btn"+ >+ <CloseIcon sx={{ fontSize: "1.1rem" }} />+ </ActionIcon></div></div>) : null}diff --git a/frontend/editor/src/core/components/tools/ToolPanel.css b/frontend/editor/src/core/components/tools/ToolPanel.cssindex b27885ccf5..a6322ef0fc 100644--- a/frontend/editor/src/core/components/tools/ToolPanel.css+++ b/frontend/editor/src/core/components/tools/ToolPanel.css@@ -19,75 +19,59 @@user-select: none;}-/* Flush, with a rule on the workbench side mirroring the file sidebar's. */-.tool-panel--floating {- /* Tracks the frame, which is dvh; vh would cut the bottom off on mobile. */- height: 100%;- background: var(--c-surface);- border-inline-start: 1px solid var(--c-border-subtle);+/* Off the trailing edge and back, mirroring the file sidebar. Out of flow while+ it leaves, so the reader's rail takes the slot without waiting for it. */+[data-wings="leaving"] .tool-panel {+ position: absolute;+ inset-block: 0;+ inset-inline-end: 0;+ z-index: var(--z-dropdown);+ animation: tool-panel-leave var(--wings-ms) ease-in both;}-.tool-panel__collapsed-strip {- display: flex;- flex-direction: column;- align-items: stretch;- padding-top: 10px;- height: 100%;- width: 100%;- min-height: 0;+[data-wings="returning"] .tool-panel {+ animation: tool-panel-return var(--wings-ms) ease-out both;}-.tool-panel__collapsed-top {- display: flex;- flex-direction: column;- align-items: center;- gap: 8px;- padding: 0 0 10px;+/* Mirrored in RTL, where the panel sits on the leading edge. */+[dir="rtl"] [data-wings="leaving"] .tool-panel {+ animation-name: file-sidebar-leave;}-.tool-panel__collapsed-divider {- height: 1px;- background: var(--c-border-subtle);- margin: 0 0.5rem 8px;+[dir="rtl"] [data-wings="returning"] .tool-panel {+ animation-name: file-sidebar-return;}-.tool-panel__collapsed-tools {- display: flex;- flex-direction: column;- align-items: center;- gap: 4px;- padding: 0 0 12px;- overflow-y: auto;- overflow-x: hidden;- flex: 1 1 auto;- min-height: 0;+@keyframes tool-panel-leave {+ to {+ transform: translateX(100%);+ opacity: 0;+ }}-.tool-panel__collapsed-tool-btn {- display: inline-flex;- align-items: center;- justify-content: center;- width: 2.25rem;- height: 2.25rem;- border: 1px solid transparent;- border-radius: 0.5rem;- background: transparent;- color: var(--c-text);- cursor: pointer;- transition:- background 120ms ease-out,- border-color 120ms ease-out;- padding: 0;- flex-shrink: 0;+@keyframes tool-panel-return {+ from {+ transform: translateX(100%);+ opacity: 0;+ }+ to {+ transform: translateX(0);+ opacity: 1;+ }}-.tool-panel__collapsed-tool-btn:hover {- background: var(--mantine-color-default-hover);+@media (prefers-reduced-motion: reduce) {+ [data-wings] .tool-panel {+ animation: none;+ }}-.tool-panel__collapsed-tool-btn[data-selected="true"] {- background: var(--mantine-color-default-hover);- border-color: var(--mantine-color-default-border);+/* Flush, with a rule on the workbench side mirroring the file sidebar's. */+.tool-panel--floating {+ /* Tracks the frame, which is dvh; vh would cut the bottom off on mobile. */+ height: 100%;+ background: var(--c-surface);+ border-inline-start: 1px solid var(--c-border-subtle);}.tool-panel__expand-btn {@@ -96,13 +80,6 @@border-color: var(--c-border-subtle) !important;}-/* The collapse/expand toggle keeps a stable identity across the collapsed strip- and the expanded header, so a view transition translates it between the two- (same size) instead of cross-fading/scaling it ("big then small"). */-.tool-panel__toggle-vt {- view-transition-name: sidebar-toggle;-}-.tool-panel__expand-btn svg {color: var(--c-text-muted) !important;}@@ -112,19 +89,6 @@border-color: var(--border) !important;}-.tool-panel__collapsed-search-btn {- flex-shrink: 0;- color: var(--c-text-muted) !important;-}--.tool-panel__collapsed-search-btn svg {- color: var(--c-text-muted) !important;-}--.tool-panel__collapsed-search-btn:hover {- color: var(--c-text) !important;-}-.tool-panel__back-btn {flex-shrink: 0;}diff --git a/frontend/editor/src/core/components/viewer/BookmarkSidebar.tsx b/frontend/editor/src/core/components/viewer/BookmarkSidebar.tsxindex 8bce59de4e..4b94a696b0 100644--- a/frontend/editor/src/core/components/viewer/BookmarkSidebar.tsx+++ b/frontend/editor/src/core/components/viewer/BookmarkSidebar.tsx@@ -109,7 +109,7 @@ export const BookmarkSidebar = ({toggleBookmarkSidebar,} = useViewer();const { t } = useTranslation();- const { handleToolSelectForced } = useToolWorkflow();+ const { handleToolSelectForced, readerMode } = useToolWorkflow();const { selectors, actions: fileActions } = useFileContext();const [expanded, setExpanded] = useState<Record<string, boolean>>({});const [searchTerm, setSearchTerm] = useState("");@@ -334,9 +334,24 @@ export const BookmarkSidebar = ({// Fallback: open the full Edit Table of Contents tool when inline add is// not viable (e.g. the active file is a preview / unmanaged file we// cannot consume + replace via FileContext).+ //+ // Reading has no tool panel to open it in, and taking the reader to the editor+ // to add a bookmark is the jump this surface exists to avoid: there the inline+ // form is the whole offer, and the cases it cannot serve say so instead.+ const canFallbackToTool = !readerMode;const handleFallbackToTool = useCallback(() => {+ if (readerMode) {+ setAddBookmarkError(+ t(+ "viewer.bookmarks.editorOnly",+ "This document's bookmarks can only be edited in the editor.",+ ),+ );+ setIsAddingBookmark(false);+ return;+ }handleToolSelectForced("editTableOfContents");- }, [handleToolSelectForced]);+ }, [handleToolSelectForced, readerMode, t]);const handleSubmitAddBookmark = useCallback(async () => {const title = newBookmarkTitle.trim();@@ -864,7 +879,7 @@ export const BookmarkSidebar = ({</Text></div>)}- {bookmarkSupport && documentCacheKey && (+ {bookmarkSupport && documentCacheKey && canFallbackToTool && (<Boxpx="sm"py="xs"diff --git a/frontend/editor/src/core/components/viewer/CommentsSidebar.tsx b/frontend/editor/src/core/components/viewer/CommentsSidebar.tsxindex 9b4b3b2d20..b5ac166a1f 100644--- a/frontend/editor/src/core/components/viewer/CommentsSidebar.tsx+++ b/frontend/editor/src/core/components/viewer/CommentsSidebar.tsx@@ -303,7 +303,7 @@ export function CommentsSidebar({} = useViewer() ?? {};const scrollViewportRef = useRef<HTMLDivElement | null>(null);const { state, provides } = useAnnotation(documentId);- const { handleToolSelectForced } = useToolWorkflow();+ const { handleToolSelectForced, readerMode } = useToolWorkflow();const {activateAnnotationToolRef,activeAnnotationToolId,@@ -708,17 +708,22 @@ export function CommentsSidebar({const commentsHeaderActions =totalCount > 0 ? (<Group gap={2} wrap="nowrap" style={{ flexShrink: 0 }}>- <Tooltip label={t("viewer.comments.addComment", "Add comment")}>- <ActionIcon- variant="tertiary"- accent="neutral"- size="sm"- aria-label={t("viewer.comments.addComment", "Add comment")}- onClick={handleAddComment}- >- <Icon name="plus" size="1.25rem" />- </ActionIcon>- </Tooltip>+ {/* Placing a comment arms the annotate tool, which only exists in the+ editor: offering it here would take the reader there mid-sentence.+ Reading shows the comments that are there and leaves it at that. */}+ {!readerMode && (+ <Tooltip label={t("viewer.comments.addComment", "Add comment")}>+ <ActionIcon+ variant="tertiary"+ accent="neutral"+ size="sm"+ aria-label={t("viewer.comments.addComment", "Add comment")}+ onClick={handleAddComment}+ >+ <Icon name="plus" size="1.25rem" />+ </ActionIcon>+ </Tooltip>+ )}<Menu position="bottom-end" withArrow><Menu.Target><Tooltip label={t("viewer.comments.moreActions", "More actions")}>@@ -790,7 +795,7 @@ export function CommentsSidebar({"Click a page to place… (cancel)",)}</Button>- ) : (+ ) : readerMode ? null : (<Buttonvariant="tertiary"size="sm"@@ -819,7 +824,7 @@ export function CommentsSidebar({"Click a page to place… (cancel)",)}</Button>- ) : (+ ) : readerMode ? null : (<Buttonvariant="tertiary"size="sm"diff --git a/frontend/editor/src/core/components/viewer/EmbedPdfViewer.tsx b/frontend/editor/src/core/components/viewer/EmbedPdfViewer.tsxindex 8aaae3bf70..70c011a6fb 100644--- a/frontend/editor/src/core/components/viewer/EmbedPdfViewer.tsx+++ b/frontend/editor/src/core/components/viewer/EmbedPdfViewer.tsx@@ -57,8 +57,6 @@ import { alert } from "@app/components/toast";// ──────────────────────────────────────────────────────────────────────────────export interface EmbedPdfViewerProps {- sidebarsVisible: boolean;- setSidebarsVisible: (v: boolean) => void;onClose?: () => void;previewFile?: File | null;// ── Signature overlay pass-through (opt-in; all default off) ──────────────@@ -81,8 +79,6 @@ const documentCacheKey = (file: StirlingFile): string =>`${file.fileId}|${file.quickKey}`;const EmbedPdfViewerContent = ({- sidebarsVisible: _sidebarsVisible,- setSidebarsVisible: _setSidebarsVisible,onClose,previewFile,signaturePreviews,diff --git a/frontend/editor/src/core/components/viewer/NonPdfViewer.stories.tsx b/frontend/editor/src/core/components/viewer/NonPdfViewer.stories.tsxindex 4f10d49303..0942a0f25a 100644--- a/frontend/editor/src/core/components/viewer/NonPdfViewer.stories.tsx+++ b/frontend/editor/src/core/components/viewer/NonPdfViewer.stories.tsx@@ -42,8 +42,6 @@ type Story = StoryObj<typeof meta>;/** CSV preview: parsed into a scrollable table. */export const Csv: Story = {args: {- sidebarsVisible: true,- setSidebarsVisible: () => {},file: makeFile("invoice.csv","text/csv",@@ -55,8 +53,6 @@ export const Csv: Story = {/** JSON preview: syntax-highlighted / pretty-printed. */export const Json: Story = {args: {- sidebarsVisible: true,- setSidebarsVisible: () => {},file: makeFile("config.json","application/json",@@ -68,8 +64,6 @@ export const Json: Story = {/** Unsupported file type: falls back to the "Preview not available" state. */export const Unsupported: Story = {args: {- sidebarsVisible: true,- setSidebarsVisible: () => {},file: makeFile("archive.zip", "application/zip", "binary-ish-content"),},};diff --git a/frontend/editor/src/core/components/viewer/NonPdfViewer.tsx b/frontend/editor/src/core/components/viewer/NonPdfViewer.tsxindex 9b584e4e9e..0878ab53c4 100644--- a/frontend/editor/src/core/components/viewer/NonPdfViewer.tsx+++ b/frontend/editor/src/core/components/viewer/NonPdfViewer.tsx@@ -19,8 +19,6 @@ import { TextViewer } from "@app/components/viewer/nonpdf/TextViewer";import { HtmlViewer } from "@app/components/viewer/nonpdf/HtmlViewer";export interface ViewerProps {- sidebarsVisible: boolean;- setSidebarsVisible: (v: boolean) => void;onClose?: () => void;previewFile?: File | null;}diff --git a/frontend/editor/src/core/components/viewer/PdfViewerToolbar.css b/frontend/editor/src/core/components/viewer/PdfViewerToolbar.cssindex 4cc56de328..0cc0306640 100644--- a/frontend/editor/src/core/components/viewer/PdfViewerToolbar.css+++ b/frontend/editor/src/core/components/viewer/PdfViewerToolbar.css@@ -46,3 +46,12 @@animation: none;}}++/* The rails' hairline divider, horizontal bar orientation. */+.pdf-viewer-toolbar__divider {+ width: 1px;+ height: 1.25rem;+ background: var(--c-border-subtle);+ flex-shrink: 0;+ margin: 0 0.25rem;+}diff --git a/frontend/editor/src/core/components/viewer/PdfViewerToolbar.tsx b/frontend/editor/src/core/components/viewer/PdfViewerToolbar.tsxindex 958c5f4ed6..ec0af3ee72 100644--- a/frontend/editor/src/core/components/viewer/PdfViewerToolbar.tsx+++ b/frontend/editor/src/core/components/viewer/PdfViewerToolbar.tsx@@ -7,6 +7,7 @@ import { Tooltip } from "@app/components/shared/Tooltip";import { ActionIcon } from "@app/ui/ActionIcon";import "@app/components/viewer/PdfViewerToolbar.css";import { Icon } from "@app/ui/Icon";+// Sizing constants for the page number inputconst MIN_PAGE_DIGITS = 2;const MIN_INPUT_WIDTH_PX = 48;@@ -27,8 +28,9 @@ export function PdfViewerToolbar({}: PdfViewerToolbarProps) {const { t } = useTranslation();const isPhone = useIsPhone();- const buttonMinWidth = isPhone ? "3rem" : "2.5rem";- const buttonSize = isPhone ? "lg" : "md";+ // Phone keeps big hit targets; on desktop the bar sits at the rails' scale.+ const buttonMinWidth = isPhone ? "3rem" : undefined;+ const buttonSize = isPhone ? "lg" : "sm";const {getScrollState,getZoomState,@@ -138,14 +140,14 @@ export function PdfViewerToolbar({return (<PaperclassName="pdf-viewer-toolbar"- p={12}- pb={12}+ px={10}+ py={6}style={{display: "flex",alignItems: "center",flexWrap: "wrap",- rowGap: 8,- gap: 10,+ rowGap: 4,+ gap: 6,justifyContent: "center",pointerEvents: "auto",}}@@ -162,7 +164,7 @@ export function PdfViewerToolbar({title={t("viewer.firstPage", "First Page")}aria-label={t("viewer.firstPage", "First Page")}>- <Icon name="chevron-first" size={20} />+ <Icon name="chevron-first" size={18} /></ActionIcon>)}@@ -176,7 +178,7 @@ export function PdfViewerToolbar({title={t("viewer.previousPage", "Previous Page")}aria-label={t("viewer.previousPage", "Previous Page")}>- <Icon name="chevron-left" size={20} />+ <Icon name="chevron-left" size={18} /></ActionIcon>{/* Page Input */}@@ -192,12 +194,13 @@ export function PdfViewerToolbar({min={1}max={scrollState.totalPages}hideControls+ size="xs"styles={{input: {width: inputWidth,textAlign: "center",fontWeight: 500,- fontSize: 16,+ fontSize: 13,paddingLeft: 4,paddingRight: 4,boxSizing: "border-box",@@ -205,7 +208,13 @@ export function PdfViewerToolbar({}}/>- <span style={{ fontWeight: 500, fontSize: 16 }}>+ <span+ style={{+ fontWeight: 500,+ fontSize: 13,+ color: "var(--c-text-subtle)",+ }}+ >/ {scrollState.totalPages}</span>@@ -219,7 +228,7 @@ export function PdfViewerToolbar({title={t("viewer.nextPage", "Next Page")}aria-label={t("viewer.nextPage", "Next Page")}>- <Icon name="chevron-right" size={20} />+ <Icon name="chevron-right" size={18} /></ActionIcon>{/* Last Page Button */}@@ -234,10 +243,15 @@ export function PdfViewerToolbar({title={t("viewer.lastPage", "Last Page")}aria-label={t("viewer.lastPage", "Last Page")}>- <Icon name="chevron-last" size={20} />+ <Icon name="chevron-last" size={18} /></ActionIcon>)}+ {/* Hairline between the groups, as the rails divide theirs. */}+ {!isPhone && (+ <div className="pdf-viewer-toolbar__divider pdf-viewer-toolbar-wide-only" />+ )}+{/* Dual Page Toggle */}{!isPhone && (<Tooltip@@ -250,7 +264,7 @@ export function PdfViewerToolbar({arrow><ActionIcon- variant={isDualPageActive ? "primary" : "secondary"}+ variant={isDualPageActive ? "primary" : "tertiary"}size={buttonSize}className="pdf-viewer-toolbar-wide-only"onClick={handleDualPageToggle}@@ -263,9 +277,9 @@ export function PdfViewerToolbar({}>{isDualPageActive ? (- <Icon name="file-text" size={20} />+ <Icon name="file-text" size={18} />) : (- <Icon name="columns-3" size={20} />+ <Icon name="columns-2" size={18} />)}</ActionIcon></Tooltip>@@ -285,7 +299,7 @@ export function PdfViewerToolbar({arrow><ActionIcon- variant={pdfRenderMode !== "normal" ? "primary" : "secondary"}+ variant={pdfRenderMode !== "normal" ? "primary" : "tertiary"}size={buttonSize}className="pdf-viewer-toolbar-wide-only"onClick={cyclePdfRenderMode}@@ -298,29 +312,24 @@ export function PdfViewerToolbar({: t("viewer.disableColorFilter", "Disable Color Filter")}>- {/* One glyph per state: the three must stay distinct, or the cycle- button stops telling you which filter is active. */}- {pdfRenderMode === "normal" && <Icon name="moon" size={20} />}- {pdfRenderMode === "dark" && <Icon name="sunset" size={20} />}- {pdfRenderMode === "sepia" && <Icon name="sun" size={20} />}+ {pdfRenderMode === "normal" && <Icon name="moon" size={18} />}+ {pdfRenderMode === "dark" && <Icon name="sunset" size={18} />}+ {pdfRenderMode === "sepia" && <Icon name="sun" size={18} />}</ActionIcon></Tooltip>)}{/* Desktop zoom controls (slider + buttons) */}{!isPhone && (- <Group- gap={4}- align="center"- wrap="nowrap"- style={{ marginLeft: 16, flexShrink: 0 }}- >+ <Group gap={4} align="center" wrap="nowrap" style={{ flexShrink: 0 }}>+ <div className="pdf-viewer-toolbar__divider" /><ActionIconvariant="tertiary"+ size={buttonSize}onClick={handleZoomOut}aria-label={t("viewer.zoomOut", "Zoom out")}>- <Icon name="zoom-out" size={20} />+ <Icon name="zoom-out" size={18} /></ActionIcon><SliderclassName="pdf-viewer-toolbar-zoom-slider"@@ -332,17 +341,18 @@ export function PdfViewerToolbar({size="xs"styles={{root: { minWidth: "6rem", width: "6rem", flexShrink: 0 },- thumb: { width: 14, height: 14 },- track: { height: 3 },+ thumb: { width: 12, height: 12 },+ track: { height: 2 },}}label={null}/><ActionIconvariant="tertiary"+ size={buttonSize}onClick={handleZoomIn}aria-label={t("viewer.zoomIn", "Zoom in")}>- <Icon name="zoom-in" size={20} />+ <Icon name="zoom-in" size={18} /></ActionIcon><spanstyle={{@@ -371,7 +381,7 @@ export function PdfViewerToolbar({aria-label={t("viewer.moreOptions", "More")}style={{ marginLeft: 4 }}>- <Icon name="ellipsis-vertical" size={20} />+ <Icon name="ellipsis-vertical" size={18} /></ActionIcon></Menu.Target><Menu.Dropdown>@@ -379,14 +389,14 @@ export function PdfViewerToolbar({{t("viewer.pageNavigation", "Page navigation")}</Menu.Label><Menu.Item- leftSection={<Icon name="chevron-first" size={20} />}+ leftSection={<Icon name="chevron-first" size={18} />}disabled={scrollState.currentPage === 1}onClick={handleFirstPage}>{t("viewer.firstPage", "First page")}</Menu.Item><Menu.Item- leftSection={<Icon name="chevron-last" size={20} />}+ leftSection={<Icon name="chevron-last" size={18} />}disabled={scrollState.currentPage === scrollState.totalPages}onClick={handleLastPage}>@@ -396,13 +406,13 @@ export function PdfViewerToolbar({<Menu.Divider /><Menu.Label>{t("viewer.zoom", "Zoom")}</Menu.Label><Menu.Item- leftSection={<Icon name="zoom-out" size={20} />}+ leftSection={<Icon name="zoom-out" size={18} />}onClick={handleZoomOut}>{t("viewer.zoomOut", "Zoom out")}</Menu.Item><Menu.Item- leftSection={<Icon name="zoom-in" size={20} />}+ leftSection={<Icon name="zoom-in" size={18} />}onClick={handleZoomIn}>{t("viewer.zoomIn", "Zoom in")} ({displayZoomPercent}%)@@ -413,9 +423,9 @@ export function PdfViewerToolbar({<Menu.ItemleftSection={isDualPageActive ? (- <Icon name="file-text" size={20} />+ <Icon name="file-text" size={18} />) : (- <Icon name="columns-3" size={20} />+ <Icon name="columns-2" size={18} />)}disabled={scrollState.totalPages <= 1}@@ -428,11 +438,11 @@ export function PdfViewerToolbar({<Menu.ItemleftSection={pdfRenderMode === "normal" ? (- <Icon name="moon" size={20} />+ <Icon name="moon" size={18} />) : pdfRenderMode === "dark" ? (- <Icon name="sunset" size={20} />+ <Icon name="sunset" size={18} />) : (- <Icon name="sun" size={20} />+ <Icon name="sun" size={18} />)}onClick={cyclePdfRenderMode}diff --git a/frontend/editor/src/core/components/viewer/ViewerAnnotationControls.tsx b/frontend/editor/src/core/components/viewer/ViewerAnnotationControls.tsxindex ce9fba7177..8d517577dc 100644--- a/frontend/editor/src/core/components/viewer/ViewerAnnotationControls.tsx+++ b/frontend/editor/src/core/components/viewer/ViewerAnnotationControls.tsx@@ -34,7 +34,7 @@ export default function ViewerAnnotationControls({disabled = false,}: ViewerAnnotationControlsProps) {const { t } = useTranslation();- const { setLeftPanelView, setSidebarsVisible } = useToolWorkflow();+ const { setLeftPanelView } = useToolWorkflow();// Viewer context for PDF controls - safely handle when not availableconst viewerContext = React.useContext(ViewerContext);@@ -139,7 +139,6 @@ export default function ViewerAnnotationControls({navActions.setToolAndWorkbench("redact", "viewer");- setSidebarsVisible(true);setLeftPanelView("toolContent");setRedactionMode(true);diff --git a/frontend/editor/src/core/components/viewer/readerRail/ReaderRail.css b/frontend/editor/src/core/components/viewer/readerRail/ReaderRail.cssnew file mode 100644index 0000000000..192c292933--- /dev/null+++ b/frontend/editor/src/core/components/viewer/readerRail/ReaderRail.css@@ -0,0 +1,103 @@+/* The rail beside a document being read: icons only, down the right edge, in the+ slot the tool panel occupies everywhere else. */+.reader-rail {+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 0.375rem;+ flex-shrink: 0;+ width: var(--nav-rail-w);+ /* Full height whatever it holds: the rail is the edge of the workspace, not a+ floating cluster of buttons that grows and shrinks with the document. */+ align-self: stretch;+ height: 100%;+ padding: 0.75rem 0;+ border-left: 1px solid var(--c-border-subtle);+ background: var(--c-bg-raised);+ overflow-y: auto;+ overflow-x: hidden;+}++.reader-rail__group {+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 0.375rem;+ width: 100%;+}++.reader-rail__item {+ display: inline-flex;+}++.reader-rail__divider {+ width: 1.25rem;+ height: 1px;+ margin: 0.25rem 0;+ background: var(--c-border-subtle);+ flex-shrink: 0;+}++/* A name can never widen or wrap the dropdown: the item and Mantine's label wrapper+ both give up width (min-width: 0) so the ellipsis on the name actually engages. */+.reader-rail__doc {+ min-width: 0;+ max-width: 100%;+}++.reader-rail__doc .mantine-Menu-itemLabel {+ min-width: 0;+ overflow: hidden;+}++.reader-rail__doc-name {+ display: block;+ max-width: 100%;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++/* The document you are reading, marked down its leading edge. The stripe is+ inset rather than drawn as a border so the row's own hover fill still reaches+ the edge of the dropdown. */+.reader-rail__doc[data-current] {+ position: relative;+ background: var(--c-primary-tint);+ font-weight: 500;+}++.reader-rail__doc[data-current]::before {+ content: "";+ position: absolute;+ inset-block: 0.25rem;+ inset-inline-start: 0;+ width: 2px;+ border-radius: 1px;+ background: var(--c-primary);+}++/* A disabled control keeps its slot but loses its chrome: the filled circle reads+ as something to press, and a faded glyph alone says "not right now" better. */+.reader-rail .mantine-ActionIcon-root:disabled,+.reader-rail .mantine-ActionIcon-root[data-disabled] {+ background-color: transparent;+ border-color: transparent;+ opacity: 0.45;+}++/* Controls that bring the workbench bar's compact styling with them (the search+ popover, read-aloud) revert to the rail's own button look here: the bar's muted+ rest color and hover-to-bright read as faded beside the rail's other buttons,+ and its 24px clamp shrinks the hit target. */+.reader-rail .workbench-bar-action-icon,+.reader-rail .workbench-bar-action-icon:hover {+ color: var(--ai-color, var(--c-text)) !important;+}++.reader-rail .workbench-bar-action-icon {+ width: var(--ai-size) !important;+ height: var(--ai-size) !important;+ min-width: var(--ai-size) !important;+ min-height: var(--ai-size) !important;+}diff --git a/frontend/editor/src/core/components/viewer/readerRail/ReaderRail.tsx b/frontend/editor/src/core/components/viewer/readerRail/ReaderRail.tsxnew file mode 100644index 0000000000..86aa623429--- /dev/null+++ b/frontend/editor/src/core/components/viewer/readerRail/ReaderRail.tsx@@ -0,0 +1,257 @@+import { useCallback, useMemo } from "react";+import { useTranslation } from "react-i18next";+import { Menu } from "@mantine/core";++import { Icon } from "@app/ui/Icon";+import { ActionIcon } from "@app/ui/ActionIcon";+import { Tooltip as AppTooltip } from "@app/components/shared/Tooltip";+import { useWorkbenchBar } from "@app/contexts/WorkbenchBarContext";+import { useViewer } from "@app/contexts/ViewerContext";+import { useNavigationGuard } from "@app/contexts/NavigationContext";+import { useAllFiles, useFileManagement } from "@app/contexts/file/fileHooks";+import { useFilesModalContext } from "@app/contexts/FilesModalContext";+import { truncateCenter } from "@app/utils/textUtils";+import { isStirlingFile } from "@app/types/fileContext";+import "@app/components/viewer/readerRail/ReaderRail.css";++/** The quick-nav rail's icon size, so the two rails read as one family. */+const SIZE = "1.125rem";++interface RailItem {+ /** The viewer's id for this control, where the viewer has one. */+ id: string;+ icon: React.ReactNode;+}++/**+ * The controls beside a document being read, declared here rather than taken from the+ * viewer: the viewer only mounts once something is open, so a rail built from its+ * registrations would fill in as files arrived.+ *+ * Absent on purpose: page navigation, zoom and the colour filters, which live in the+ * viewer's own toolbar that reading collapses rather than removes; and anything that+ * changes the document rather than the reading of it, which is the editor's business.+ */+const RAIL_GROUPS: readonly (readonly RailItem[])[] = [+ [+ {+ id: "viewer-toggle-bookmarks",+ icon: <Icon name="bookmark" size={SIZE} />,+ },+ {+ id: "viewer-toggle-sidebar",+ icon: <Icon name="rows-2" size={SIZE} />,+ },+ {+ id: "viewer-search",+ icon: <Icon name="search" size={SIZE} />,+ },+ ],+ [+ {+ id: "viewer-rotate-left",+ icon: <Icon name="rotate-ccw" size={SIZE} />,+ },+ {+ id: "viewer-rotate-right",+ icon: <Icon name="rotate-cw" size={SIZE} />,+ },+ ],+ [+ {+ id: "viewer-toggle-comments",+ icon: <Icon name="message-square" size={SIZE} />,+ },+ {+ id: "viewer-read-aloud",+ icon: <Icon name="volume-2" size={SIZE} />,+ },+ ],+];++export function ReaderRail() {+ const { t } = useTranslation();+ const { buttons, actions } = useWorkbenchBar();+ const { activeFileId, setActiveFileId } = useViewer();+ const { removeFiles } = useFileManagement();+ const { openFilesModal } = useFilesModalContext();+ const { requestNavigation } = useNavigationGuard();+ const { files, fileIds } = useAllFiles();++ // Resolved against the workbench's own ids, so a close cannot act on a document+ // the viewer has not caught up with.+ const openFileId = useMemo(+ () => fileIds.find((id) => (id as string) === activeFileId) ?? null,+ [fileIds, activeFileId],+ );++ // Through the guard, because closing what you are reading is a way out of it and+ // unsaved changes still deserve their prompt. Storage keeps its copy: this closes+ // the document, it does not delete it. Left pressable with nothing open, because+ // the rail cannot always tell, and a wrongly greyed-out control is the worse failure.+ const closeDocument = useCallback(() => {+ if (!openFileId) return;+ requestNavigation(() => {+ void removeFiles([openFileId], false);+ });+ }, [openFileId, removeFiles, requestNavigation]);++ const labels: Record<string, string> = useMemo(+ () => ({+ "viewer-toggle-bookmarks": t("reader.rail.bookmarks", "Bookmarks"),+ "viewer-toggle-sidebar": t("reader.rail.thumbnails", "Pages"),+ "viewer-search": t("reader.rail.search", "Find in document"),+ "viewer-rotate-left": t("reader.rail.rotateLeft", "Rotate left"),+ "viewer-rotate-right": t("reader.rail.rotateRight", "Rotate right"),+ "viewer-toggle-comments": t("reader.rail.comment", "Comments"),+ "viewer-read-aloud": t("reader.rail.readAloud", "Read aloud"),+ }),+ [t],+ );++ const closeLabel = t("reader.rail.close", "Close document");++ const documents = useMemo(+ () =>+ files+ .filter((file) => isStirlingFile(file))+ .map((file) => ({ id: file.fileId as string, name: file.name })),+ [files],+ );++ const registered = useMemo(+ () => new Map(buttons.map((button) => [button.id, button])),+ [buttons],+ );++ return (+ <nav+ className="reader-rail"+ aria-label={t("reader.rail.label", "Reading tools")}+ >+ {/* The document-level controls lead the rail; the groups below act on how it+ is read. */}+ <div className="reader-rail__group">+ <AppTooltip content={closeLabel} position="left" arrow delay={0}>+ <ActionIcon+ variant="tertiary"+ size="md"+ shape="circle"+ aria-label={closeLabel}+ onClick={closeDocument}+ >+ <Icon name="x" size={SIZE} />+ </ActionIcon>+ </AppTooltip>+ {/* Capped and scrolling: with enough documents open the list would run+ past the viewport and take Add file off the bottom with it. */}+ <Menu+ shadow="md"+ width={320}+ position="left-start"+ styles={{ dropdown: { maxHeight: "70vh", overflowY: "auto" } }}+ >+ <Menu.Target>+ {/* Labelled like every other control in the rail: icons only, so the+ tooltip is the only name a pointer ever sees. */}+ <AppTooltip+ content={t("reader.rail.switchDocument", "Switch document")}+ position="left"+ arrow+ delay={0}+ >+ <ActionIcon+ variant="tertiary"+ size="md"+ shape="circle"+ // The name is in the dropdown; the trigger says what it opens.+ aria-label={t("reader.rail.switchDocument", "Switch document")}+ >+ <Icon name="file-text" size={SIZE} />+ </ActionIcon>+ </AppTooltip>+ </Menu.Target>+ <Menu.Dropdown>+ {documents.map((doc) => (+ <Menu.Item+ key={doc.id}+ className="reader-rail__doc"+ // The stripe marks the one you are reading, so no tick column+ // has to sit beside every name.+ data-current={doc.id === activeFileId || undefined}+ onClick={() => setActiveFileId(doc.id)}+ >+ <span className="reader-rail__doc-name" title={doc.name}>+ {truncateCenter(doc.name, 48)}+ </span>+ </Menu.Item>+ ))}+ {documents.length > 0 && <Menu.Divider />}+ <Menu.Item+ leftSection={<Icon name="plus" size={SIZE} />}+ // The full library modal, as the home screen opens it: Stirling's+ // own files as well as the device.+ onClick={() => openFilesModal()}+ >+ {t("reader.rail.addDocument", "Add file")}+ </Menu.Item>+ </Menu.Dropdown>+ </Menu>+ <div className="reader-rail__divider" />+ </div>+ {RAIL_GROUPS.map((group, index) => (+ <div className="reader-rail__group" key={group[0].id}>+ {index > 0 && <div className="reader-rail__divider" />}+ {group.map((item) => {+ const label = labels[item.id] ?? item.id;+ const button = registered.get(item.id);+ const action = button ? actions[button.id] : undefined;++ // A control that brought its own renderer keeps it: that is where the+ // search field and the read-aloud controls live.+ if (button?.render) {+ return (+ <div className="reader-rail__item" key={item.id}>+ {button.render({+ id: button.id,+ disabled: Boolean(button.disabled),+ allButtonsDisabled: false,+ action,+ triggerAction: () => action?.(),+ active: Boolean(button.active),+ })}+ </div>+ );+ }++ return (+ <AppTooltip+ key={item.id}+ content={label}+ position="left"+ arrow+ // No delay: the rail is icons only, so the tooltip is the label.+ delay={0}+ >+ <ActionIcon+ variant={button?.active ? "primary" : "tertiary"}+ size="md"+ shape="circle"+ aria-label={label}+ aria-pressed={button?.active}+ // Nothing open means nothing to act on, but the rail keeps its shape.+ disabled={!action || Boolean(button?.disabled)}+ onClick={() => action?.()}+ >+ {item.icon}+ </ActionIcon>+ </AppTooltip>+ );+ })}+ </div>+ ))}+ </nav>+ );+}++export default ReaderRail;diff --git a/frontend/editor/src/core/components/viewer/readerRail/ReaderSuperSearch.css b/frontend/editor/src/core/components/viewer/readerRail/ReaderSuperSearch.cssnew file mode 100644index 0000000000..349b7087c0--- /dev/null+++ b/frontend/editor/src/core/components/viewer/readerRail/ReaderSuperSearch.css@@ -0,0 +1,26 @@+/* Floated over the document, clear of the rail on the trailing edge. Centred on+ the page the way the workbench bar's search is, so the shortcut lands where a+ reader already looks for it. */+.reader-super-search {+ position: fixed;+ top: calc(var(--nav-gutter) + env(safe-area-inset-top, 0px));+ left: 50%;+ transform: translateX(-50%);+ z-index: var(--z-popover);+ display: flex;+ justify-content: center;+ width: min(100%, 28rem);+ padding: 0 1rem;+}++.reader-super-search .super-search {+ flex: 1 1 auto;+ max-width: 26rem;+}++/* Painted, unlike the workbench bar's: here it sits on the page itself, which+ carries its own colour. */+.reader-super-search .super-search input {+ background-color: var(--c-surface);+ box-shadow: var(--shadow-lg);+}diff --git a/frontend/editor/src/core/components/viewer/readerRail/ReaderSuperSearch.tsx b/frontend/editor/src/core/components/viewer/readerRail/ReaderSuperSearch.tsxnew file mode 100644index 0000000000..53584f738c--- /dev/null+++ b/frontend/editor/src/core/components/viewer/readerRail/ReaderSuperSearch.tsx@@ -0,0 +1,68 @@+import { useCallback, useEffect, useRef, useState } from "react";++import SuperSearch from "@app/components/shared/superSearch/SuperSearch";+import { useEditorSearchScopes } from "@app/hooks/useSuperSearch";+import "@app/components/viewer/readerRail/ReaderSuperSearch.css";++/**+ * Super search over the document being read. The workbench bar that normally+ * carries it is not on screen here, and leaving reading to reach it is the jump+ * this surface exists to avoid, so Ctrl+K floats it over the page instead.+ *+ * Mounted only while open: the search binds Ctrl+K itself, so a hidden instance+ * would race this one for the shortcut and focus a box nobody can see.+ */+export function ReaderSuperSearch() {+ const scopes = useEditorSearchScopes();+ const [open, setOpen] = useState(false);+ const hostRef = useRef<HTMLDivElement>(null);++ useEffect(() => {+ const onKeyDown = (e: KeyboardEvent) => {+ const combo = (e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey;+ if (!combo || e.code !== "KeyK") return;+ // The same carve-out the search itself makes: a dialog owns the keyboard.+ if ((e.target as HTMLElement | null)?.closest?.('[role="dialog"]'))+ return;+ e.preventDefault();+ setOpen(true);+ };+ window.addEventListener("keydown", onKeyDown);+ return () => window.removeEventListener("keydown", onKeyDown);+ }, []);++ // The search opens and takes focus on this event, which it can only answer+ // once it has a box on screen to be focused in.+ useEffect(() => {+ if (!open) return;+ const handoff = requestAnimationFrame(() =>+ window.dispatchEvent(new Event("superSearch:focus")),+ );+ return () => cancelAnimationFrame(handoff);+ }, [open]);++ // Focus leaving closes it. The dropdown keeps focus on the input while it is+ // clicked, so reaching a result never counts as leaving.+ const handleBlur = useCallback((event: React.FocusEvent<HTMLDivElement>) => {+ const next = event.relatedTarget as Node | null;+ if (next && event.currentTarget.contains(next)) return;+ setOpen(false);+ }, []);++ if (!open) return null;++ return (+ <div+ ref={hostRef}+ className="reader-super-search"+ onBlur={handleBlur}+ onKeyDown={(e) => {+ if (e.key === "Escape") setOpen(false);+ }}+ >+ <SuperSearch scopes={scopes} />+ </div>+ );+}++export default ReaderSuperSearch;diff --git a/frontend/editor/src/core/components/viewer/useViewerWorkbenchBarButtons.tsx b/frontend/editor/src/core/components/viewer/useViewerWorkbenchBarButtons.tsxindex 17029062cf..31f8c0c88e 100644--- a/frontend/editor/src/core/components/viewer/useViewerWorkbenchBarButtons.tsx+++ b/frontend/editor/src/core/components/viewer/useViewerWorkbenchBarButtons.tsx@@ -306,7 +306,7 @@ export function useViewerWorkbenchBarButtons(},{id: "viewer-toggle-sidebar",- icon: <Icon name="list" size="1rem" />,+ icon: <Icon name="rows-2" size="1rem" />,tooltip: sidebarLabel,ariaLabel: sidebarLabel,section: "top" as const,diff --git a/frontend/editor/src/core/contexts/FilesPageContext.tsx b/frontend/editor/src/core/contexts/FilesPageContext.tsxindex ca8e3d443d..c1b82ff9d5 100644--- a/frontend/editor/src/core/contexts/FilesPageContext.tsx+++ b/frontend/editor/src/core/contexts/FilesPageContext.tsx@@ -75,6 +75,22 @@ export interface MoveDialogState {initial: FolderId | null;}+const VIEW_MODE_STORAGE_KEY = "stirling.filesPageViewMode";++/**+ * The list is the default: it shows more files per screen and carries the columns the+ * grid has no room for.+ */+function readPersistedViewMode(): FilesPageViewMode {+ try {+ const stored = localStorage.getItem(VIEW_MODE_STORAGE_KEY);+ if (stored === "grid" || stored === "list") return stored;+ } catch {+ // Private mode, or storage denied: the default stands.+ }+ return "list";+}+interface FilesPageContextValue {// Cached files (leaf-only)allFiles: StirlingFileStub[];@@ -266,7 +282,17 @@ export function FilesPageProvider({ children }: { children: React.ReactNode }) {}, [folders.currentFolderId, clearSelection]);// View + sort + search + filters ----------------------------------------- const [viewMode, setViewMode] = useState<FilesPageViewMode>("grid");+ const [viewMode, setViewModeState] = useState<FilesPageViewMode>(+ readPersistedViewMode,+ );+ const setViewMode = useCallback((mode: FilesPageViewMode) => {+ setViewModeState(mode);+ try {+ localStorage.setItem(VIEW_MODE_STORAGE_KEY, mode);+ } catch {+ // A browser that refuses storage still gets the choice for this session.+ }+ }, []);const [sortMode, setSortMode] = useState<FilesPageSortMode>("modified-desc");const [search, setSearch] = useState("");const [originFilter, setOriginFilter] =diff --git a/frontend/editor/src/core/contexts/SidebarContext.tsx b/frontend/editor/src/core/contexts/SidebarContext.tsxindex ce0e5184bb..565b8c3352 100644--- a/frontend/editor/src/core/contexts/SidebarContext.tsx+++ b/frontend/editor/src/core/contexts/SidebarContext.tsx@@ -15,7 +15,6 @@ export function SidebarProvider({ children }: SidebarProviderProps) {const quickAccessRef = useRef<HTMLDivElement>(null);const toolPanelRef = useRef<HTMLDivElement>(null);- const [sidebarsVisible, setSidebarsVisible] = useState(true);const [leftPanelView, setLeftPanelView] = useState<"toolPicker" | "toolContent">("toolPicker");@@ -23,11 +22,10 @@ export function SidebarProvider({ children }: SidebarProviderProps) {const sidebarState: SidebarState = useMemo(() => ({- sidebarsVisible,leftPanelView,readerMode,}),- [sidebarsVisible, leftPanelView, readerMode],+ [leftPanelView, readerMode],);const sidebarRefs: SidebarRefs = useMemo(@@ -42,17 +40,10 @@ export function SidebarProvider({ children }: SidebarProviderProps) {() => ({sidebarState,sidebarRefs,- setSidebarsVisible,setLeftPanelView,setReaderMode,}),- [- sidebarState,- sidebarRefs,- setSidebarsVisible,- setLeftPanelView,- setReaderMode,- ],+ [sidebarState, sidebarRefs, setLeftPanelView, setReaderMode],);return (diff --git a/frontend/editor/src/core/contexts/ToolWorkflowContext.tsx b/frontend/editor/src/core/contexts/ToolWorkflowContext.tsxindex 6365273039..0fa0555d17 100644--- a/frontend/editor/src/core/contexts/ToolWorkflowContext.tsx+++ b/frontend/editor/src/core/contexts/ToolWorkflowContext.tsx@@ -33,6 +33,7 @@ import { stripBasePath } from "@app/constants/app";import { EDITOR_BASENAME } from "@app/routes/editorBasename";import { filterToolRegistryByQuery } from "@app/utils/toolSearch";import { useToolHistory } from "@app/hooks/tools/useUserToolActivity";+import { markReaderModeFromPreference } from "@app/utils/pendingReaderMode";import {ToolWorkflowState,createInitialState,@@ -72,8 +73,7 @@ interface ToolWorkflowContextValue extends ToolWorkflowState {toolAvailability: ToolAvailabilityMap;// UI Actions- setSidebarsVisible: (visible: boolean) => void;- setLeftPanelView: (view: "toolPicker" | "toolContent" | "hidden") => void;+ setLeftPanelView: (view: "toolPicker" | "toolContent") => void;setReaderMode: (mode: boolean) => void;setToolPanelMode: (mode: ToolPanelMode) => void;setPreviewFile: (file: File | null) => void;@@ -105,7 +105,6 @@ interface ToolWorkflowContextValue extends ToolWorkflowState {item: [ToolId, ToolRegistryEntry];matchedText?: string;}>; // Filtered by search- isPanelVisible: boolean;// Tool HistoryfavoriteTools: ToolId[];@@ -151,8 +150,7 @@ export interface ToolWorkflowActionsValue {handleToolSelectForced: (toolId: ToolId) => void;handleBackToTools: () => void;handleReaderToggle: () => void;- setSidebarsVisible: (visible: boolean) => void;- setLeftPanelView: (view: "toolPicker" | "toolContent" | "hidden") => void;+ setLeftPanelView: (view: "toolPicker" | "toolContent") => void;setReaderMode: (mode: boolean) => void;setToolPanelMode: (mode: ToolPanelMode) => void;setPreviewFile: (file: File | null) => void;@@ -221,17 +219,10 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {const selectedTool = getSelectedTool(navigationState.selectedTool);// UI Action creators- const setSidebarsVisible = useCallback((visible: boolean) => {- dispatch({ type: "SET_SIDEBARS_VISIBLE", payload: visible });+ const setLeftPanelView = useCallback((view: "toolPicker" | "toolContent") => {+ dispatch({ type: "SET_LEFT_PANEL_VIEW", payload: view });}, []);- const setLeftPanelView = useCallback(- (view: "toolPicker" | "toolContent" | "hidden") => {- dispatch({ type: "SET_LEFT_PANEL_VIEW", payload: view });- },- [],- );-const setReaderMode = useCallback((mode: boolean) => {if (mode) {@@ -422,6 +413,7 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {if (startupView === "read") {hasAppliedStartupView.current = true;startupSelectedToolRef.current = "read";+ markReaderModeFromPreference();setReaderMode(true);actions.setSelectedTool("read");} else if (startupView === "automate") {@@ -441,29 +433,6 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {setLeftPanelView,]);- // When in multi-tool, sync left panel visibility with workbench:- // hide the panel on pageEditor, show it when navigating to viewer/fileEditor.- const prevMultiToolWorkbenchRef = React.useRef<WorkbenchType | null>(null);- useEffect(() => {- const prev = prevMultiToolWorkbenchRef.current;- prevMultiToolWorkbenchRef.current = navigationState.workbench;-- if (navigationState.selectedTool !== "multiTool") return;-- if (navigationState.workbench === "pageEditor" && prev !== "pageEditor") {- setLeftPanelView("hidden");- } else if (- navigationState.workbench !== "pageEditor" &&- prev === "pageEditor"- ) {- setLeftPanelView("toolPicker");- }- }, [- navigationState.workbench,- navigationState.selectedTool,- setLeftPanelView,- ]);-// Tool reset methodsconst registerToolReset = useCallback((toolId: string, resetFunction: () => void) => {@@ -532,7 +501,9 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {// Handle multiTool selection - enable page editor workbenchif (toolId === "multiTool") {setReaderMode(false);- setLeftPanelView("hidden");+ // The page editor is the tool, so the panel beside it stays on the picker:+ // left on toolContent it would render this tool's header over no body.+ setLeftPanelView("toolPicker");actions.setSelectedTool("multiTool");actions.setWorkbench(wasInCustomWorkbench ? getDefaultWorkbench() : "pageEditor",@@ -612,14 +583,6 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {return filterToolRegistryByQuery(toolRegistry, state.searchQuery);}, [toolRegistry, state.searchQuery]);- const isPanelVisible = useMemo(- () =>- state.sidebarsVisible &&- !state.readerMode &&- state.leftPanelView !== "hidden",- [state.sidebarsVisible, state.readerMode, state.leftPanelView],- );-useNavigationUrlSync(navigationState.selectedTool,handleToolSelect,@@ -700,7 +663,6 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {handleToolSelectForced: stableHandleToolSelectForced,handleBackToTools: stableHandleBackToTools,handleReaderToggle: stableHandleReaderToggle,- setSidebarsVisible,setLeftPanelView,setReaderMode: stableSetReaderMode,setToolPanelMode: stableSetToolPanelMode,@@ -719,7 +681,6 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {stableHandleToolSelectForced,stableHandleBackToTools,stableHandleReaderToggle,- setSidebarsVisible,setLeftPanelView,stableSetReaderMode,stableSetToolPanelMode,@@ -759,7 +720,6 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {getSelectedTool,// Actions- setSidebarsVisible,setLeftPanelView,setReaderMode,setToolPanelMode,@@ -784,7 +744,6 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {// ComputedfilteredTools,- isPanelVisible,// Tool HistoryfavoriteTools,@@ -805,7 +764,6 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {toolRegistry,getSelectedTool,toolAvailability,- setSidebarsVisible,setLeftPanelView,setReaderMode,setToolPanelMode,@@ -819,7 +777,6 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {handleBackToTools,handleReaderToggle,filteredTools,- isPanelVisible,favoriteTools,toggleFavorite,isFavorite,diff --git a/frontend/editor/src/core/contexts/toolWorkflow/toolWorkflowState.ts b/frontend/editor/src/core/contexts/toolWorkflow/toolWorkflowState.tsindex 2c55315ccb..8daf383334 100644--- a/frontend/editor/src/core/contexts/toolWorkflow/toolWorkflowState.ts+++ b/frontend/editor/src/core/contexts/toolWorkflow/toolWorkflowState.ts@@ -1,11 +1,12 @@import { PageEditorFunctions } from "@app/types/pageEditor";import { type ToolPanelMode } from "@app/constants/toolPanel";import { preferencesService } from "@app/services/preferencesService";+import { stripBasePath } from "@app/constants/app";+import { READER_PATH } from "@app/routes/readerRoute";export interface ToolWorkflowState {// UI State- sidebarsVisible: boolean;- leftPanelView: "toolPicker" | "toolContent" | "hidden";+ leftPanelView: "toolPicker" | "toolContent";readerMode: boolean;toolPanelMode: ToolPanelMode;@@ -18,10 +19,9 @@ export interface ToolWorkflowState {// Actionsexport type ToolWorkflowAction =- | { type: "SET_SIDEBARS_VISIBLE"; payload: boolean }| {type: "SET_LEFT_PANEL_VIEW";- payload: "toolPicker" | "toolContent" | "hidden";+ payload: "toolPicker" | "toolContent";}| { type: "SET_READER_MODE"; payload: boolean }| { type: "SET_TOOL_PANEL_MODE"; payload: ToolPanelMode }@@ -31,7 +31,6 @@ export type ToolWorkflowAction =| { type: "RESET_UI_STATE" };export const baseState: Omit<ToolWorkflowState, "toolPanelMode"> = {- sidebarsVisible: true,leftPanelView: "toolPicker",readerMode: false,previewFile: null,@@ -39,8 +38,19 @@ export const baseState: Omit<ToolWorkflowState, "toolPanelMode"> = {searchQuery: "",};+/**+ * Reading is seeded from the path rather than switched on by an effect after the+ * first paint, so a reload at the reader's own URL never paints the editor and+ * then animates it away.+ */+function startsInReader(): boolean {+ if (typeof window === "undefined") return false;+ return stripBasePath(window.location.pathname).startsWith(READER_PATH);+}+export const createInitialState = (): ToolWorkflowState => ({...baseState,+ readerMode: startsInReader(),toolPanelMode: preferencesService.getPreference("defaultToolPanelMode"),});@@ -49,8 +59,6 @@ export function toolWorkflowReducer(action: ToolWorkflowAction,): ToolWorkflowState {switch (action.type) {- case "SET_SIDEBARS_VISIBLE":- return { ...state, sidebarsVisible: action.payload };case "SET_LEFT_PANEL_VIEW":return { ...state, leftPanelView: action.payload };case "SET_READER_MODE":diff --git a/frontend/editor/src/core/pages/HomePage.tsx b/frontend/editor/src/core/pages/HomePage.tsxindex ec4f2aaa41..62230b0fc1 100644--- a/frontend/editor/src/core/pages/HomePage.tsx+++ b/frontend/editor/src/core/pages/HomePage.tsx@@ -27,8 +27,11 @@ import {import { isApplyingRestoredView } from "@app/services/workbenchSession";import { useViewer } from "@app/contexts/ViewerContext";import { useLocation, useNavigate } from "react-router-dom";+import { Icon } from "@app/ui/Icon";import RightSidebar from "@app/components/tools/RightSidebar";+import { ReaderRail } from "@app/components/viewer/readerRail/ReaderRail";+import { ReaderSuperSearch } from "@app/components/viewer/readerRail/ReaderSuperSearch";import Workbench from "@app/components/layout/Workbench";import FileSidebar from "@app/components/shared/FileSidebar";import FileManager from "@app/components/FileManager";@@ -37,6 +40,7 @@ import {getDefaultWorkbenchForFileCount,} from "@app/utils/homePageNavigation";import { EDITOR_BASENAME } from "@app/routes/editorBasename";+import { READER_PATH } from "@app/routes/readerRoute";import { rememberSettingsOrigin } from "@app/utils/settingsNavigation";import { HomePageExtensions } from "@app/components/home/HomePageExtensions";import { PolicyAutoRunController } from "@app/components/policies/PolicyAutoRunController";@@ -47,7 +51,10 @@ import {getToolDisabledReason,getDisabledLabel,} from "@app/components/tools/fullscreen/shared";-import { consumeReaderModeRequest } from "@app/utils/pendingReaderMode";+import {+ consumeReaderModeFromPreference,+ consumeReaderModeRequest,+} from "@app/utils/pendingReaderMode";import {FilesPageProvider,useFilesPage,@@ -70,9 +77,28 @@ import { Button } from "@app/ui/Button";import "@app/components/layout/WorkspaceFrame.css";import "@app/pages/HomePage.css";-const SIDEBAR_COLLAPSED_STORAGE_KEY = "stirling.fileSidebarCollapsed";const SWIPE_HINT_SEEN_STORAGE_KEY = "stirling.mobileSwipeHintSeen";+/**+ * The wings' slide is `--wings-ms` (dimensions.css). Read from the document so one+ * value drives both, with the literal as the fallback for a test environment that+ * loads no stylesheet, and a frame of headroom so the unmount never clips the+ * last frame of the animation.+ */+const WINGS_FALLBACK_MS = 220;+const WINGS_HEADROOM_MS = 60;++function wingsDurationMs(): number {+ if (typeof window === "undefined") return WINGS_FALLBACK_MS;+ const token = window+ .getComputedStyle(document.documentElement)+ .getPropertyValue("--wings-ms")+ .trim();+ const parsed = Number.parseFloat(token);+ if (!Number.isFinite(parsed) || parsed <= 0) return WINGS_FALLBACK_MS;+ return token.endsWith("ms") ? parsed : parsed * 1000;+}+function readSwipeHintSeen(): boolean {try {return window.localStorage.getItem(SWIPE_HINT_SEEN_STORAGE_KEY) === "true";@@ -81,27 +107,6 @@ function readSwipeHintSeen(): boolean {}}-function readPersistedSidebarCollapsed(): boolean {- try {- return (- window.localStorage.getItem(SIDEBAR_COLLAPSED_STORAGE_KEY) === "true"- );- } catch {- return false;- }-}--function writePersistedSidebarCollapsed(collapsed: boolean): void {- try {- window.localStorage.setItem(- SIDEBAR_COLLAPSED_STORAGE_KEY,- String(collapsed),- );- } catch {- // private mode / quota: silently no-op- }-}-type MobileView = "tools" | "workbench";export default function HomePage() {@@ -141,13 +146,6 @@ export default function HomePage() {processingFolderCreation.open();}}, [location.key, processingFolderCreation.open]);- // 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.- () => readerMode || readPersistedSidebarCollapsed(),- );// Settings is its own page; it restores the recorded origin on Back.const openSettings = useCallback(() => {@@ -170,37 +168,24 @@ export default function HomePage() {const { searchInterfaceActions } = useViewer();- // Reading hides both search controls, so leave it first. e.code, for non-QWERTY layouts.- const focusSearchAfterRestore = useRef(false);+ // Find in document lives in the rail, not the bar reading hides, so the+ // shortcut opens it where the reader already is. e.code, for non-QWERTY+ // layouts. Ctrl+K belongs to ReaderSuperSearch, which floats the global+ // search over the page rather than leaving reading to reach it.useEffect(() => {if (!readerMode) return;const onKeyDown = (e: KeyboardEvent) => {const combo = (e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey;- if (!combo) return;- if (e.code !== "KeyK" && e.code !== "KeyF") return;+ if (!combo || e.code !== "KeyF") return;// Same carve-out the search itself makes: a dialog owns the keyboard.if ((e.target as HTMLElement | null)?.closest?.('[role="dialog"]'))return;e.preventDefault();- setReaderMode(false);- if (e.code === "KeyK") {- focusSearchAfterRestore.current = true;- return;- }- // Visibility is state, so it can open before the bar it renders in exists.searchInterfaceActions.open();};window.addEventListener("keydown", onKeyDown);return () => window.removeEventListener("keydown", onKeyDown);- }, [readerMode, setReaderMode, searchInterfaceActions]);-- useEffect(() => {- if (readerMode || !focusSearchAfterRestore.current) return;- focusSearchAfterRestore.current = false;- requestAnimationFrame(() =>- window.dispatchEvent(new Event("superSearch:focus")),- );- }, [readerMode]);+ }, [readerMode, searchInterfaceActions]);// Clean slate: no tool, out of the file library and reading.const goToDefaultState = useCallback(() => {@@ -241,22 +226,67 @@ export default function HomePage() {const onFilesPath = location.pathname.startsWith("/files");if (inLibrary && !onFilesPath) {navigate("/files");- } else if (!inLibrary && onFilesPath) {+ } else if (!inLibrary && onFilesPath && !readerMode) {+ // Reading also leaves the library, and its own effect names the path it+ // leaves for. Both navigating puts the editor between the two in history,+ // so Back out of reading would land somewhere the user never went.navigate(EDITOR_BASENAME);}- }, [navigationState.workbench, location.pathname, navigate]);+ }, [navigationState.workbench, location.pathname, navigate, readerMode]);- // Imperative, so the toggle still works while reading. Never persisted: not a preference.- const prevReaderModeRef = useRef(readerMode);+ // Path moved, so the path is the cause. The ref starts null so mount counts too:+ // that is what makes a reload land back in reading, and what takes you out of it+ // when the library moves the path to its own.+ const readerDerivedFromPath = useRef<string | null>(null);useEffect(() => {- if (readerMode !== prevReaderModeRef.current) {- setFileSidebarCollapsed(- readerMode ? true : readPersistedSidebarCollapsed(),- );- prevReaderModeRef.current = readerMode;+ if (readerDerivedFromPath.current === location.pathname) return;+ readerDerivedFromPath.current = location.pathname;+ const onReadPath = location.pathname.startsWith(READER_PATH);+ if (onReadPath !== readerMode) setReaderMode(onReadPath);+ }, [location.pathname, readerMode, setReaderMode]);++ // The wings animate off their own edge, so the unmount waits out the leave rather+ // than happening with it. The rails' stylesheets take them out of flow while it+ // runs, so what is underneath is already in its reading position and nothing+ // reflows twice.+ const [wingsMounted, setWingsMounted] = useState(!readerMode);+ const [wingsPhase, setWingsPhase] = useState<"leaving" | "returning" | null>(+ null,+ );+ const readingRef = useRef(readerMode);+ useEffect(() => {+ if (readingRef.current === readerMode) return;+ readingRef.current = readerMode;+ const slide = wingsDurationMs() + WINGS_HEADROOM_MS;+ if (readerMode) {+ setWingsPhase("leaving");+ const gone = window.setTimeout(() => {+ setWingsPhase(null);+ setWingsMounted(false);+ }, slide);+ return () => window.clearTimeout(gone);}+ setWingsMounted(true);+ setWingsPhase("returning");+ const settled = window.setTimeout(() => setWingsPhase(null), slide);+ return () => window.clearTimeout(settled);}, [readerMode]);+ // Reading moved, so the path follows. Pushed, not replaced, so Back leaves it.+ const wasReadingRef = useRef(readerMode);+ useEffect(() => {+ if (readerMode === wasReadingRef.current) return;+ wasReadingRef.current = readerMode;+ const onReadPath = location.pathname.startsWith(READER_PATH);+ if (readerMode && !onReadPath) {+ navigate(READER_PATH, {+ replace: consumeReaderModeFromPreference(),+ });+ } else if (!readerMode && onReadPath) {+ navigate(EDITOR_BASENAME);+ }+ }, [readerMode, location.pathname, navigate]);+const { setActiveFileIndex } = useViewer();const prevFileCountRef = useRef(activeFiles.length);@@ -324,15 +354,6 @@ export default function HomePage() {return reasons;}, [toolRegistry, toolAvailability, config?.premiumEnabled, t]);- // The collapse is a preference, so it is written as one; every view reads it back.- const handleSidebarToggle = useCallback(() => {- setFileSidebarCollapsed((c) => {- const next = !c;- writePersistedSidebarCollapsed(next);- return next;- });- }, []);-const openFromComputerRef = useRef<(() => void) | null>(null);const registerOpenFromComputer = useCallback((open: (() => void) | null) => {openFromComputerRef.current = open;@@ -693,20 +714,28 @@ export default function HomePage() {h="100%"className="flex-nowrap flex"bg="var(--c-bg)"+ data-wings={wingsPhase ?? undefined}>- <div className="workspace-frame">- <MyFilesAwareFileSidebar- ref={quickAccessRef}- accountHoisted- active={navigationState.workbench === "myFiles"}- collapsed={fileSidebarCollapsed}- onToggleCollapse={handleSidebarToggle}- onOpenSettings={openSettings}- onRegisterOpenFromComputer={registerOpenFromComputer}- />- </div>+ {/* Reading leaves the document and nothing beside it, so the wing goes+ rather than shrinking to a rail. Everywhere else it is fixed open. */}+ {wingsMounted && (+ <div className="workspace-frame">+ <MyFilesAwareFileSidebar+ ref={quickAccessRef}+ accountHoisted+ active={navigationState.workbench === "myFiles"}+ onOpenSettings={openSettings}+ onRegisterOpenFromComputer={registerOpenFromComputer}+ />+ </div>+ )}<Workbench />- {!hideToolPanel && <RightSidebar />}+ {/* The reader's rail takes the slot the tool panel holds otherwise: the+ panel's controls are the editor's, and reading wants the viewer's.+ Both render together only while the panel is on its way out. */}+ {wingsMounted && !hideToolPanel && <RightSidebar />}+ {readerMode && <ReaderRail />}+ {readerMode && <ReaderSuperSearch />}<FileManager selectedTool={selectedTool} /></Group>)}@@ -799,10 +828,9 @@ const MyFilesSidebarOverrides = forwardRef<HTMLDivElement, FileSidebarProps>(// 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 }) => (+ render: () => (<NewFolderButtontrigger="row"- collapsed={collapsed}testId="files-rail-new-folder"label={t("filesPage.newFolder", "New folder")}disabledReason={newFolderDisabledReason}diff --git a/frontend/editor/src/core/routes/readerRoute.ts b/frontend/editor/src/core/routes/readerRoute.tsnew file mode 100644index 0000000000..4b945de544--- /dev/null+++ b/frontend/editor/src/core/routes/readerRoute.ts@@ -0,0 +1,12 @@+/**+ * Path that names the reading surface, so a reload lands back in it and the URL+ * can be bookmarked as "open this in the reader".+ *+ * Not "/read": that is the Read tool's own alias in URL_TO_TOOL_MAP, and a reload+ * there selects the tool as well as the surface.+ *+ * Bare rather than under the editor's basename, like the file library's own path:+ * both are surfaces reached from the rail rather than places inside the editor, so+ * neither moves when a build gives the editor a basename of its own.+ */+export const READER_PATH = "/reader";diff --git a/frontend/editor/src/core/tests/helpers/stub-test-base.ts b/frontend/editor/src/core/tests/helpers/stub-test-base.tsindex e8c4467811..7c9afc163e 100644--- a/frontend/editor/src/core/tests/helpers/stub-test-base.ts+++ b/frontend/editor/src/core/tests/helpers/stub-test-base.ts@@ -44,6 +44,8 @@ type StubFixtures = {stubOptions: MockAppApiOptions;autoGoto: false | string;seedJwt: boolean;+ /** The library's view. Set it where a test reads cards or rows by shape. */+ filesViewMode: "grid" | "list" | null;};// Minimal JWT-shaped value — the proprietary auth client only checks for@@ -58,8 +60,12 @@ export const test = base.extend<StubFixtures>({// the app instead of racing a redirect on every single test.autoGoto: ["/editor", { option: true }],seedJwt: [false, { option: true }],+ filesViewMode: [null, { option: true }],- page: async ({ page, stubOptions, autoGoto, seedJwt }, use) => {+ page: async (+ { page, stubOptions, autoGoto, seedJwt, filesViewMode },+ use,+ ) => {suppressNativeFilePicker(page);await seedCookieConsent(page);await bypassOnboarding(page);@@ -68,6 +74,11 @@ export const test = base.extend<StubFixtures>({localStorage.setItem("stirling_jwt", token);}, STUB_JWT);}+ if (filesViewMode) {+ await page.addInitScript((mode) => {+ localStorage.setItem("stirling.filesPageViewMode", mode);+ }, filesViewMode);+ }await mockAppApis(page, stubOptions);if (autoGoto !== false) {// waitUntil: 'domcontentloaded' avoids hanging on third-party CDNdiff --git a/frontend/editor/src/core/tests/stubbed/comments-sidebar-order.spec.ts b/frontend/editor/src/core/tests/stubbed/comments-sidebar-order.spec.tsindex 91206b1222..2504643b61 100644--- a/frontend/editor/src/core/tests/stubbed/comments-sidebar-order.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/comments-sidebar-order.spec.ts@@ -18,7 +18,7 @@ test.describe("Comments sidebar - annotation reading order", () => {test("annotations on each page are listed in visual reading order", async ({page,}) => {- await page.goto("/read");+ await page.goto("/");await page.waitForLoadState("domcontentloaded");// Upload the test fixture via the hidden file input (avoids the native@@ -28,6 +28,10 @@ test.describe("Comments sidebar - annotation reading order", () => {.first().setInputFiles(ANNOTATED_PDF);+ // Then into reading, which is a surface of its own: the sidebar that owns+ // the input above is not on screen once you are in it.+ await page.getByRole("button", { name: "Reader", exact: true }).click();+// Sanity-check that the page indicator reflects a 3-page document.await expect(page.getByText(/\/\s*3/)).toBeVisible({ timeout: 30_000 });diff --git a/frontend/editor/src/core/tests/stubbed/disk-link-capture.spec.ts b/frontend/editor/src/core/tests/stubbed/disk-link-capture.spec.tsindex 64349001fd..53ab44f671 100644--- a/frontend/editor/src/core/tests/stubbed/disk-link-capture.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/disk-link-capture.spec.ts@@ -14,6 +14,9 @@ import {import fs from "node:fs";import path from "node:path";+// Reads the library as cards, so it asks for the grid.+test.use({ filesViewMode: "grid" });+/** Capture harness, not a regression test: fakes Tauri IPC over an in-memory disk.* Needs `vite --mode desktop` (for desktopFileLinkingSupported) and SHOT_DIR set. */diff --git a/frontend/editor/src/core/tests/stubbed/disk-link-regressions.spec.ts b/frontend/editor/src/core/tests/stubbed/disk-link-regressions.spec.tsindex ad442fbb8f..8dea757dcb 100644--- a/frontend/editor/src/core/tests/stubbed/disk-link-regressions.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/disk-link-regressions.spec.ts@@ -15,6 +15,9 @@ import {import fs from "node:fs";import path from "node:path";+// Reads the library as cards, so it asks for the grid.+test.use({ filesViewMode: "grid" });+// The three ways an external edit could still cost the user work, driven through// the real desktop build rather than asserted on the units underneath it.// Needs `vite --mode desktop`: on any other build desktopFileLinkingSupported isdiff --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 6e62cd810e..9695a36d6a 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@@ -3,6 +3,9 @@ import type { Page } from "@playwright/test";import { test, expect } from "@app/tests/helpers/stub-test-base";import { uploadFiles } from "@app/tests/helpers/ui-helpers";+// Reads the library as cards, so it asks for the grid.+test.use({ filesViewMode: "grid" });+// Per-file actions live behind a kebab on two surfaces - the file sidebar and// the My Files grid. They must offer the same file actions on both.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.tsindex c24b6e9cf7..73ab43fb8a 100644--- a/frontend/editor/src/core/tests/stubbed/file-library-view.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/file-library-view.spec.ts@@ -37,7 +37,7 @@ test.describe("The file library behaves like the other views", () => {await railButton(page, /^Reader$/i).click();await expect(page).not.toHaveURL(/\/files/);await expect(railButton(page, /^Reader$/i)).toHaveAttribute(- "aria-pressed",+ "aria-current","true",);});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 458bfdf0cc..ddd274c175 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@@ -2,6 +2,9 @@ import { test, expect } from "@app/tests/helpers/stub-test-base";import { uploadFiles } from "@app/tests/helpers/ui-helpers";import path from "path";+// Reads the library as cards, so it asks for the grid.+test.use({ filesViewMode: "grid" });+const FIXTURES_DIR = path.join(import.meta.dirname, "../test-fixtures");const SAMPLE_PDF = path.join(FIXTURES_DIR, "sample.pdf");diff --git a/frontend/editor/src/core/tests/stubbed/files-page-screenshots.spec.ts b/frontend/editor/src/core/tests/stubbed/files-page-screenshots.spec.tsindex f4948945fe..1f0172cc94 100644--- a/frontend/editor/src/core/tests/stubbed/files-page-screenshots.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/files-page-screenshots.spec.ts@@ -145,6 +145,7 @@ test.describe("Files page screenshots", () => {// create-folder, the seeded "Reports" folder) only render once a confirmed,// non-anonymous user triggers the folder pull (see FolderContext gating).test.use({+ filesViewMode: "grid",autoGoto: false,viewport: { width: 1600, height: 900 },seedJwt: true,diff --git a/frontend/editor/src/core/tests/stubbed/files-page.spec.ts b/frontend/editor/src/core/tests/stubbed/files-page.spec.tsindex a4e6620309..fb0128c144 100644--- a/frontend/editor/src/core/tests/stubbed/files-page.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/files-page.spec.ts@@ -179,6 +179,9 @@ async function gotoFilesPage(page: Page): Promise<void> {}test.describe("Files page", () => {+ // Most of these read the library as cards.+ test.use({ filesViewMode: "grid" });+test.describe("Selection model", () => {test.beforeEach(async ({ page }) => {await stubStorageApis(page);@@ -1024,6 +1027,61 @@ test.describe("Files page", () => {});});+ test.describe("List view", () => {+ test.use({ autoGoto: false, filesViewMode: null });++ const FOLDER = "11111111-2222-4333-8444-555555555595";++ /** The library opens as a list, and remembers the grid once it is chosen. */+ test("is where the library starts, and the choice sticks", async ({+ page,+ }) => {+ await stubStorageApis(page);+ await seedFiles(page, [+ { id: "l-1", name: "l-1.pdf", remoteStorageId: null },+ ]);+ await page.goto("/files", { waitUntil: "domcontentloaded" });++ await expect(page.locator(".files-page-list-row").first()).toBeVisible({+ timeout: 15_000,+ });+ await expect(page.locator(".files-page-card")).toHaveCount(0);++ await page+ .locator('.files-page-view-toggle-icon[title="Grid view"]')+ .first()+ .click();+ await expect(page.locator(".files-page-card").first()).toBeVisible();++ await page.reload({ waitUntil: "domcontentloaded" });+ await expect(page.locator(".files-page-card").first()).toBeVisible({+ timeout: 15_000,+ });+ });++ /** A processing folder tells the same story in either view. */+ test("a processing folder carries its counts in a row", async ({+ page,+ }) => {+ await stubStorageApis(page);+ await seedFiles(+ page,+ [{ id: "l-2", name: "l-2.pdf", remoteStorageId: null }],+ [{ id: FOLDER, name: "Scans" }],+ );+ await page.goto("/files", { waitUntil: "domcontentloaded" });++ const row = page+ .locator(".files-page-list-row")+ .filter({ hasText: "Scans" });+ await expect(row).toBeVisible({ timeout: 15_000 });+ await row.getByRole("button", { name: /folder actions/i }).click();+ await expect(+ page.getByRole("menuitem", { name: /Process files in this folder/i }),+ ).toBeVisible();+ });+ });+test.describe("Library chrome placement", () => {test.use({ autoGoto: false });diff --git a/frontend/editor/src/core/tests/stubbed/main-dashboard.spec.ts b/frontend/editor/src/core/tests/stubbed/main-dashboard.spec.tsindex babcbe4272..07f7f32453 100644--- a/frontend/editor/src/core/tests/stubbed/main-dashboard.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/main-dashboard.spec.ts@@ -23,8 +23,12 @@ test.describe("2. Main Dashboard / Home Page", () => {// Tool search lives in the global super search bar, always mounted.await expect(page.getByPlaceholder(/search/i).first()).toBeVisible();+ // Both wings are fixed open, so they are on screen with nothing to press.await expect(- page.getByRole("button", { name: /fullscreen|sidebar/i }).first(),+ page.locator('[data-sidebar="file-sidebar"]').first(),+ ).toBeVisible();+ await expect(+ page.locator('[data-sidebar="tool-panel"]').first(),).toBeVisible();const categories = [diff --git a/frontend/editor/src/core/tests/stubbed/pdf-text-search.spec.ts b/frontend/editor/src/core/tests/stubbed/pdf-text-search.spec.tsindex 89d2fcfcce..55324a13be 100644--- a/frontend/editor/src/core/tests/stubbed/pdf-text-search.spec.ts+++ b/frontend/editor/src/core/tests/stubbed/pdf-text-search.spec.ts@@ -16,7 +16,7 @@ test.describe("Reader - in-document text search", () => {test("search input is reachable from the reader and accepts a query", async ({page,}) => {- await page.goto("/read");+ await page.goto("/");await page.waitForLoadState("domcontentloaded");// Upload a PDF first so the reader has content. The `files-button` native@@ -25,6 +25,16 @@ test.describe("Reader - in-document text search", () => {await page.getByTestId("files-button").click();await page.locator('[data-testid="file-input"]').setInputFiles(SAMPLE_PDF);+ // The rail takes its controls from the viewer, so the document has to be+ // open before reading has a search to reach.+ await expect(page.getByText(/\/\s*\d+/).first()).toBeVisible({+ timeout: 30_000,+ });++ // Then into reading, which is a surface of its own: the sidebar that+ // carries the upload control above is not on screen once you are in it.+ await page.getByRole("button", { name: "Reader", exact: true }).click();+// The WorkbenchBar exposes a "Search PDF" button (aria-label="Search PDF")// that opens a Popover with the in-document search input.// We target this button specifically to avoid matching the FileSidebar'sdiff --git a/frontend/editor/src/core/theme/dimensions.css b/frontend/editor/src/core/theme/dimensions.cssindex 50531641cb..8b1f17abae 100644--- a/frontend/editor/src/core/theme/dimensions.css+++ b/frontend/editor/src/core/theme/dimensions.css@@ -63,6 +63,9 @@--motion-spring: 0.22s cubic-bezier(0.32, 0.72, 0, 1);--fullscreen-anim-duration-in: 0.28s;--fullscreen-anim-duration-out: 0.22s;+ /* The wings' slide on and off reading. HomePage waits this out before it+ unmounts them, so the two stylesheets and the timer cannot drift. */+ --wings-ms: 220ms;/* ── Z-index ladder ── */--z-dropdown: 25;diff --git a/frontend/editor/src/core/types/sidebar.ts b/frontend/editor/src/core/types/sidebar.tsindex 0db86088b9..0cba9cf436 100644--- a/frontend/editor/src/core/types/sidebar.ts+++ b/frontend/editor/src/core/types/sidebar.ts@@ -1,5 +1,4 @@export interface SidebarState {- sidebarsVisible: boolean;leftPanelView: "toolPicker" | "toolContent";readerMode: boolean;}@@ -19,7 +18,6 @@ export interface SidebarInfo {export interface SidebarContextValue {sidebarState: SidebarState;sidebarRefs: SidebarRefs;- setSidebarsVisible: React.Dispatch<React.SetStateAction<boolean>>;setLeftPanelView: React.Dispatch<React.SetStateAction<"toolPicker" | "toolContent">>;diff --git a/frontend/editor/src/core/utils/pendingReaderMode.ts b/frontend/editor/src/core/utils/pendingReaderMode.tsindex faacfba6b8..cf8f26040c 100644--- a/frontend/editor/src/core/utils/pendingReaderMode.ts+++ b/frontend/editor/src/core/utils/pendingReaderMode.ts@@ -11,3 +11,21 @@ export function consumeReaderModeRequest(): boolean {pending = false;return true;}++let fromPreference = false;++/**+ * Marks reading as opened by the startup-view preference rather than by a click,+ * so the path that follows replaces the entry the app loaded on. Pushing it would+ * put reading behind the first Back press of every session that prefers it.+ */+export function markReaderModeFromPreference(): void {+ fromPreference = true;+}++/** True once per marked open. */+export function consumeReaderModeFromPreference(): boolean {+ if (!fromPreference) return false;+ fromPreference = false;+ return true;+}diff --git a/frontend/editor/src/core/utils/sidebarUtils.ts b/frontend/editor/src/core/utils/sidebarUtils.tsindex d111592d43..f4447f8728 100644--- a/frontend/editor/src/core/utils/sidebarUtils.ts+++ b/frontend/editor/src/core/utils/sidebarUtils.ts@@ -11,10 +11,10 @@ export function getSidebarInfo(state: SidebarState,): SidebarInfo {const { quickAccessRef, toolPanelRef } = refs;- const { sidebarsVisible, readerMode } = state;+ const { readerMode } = state;- // Determine if tool panel should be active based on state- const isToolPanelActive = sidebarsVisible && !readerMode;+ // Reading swaps the tool panel out for the reader's own rail.+ const isToolPanelActive = !readerMode;let rect: DOMRect | null = null;diff --git a/frontend/editor/src/desktop/components/windowChrome.css b/frontend/editor/src/desktop/components/windowChrome.cssindex f507a64b2d..7fa8f8f231 100644--- a/frontend/editor/src/desktop/components/windowChrome.css+++ b/frontend/editor/src/desktop/components/windowChrome.css@@ -28,20 +28,14 @@ html[data-window-controls="custom"] .tool-panel .sui-panelhdr {margin-top: var(--wincontrols-h);}-/* Right panel, collapsed: the strip is narrower than the controls, so push its- expand toggle straight down. */-html[data-window-controls="custom"] .tool-panel__collapsed-strip {- padding-top: calc(10px + var(--wincontrols-h));+html[data-window-controls="custom"] .reader-rail {+ padding-top: calc(0.75rem + var(--wincontrols-h));}-/* Viewer top bar: when the right panel is collapsed the bar widens under the- controls. :has() detects the collapsed strip (no flag needed in core) and we- push the right cluster clear. --nav-rail-w is the collapsed strip's width, so- only the controls' overhang past it is reserved. */+/* The tool picker draws no header to carry the offset, so the panel takes it. */html[data-window-controls="custom"]- .app-frame__content:has(.tool-panel__collapsed-strip)- .workbench-bar-globals {- margin-right: calc(var(--wincontrols-w) - var(--nav-rail-w));+ .tool-panel:not(:has(.tool-panel__compact-header)):not(:has(.sui-panelhdr)) {+ padding-top: var(--wincontrols-h);}/* Mobile layout: the top bar spans the full width. Keep the brand top-leftdiff --git a/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsx b/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsxindex 85debd23da..0cabbf8620 100644--- a/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsx+++ b/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsx@@ -1,13 +1,10 @@-import { type SidebarProcessingSlotProps } from "@core/components/shared/SidebarProcessingSlot";-export { type SidebarProcessingSlotProps };-import { DownloadsProcessingWizard } from "@app/components/policies/DownloadsProcessingWizard";/**- * The sentence-length Downloads offer is hidden when the sidebar is collapsed.+ * The Downloads offer, beside the sidebar's other file-entry actions — one more way of+ * getting files in. Not gated on policies being available: it gates itself by asking the+ * server for a readable Downloads directory, and renders nothing without one.*/-export function SidebarProcessingSlot({- collapsed,-}: SidebarProcessingSlotProps) {- return collapsed ? null : <DownloadsProcessingWizard />;+export function SidebarProcessingSlot() {+ return <DownloadsProcessingWizard />;}diff --git a/frontend/editor/src/saas/components/shared/SidebarChecklistSlot.tsx b/frontend/editor/src/saas/components/shared/SidebarChecklistSlot.tsxindex 84dea6ccde..3d19acce14 100644--- a/frontend/editor/src/saas/components/shared/SidebarChecklistSlot.tsx+++ b/frontend/editor/src/saas/components/shared/SidebarChecklistSlot.tsx@@ -1,13 +1,6 @@-import { type SidebarChecklistSlotProps } from "@core/components/shared/SidebarChecklistSlot";-export { type SidebarChecklistSlotProps };-import { OnboardingChecklist } from "@app/components/onboarding/OnboardingChecklist";-/**- * SaaS getting-started checklist, floating above the sidebar footer. Hidden- * when the sidebar is collapsed to its narrow rail.- */-export function SidebarChecklistSlot({ collapsed }: SidebarChecklistSlotProps) {- if (collapsed) return null;+/** SaaS getting-started checklist, floating above the sidebar footer. */+export function SidebarChecklistSlot() {return <OnboardingChecklist />;}