Skip to content

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

Show the getting-started checklist on desktop (#8151)

EthanHealy01910b5d012f5c
diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.toml
index 99bd2443e5..20d894d64b 100644
--- a/frontend/editor/public/locales/en-US/translation.toml
+++ b/frontend/editor/public/locales/en-US/translation.toml
@@ -4183,17 +4183,12 @@ fileName = "File Name"
title = "Database Import/Export"
[defaultApp]
-setDefault = "Set Default"
title = "Set as Default PDF App"
[defaultApp.error]
message = "Failed to set default PDF handler"
title = "Error"
-[defaultApp.prompt]
-dontRemind = "Don't remind me again"
-message = "Make Stirling PDF your default application for opening PDF files."
-
[defaultApp.settingsOpened]
message = "In Windows Settings, search for 'PDF' and select Stirling PDF as your default app"
title = "Settings Opened"
@@ -6118,9 +6113,9 @@ title = "Download Stirling for Desktop"
description = "Collaborate with your team"
title = "Invite team members"
-[onboarding.checklist.shareAnalytics]
-description = "Help improve Stirling"
-title = "Share anonymous usage data"
+[onboarding.checklist.setDefaultApp]
+description = "Open PDF files in Stirling PDF"
+title = "Make Stirling your default"
[onboarding.checklist.takeTour]
description = "See how Stirling works in a quick walkthrough"
@@ -10437,31 +10432,6 @@ unlimited = "{{used}} seats · Unlimited"
[printFile]
title = "Print File"
-[processingFolders.downloads]
-approve = "Process my Downloads"
-cancelSweep = "Cancel"
-capped = "You have {{found}} PDFs; the first {{limit}} are processed now and the rest follow."
-close = "Done"
-explain_one = "Stirling can classify the {{count}} PDF already in your Downloads folder and open the results here."
-explain_other = "Stirling can classify the {{count}} PDFs already in your Downloads folder and open the results here."
-failed = "Could not set that up. Your files have not been changed."
-finished_one = "Classified {{count}} file and opened {{opened}} of them here, ready to work on."
-finished_other = "Classified {{count}} files and opened {{opened}} of them here, ready to work on."
-nothingNew_one = "Nothing new to process - this {{count}} file has already been through."
-nothingNew_other = "Nothing new to process - these {{count}} files have already been through."
-notModified = "Your files in Downloads are not changed - Stirling reads them and opens them here."
-notNow = "Not now"
-progressCounts = "of {{total}} processed"
-someFailed_one = "{{count}} could not be processed and was left untouched."
-someFailed_other = "{{count}} could not be processed and were left untouched."
-stillRunning = "Some files are still being processed in the background."
-title = "Organize your Downloads?"
-trigger_one = "Process {{count}} PDF in Downloads"
-trigger_other = "Process {{count}} PDFs in Downloads"
-typesFound_one = "{{count}} document type found"
-typesFound_other = "{{count}} document types found"
-working = "Processing ..."
-
[processingFolders.setup]
addFolder = "Add folder"
advancedSteps = "This folder uses a processing setup this wizard cannot edit. Its saved steps have not been changed."
@@ -11360,8 +11330,6 @@ defaultPdfEditor = "Default PDF editor"
defaultPdfEditorActive = "Stirling PDF is your default PDF editor"
defaultPdfEditorChecking = "Checking..."
defaultPdfEditorInactive = "Another application is set as default"
-defaultPdfEditorRemind = "Remind me to set as default"
-defaultPdfEditorRemindDescription = "Show a banner when Stirling PDF is not your default PDF application."
defaultPdfEditorSet = "Already Default"
defaultStartupView = "Default view on launch"
defaultStartupViewDescription = "Choose which view is active when the app starts"
diff --git a/frontend/editor/src/saas/components/onboarding/OnboardingChecklist.module.css b/frontend/editor/src/cloud/components/onboarding/OnboardingChecklist.module.css
similarity index 100%
rename from frontend/editor/src/saas/components/onboarding/OnboardingChecklist.module.css
rename to frontend/editor/src/cloud/components/onboarding/OnboardingChecklist.module.css
diff --git a/frontend/editor/src/saas/components/onboarding/OnboardingChecklist.tsx b/frontend/editor/src/cloud/components/onboarding/OnboardingChecklist.tsx
similarity index 57%
rename from frontend/editor/src/saas/components/onboarding/OnboardingChecklist.tsx
rename to frontend/editor/src/cloud/components/onboarding/OnboardingChecklist.tsx
index f8c6068151..2074728c57 100644
--- a/frontend/editor/src/saas/components/onboarding/OnboardingChecklist.tsx
+++ b/frontend/editor/src/cloud/components/onboarding/OnboardingChecklist.tsx
@@ -1,10 +1,12 @@
-import { useCallback, useMemo, useState } from "react";
+import { useCallback, useState } from "react";
import { useTranslation } from "react-i18next";
import { Icon } from "@app/ui/Icon";
import { useAuth } from "@app/auth/UseSession";
-import SaasOnboardingModal from "@app/components/onboarding/SaasOnboardingModal";
-import StaticOnboardingSlide from "@app/components/onboarding/StaticOnboardingSlide";
-import { DEFAULT_RUNTIME_STATE } from "@app/components/onboarding/orchestrator/onboardingConfig";
+import { useChecklistInviteTarget } from "@app/components/onboarding/checklistInviteTarget";
+import {
+ useChecklistSetupItem,
+ type ChecklistItem,
+} from "@app/components/onboarding/checklistSetupItem";
import {
getFlowProgress,
hasSeenFlow,
@@ -13,40 +15,23 @@ import {
} from "@app/components/onboarding/orchestrator/onboardingStorage";
import { openAppSettings } from "@app/utils/appSettings";
import { requestStartTour } from "@app/constants/events";
-import apiClient from "@app/services/apiClient";
import stirlingMark from "@app/assets/brand/modern-logo/logo512.png";
import styles from "@app/components/onboarding/OnboardingChecklist.module.css";
const FLOW_ID = "saas-checklist";
-const STEP_DOWNLOAD_DESKTOP = "download-desktop";
const STEP_INVITE_TEAM = "invite-team";
const STEP_TAKE_TOUR = "take-tour";
-const STEP_SHARE_ANALYTICS = "share-analytics";
-
-interface ChecklistItem {
- id: string;
- titleKey: string;
- titleFallback: string;
- descriptionKey: string;
- descriptionFallback: string;
- onClick: () => void;
-}
-/**
- * SaaS-only getting-started checklist that floats above the sidebar footer for
- * new users. Progress is persisted per step via the shared onboarding store, so
- * completed items stay ticked across reloads. Dismissing it (the X) hides it
- * permanently for the user.
- */
+/** Getting-started checklist above the sidebar footer. Ticks and the X dismissal
+ * persist per browser in the shared onboarding store. */
export function OnboardingChecklist() {
const { t } = useTranslation();
const { isAnonymous, loading } = useAuth();
+ const inviteTarget = useChecklistInviteTarget();
const [dismissed, setDismissed] = useState(() => hasSeenFlow(FLOW_ID));
const [done, setDone] = useState<string[]>(() => getFlowProgress(FLOW_ID));
const [expanded, setExpanded] = useState(true);
- const [downloadOpen, setDownloadOpen] = useState(false);
- const [analyticsOpen, setAnalyticsOpen] = useState(false);
const markDone = useCallback((stepId: string) => {
setStepDone(FLOW_ID, stepId);
@@ -54,11 +39,9 @@ export function OnboardingChecklist() {
}, []);
const handleInviteTeam = useCallback(() => {
- // Open the settings modal on the Teams section without touching the URL
- // (event-driven open + navigate; no /settings/teams pushState).
- openAppSettings("teams");
+ if (inviteTarget) openAppSettings(inviteTarget);
markDone(STEP_INVITE_TEAM);
- }, [markDone]);
+ }, [inviteTarget, markDone]);
const handleTakeTour = useCallback(() => {
// Always the user (tools) walkthrough, regardless of admin/user role. The
@@ -67,43 +50,31 @@ export function OnboardingChecklist() {
markDone(STEP_TAKE_TOUR);
}, [markDone]);
- const items: ChecklistItem[] = useMemo(
- () => [
- {
- id: STEP_DOWNLOAD_DESKTOP,
- titleKey: "onboarding.checklist.downloadDesktop.title",
- titleFallback: "Download Stirling for Desktop",
- descriptionKey: "onboarding.checklist.downloadDesktop.description",
- descriptionFallback: "Run Stirling natively on your machine",
- onClick: () => setDownloadOpen(true),
- },
- {
- id: STEP_INVITE_TEAM,
- titleKey: "onboarding.checklist.inviteTeam.title",
- titleFallback: "Invite team members",
- descriptionKey: "onboarding.checklist.inviteTeam.description",
- descriptionFallback: "Collaborate with your team",
- onClick: handleInviteTeam,
- },
- {
- id: STEP_TAKE_TOUR,
- titleKey: "onboarding.checklist.takeTour.title",
- titleFallback: "Take the tour",
- descriptionKey: "onboarding.checklist.takeTour.description",
- descriptionFallback: "See how Stirling works in a quick walkthrough",
- onClick: handleTakeTour,
- },
- {
- id: STEP_SHARE_ANALYTICS,
- titleKey: "onboarding.checklist.shareAnalytics.title",
- titleFallback: "Share anonymous usage data",
- descriptionKey: "onboarding.checklist.shareAnalytics.description",
- descriptionFallback: "Help improve Stirling",
- onClick: () => setAnalyticsOpen(true),
- },
- ],
- [handleInviteTeam, handleTakeTour],
- );
+ const setup = useChecklistSetupItem(markDone);
+
+ const items: ChecklistItem[] = [
+ ...(setup.item ? [setup.item] : []),
+ ...(inviteTarget
+ ? [
+ {
+ id: STEP_INVITE_TEAM,
+ titleKey: "onboarding.checklist.inviteTeam.title",
+ titleFallback: "Invite team members",
+ descriptionKey: "onboarding.checklist.inviteTeam.description",
+ descriptionFallback: "Collaborate with your team",
+ onClick: handleInviteTeam,
+ },
+ ]
+ : []),
+ {
+ id: STEP_TAKE_TOUR,
+ titleKey: "onboarding.checklist.takeTour.title",
+ titleFallback: "Take the tour",
+ descriptionKey: "onboarding.checklist.takeTour.description",
+ descriptionFallback: "See how Stirling works in a quick walkthrough",
+ onClick: handleTakeTour,
+ },
+ ];
const doneCount = items.filter((item) => done.includes(item.id)).length;
const total = items.length;
@@ -114,40 +85,6 @@ export function OnboardingChecklist() {
setDismissed(true);
}, []);
- // Both "skip" and "download" in the reused slide close the modal, and either
- // one should complete the task.
- const handleDownloadClose = useCallback(() => {
- markDone(STEP_DOWNLOAD_DESKTOP);
- setDownloadOpen(false);
- }, [markDone]);
-
- const closeAnalytics = useCallback(() => {
- markDone(STEP_SHARE_ANALYTICS);
- setAnalyticsOpen(false);
- }, [markDone]);
-
- const handleAnalyticsAction = useCallback(
- (action: string) => {
- if (action === "enable-analytics" || action === "disable-analytics") {
- const formData = new FormData();
- formData.append(
- "enabled",
- action === "enable-analytics" ? "true" : "false",
- );
- void apiClient
- .post("/api/v1/settings/update-enable-analytics", formData)
- .catch((error) => {
- console.error(
- "[OnboardingChecklist] analytics update failed",
- error,
- );
- });
- }
- closeAnalytics();
- },
- [closeAnalytics],
- );
-
if (loading || isAnonymous || dismissed) {
return null;
}
@@ -267,16 +204,12 @@ export function OnboardingChecklist() {
</span>
<span className={styles.itemText}>
<span
- className={`${styles.itemTitle} ${
- isDone ? styles.itemTitleDone : ""
- }`}
+ className={`${styles.itemTitle} ${isDone ? styles.itemTitleDone : ""}`}
>
{t(item.titleKey, item.titleFallback)}
</span>
<span
- className={`${styles.itemDescription} ${
- isDone ? styles.itemDescriptionDone : ""
- }`}
+ className={`${styles.itemDescription} ${isDone ? styles.itemDescriptionDone : ""}`}
>
{t(item.descriptionKey, item.descriptionFallback)}
</span>
@@ -288,22 +221,7 @@ export function OnboardingChecklist() {
)}
</div>
- <SaasOnboardingModal
- opened={downloadOpen}
- onClose={handleDownloadClose}
- slideIds={["desktop-install"]}
- />
-
- {analyticsOpen && (
- <StaticOnboardingSlide
- key="analytics-choice"
- slideId="analytics-choice"
- runtimeState={DEFAULT_RUNTIME_STATE}
- allowDismiss
- onSkip={closeAnalytics}
- onAction={handleAnalyticsAction}
- />
- )}
+ {setup.dialog}
</>
);
}
diff --git a/frontend/editor/src/cloud/components/onboarding/checklistInviteTarget.ts b/frontend/editor/src/cloud/components/onboarding/checklistInviteTarget.ts
new file mode 100644
index 0000000000..9b307e08c3
--- /dev/null
+++ b/frontend/editor/src/cloud/components/onboarding/checklistInviteTarget.ts
@@ -0,0 +1,11 @@
+import { useAuth } from "@app/auth/UseSession";
+import type { NavKey } from "@app/components/shared/config/types";
+import { useSaaSTeam } from "@app/contexts/SaaSTeamContext";
+
+/** The settings section where this user can invite people, or null if they can't.
+ * Guests never can: they lead the personal team created for them, but have no account. */
+export function useChecklistInviteTarget(): NavKey | null {
+ const { isAnonymous } = useAuth();
+ const { isTeamLeader } = useSaaSTeam();
+ return isTeamLeader && !isAnonymous ? "users" : null;
+}
diff --git a/frontend/editor/src/cloud/components/onboarding/checklistSetupItem.tsx b/frontend/editor/src/cloud/components/onboarding/checklistSetupItem.tsx
new file mode 100644
index 0000000000..a1da2da2be
--- /dev/null
+++ b/frontend/editor/src/cloud/components/onboarding/checklistSetupItem.tsx
@@ -0,0 +1,50 @@
+import { useCallback, useState, type ReactNode } from "react";
+import SaasOnboardingModal from "@app/components/onboarding/SaasOnboardingModal";
+
+export interface ChecklistItem {
+ id: string;
+ titleKey: string;
+ titleFallback: string;
+ descriptionKey: string;
+ descriptionFallback: string;
+ onClick: () => void;
+}
+
+export interface ChecklistSetupItem {
+ /** Null hides the row, and it no longer counts towards the total. */
+ item: ChecklistItem | null;
+ dialog: ReactNode;
+}
+
+const STEP_DOWNLOAD_DESKTOP = "download-desktop";
+
+/** The platform-specific first row of the getting-started checklist. */
+export function useChecklistSetupItem(
+ markDone: (stepId: string) => void,
+): ChecklistSetupItem {
+ const [open, setOpen] = useState(false);
+
+ // The slide's skip and download buttons both close it, and either completes the task.
+ const handleClose = useCallback(() => {
+ markDone(STEP_DOWNLOAD_DESKTOP);
+ setOpen(false);
+ }, [markDone]);
+
+ return {
+ item: {
+ id: STEP_DOWNLOAD_DESKTOP,
+ titleKey: "onboarding.checklist.downloadDesktop.title",
+ titleFallback: "Download Stirling for Desktop",
+ descriptionKey: "onboarding.checklist.downloadDesktop.description",
+ descriptionFallback: "Run Stirling natively on your machine",
+ onClick: () => setOpen(true),
+ },
+ dialog: (
+ <SaasOnboardingModal
+ opened={open}
+ onClose={handleClose}
+ slideIds={["desktop-install"]}
+ />
+ ),
+ };
+}
diff --git a/frontend/editor/src/saas/components/shared/SidebarChecklistSlot.tsx b/frontend/editor/src/cloud/components/shared/SidebarChecklistSlot.tsx
similarity index 68%
rename from frontend/editor/src/saas/components/shared/SidebarChecklistSlot.tsx
rename to frontend/editor/src/cloud/components/shared/SidebarChecklistSlot.tsx
index 3d19acce14..f36411c585 100644
--- a/frontend/editor/src/saas/components/shared/SidebarChecklistSlot.tsx
+++ b/frontend/editor/src/cloud/components/shared/SidebarChecklistSlot.tsx
@@ -1,6 +1,6 @@
import { OnboardingChecklist } from "@app/components/onboarding/OnboardingChecklist";
-/** SaaS getting-started checklist, floating above the sidebar footer. */
+/** Getting-started checklist, floating above the sidebar footer. */
export function SidebarChecklistSlot() {
return <OnboardingChecklist />;
}
diff --git a/frontend/editor/src/saas/utils/appSettings.ts b/frontend/editor/src/cloud/utils/appSettings.ts
similarity index 85%
rename from frontend/editor/src/saas/utils/appSettings.ts
rename to frontend/editor/src/cloud/utils/appSettings.ts
index a8505cfd1d..64dd18fc02 100644
--- a/frontend/editor/src/saas/utils/appSettings.ts
+++ b/frontend/editor/src/cloud/utils/appSettings.ts
@@ -4,9 +4,9 @@
import type { NavKey } from "@app/components/shared/config/types";
import { navigateToSettings } from "@app/utils/settingsNavigation";
-export function openAppSettings(targetKey?: NavKey, notice?: string) {
+export function openAppSettings(targetKey: NavKey, notice?: string) {
try {
- navigateToSettings(targetKey ?? "overview");
+ navigateToSettings(targetKey);
// The Plan section shows why the caller sent the user here (e.g. "Not
// enough credits"), and only it listens.
if (notice) {
diff --git a/frontend/editor/src/core/components/policies/DownloadsProcessingWizard.tsx b/frontend/editor/src/core/components/policies/DownloadsProcessingWizard.tsx
deleted file mode 100644
index effe5fa74a..0000000000
--- a/frontend/editor/src/core/components/policies/DownloadsProcessingWizard.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * Core stub for the Downloads processing offer. The real implementation lives at the
- * same path under proprietary/ and shadows this via the @app/* alias cascade.
- */
-export function DownloadsProcessingWizard(_props?: { active?: boolean }) {
- return null;
-}
diff --git a/frontend/editor/src/core/components/shared/AppBanner.stories.tsx b/frontend/editor/src/core/components/shared/AppBanner.stories.tsx
index fc1719b8f9..c011c16662 100644
--- a/frontend/editor/src/core/components/shared/AppBanner.stories.tsx
+++ b/frontend/editor/src/core/components/shared/AppBanner.stories.tsx
@@ -167,17 +167,6 @@ export const AllTopBars: StoryObj = {
/>
</Row>
- <Row caption="Set as default app · DefaultAppBanner (desktop)">
- <AppBanner
- icon="file-text"
- message="Make Stirling PDF your default application for opening PDF files."
- buttonText="Set Default"
- onButtonClick={() => {}}
- secondaryButtonText="Don't remind me again"
- onSecondaryButtonClick={() => {}}
- />
- </Row>
-
<Row caption="Danger tone (available, no caller yet)">
<AppBanner
tone="danger"
diff --git a/frontend/editor/src/core/components/shared/FileSidebar.tsx b/frontend/editor/src/core/components/shared/FileSidebar.tsx
index 957492b365..4f4113262c 100644
--- a/frontend/editor/src/core/components/shared/FileSidebar.tsx
+++ b/frontend/editor/src/core/components/shared/FileSidebar.tsx
@@ -48,7 +48,6 @@ import { DeleteFilesDialog } from "@app/components/filesPage/DeleteFilesDialog";
import { RenameFileDialog } from "@app/components/shared/RenameFileDialog";
import { duplicateStoredFile } from "@app/utils/duplicateFile";
import { SidebarChecklistSlot } from "@app/components/shared/SidebarChecklistSlot";
-import { SidebarProcessingSlot } from "@app/components/shared/SidebarProcessingSlot";
import {
deleteServerFile,
type DeleteScope,
@@ -1122,8 +1121,6 @@ const FileSidebar = forwardRef<HTMLDivElement, FileSidebarProps>(
)}
</div>
</NavSurface>
-
- <SidebarProcessingSlot />
</div>
<BulkUploadToServerModal
diff --git a/frontend/editor/src/core/components/shared/SidebarChecklistSlot.tsx b/frontend/editor/src/core/components/shared/SidebarChecklistSlot.tsx
index 29037a7590..3eba84dba5 100644
--- a/frontend/editor/src/core/components/shared/SidebarChecklistSlot.tsx
+++ b/frontend/editor/src/core/components/shared/SidebarChecklistSlot.tsx
@@ -1,8 +1,5 @@
-/**
- * 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.
- */
+/** Extension point for the getting-started checklist above the sidebar footer.
+ * Core renders nothing; the cloud builds (web SaaS and desktop) shadow it. */
export function SidebarChecklistSlot() {
return null;
}
diff --git a/frontend/editor/src/core/components/shared/SidebarProcessingSlot.tsx b/frontend/editor/src/core/components/shared/SidebarProcessingSlot.tsx
deleted file mode 100644
index 7dbc39386d..0000000000
--- a/frontend/editor/src/core/components/shared/SidebarProcessingSlot.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * 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() {
- return null;
-}
diff --git a/frontend/editor/src/core/services/downloadsDirectory.test.ts b/frontend/editor/src/core/services/downloadsDirectory.test.ts
deleted file mode 100644
index 82fa0b872c..0000000000
--- a/frontend/editor/src/core/services/downloadsDirectory.test.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { describe, expect, it } from "vitest";
-import { getDownloadsDirectory } from "@app/services/downloadsDirectory";
-
-describe("getDownloadsDirectory (core)", () => {
- // Pins the stub: a real path here would make the Downloads offer appear on web builds,
- // which have no machine to read.
- it("has no directory to report", async () => {
- await expect(getDownloadsDirectory()).resolves.toBeNull();
- });
-});
diff --git a/frontend/editor/src/core/services/downloadsDirectory.ts b/frontend/editor/src/core/services/downloadsDirectory.ts
deleted file mode 100644
index 6a97f2cace..0000000000
--- a/frontend/editor/src/core/services/downloadsDirectory.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-/** Absolute path to the user's Downloads folder, or null where this build cannot see a filesystem.
- * Hazard: readDiskFile refuses paths outside a mounted directory, so mount this before reading. */
-export async function getDownloadsDirectory(): Promise<string | null> {
- return null;
-}
diff --git a/frontend/editor/src/desktop/components/DesktopBannerInitializer.tsx b/frontend/editor/src/desktop/components/DesktopBannerInitializer.tsx
index ec4290590c..8619254189 100644
--- a/frontend/editor/src/desktop/components/DesktopBannerInitializer.tsx
+++ b/frontend/editor/src/desktop/components/DesktopBannerInitializer.tsx
@@ -1,6 +1,5 @@
import { useEffect } from "react";
import { useBanner } from "@app/contexts/BannerContext";
-import { DefaultAppBanner } from "@app/components/shared/DefaultAppBanner";
import UpgradeBanner from "@app/components/shared/UpgradeBanner";
import { TeamInvitationBanner } from "@app/components/shared/TeamInvitationBanner";
import { SelfHostedOfflineBanner } from "@app/components/shared/SelfHostedOfflineBanner";
@@ -14,7 +13,6 @@ export function DesktopBannerInitializer() {
<SelfHostedOfflineBanner />
<TeamInvitationBanner />
<UpgradeBanner />
- <DefaultAppBanner />
</>,
);
return () => {
diff --git a/frontend/editor/src/desktop/components/onboarding/checklistInviteTarget.ts b/frontend/editor/src/desktop/components/onboarding/checklistInviteTarget.ts
new file mode 100644
index 0000000000..224bc195df
--- /dev/null
+++ b/frontend/editor/src/desktop/components/onboarding/checklistInviteTarget.ts
@@ -0,0 +1,21 @@
+import type { NavKey } from "@app/components/shared/config/types";
+import { useAppConfig } from "@app/contexts/AppConfigContext";
+import { useSelfHostedAuth } from "@app/hooks/useSelfHostedAuth";
+import { useChecklistInviteTarget as useCloudInviteTarget } from "@cloud/components/onboarding/checklistInviteTarget";
+
+/** Cloud team leaders invite from Users; self-hosted admins from People, once login is on.
+ * Guests are excluded by the Cloud check and are never self-hosted admins. */
+export function useChecklistInviteTarget(): NavKey | null {
+ const cloudTarget = useCloudInviteTarget();
+ const { isSelfHosted, isAuthenticated } = useSelfHostedAuth();
+ const { config } = useAppConfig();
+ if (
+ isSelfHosted &&
+ isAuthenticated &&
+ config?.enableLogin &&
+ config.isAdmin
+ ) {
+ return "people";
+ }
+ return cloudTarget;
+}
diff --git a/frontend/editor/src/desktop/components/onboarding/checklistSetupItem.tsx b/frontend/editor/src/desktop/components/onboarding/checklistSetupItem.tsx
new file mode 100644
index 0000000000..ac3426c905
--- /dev/null
+++ b/frontend/editor/src/desktop/components/onboarding/checklistSetupItem.tsx
@@ -0,0 +1,36 @@
+import { useEffect } from "react";
+import { useDefaultApp } from "@app/hooks/useDefaultApp";
+import type { ChecklistSetupItem } from "@cloud/components/onboarding/checklistSetupItem";
+
+export type {
+ ChecklistItem,
+ ChecklistSetupItem,
+} from "@cloud/components/onboarding/checklistSetupItem";
+
+export function useChecklistSetupItem(
+ _markDone: (stepId: string) => void,
+): ChecklistSetupItem {
+ const { isDefault, handleSetDefault, checkDefaultStatus } = useDefaultApp();
+
+ // Windows makes the choice in its own settings dialog, so re-check when the user comes back.
+ useEffect(() => {
+ window.addEventListener("focus", checkDefaultStatus);
+ return () => window.removeEventListener("focus", checkDefaultStatus);
+ }, [checkDefaultStatus]);
+
+ if (isDefault !== false) {
+ return { item: null, dialog: null };
+ }
+
+ return {
+ item: {
+ id: "set-default-app",
+ titleKey: "onboarding.checklist.setDefaultApp.title",
+ titleFallback: "Make Stirling your default",
+ descriptionKey: "onboarding.checklist.setDefaultApp.description",
+ descriptionFallback: "Open PDF files in Stirling PDF",
+ onClick: () => void handleSetDefault(),
+ },
+ dialog: null,
+ };
+}
diff --git a/frontend/editor/src/desktop/components/shared/DefaultAppBanner.tsx b/frontend/editor/src/desktop/components/shared/DefaultAppBanner.tsx
deleted file mode 100644
index 120f2449c5..0000000000
--- a/frontend/editor/src/desktop/components/shared/DefaultAppBanner.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import React, { useState } from "react";
-import { useTranslation } from "react-i18next";
-import { AppBanner } from "@app/components/shared/AppBanner";
-import { useDefaultApp } from "@app/hooks/useDefaultApp";
-
-export const DefaultAppBanner: React.FC = () => {
- const { t } = useTranslation();
- const {
- isDefault,
- isLoading,
- promptDismissed,
- handleSetDefault,
- dontRemindAgain,
- } = useDefaultApp();
- const [sessionDismissed, setSessionDismissed] = useState(false);
-
- return (
- <AppBanner
- icon="file-text"
- message={t(
- "defaultApp.prompt.message",
- "Make Stirling PDF your default application for opening PDF files.",
- )}
- buttonText={t("defaultApp.setDefault", "Set Default")}
- buttonIcon="circle-check"
- onButtonClick={handleSetDefault}
- secondaryButtonText={t(
- "defaultApp.prompt.dontRemind",
- "Don't remind me again",
- )}
- onSecondaryButtonClick={dontRemindAgain}
- onDismiss={() => setSessionDismissed(true)}
- loading={isLoading}
- show={!sessionDismissed && !promptDismissed && isDefault === false}
- />
- );
-};
diff --git a/frontend/editor/src/desktop/components/shared/SidebarProcessingSlot.tsx b/frontend/editor/src/desktop/components/shared/SidebarProcessingSlot.tsx
deleted file mode 100644
index f426bde777..0000000000
--- a/frontend/editor/src/desktop/components/shared/SidebarProcessingSlot.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import { useState } from "react";
-import { useTranslation } from "react-i18next";
-import { usePoliciesEnabled } from "@app/components/policies/usePoliciesEnabled";
-import { ClassificationDemoModal } from "@app/components/onboarding/classificationDemo/ClassificationDemoModal";
-import { Button } from "@app/ui/Button";
-
-/** Reopens the desktop Downloads offer after the first-run modal was dismissed. */
-export function SidebarProcessingSlot() {
- const { t } = useTranslation();
- const enabled = usePoliciesEnabled();
- const [open, setOpen] = useState(false);
- if (!enabled) return null;
- return (
- <>
- <Button variant="secondary" size="sm" onClick={() => setOpen(true)}>
- {t("classificationDemo.offer.cta", "Process my Downloads folder")}
- </Button>
- {open && (
- <ClassificationDemoModal opened onClose={() => setOpen(false)} />
- )}
- </>
- );
-}
diff --git a/frontend/editor/src/desktop/components/shared/config/configSections/DefaultAppSettings.tsx b/frontend/editor/src/desktop/components/shared/config/configSections/DefaultAppSettings.tsx
index 01d908f0b2..72857eb181 100644
--- a/frontend/editor/src/desktop/components/shared/config/configSections/DefaultAppSettings.tsx
+++ b/frontend/editor/src/desktop/components/shared/config/configSections/DefaultAppSettings.tsx
@@ -1,21 +1,12 @@
import React from "react";
-import { Paper, Text, Group, Switch, Stack } from "@mantine/core";
+import { Paper, Text, Group, Stack } from "@mantine/core";
import { Button } from "@app/ui/Button";
import { useTranslation } from "react-i18next";
import { useDefaultApp } from "@app/hooks/useDefaultApp";
export const DefaultAppSettings: React.FC = () => {
const { t } = useTranslation();
- const {
- isDefault,
- isLoading,
- promptDismissed,
- handleSetDefault,
- setRemindWhenNotDefault,
- } = useDefaultApp();
-
- // Remind is on by default (promptDismissed is false until the user opts out).
- const remindEnabled = !promptDismissed;
+ const { isDefault, isLoading, handleSetDefault } = useDefaultApp();
return (
<Paper withBorder p="md" radius="md">
@@ -54,35 +45,6 @@ export const DefaultAppSettings: React.FC = () => {
: t("settings.general.setAsDefault", "Set as Default")}
</Button>
</Group>
-
- {isDefault === false && (
- <Group justify="space-between" align="center" wrap="nowrap">
- <div style={{ flex: 1, minWidth: 0 }}>
- <Text fw={500} size="sm">
- {t(
- "settings.general.defaultPdfEditorRemind",
- "Remind me to set as default",
- )}
- </Text>
- <Text size="xs" c="dimmed" mt={4}>
- {t(
- "settings.general.defaultPdfEditorRemindDescription",
- "Show a banner when Stirling PDF is not your default PDF application.",
- )}
- </Text>
- </div>
- <Switch
- checked={remindEnabled}
- onChange={(event) =>
- setRemindWhenNotDefault(event.currentTarget.checked)
- }
- aria-label={t(
- "settings.general.defaultPdfEditorRemind",
- "Remind me to set as default",
- )}
- />
- </Group>
- )}
</Stack>
</Paper>
);
diff --git a/frontend/editor/src/desktop/hooks/useDefaultApp.ts b/frontend/editor/src/desktop/hooks/useDefaultApp.ts
index 1719ee0924..477e21d632 100644
--- a/frontend/editor/src/desktop/hooks/useDefaultApp.ts
+++ b/frontend/editor/src/desktop/hooks/useDefaultApp.ts
@@ -1,4 +1,4 @@
-import { useState, useEffect } from "react";
+import { useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { defaultAppService } from "@app/services/defaultAppService";
import { alert } from "@app/components/toast";
@@ -7,40 +7,19 @@ export const useDefaultApp = () => {
const { t } = useTranslation();
const [isDefault, setIsDefault] = useState<boolean | null>(null);
const [isLoading, setIsLoading] = useState(false);
- const [promptDismissed, setPromptDismissed] = useState(() =>
- defaultAppService.hasUserDismissedPrompt(),
- );
- useEffect(() => {
- checkDefaultStatus();
- }, []);
-
- useEffect(() => {
- return defaultAppService.subscribePromptDismissed(() => {
- setPromptDismissed(defaultAppService.hasUserDismissedPrompt());
- });
- }, []);
-
- const checkDefaultStatus = async () => {
+ const checkDefaultStatus = useCallback(async () => {
try {
const status = await defaultAppService.isDefaultPdfHandler();
setIsDefault(status);
} catch (error) {
console.error("Failed to check default status:", error);
}
- };
-
- /** Permanently stop showing the banner (same as turning off the settings toggle). */
- const dontRemindAgain = () => {
- defaultAppService.setPromptDismissed(true);
- setPromptDismissed(true);
- };
+ }, []);
- /** Settings toggle: remind is on by default until the user opts out. */
- const setRemindWhenNotDefault = (remind: boolean) => {
- defaultAppService.setPromptDismissed(!remind);
- setPromptDismissed(!remind);
- };
+ useEffect(() => {
+ void checkDefaultStatus();
+ }, [checkDefaultStatus]);
const handleSetDefault = async () => {
setIsLoading(true);
@@ -85,10 +64,7 @@ export const useDefaultApp = () => {
return {
isDefault,
isLoading,
- promptDismissed,
checkDefaultStatus,
- dontRemindAgain,
- setRemindWhenNotDefault,
handleSetDefault,
};
};
diff --git a/frontend/editor/src/desktop/services/defaultAppService.ts b/frontend/editor/src/desktop/services/defaultAppService.ts
index 0d5d17e45d..c3875f3120 100644
--- a/frontend/editor/src/desktop/services/defaultAppService.ts
+++ b/frontend/editor/src/desktop/services/defaultAppService.ts
@@ -1,20 +1,6 @@
import { invoke } from "@tauri-apps/api/core";
-const PROMPT_DISMISSED_KEY = "stirlingpdf_default_app_prompt_dismissed";
-
-type PromptDismissedListener = () => void;
-const promptDismissedListeners = new Set<PromptDismissedListener>();
-
-function notifyPromptDismissedListeners(): void {
- for (const listener of promptDismissedListeners) {
- listener();
- }
-}
-
-/**
- * Service for managing default PDF handler settings
- * Note: Uses localStorage for machine-specific preferences (not synced to server)
- */
+/** Service for managing default PDF handler settings */
export const defaultAppService = {
/**
* Check if Stirling PDF is the default PDF handler
@@ -44,52 +30,4 @@ export const defaultAppService = {
return "error";
}
},
-
- /**
- * Check if user has dismissed the default app prompt (machine-specific)
- */
- hasUserDismissedPrompt(): boolean {
- try {
- const dismissed = localStorage.getItem(PROMPT_DISMISSED_KEY);
- return dismissed === "true";
- } catch {
- return false;
- }
- },
-
- /**
- * Mark that user has dismissed the default app prompt (machine-specific)
- */
- setPromptDismissed(dismissed: boolean): void {
- try {
- localStorage.setItem(PROMPT_DISMISSED_KEY, dismissed ? "true" : "false");
- notifyPromptDismissedListeners();
- } catch (error) {
- console.error("[DefaultApp] Failed to save prompt preference:", error);
- }
- },
-
- /**
- * Subscribe to prompt-dismissed preference changes (same-session sync).
- * Returns an unsubscribe function.
- */
- subscribePromptDismissed(listener: PromptDismissedListener): () => void {
- promptDismissedListeners.add(listener);
- return () => {
- promptDismissedListeners.delete(listener);
- };
- },
-
- /**
- * Check if we should show the default app prompt
- * Returns true if: user hasn't dismissed it AND app is not default handler
- */
- async shouldShowPrompt(): Promise<boolean> {
- if (this.hasUserDismissedPrompt()) {
- return false;
- }
-
- const isDefault = await this.isDefaultPdfHandler();
- return !isDefault;
- },
};
diff --git a/frontend/editor/src/desktop/services/downloadsDirectory.test.ts b/frontend/editor/src/desktop/services/downloadsDirectory.test.ts
deleted file mode 100644
index a577a3064a..0000000000
--- a/frontend/editor/src/desktop/services/downloadsDirectory.test.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { beforeEach, describe, expect, it, vi } from "vitest";
-
-const { downloadDirMock } = vi.hoisted(() => ({ downloadDirMock: vi.fn() }));
-
-vi.mock("@tauri-apps/api/path", () => ({ downloadDir: downloadDirMock }));
-
-import { getDownloadsDirectory } from "@app/services/downloadsDirectory";
-
-/** The only project where @app/* resolves the desktop implementation rather than the core stub. */
-describe("getDownloadsDirectory (desktop)", () => {
- beforeEach(() => {
- // Braces matter: mockReset() returns the mock for chaining, and a function returned from a
- // hook is treated as a teardown callback - which would call the mock after every test.
- downloadDirMock.mockReset();
- });
-
- it("returns the path the OS reports", async () => {
- downloadDirMock.mockResolvedValue("/Users/ada/Downloads");
- await expect(getDownloadsDirectory()).resolves.toBe("/Users/ada/Downloads");
- });
-
- it("answers null rather than throwing when the OS has no Downloads directory", async () => {
- downloadDirMock.mockImplementation(() => {
- throw new Error("no Download dir");
- });
- await expect(getDownloadsDirectory()).resolves.toBeNull();
- });
-
- it("answers null when access is refused, so the offer simply does not appear", async () => {
- downloadDirMock.mockImplementation(() => {
- throw new Error("forbidden path");
- });
- await expect(getDownloadsDirectory()).resolves.toBeNull();
- });
-});
diff --git a/frontend/editor/src/desktop/services/downloadsDirectory.ts b/frontend/editor/src/desktop/services/downloadsDirectory.ts
deleted file mode 100644
index d72ca4ab00..0000000000
--- a/frontend/editor/src/desktop/services/downloadsDirectory.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { downloadDir } from "@tauri-apps/api/path";
-
-/** Desktop: the real Downloads folder, from the OS. Null rather than a throw when there is none
- * or access is refused - to a caller that is "nothing to offer", not an error. */
-export async function getDownloadsDirectory(): Promise<string | null> {
- try {
- return await downloadDir();
- } catch {
- return null;
- }
-}
diff --git a/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.css b/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.css
deleted file mode 100644
index d2897a72b4..0000000000
--- a/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.css
+++ /dev/null
@@ -1,96 +0,0 @@
-.downloads-wizard__title {
- display: inline-flex;
- align-items: center;
- gap: 0.45rem;
-}
-
-.downloads-wizard__body {
- display: flex;
- flex-direction: column;
- gap: 0.7rem;
- font-size: 0.9rem;
- color: var(--c-text);
-}
-
-.downloads-wizard__path {
- font-family: var(--font-mono, monospace);
- font-size: 0.8rem;
- color: var(--c-text-muted);
- background: var(--c-surface);
- border: 1px solid var(--c-border-subtle);
- border-radius: var(--radius-sm, 4px);
- padding: 0.35rem 0.5rem;
- word-break: break-all;
-}
-
-.downloads-wizard__facts {
- margin: 0;
- padding-left: 1.1rem;
- display: flex;
- flex-direction: column;
- gap: 0.35rem;
- font-size: 0.84rem;
- color: var(--c-text-muted);
-}
-
-.downloads-wizard__progress {
- align-items: center;
- text-align: center;
-}
-
-/* Fills as runs settle; width is driven inline from the settled/total ratio. */
-.downloads-wizard__bar {
- width: 100%;
- height: 0.35rem;
- border-radius: 999px;
- background: var(--c-border-subtle);
- overflow: hidden;
-}
-
-.downloads-wizard__bar > span {
- display: block;
- height: 100%;
- border-radius: 999px;
- background: var(--c-primary);
- transition: width 0.3s ease;
-}
-
-.downloads-wizard__tick {
- color: var(--c-success, var(--c-primary));
-}
-
-.downloads-wizard__warn {
- color: var(--c-danger-text, var(--c-text));
- font-size: 0.84rem;
-}
-
-.downloads-wizard__foot {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- gap: 0.5rem;
-}
-
-/* The entry point: a compact row in the side panel holding the button that opens the offer. */
-.downloads-wizard__trigger {
- display: flex;
- padding: 0.5rem;
-}
-
-.downloads-wizard__trigger > * {
- width: 100%;
- justify-content: flex-start;
-}
-
-/* ---- The card wall: every file in the sweep, lighting up as its run settles. ---- */
-
-/* Counts header above the wall ("12 of 100 · 4 types found"). */
-.downloads-wizard__counts {
- font-size: 0.82rem;
- color: var(--c-text-muted);
-}
-
-.downloads-wizard__counts strong {
- color: var(--c-text);
- font-variant-numeric: tabular-nums;
-}
diff --git a/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.test.tsx b/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.test.tsx
deleted file mode 100644
index 7954689dd0..0000000000
--- a/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.test.tsx
+++ /dev/null
@@ -1,208 +0,0 @@
-import { MantineProvider } from "@mantine/core";
-import { render as rtlRender, screen, waitFor } from "@testing-library/react";
-import userEvent from "@testing-library/user-event";
-import { beforeEach, describe, expect, it, vi } from "vitest";
-
-const h = vi.hoisted(() => ({
- downloadsDir: "/Users/ada/Downloads" as string | null,
- listing: null as { files: unknown[]; directories: unknown[] } | null,
- listThrows: false,
- canList: true,
- block: null as string | null,
- classificationActive: true,
- stubs: [] as { id: string; name: string; classificationLabels?: string[] }[],
- addFiles: vi.fn(),
- mountLocalFolder: vi.fn(),
- readDiskFile: vi.fn(),
-}));
-
-vi.mock("@app/services/downloadsDirectory", () => ({
- getDownloadsDirectory: async () => h.downloadsDir,
-}));
-vi.mock("@app/services/localFolderContents", () => ({
- get canListDirectory() {
- return h.canList;
- },
- listDirectory: async () => {
- if (h.listThrows) throw new Error("Operation not permitted");
- return h.listing;
- },
- readDiskFile: (entry: { name: string }) => h.readDiskFile(entry),
-}));
-vi.mock("@app/hooks/useServerProcessingBlock", () => ({
- useServerProcessingBlock: () => h.block,
-}));
-vi.mock("@app/hooks/usePolicies", () => ({
- usePolicies: () => ({
- policies: {
- classification: h.classificationActive
- ? {
- configured: true,
- enabled: true,
- backendId: "be-1",
- runsOnEditor: true,
- runOn: "upload",
- }
- : { configured: false, enabled: false, runsOnEditor: true },
- },
- }),
-}));
-vi.mock("@app/hooks/useFileHandler", () => ({
- useFileHandler: () => ({ addFiles: h.addFiles }),
-}));
-vi.mock("@app/contexts/FolderContext", () => ({
- useFolders: () => ({ mountLocalFolder: h.mountLocalFolder }),
-}));
-vi.mock("@app/contexts/FileContext", () => ({
- useAllFiles: () => ({ fileStubs: h.stubs }),
-}));
-vi.mock("@app/services/apiClient", () => ({
- default: { get: vi.fn().mockResolvedValue({}) },
-}));
-// Render the English copy rather than raw keys, so assertions read like the UI.
-vi.mock("react-i18next", () => ({
- useTranslation: () => ({
- t: (key: string, arg?: unknown) => {
- if (typeof arg === "string") return arg;
- const opts = arg as { defaultValue?: string } | undefined;
- return opts?.defaultValue ?? key;
- },
- }),
-}));
-
-import { DownloadsProcessingWizard } from "@app/components/policies/DownloadsProcessingWizard";
-
-const render = (ui: React.ReactElement) =>
- rtlRender(<MantineProvider>{ui}</MantineProvider>);
-
-const pdf = (name: string, lastModified = 1) => ({
- path: `/Users/ada/Downloads/${name}`,
- name,
- sizeBytes: 10,
- lastModified,
-});
-
-describe("DownloadsProcessingWizard", () => {
- beforeEach(() => {
- h.downloadsDir = "/Users/ada/Downloads";
- h.listing = { files: [pdf("a.pdf"), pdf("b.pdf")], directories: [] };
- h.listThrows = false;
- h.canList = true;
- h.block = null;
- h.classificationActive = true;
- h.stubs = [];
- h.addFiles
- .mockReset()
- .mockImplementation(async (files: File[]) =>
- files.map((f, i) => ({ fileId: `id-${f.name}-${i}` })),
- );
- h.mountLocalFolder.mockReset().mockResolvedValue({});
- h.readDiskFile
- .mockReset()
- .mockImplementation(
- async (e: { name: string }) =>
- new File([new Uint8Array([1])], e.name, { type: "application/pdf" }),
- );
- });
-
- it("offers the PDFs it found on the machine", async () => {
- render(<DownloadsProcessingWizard />);
- expect(
- await screen.findByRole("button", { name: /Downloads/i }),
- ).toBeTruthy();
- });
-
- it("stays hidden without a connected server", async () => {
- h.block = "Sign in to Stirling Cloud or connect a self-hosted server.";
- render(<DownloadsProcessingWizard />);
- await new Promise((r) => setTimeout(r, 0));
- expect(screen.queryByRole("button", { name: /Downloads/i })).toBeNull();
- });
-
- it("stays hidden when the build cannot read the disk", async () => {
- h.canList = false;
- render(<DownloadsProcessingWizard />);
- await new Promise((r) => setTimeout(r, 0));
- expect(screen.queryByRole("button", { name: /Downloads/i })).toBeNull();
- });
-
- it("stays hidden when the server will not run the classification policy", async () => {
- h.classificationActive = false;
- render(<DownloadsProcessingWizard />);
- await new Promise((r) => setTimeout(r, 0));
- expect(screen.queryByRole("button", { name: /Downloads/i })).toBeNull();
- });
-
- it("stays hidden when the machine reports no Downloads folder", async () => {
- h.downloadsDir = null;
- render(<DownloadsProcessingWizard />);
- await new Promise((r) => setTimeout(r, 0));
- expect(screen.queryByRole("button", { name: /Downloads/i })).toBeNull();
- });
-
- it("stays hidden when Downloads holds no PDFs", async () => {
- h.listing = { files: [], directories: [] };
- render(<DownloadsProcessingWizard />);
- await new Promise((r) => setTimeout(r, 0));
- expect(screen.queryByRole("button", { name: /Downloads/i })).toBeNull();
- });
-
- it("stays hidden when reading Downloads is refused", async () => {
- // The macOS Downloads-access case: listDirectory throws.
- h.listThrows = true;
- render(<DownloadsProcessingWizard />);
- await new Promise((r) => setTimeout(r, 0));
- expect(screen.queryByRole("button", { name: /Downloads/i })).toBeNull();
- });
-
- it("mounts Downloads and imports its PDFs when approved", async () => {
- const user = userEvent.setup();
- render(<DownloadsProcessingWizard />);
- await user.click(await screen.findByRole("button", { name: /Downloads/i }));
- await user.click(
- await screen.findByRole("button", { name: /Process my Downloads/i }),
- );
-
- await waitFor(() => expect(h.mountLocalFolder).toHaveBeenCalled());
- expect(h.mountLocalFolder.mock.calls[0][0]).toBe("/Users/ada/Downloads");
- await waitFor(() => expect(h.addFiles).toHaveBeenCalled());
-
- // Never steal the workbench selection for a background sweep.
- expect(h.addFiles.mock.calls[0][1]).toMatchObject({ selectFiles: false });
- const imported = h.addFiles.mock.calls.flatMap((c) => c[0] as File[]);
- expect(imported.map((f) => f.name).sort()).toEqual(["a.pdf", "b.pdf"]);
- });
-
- it("takes the newest PDFs first", async () => {
- h.listing = {
- files: [pdf("old.pdf", 1), pdf("new.pdf", 999)],
- directories: [],
- };
- const user = userEvent.setup();
- render(<DownloadsProcessingWizard />);
- await user.click(await screen.findByRole("button", { name: /Downloads/i }));
- await user.click(
- await screen.findByRole("button", { name: /Process my Downloads/i }),
- );
-
- await waitFor(() => expect(h.readDiskFile).toHaveBeenCalled());
- expect(h.readDiskFile.mock.calls[0][0].name).toBe("new.pdf");
- });
-
- it("ignores files that are not PDFs", async () => {
- h.listing = {
- files: [pdf("a.pdf"), { ...pdf("notes.txt"), name: "notes.txt" }],
- directories: [],
- };
- const user = userEvent.setup();
- render(<DownloadsProcessingWizard />);
- await user.click(await screen.findByRole("button", { name: /Downloads/i }));
- await user.click(
- await screen.findByRole("button", { name: /Process my Downloads/i }),
- );
-
- await waitFor(() => expect(h.addFiles).toHaveBeenCalled());
- const imported = h.addFiles.mock.calls.flatMap((c) => c[0] as File[]);
- expect(imported.map((f) => f.name)).toEqual(["a.pdf"]);
- });
-});
diff --git a/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.tsx b/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.tsx
deleted file mode 100644
index 5c46eba55b..0000000000
--- a/frontend/editor/src/proprietary/components/policies/DownloadsProcessingWizard.tsx
+++ /dev/null
@@ -1,411 +0,0 @@
-import { useEffect, useMemo, useRef, useState } from "react";
-import { useTranslation } from "react-i18next";
-import { Loader } from "@mantine/core";
-import { Icon } from "@app/ui/Icon";
-import { Button } from "@app/ui/Button";
-import { Modal } from "@app/ui/Modal";
-import {
- SweepRunWall,
- type SweepWallCard,
-} from "@app/components/policies/SweepRunWall";
-import { useFileHandler } from "@app/hooks/useFileHandler";
-import { useFolders } from "@app/contexts/FolderContext";
-import { useAllFiles } from "@app/contexts/FileContext";
-import { getDownloadsDirectory } from "@app/services/downloadsDirectory";
-import {
- canListDirectory,
- listDirectory,
- readDiskFile,
- type DiskFileEntry,
-} from "@app/services/localFolderContents";
-import { useServerProcessingBlock } from "@app/hooks/useServerProcessingBlock";
-import { usePolicies } from "@app/hooks/usePolicies";
-import { CLASSIFICATION_POLICY_KEY } from "@app/data/classificationPolicy";
-import { editorTriggerOf } from "@app/policies/runOn";
-import type { FileId, StirlingFileStub } from "@app/types/fileContext";
-import apiClient from "@app/services/apiClient";
-import "@app/components/policies/DownloadsProcessingWizard.css";
-
-type Phase = "asking" | "working" | "done" | "failed";
-
-/** Newest PDFs one offer takes on. Matches the server sweep's own cap, so the number the offer
- * has always shown does not move. */
-const SCAN_LIMIT = 100;
-
-/** Files read at once. readDiskFile holds each file's bytes twice while building the File, so
- * the whole folder must not be read in one go. */
-const READ_BATCH = 4;
-
-interface DownloadsProcessingWizardProps {
- /** Renders nothing until true, so the offer never competes with a first load. */
- active?: boolean;
-}
-
-interface FoundDownloads {
- directory: string;
- /** Newest first, so a capped offer takes the files the user most likely wants. */
- entries: DiskFileEntry[];
-}
-
-/**
- * Offers to classify the PDFs in the user's Downloads folder, read here because a connected
- * server has no such directory. Importing them is the whole job; the files on disk are untouched.
- */
-export function DownloadsProcessingWizard({
- active = true,
-}: DownloadsProcessingWizardProps) {
- const { t } = useTranslation();
- const [found, setFound] = useState<FoundDownloads | null>(null);
- const [open, setOpen] = useState(false);
- const [phase, setPhase] = useState<Phase>("asking");
- const [error, setError] = useState<string | null>(null);
- /** Workspace ids this run took on; their stubs carry the verdict as it arrives. */
- const [trackedIds, setTrackedIds] = useState<FileId[]>([]);
- /** Names still waiting to be read, so the wall shows the whole job from the first frame. */
- const [queued, setQueued] = useState<string[]>([]);
- const [unreadable, setUnreadable] = useState(0);
- // Set when the user cancels; the read loop checks it between batches.
- const cancelRequested = useRef(false);
- const { addFiles } = useFileHandler();
- const { mountLocalFolder } = useFolders();
- const { fileStubs } = useAllFiles();
- const { policies } = usePolicies();
- const block = useServerProcessingBlock();
- // Importing achieves nothing unless the server classifies: a core-flavour self-hosted build
- // seeds no such policy, and every imported file would sit without a verdict.
- const willClassify =
- editorTriggerOf(policies[CLASSIFICATION_POLICY_KEY]) === "upload";
-
- // Needs a connected server, the classification policy, and a build that can read the disk.
- // canListDirectory is a build constant, so only block and willClassify can settle later.
- useEffect(() => {
- if (!active || block || !willClassify || !canListDirectory) return;
- let cancelled = false;
-
- void (async () => {
- const directory = await getDownloadsDirectory();
- if (cancelled || !directory) return;
- const listing = await listDirectory(directory).catch(() => null);
- if (cancelled || !listing) return;
- const pdfs = listing.files
- .filter((entry) => entry.name.toLowerCase().endsWith(".pdf"))
- .sort((a, b) => b.lastModified - a.lastModified);
- if (pdfs.length === 0) return;
- setFound({ directory, entries: pdfs });
- // Warm the AI engine while the user reads the offer, so the first escalation pays no
- // cold start. Best-effort.
- void apiClient
- .get("/api/v1/ai/health", { suppressErrorToast: true })
- .catch(() => {});
- })();
-
- return () => {
- cancelled = true;
- };
- }, [active, block, willClassify]);
-
- /** Closing resets to the question, so the offer can be reopened and re-run. */
- const close = () => {
- setOpen(false);
- setPhase("asking");
- setError(null);
- setTrackedIds([]);
- setQueued([]);
- setUnreadable(0);
- };
-
- const cancelSweep = () => {
- cancelRequested.current = true;
- close();
- };
-
- const tracked = useMemo<StirlingFileStub[]>(() => {
- const byId = new Map(fileStubs.map((stub) => [stub.id, stub]));
- return trackedIds
- .map((id) => byId.get(id))
- .filter((stub): stub is StirlingFileStub => stub != null);
- }, [fileStubs, trackedIds]);
-
- // A verdict, including a deliberate "nothing found" empty array, means that file is done.
- const classified = tracked.filter(
- (stub) => stub.classificationLabels !== undefined,
- ).length;
-
- const cards = useMemo<SweepWallCard[]>(
- () => [
- ...tracked.map((stub) => ({
- name: stub.name,
- state:
- stub.classificationLabels === undefined
- ? ("running" as const)
- : ("done" as const),
- labels: stub.classificationLabels ?? [],
- })),
- ...queued.map((name) => ({
- name,
- state: "pending" as const,
- labels: [],
- })),
- ],
- [tracked, queued],
- );
-
- const approve = async () => {
- if (!found) return;
- cancelRequested.current = false;
- setPhase("working");
- setUnreadable(0);
- // A cancelled run's ids outlive close(): its in-flight batch appends after the reset.
- setTrackedIds([]);
- const batch = found.entries.slice(0, SCAN_LIMIT);
- setQueued(batch.map((entry) => entry.name));
-
- try {
- // readDiskFile refuses a path outside a mounted directory, so the mount comes first. It
- // also puts Downloads in the file manager, which is where the user looks next.
- const segments = found.directory.split(/[/\\]/).filter(Boolean);
- await mountLocalFolder(
- found.directory,
- segments[segments.length - 1] ?? found.directory,
- );
-
- for (let index = 0; index < batch.length; index += READ_BATCH) {
- if (cancelRequested.current) return;
- const slice = batch.slice(index, index + READ_BATCH);
- const read = await Promise.all(
- slice.map((entry) => readDiskFile(entry).catch(() => null)),
- );
- const files = read.filter((file): file is File => file != null);
- if (files.length < slice.length) {
- setUnreadable((count) => count + (slice.length - files.length));
- }
- if (files.length > 0) {
- // selectFiles:false: a couple of dozen auto-selected files would take the workbench
- // away from whatever the user was doing.
- const added = await addFiles(files, { selectFiles: false });
- setTrackedIds((prev) => [
- ...prev,
- ...added.map((file) => file.fileId),
- ]);
- }
- const names = new Set(slice.map((entry) => entry.name));
- setQueued((prev) => prev.filter((name) => !names.has(name)));
- }
- setPhase("done");
- } catch (e) {
- setError(e instanceof Error ? e.message : String(e));
- setPhase("failed");
- }
- };
-
- const typesFound = useMemo(() => {
- const ids = new Set<string>();
- for (const card of cards) {
- for (const label of card.labels) ids.add(label);
- }
- return ids.size;
- }, [cards]);
-
- if (!found) return null;
-
- const capped = found.entries.length > SCAN_LIMIT;
- const total = Math.min(found.entries.length, SCAN_LIMIT);
- const settled = classified + unreadable;
- const outstanding = tracked.length - classified;
-
- if (!open) {
- return (
- <div className="downloads-wizard__trigger">
- <Button
- variant="secondary"
- size="sm"
- onClick={() => setOpen(true)}
- leftSection={<Icon name="folder-bookmark" size={20} />}
- >
- {t("processingFolders.downloads.trigger", {
- count: found.entries.length,
- defaultValue: "Process {{count}} PDFs in Downloads",
- })}
- </Button>
- </div>
- );
- }
-
- const wall = cards.length > 0 && <SweepRunWall cards={cards} />;
-
- return (
- <Modal
- open
- // Closing hides the modal while the reads carry on; reopening shows progress.
- onClose={phase === "working" ? () => setOpen(false) : close}
- width={phase === "asking" ? "sm" : "lg"}
- title={
- <span className="downloads-wizard__title">
- <Icon name="folder-bookmark" size={20} />
- {t("processingFolders.downloads.title", "Organise your Downloads?")}
- </span>
- }
- footer={
- <div className="downloads-wizard__foot">
- {phase === "asking" && (
- <>
- <Button variant="tertiary" size="sm" onClick={close}>
- {t("processingFolders.downloads.notNow", "Not now")}
- </Button>
- <Button size="sm" onClick={() => void approve()}>
- {t(
- "processingFolders.downloads.approve",
- "Process my Downloads",
- )}
- </Button>
- </>
- )}
- {phase === "working" && (
- <>
- <Button variant="tertiary" size="sm" onClick={cancelSweep}>
- {t("processingFolders.downloads.cancelSweep", "Cancel")}
- </Button>
- <Button size="sm" disabled loading>
- {t("processingFolders.downloads.working", "Processing...")}
- </Button>
- </>
- )}
- {(phase === "done" || phase === "failed") && (
- <Button size="sm" onClick={close}>
- {t("processingFolders.downloads.close", "Done")}
- </Button>
- )}
- </div>
- }
- >
- {phase === "asking" && (
- <div className="downloads-wizard__body">
- <p>
- {t("processingFolders.downloads.explain", {
- count: total,
- defaultValue:
- "Stirling can classify the {{count}} PDFs already in your Downloads folder and open the results here.",
- })}
- </p>
- <p className="downloads-wizard__path">{found.directory}</p>
- <ul className="downloads-wizard__facts">
- <li>
- {t(
- "processingFolders.downloads.notModified",
- "Your files in Downloads are not changed - Stirling reads them and opens them here.",
- )}
- </li>
- {capped && (
- <li>
- {t("processingFolders.downloads.capped", {
- limit: SCAN_LIMIT,
- found: found.entries.length,
- defaultValue:
- "You have {{found}} PDFs; the first {{limit}} are processed now and the rest follow.",
- })}
- </li>
- )}
- </ul>
- </div>
- )}
-
- {phase === "working" && (
- <div className="downloads-wizard__body">
- <p className="downloads-wizard__counts">
- <strong>{settled}</strong>{" "}
- {t("processingFolders.downloads.progressCounts", {
- total,
- defaultValue: "of {{total}} processed",
- })}
- {typesFound > 0 && (
- <>
- {" · "}
- {t("processingFolders.downloads.typesFound", {
- count: typesFound,
- defaultValue: "{{count}} document types found",
- })}
- </>
- )}
- </p>
- <div className="downloads-wizard__bar" role="progressbar">
- <span
- style={{
- width: `${total === 0 ? 0 : Math.round((settled / total) * 100)}%`,
- }}
- />
- </div>
- {wall || (
- <div className="downloads-wizard__progress">
- <Loader size="sm" />
- </div>
- )}
- </div>
- )}
-
- {phase === "done" && (
- <div className="downloads-wizard__body">
- <p className="downloads-wizard__counts">
- <Icon
- name="circle-check"
- className="downloads-wizard__tick"
- size="1em"
- />{" "}
- {tracked.length === 0 && unreadable < total
- ? t("processingFolders.downloads.nothingNew", {
- count: total - unreadable,
- defaultValue:
- "Nothing new to process - these {{count}} files have already been through.",
- })
- : tracked.length === 0
- ? null
- : t("processingFolders.downloads.finished", {
- count: classified,
- opened: tracked.length,
- defaultValue:
- "Classified {{count}} files and opened {{opened}} of them here, ready to work on.",
- })}
- {typesFound > 0 && (
- <>
- {" · "}
- {t("processingFolders.downloads.typesFound", {
- count: typesFound,
- defaultValue: "{{count}} document types found",
- })}
- </>
- )}
- </p>
- {unreadable > 0 && (
- <p className="downloads-wizard__warn">
- {t("processingFolders.downloads.someFailed", {
- count: unreadable,
- defaultValue:
- "{{count}} could not be processed and were left untouched.",
- })}
- </p>
- )}
- {outstanding > 0 && (
- <p className="downloads-wizard__warn">
- {t(
- "processingFolders.downloads.stillRunning",
- "Some files are still being processed in the background.",
- )}
- </p>
- )}
- {wall}
- </div>
- )}
-
- {phase === "failed" && (
- <div className="downloads-wizard__body">
- <p className="downloads-wizard__warn">
- {error ??
- t(
- "processingFolders.downloads.failed",
- "Could not set that up. Your files have not been changed.",
- )}
- </p>
- </div>
- )}
- </Modal>
- );
-}
diff --git a/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsx b/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsx
deleted file mode 100644
index 3eb4cb5bb4..0000000000
--- a/frontend/editor/src/proprietary/components/shared/SidebarProcessingSlot.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { DownloadsProcessingWizard } from "@app/components/policies/DownloadsProcessingWizard";
-import { useServerProcessingBlock } from "@app/hooks/useServerProcessingBlock";
-import { usePoliciesEnabled } from "@app/components/policies/usePoliciesEnabled";
-
-/** Offers Downloads processing where a server can execute and meter it. */
-export function SidebarProcessingSlot() {
- const enabled = usePoliciesEnabled();
- const blocked = useServerProcessingBlock();
- if (!enabled || blocked) return null;
- return <DownloadsProcessingWizard />;
-}