Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Hide folder processing and watched folders without a connected server (#7962)

Anthony Stirlingd4d8cafb2538
diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.toml
index ca54168878..0916e726b5 100644
--- a/frontend/editor/public/locales/en-US/translation.toml
+++ b/frontend/editor/public/locales/en-US/translation.toml
@@ -4793,6 +4793,7 @@ sharedHint = "Shared with you via link"
[filesPage.processing]
active = "Processing folder"
+blockedNeedsConnection = "Sign in to Stirling Cloud or connect a self-hosted server to process folders."
edit = "Edit processing..."
nothingToRestore = "No originals to restore - these files are already their originals."
paused = "Processing paused"
diff --git a/frontend/editor/src/core/components/filesPage/FileGrid.tsx b/frontend/editor/src/core/components/filesPage/FileGrid.tsx
index 297e1cd0bd..039dd8b5fe 100644
--- a/frontend/editor/src/core/components/filesPage/FileGrid.tsx
+++ b/frontend/editor/src/core/components/filesPage/FileGrid.tsx
@@ -15,6 +15,7 @@ import {
} from "@app/types/folder";
import type { DiskFileEntry } from "@app/services/localFolderContents";
import { usePolicyFileBadges } from "@app/hooks/usePolicyFileBadges";
+import { useServerProcessingBlock } from "@app/hooks/useServerProcessingBlock";
import {
useProcessingFolders,
type ProcessingFolderState,
@@ -628,6 +629,7 @@ const FolderCard = React.memo(function FolderCard({
actions.reportError(err, label),
);
const editsDisabled = kind === "server" && !serverReachable;
+ const processingBlock = useServerProcessingBlock();
const editsHidden = kind === "local";
const offlineHint = t(
"filesPage.offlineNoFolderEdits",
@@ -747,7 +749,8 @@ const FolderCard = React.memo(function FolderCard({
{editsHidden && (
<ProcessingMenuItems
processing={processing}
- disabled={false}
+ disabled={Boolean(processingBlock)}
+ disabledHint={processingBlock ?? undefined}
onRun={() => void runProcessing("process folder now")}
onStop={() => void stopProcessing("pause processing folder")}
onStart={() => actions.startProcessing(folder)}
@@ -799,8 +802,8 @@ const FolderCard = React.memo(function FolderCard({
<ProcessingMenuItems
processing={processing}
continuous={kind === "virtual"}
- disabled={editsDisabled}
- disabledHint={offlineHint}
+ disabled={editsDisabled || Boolean(processingBlock)}
+ disabledHint={processingBlock ?? offlineHint}
onRun={() => void runProcessing("process folder now")}
onStop={() => void stopProcessing("pause processing folder")}
onStart={() => actions.startProcessing(folder)}
@@ -1649,6 +1652,7 @@ const FolderRow = React.memo(function FolderRow({
actions.reportError(err, label),
);
const editsDisabled = kind === "server" && !serverReachable;
+ const processingBlock = useServerProcessingBlock();
const editsHidden = kind === "local";
const offlineHint = t(
"filesPage.offlineNoFolderEdits",
@@ -1708,7 +1712,8 @@ const FolderRow = React.memo(function FolderRow({
{editsHidden && (
<ProcessingMenuItems
processing={processing}
- disabled={false}
+ disabled={Boolean(processingBlock)}
+ disabledHint={processingBlock ?? undefined}
onRun={() => void runProcessing("process folder now")}
onStop={() => void stopProcessing("pause processing folder")}
onStart={() => actions.startProcessing(folder)}
@@ -1760,8 +1765,8 @@ const FolderRow = React.memo(function FolderRow({
<ProcessingMenuItems
processing={processing}
continuous={kind === "virtual"}
- disabled={editsDisabled}
- disabledHint={offlineHint}
+ disabled={editsDisabled || Boolean(processingBlock)}
+ disabledHint={processingBlock ?? offlineHint}
onRun={() => void runProcessing("process folder now")}
onStop={() => void stopProcessing("pause processing folder")}
onStart={() => actions.startProcessing(folder)}
diff --git a/frontend/editor/src/core/components/filesPage/FileManagerView.tsx b/frontend/editor/src/core/components/filesPage/FileManagerView.tsx
index 93390d3e69..36419b1511 100644
--- a/frontend/editor/src/core/components/filesPage/FileManagerView.tsx
+++ b/frontend/editor/src/core/components/filesPage/FileManagerView.tsx
@@ -67,6 +67,7 @@ import {
import { FolderAppearancePicker } from "@app/components/filesPage/FolderAppearancePicker";
import { useProcessingFolders } from "@app/hooks/useProcessingFolders";
import { FolderProcessingSetup } from "@app/components/policies/FolderProcessingSetup";
+import { useServerProcessingBlock } from "@app/hooks/useServerProcessingBlock";
import { FolderSweepWall } from "@app/components/policies/SweepRunWall";
import { RestoreOriginalsDialog } from "@app/components/filesPage/RestoreOriginalsDialog";
import { FileDetailsPanel } from "@app/components/filesPage/FileDetailsPanel";
@@ -1338,6 +1339,10 @@ export default function FileManagerView() {
// disabled item's caption.
const serverFolderDisabledReason = useServerFolderBlock() ?? undefined;
+ // Why folder processing has no server to run on, or null. The controls that open
+ // the setup dialog carry it as their disabled reason.
+ const processingBlock = useServerProcessingBlock();
+
const { addLocalFolder } = useNewFolderFlow();
// null = New folder actionable; string = disabled tooltip reason.
@@ -1619,23 +1624,31 @@ export default function FileManagerView() {
<div className="files-page-folder-actions">
{!currentProcessing ? (
<Tooltip
- label={t(
- "filesPage.processing.start",
- "Process files in this folder...",
- )}
- withinPortal
- >
- <ActionIcon
- size="sm"
- variant="secondary"
- onClick={() => setProcessingSetupFolder(currentFolder)}
- aria-label={t(
+ label={
+ processingBlock ??
+ t(
"filesPage.processing.start",
"Process files in this folder...",
- )}
- >
- <Icon name="workflow" size={20} />
- </ActionIcon>
+ )
+ }
+ withinPortal
+ >
+ {/* Mantine drops hover events on a disabled control, so the
+ tooltip needs a live element to hang off. */}
+ <span style={{ display: "inline-flex" }}>
+ <ActionIcon
+ size="sm"
+ variant="secondary"
+ disabled={Boolean(processingBlock)}
+ onClick={() => setProcessingSetupFolder(currentFolder)}
+ aria-label={t(
+ "filesPage.processing.start",
+ "Process files in this folder...",
+ )}
+ >
+ <Icon name="workflow" size={20} />
+ </ActionIcon>
+ </span>
</Tooltip>
) : (
<>
@@ -1720,23 +1733,30 @@ export default function FileManagerView() {
</Tooltip>
)}
<Tooltip
- label={t(
- "filesPage.processing.edit",
- "Edit processing...",
- )}
+ label={
+ processingBlock ??
+ t("filesPage.processing.edit", "Edit processing...")
+ }
withinPortal
>
- <ActionIcon
- size="sm"
- variant="secondary"
- onClick={() => setProcessingSetupFolder(currentFolder)}
- aria-label={t(
- "filesPage.processing.edit",
- "Edit processing...",
- )}
- >
- <Icon name="sliders-horizontal" size={20} />
- </ActionIcon>
+ {/* Mantine drops hover events on a disabled control, so the
+ tooltip needs a live element to hang off. */}
+ <span style={{ display: "inline-flex" }}>
+ <ActionIcon
+ size="sm"
+ variant="secondary"
+ disabled={Boolean(processingBlock)}
+ onClick={() =>
+ setProcessingSetupFolder(currentFolder)
+ }
+ aria-label={t(
+ "filesPage.processing.edit",
+ "Edit processing...",
+ )}
+ >
+ <Icon name="sliders-horizontal" size={20} />
+ </ActionIcon>
+ </span>
</Tooltip>
{folderKind(currentFolder) === "local" && (
<Tooltip
@@ -2434,7 +2454,7 @@ export default function FileManagerView() {
}}
/>
<FolderProcessingSetup
- folder={processingSetupFolder}
+ folder={processingBlock ? null : processingSetupFolder}
onClose={() => setProcessingSetupFolder(null)}
/>
diff --git a/frontend/editor/src/core/hooks/useServerProcessingBlock.test.ts b/frontend/editor/src/core/hooks/useServerProcessingBlock.test.ts
new file mode 100644
index 0000000000..9544a39222
--- /dev/null
+++ b/frontend/editor/src/core/hooks/useServerProcessingBlock.test.ts
@@ -0,0 +1,10 @@
+import { describe, expect, it } from "vitest";
+import { useServerProcessingBlock } from "@app/hooks/useServerProcessingBlock";
+
+describe("useServerProcessingBlock (core)", () => {
+ // Pins the stub: a non-null reason here would disable folder processing on every
+ // web build, where the serving backend runs the pipelines perfectly well.
+ it("never blocks - the serving backend runs the pipelines", () => {
+ expect(useServerProcessingBlock()).toBeNull();
+ });
+});
diff --git a/frontend/editor/src/core/hooks/useServerProcessingBlock.ts b/frontend/editor/src/core/hooks/useServerProcessingBlock.ts
new file mode 100644
index 0000000000..c8b1e1b123
--- /dev/null
+++ b/frontend/editor/src/core/hooks/useServerProcessingBlock.ts
@@ -0,0 +1,5 @@
+/** Why folder processing cannot be set up right now, or null when it can.
+ * Always null on web, served by the backend that runs the pipelines; other builds shadow this. */
+export function useServerProcessingBlock(): string | null {
+ return null;
+}
diff --git a/frontend/editor/src/desktop/hooks/useServerProcessingBlock.test.ts b/frontend/editor/src/desktop/hooks/useServerProcessingBlock.test.ts
new file mode 100644
index 0000000000..c08343575b
--- /dev/null
+++ b/frontend/editor/src/desktop/hooks/useServerProcessingBlock.test.ts
@@ -0,0 +1,43 @@
+import { renderHook } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+const { useConnectedServerMock } = vi.hoisted(() => ({
+ useConnectedServerMock: vi.fn(),
+}));
+
+vi.mock("@app/hooks/useConnectedServer", () => ({
+ useConnectedServer: useConnectedServerMock,
+}));
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({
+ t: (_key: string, fallback: string) => fallback,
+ }),
+}));
+
+import { useServerProcessingBlock } from "@app/hooks/useServerProcessingBlock";
+
+describe("useServerProcessingBlock", () => {
+ beforeEach(() => useConnectedServerMock.mockReset());
+ afterEach(() => vi.clearAllMocks());
+
+ it("allows processing once a server is connected", () => {
+ useConnectedServerMock.mockReturnValue(true);
+ const { result } = renderHook(() => useServerProcessingBlock());
+ expect(result.current).toBeNull();
+ });
+
+ it("blocks with a reason naming both ways to connect", () => {
+ useConnectedServerMock.mockReturnValue(false);
+ const { result } = renderHook(() => useServerProcessingBlock());
+ expect(result.current).toContain("Stirling Cloud");
+ expect(result.current).toContain("self-hosted");
+ });
+
+ it("fails closed while the connection is unresolved", () => {
+ // useConnectedServer starts pessimistically false, so an unresolved connection
+ // must block rather than let the Downloads probe fire at the bundled backend.
+ useConnectedServerMock.mockReturnValue(false);
+ const { result } = renderHook(() => useServerProcessingBlock());
+ expect(result.current).not.toBeNull();
+ });
+});
diff --git a/frontend/editor/src/desktop/hooks/useServerProcessingBlock.ts b/frontend/editor/src/desktop/hooks/useServerProcessingBlock.ts
new file mode 100644
index 0000000000..572cb609ef
--- /dev/null
+++ b/frontend/editor/src/desktop/hooks/useServerProcessingBlock.ts
@@ -0,0 +1,13 @@
+import { useTranslation } from "react-i18next";
+import { useConnectedServer } from "@app/hooks/useConnectedServer";
+
+/** Desktop: folder processing runs on the connected server, so it waits for one. Fails closed
+ * while the connection resolves, or the Downloads offer probes the bundled backend for nothing. */
+export function useServerProcessingBlock(): string | null {
+ const { t } = useTranslation();
+ if (useConnectedServer()) return null;
+ return t(
+ "filesPage.processing.blockedNeedsConnection",
+ "Sign in to Stirling Cloud or connect a self-hosted server to process folders.",
+ );
+}
diff --git a/frontend/editor/src/proprietary/App.tsx b/frontend/editor/src/proprietary/App.tsx
index 78e8eb8b79..0ff43f75cf 100644
--- a/frontend/editor/src/proprietary/App.tsx
+++ b/frontend/editor/src/proprietary/App.tsx
@@ -5,6 +5,7 @@ import { AppLayout } from "@app/components/AppLayout";
import { LoadingFallback } from "@app/components/shared/LoadingFallback";
import { PreferencesProvider } from "@app/contexts/PreferencesContext";
import { ThemeProvider } from "@app/components/shared/ThemeProvider";
+import { useConnectedServer } from "@app/hooks/useConnectedServer";
const Landing = lazy(() => import("@app/routes/Landing"));
const Login = lazy(() => import("@app/routes/Login"));
@@ -54,6 +55,7 @@ function ParticipantViewPage() {
}
export default function App() {
+ const connectedServer = useConnectedServer();
return (
<Suspense fallback={<LoadingFallback />}>
<Routes>
@@ -126,7 +128,9 @@ export default function App() {
<Route path="/*" element={<Landing />} />
</Routes>
<Onboarding />
- {WATCHED_FOLDERS_ENABLED && <WatchedFoldersRegistration />}
+ {WATCHED_FOLDERS_ENABLED && connectedServer && (
+ <WatchedFoldersRegistration />
+ )}
</AppLayout>
</AppProviders>
</RootGate>
diff --git a/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.tsx b/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.tsx
index da36064d26..6959fb0983 100644
--- a/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.tsx
+++ b/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.tsx
@@ -27,6 +27,7 @@ import { readClassificationLabelsFromFile } from "@app/services/fileClassificati
import { useFileHandler } from "@app/hooks/useFileHandler";
import { useFolders } from "@app/contexts/FolderContext";
import { canListDirectory } from "@app/services/localFolderContents";
+import { useServerProcessingBlock } from "@app/hooks/useServerProcessingBlock";
import apiClient from "@app/services/apiClient";
import "@app/components/policies/DownloadsProcessingWizard.css";
@@ -69,14 +70,12 @@ export function DownloadsProcessingWizard({
const cancelRequested = useRef(false);
const { addFiles } = useFileHandler();
const { mountLocalFolder } = useFolders();
+ const block = useServerProcessingBlock();
- // Only offer where it can work: the build must be able to read a file on disk, and Downloads
- // must exist, be permitted, and hold something. Without canListDirectory the results are
- // unreadable here (fetchRunOutputFile throws), so the offer would rewrite the server's own
- // Downloads in place and show the user nothing. Retried because the window can open before
- // the bundled backend is reachable, with a bounded wait so a genuine "no" stops asking.
+ // Needs a connected server; without canListDirectory fetchRunOutputFile throws, so the offer
+ // would rewrite the server's own Downloads and show nothing. Retried: session may lag the open.
useEffect(() => {
- if (!active || !canListDirectory) return;
+ if (!active || block || !canListDirectory) return;
let cancelled = false;
let attempts = 0;
let timer: ReturnType<typeof setTimeout> | undefined;
@@ -107,7 +106,7 @@ export function DownloadsProcessingWizard({
cancelled = true;
if (timer) clearTimeout(timer);
};
- }, [active]);
+ }, [active, block]);
/** Closing resets to the question, so the offer can be reopened and re-run. */
const close = () => {
diff --git a/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsx b/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsx
index 0cabbf8620..4604303d82 100644
--- a/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsx
+++ b/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsx
@@ -1,10 +1,12 @@
import { DownloadsProcessingWizard } from "@app/components/policies/DownloadsProcessingWizard";
+import { useServerProcessingBlock } from "@app/hooks/useServerProcessingBlock";
/**
- * 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.
+ * The Downloads offer, one more way of getting files in. Hidden without a server that can
+ * run it, and hidden again by the wizard when that server has no readable Downloads directory.
*/
export function SidebarProcessingSlot() {
+ const blocked = useServerProcessingBlock();
+ if (blocked) return null;
return <DownloadsProcessingWizard />;
}