TagSpaces is an offline, open source, document manager with tagging support
feat: added support for external perspectives, shipped with packages, added e2e tests for the configuralbe perspectives and external packages
Ilian Sapundshievee1b08677eb0
diff --git a/.erb/configs/webpack.config.base.ts b/.erb/configs/webpack.config.base.tsindex 17583cc9c..7adcda7b9 100644--- a/.erb/configs/webpack.config.base.ts+++ b/.erb/configs/webpack.config.base.ts@@ -56,7 +56,22 @@ const configuration: webpack.Configuration = {resolve: {extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],modules: [webpackPaths.srcPath, 'node_modules'],- // There is no need to add aliases here, the paths in tsconfig get mirrored+ // Pin react / react-dom to the renderer's own copies. Without this, an+ // external perspective package symlinked into release/app/node_modules+ // (via `npm run link4dev` from extensions-pro) would walk up looking+ // for react from outside the tagspaces tree and either fail or — worse+ // — load a duplicate React instance, breaking hooks. The aliases force+ // every `require('react')` / `require('react-dom')` in symlinked+ // packages to resolve to the host renderer's copy, guaranteeing a+ // single React runtime across all dynamically imported chunks.+ alias: {+ react: path.resolve(webpackPaths.rootPath, 'node_modules', 'react'),+ 'react-dom': path.resolve(+ webpackPaths.rootPath,+ 'node_modules',+ 'react-dom',+ ),+ },plugins: [new TsconfigPathsPlugins()],},diff --git a/scripts/extconfig-perspectives-locked.js b/scripts/extconfig-perspectives-locked.jsnew file mode 100644index 000000000..f62562da6--- /dev/null+++ b/scripts/extconfig-perspectives-locked.js@@ -0,0 +1,22 @@+// Test fixture: simulates a deployer who pins the available perspectives+// via extconfig. With ExtEnabledPerspectives set, the Settings → Perspectives+// tab becomes read-only and the switcher shows only the listed IDs.+// Used by tests/e2e/perspective-config.pw.e2e.js (TST7110).+window.ExtIsFirstRun = false;+window.ExtCheckForUpdatesOnStartup = false;+window.ExtUseGenerateThumbnails = true;+window.ExtEnabledPerspectives = ['grid', 'list'];+window.ExtDefaultPerspective = 'grid';+window.ExtLocations = [+ {+ uuid: '30565f09-c7fd-2333-fc67-a75db27rt5ba',+ type: '0',+ name: 'supported-filestypes',+ path: './tests/testdata-tmp/file-structure/supported-filestypes',+ isDefault: false,+ isReadOnly: false,+ disableIndexing: false,+ fullTextIndex: false,+ watchForChanges: false,+ },+];diff --git a/scripts/generateExtensionsConfig.ts b/scripts/generateExtensionsConfig.tsindex 3a3c7209b..014e29bce 100644--- a/scripts/generateExtensionsConfig.ts+++ b/scripts/generateExtensionsConfig.ts@@ -43,6 +43,90 @@ function writeExtensions(extensions, supportedFileTypes) {color: '#ac21f3',viewer: '@tagspacespro/extensions/font-viewer',});*/++ // Pull perspectives out of the generic extensions list. They drive the+ // perspective registry (id, title, icon name, beta/pro flags) and the+ // dynamic-import loader map below — both consumed at runtime by+ // src/renderer/perspectives/index.tsx and RenderPerspective.tsx.+ //+ // Identifier fields (id, componentExport, onboardingExport) are emitted+ // verbatim into a webpackChunkName comment and used as JS identifier+ // accessors at runtime. Validate them up-front so a typo in a manifest+ // (or a malformed string with `*/`, quotes, or other syntax-breaking+ // characters) fails the generation step with a clear warning instead of+ // producing broken extension-config.ts source.+ const IDENT_RE = /^[A-Za-z_][A-Za-z0-9_-]*$/;+ const PACKAGE_RE = /^@?[A-Za-z0-9_./-]+$/;++ const perspectives = extensions+ .filter((ext) => {+ if (+ !Array.isArray(ext.extensionTypes) ||+ !ext.extensionTypes.includes('perspective')+ ) {+ return false;+ }+ if (!ext.id || !ext.packageName) {+ console.warn(+ `generateExtensionsConfig: perspective skipped — missing id or packageName: ${ext.extensionId || ext.extensionName}`,+ );+ return false;+ }+ if (!IDENT_RE.test(ext.id)) {+ console.warn(+ `generateExtensionsConfig: perspective skipped — id "${ext.id}" must match ${IDENT_RE}`,+ );+ return false;+ }+ if (!PACKAGE_RE.test(ext.packageName)) {+ console.warn(+ `generateExtensionsConfig: perspective skipped — packageName "${ext.packageName}" must match ${PACKAGE_RE}`,+ );+ return false;+ }+ const componentExport = ext.componentExport || 'default';+ if (!IDENT_RE.test(componentExport)) {+ console.warn(+ `generateExtensionsConfig: perspective "${ext.id}" skipped — componentExport "${componentExport}" must match ${IDENT_RE}`,+ );+ return false;+ }+ if (ext.onboardingExport && !IDENT_RE.test(ext.onboardingExport)) {+ console.warn(+ `generateExtensionsConfig: perspective "${ext.id}" skipped — onboardingExport "${ext.onboardingExport}" must match ${IDENT_RE}`,+ );+ return false;+ }+ return true;+ })+ .map((ext) => ({+ id: ext.id,+ packageName: ext.packageName,+ title: ext.title || ext.extensionName,+ key: ext.key || 'open' + ext.id + 'Perspective',+ pro: ext.pro === true,+ beta: ext.beta === true,+ iconName: ext.iconName || 'Extension',+ componentExport: ext.componentExport || 'default',+ onboardingExport: ext.onboardingExport || null,+ }));++ // Loader map — emitted as real source so webpack statically analyses each+ // dynamic import() and produces a separate code-split chunk per+ // perspective package.+ const loaderEntries = perspectives+ .map((p) => {+ const chunk = JSON.stringify('Perspective_' + p.id);+ return ` ${JSON.stringify(p.id)}: () => import(/* webpackChunkName: ${chunk} */ ${JSON.stringify(p.packageName)}),`;+ })+ .join('\n');+ const loaderMapSrc =+ perspectives.length > 0+ ? 'export const externalPerspectiveLoaders: Record<string, () => Promise<any>> = {\n' ++ loaderEntries ++ '\n};\n'+ : 'export const externalPerspectiveLoaders: Record<string, () => Promise<any>> = {};\n';+const generated ='/** GENERATED CODE - DO NOT MODIFY: This source file was generated automatically and any changes made to it may be overwritten */\n' +'export const extensionsFound = ' +@@ -50,7 +134,11 @@ function writeExtensions(extensions, supportedFileTypes) {';\n' +'export const supportedFileTypes = ' +JSON.stringify(supportedFileTypes, null, 2) +- ';';+ ';\n' ++ 'export const externalPerspectives = ' ++ JSON.stringify(perspectives, null, 2) ++ ';\n' ++ loaderMapSrc;let outputFile = path.join(__dirname,'..',diff --git a/src/main/extension-utils.ts b/src/main/extension-utils.tsindex 94061420d..a9407bde4 100644--- a/src/main/extension-utils.ts+++ b/src/main/extension-utils.ts@@ -96,9 +96,21 @@ function processDirs(...props} = packageJsonObj['tsextension'];+ const isPerspective =+ Array.isArray(types) && types.includes('perspective');++ // For perspective extensions, manifest `id` is the perspective+ // registry key (e.g. "timeline") — never the package import path —+ // so derive extensionId from the directory only. For viewer/editor+ // extensions, keep the historical behavior where `id` (if set)+ // overrides the auto-generated package path.const extensionId =- (id || '@tagspaces/extensions/' + dir.name) ++ (isPerspective || !id ? '@tagspaces/extensions/' + dir.name : id) +(buildFolder ? '/' + buildFolder : '');+ // Package name to import() at runtime (perspectives only). Webpack+ // resolves the `main` field of the package's package.json, so we+ // don't append buildFolder here.+ const packageName = packagePath + '/' + dir.name;if (fileTypes) {fileTypes.forEach((fileType) => {@@ -148,6 +160,7 @@ function processDirs(...(isExternal && { extensionExternal: true }),extensionEnabled: enabled !== undefined ? enabled : !isExternal,version: version,+ ...(isPerspective && id ? { id, packageName } : {}),...props,};}diff --git a/src/renderer/components/FolderContainer.tsx b/src/renderer/components/FolderContainer.tsxindex 7ea83f267..3d8cc5751 100644--- a/src/renderer/components/FolderContainer.tsx+++ b/src/renderer/components/FolderContainer.tsx@@ -119,7 +119,10 @@ function FolderContainer({ toggleDrawer, drawerOpened, hidden }: Props) {// tsm.json is left untouched — if the perspective is re-enabled later, the// folder reverts to it on next open.useEffect(() => {- if (!currentPerspective || currentPerspective === PerspectiveIDs.UNSPECIFIED) {+ if (+ !currentPerspective ||+ currentPerspective === PerspectiveIDs.UNSPECIFIED+ ) {return;}const stillVisible = visiblePerspectives.some(@@ -193,9 +196,7 @@ function FolderContainer({ toggleDrawer, drawerOpened, hidden }: Props) {<Tooltiptitle={perspective.title +- (perspective.beta- ? ' ' + t('core:betaStatus').toUpperCase()- : '')+ (perspective.beta ? ' ' + t('core:betaStatus').toUpperCase() : '')}><Box sx={{ display: 'flex' }}>{perspective.icon}</Box>diff --git a/src/renderer/components/RenderPerspective.tsx b/src/renderer/components/RenderPerspective.tsxindex 90e1018db..6024f227d 100644--- a/src/renderer/components/RenderPerspective.tsx+++ b/src/renderer/components/RenderPerspective.tsx@@ -16,22 +16,32 @@**/-import React from 'react';+import React, { useEffect } from 'react';import AppConfig from '-/AppConfig';import CustomDragLayer from '-/components/CustomDragLayer';import LoadingLazy from '-/components/LoadingLazy';import TargetFileBox from '-/components/TargetFileBox';+import { usePerspectiveOnboardingContext } from '-/components/dialogs/hooks/usePerspectiveOnboardingContext';import { PaginationContextProvider } from '-/hooks/PaginationContextProvider';import { PerspectiveSettingsContextProvider } from '-/hooks/PerspectiveSettingsContextProvider';import { ThumbGenerationContextProvider } from '-/hooks/ThumbGenerationContextProvider';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';-import { PerspectiveIDs } from '-/perspectives';+import {+ AvailablePerspectives,+ hasExternalPerspectiveComponent,+ loadExternalPerspectiveComponent,+ PerspectiveIDs,+ perspectiveHasOnboarding,+} from '-/perspectives';+import PerspectiveErrorBoundary from '-/perspectives/PerspectiveErrorBoundary';import { SortedDirContextProvider } from '-/perspectives/grid/hooks/SortedDirContextProvider';import { Pro } from '-/pro';+import { getSeenPerspectiveOnboardings } from '-/reducers/settings';import { NativeTypes } from 'react-dnd-html5-backend';+import { useSelector } from 'react-redux';const GridPerspective = React.lazy(() =>@@ -157,6 +167,54 @@ function CalendarPerspectiveAsync(props) {);}+// Cache of lazy components for external (package-shipped) perspectives.+// Each entry is created on first render of that perspective and reused on+// subsequent switches so the chunk is only fetched once.+const externalLazyCache: Record<string, React.LazyExoticComponent<any>> = {};++function getExternalPerspectiveLazy(+ perspectiveId: string,+): React.LazyExoticComponent<any> | undefined {+ if (externalLazyCache[perspectiveId]) {+ return externalLazyCache[perspectiveId];+ }+ // Predicate-based gate so we don't kick off the dynamic import twice+ // (once to probe, once inside React.lazy) — the discarded probe promise+ // would otherwise leak as an unhandled rejection if the chunk failed.+ if (!hasExternalPerspectiveComponent(perspectiveId)) return undefined;+ externalLazyCache[perspectiveId] = React.lazy(+ () => loadExternalPerspectiveComponent(perspectiveId)!,+ );+ return externalLazyCache[perspectiveId];+}++function ExternalPerspectiveAsync({+ perspectiveId,+}: {+ perspectiveId: string;+}) {+ const Comp = getExternalPerspectiveLazy(perspectiveId);+ if (!Comp) return null;+ // Error boundary isolates failures in package-shipped code (chunk-load+ // errors, render-time exceptions in the perspective module) so a crash+ // shows an inline error instead of taking down the directory pane.+ return (+ <PerspectiveErrorBoundary perspectiveId={perspectiveId} context="render">+ <React.Suspense fallback={<LoadingLazy />}>+ <PerspectiveSettingsContextProvider>+ <SortedDirContextProvider>+ <PaginationContextProvider>+ <ThumbGenerationContextProvider>+ <Comp />+ </ThumbGenerationContextProvider>+ </PaginationContextProvider>+ </SortedDirContextProvider>+ </PerspectiveSettingsContextProvider>+ </React.Suspense>+ </PerspectiveErrorBoundary>+ );+}+const WelcomePanel = React.lazy(() => import(/* webpackChunkName: "WelcomePanel" */ './WelcomePanel'),);@@ -173,6 +231,24 @@ interface Props {}function RenderPerspective(props: Props) {const { currentLocationId } = useCurrentLocationContext();const { currentPerspective } = useDirectoryContentContext();+ const { openPerspectiveOnboarding } = usePerspectiveOnboardingContext();+ const seenOnboardings = useSelector(getSeenPerspectiveOnboardings);++ // Auto-open the perspective's onboarding dialog the first time the user+ // switches into it. Only runs for perspectives that ship an+ // onboardingExport in their tsextension manifest. The "seen" flag is+ // persisted in Redux and cleared by the "Show intro" button in Settings+ // for manual re-runs.+ useEffect(() => {+ if (!currentPerspective || !currentLocationId) return;+ if (seenOnboardings[currentPerspective]) return;+ if (!perspectiveHasOnboarding(currentPerspective)) return;+ openPerspectiveOnboarding(currentPerspective);+ // We intentionally depend on currentPerspective only — re-running on+ // seenOnboardings changes would re-open the dialog after the user marks+ // it seen by closing it.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [currentPerspective, currentLocationId]);const showWelcomePanel = !currentLocationId;@@ -195,6 +271,16 @@ function RenderPerspective(props: Props) {if (Pro && currentPerspective === PerspectiveIDs.CALENDAR) {return <CalendarPerspectiveAsync />;}+ // External perspective from a package — resolved via the build-time+ // generated loader map. Returns null silently if the perspective ID+ // doesn't match any built-in or external entry; the fallback effect in+ // FolderContainer.tsx will route to the first enabled perspective.+ const externalMeta = AvailablePerspectives.find(+ (p) => p.external && p.id === currentPerspective,+ );+ if (externalMeta) {+ return <ExternalPerspectiveAsync perspectiveId={externalMeta.id} />;+ }return <GridPerspectiveAsync />;}diff --git a/src/renderer/components/dialogs/components/SettingsPerspectives.tsx b/src/renderer/components/dialogs/components/SettingsPerspectives.tsxindex 365c47eba..9812de739 100644--- a/src/renderer/components/dialogs/components/SettingsPerspectives.tsx+++ b/src/renderer/components/dialogs/components/SettingsPerspectives.tsx@@ -17,8 +17,13 @@*/import { BetaLabel } from '-/components/HelperComponents';+import TsButton from '-/components/TsButton';+import { usePerspectiveOnboardingContext } from '-/components/dialogs/hooks/usePerspectiveOnboardingContext';import { useNotificationContext } from '-/hooks/useNotificationContext';-import { AvailablePerspectives } from '-/perspectives';+import {+ AvailablePerspectives,+ perspectiveHasOnboarding,+} from '-/perspectives';import { Pro } from '-/pro';import {actions as SettingsActions,@@ -43,11 +48,17 @@ function SettingsPerspectives() {const { t } = useTranslation();const dispatch = useDispatch();const { showNotification } = useNotificationContext();+ const { openPerspectiveOnboarding } = usePerspectiveOnboardingContext();const enabledPerspectives: string[] = useSelector(getEnabledPerspectives);const hideProFeatures: boolean = useSelector(isHideProFeatures);const configLocked: boolean = isEnabledPerspectivesLocked();const hasPro = Pro ? true : false;+ const handleShowIntro = (perspectiveId: string) => () => {+ dispatch(SettingsActions.resetPerspectiveOnboarding(perspectiveId));+ openPerspectiveOnboarding(perspectiveId);+ };+const handleToggle =(perspectiveId: string, currentlyEnabled: boolean) =>(event: ChangeEvent<HTMLInputElement>) => {@@ -115,11 +126,25 @@ function SettingsPerspectives() {</Tooltip>);}+ const hasOnboarding = perspectiveHasOnboarding(perspective.id);return (<ListItemkey={perspective.id}data-tid={'perspectiveRow_' + perspective.id}- secondaryAction={wrappedSwitch}+ secondaryAction={+ <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>+ {hasOnboarding && (+ <TsButton+ data-tid={'showPerspectiveIntro_' + perspective.id}+ onClick={handleShowIntro(perspective.id)}+ size="small"+ >+ {t('core:showPerspectiveIntro')}+ </TsButton>+ )}+ {wrappedSwitch}+ </Box>+ }><ListItemIcon>{perspective.icon}</ListItemIcon><ListItemTextdiff --git a/src/renderer/components/dialogs/hooks/PerspectiveOnboardingContextProvider.tsx b/src/renderer/components/dialogs/hooks/PerspectiveOnboardingContextProvider.tsxnew file mode 100644index 000000000..3742c95b8--- /dev/null+++ b/src/renderer/components/dialogs/hooks/PerspectiveOnboardingContextProvider.tsx@@ -0,0 +1,144 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces GmbH+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import LoadingLazy from '-/components/LoadingLazy';+import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';+import {+ getPerspectiveMeta,+ loadExternalPerspectiveOnboarding,+ perspectiveHasOnboarding,+} from '-/perspectives';+import PerspectiveErrorBoundary from '-/perspectives/PerspectiveErrorBoundary';+import { AppDispatch } from '-/reducers/app';+import { actions as SettingsActions } from '-/reducers/settings';+import Dialog from '@mui/material/Dialog';+import DialogContent from '@mui/material/DialogContent';+import { useTheme } from '@mui/material/styles';+import useMediaQuery from '@mui/material/useMediaQuery';+import React, { createContext, useMemo, useState } from 'react';+import { useDispatch } from 'react-redux';++type PerspectiveOnboardingContextData = {+ openPerspectiveOnboarding: (perspectiveId: string) => void;+ closePerspectiveOnboarding: () => void;+};++export const PerspectiveOnboardingContext =+ createContext<PerspectiveOnboardingContextData>({+ openPerspectiveOnboarding: () => {},+ closePerspectiveOnboarding: () => {},+ });++export type PerspectiveOnboardingContextProviderProps = {+ children: React.ReactNode;+};++// Cache lazy onboarding components by perspective ID so each chunk is only+// fetched once across the lifetime of the app.+const onboardingLazyCache: Record<string, React.LazyExoticComponent<any>> = {};++function getOnboardingLazy(+ perspectiveId: string,+): React.LazyExoticComponent<any> | undefined {+ if (onboardingLazyCache[perspectiveId]) {+ return onboardingLazyCache[perspectiveId];+ }+ // Predicate-based gate so we don't fire the dynamic import twice (once+ // for the probe, once inside React.lazy). The discarded probe promise+ // would otherwise leak as an unhandled rejection on chunk-load failure.+ if (!perspectiveHasOnboarding(perspectiveId)) return undefined;+ onboardingLazyCache[perspectiveId] = React.lazy(+ () => loadExternalPerspectiveOnboarding(perspectiveId)!,+ );+ return onboardingLazyCache[perspectiveId];+}++export const PerspectiveOnboardingContextProvider = ({+ children,+}: PerspectiveOnboardingContextProviderProps) => {+ const [activeId, setActiveId] = useState<string | null>(null);+ const dispatch: AppDispatch = useDispatch();+ const theme = useTheme();+ const smallScreen = useMediaQuery(theme.breakpoints.down('md'));++ function openDialog(perspectiveId: string) {+ if (!perspectiveId) return;+ setActiveId(perspectiveId);+ }++ function closeDialog() {+ if (activeId) {+ // Persist that the user has now seen this perspective's onboarding.+ // Manual re-opens from Settings clear the seen flag first, so this+ // simply re-marks it on close.+ dispatch(SettingsActions.markPerspectiveOnboardingSeen(activeId));+ }+ setActiveId(null);+ }++ const context = useMemo(+ () => ({+ openPerspectiveOnboarding: openDialog,+ closePerspectiveOnboarding: closeDialog,+ }),+ // openDialog/closeDialog are stable closures over setActiveId/dispatch+ // which are themselves stable. activeId changes are picked up via the+ // closeDialog reference at the moment it runs.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ [activeId],+ );++ const meta = activeId ? getPerspectiveMeta(activeId) : undefined;+ const title = meta ? meta.title : '';+ const Body = activeId ? getOnboardingLazy(activeId) : undefined;++ return (+ <PerspectiveOnboardingContext.Provider value={context}>+ <Dialog+ open={Boolean(activeId)}+ onClose={closeDialog}+ fullScreen={smallScreen}+ maxWidth="sm"+ fullWidth+ scroll="paper"+ >+ <TsDialogTitle+ dialogTitle={title}+ closeButtonTestId="closePerspectiveOnboardingTID"+ onClose={closeDialog}+ />+ <DialogContent>+ {Body && activeId && (+ <PerspectiveErrorBoundary+ perspectiveId={activeId}+ context="onboarding"+ >+ <React.Suspense fallback={<LoadingLazy />}>+ {React.createElement(Body as any, {+ onClose: closeDialog,+ perspectiveId: activeId,+ })}+ </React.Suspense>+ </PerspectiveErrorBoundary>+ )}+ </DialogContent>+ </Dialog>+ {children}+ </PerspectiveOnboardingContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/usePerspectiveOnboardingContext.tsx b/src/renderer/components/dialogs/hooks/usePerspectiveOnboardingContext.tsxnew file mode 100644index 000000000..10f07b21e--- /dev/null+++ b/src/renderer/components/dialogs/hooks/usePerspectiveOnboardingContext.tsx@@ -0,0 +1,6 @@+import { useContext } from 'react';++import { PerspectiveOnboardingContext } from '-/components/dialogs/hooks/PerspectiveOnboardingContextProvider';++export const usePerspectiveOnboardingContext = () =>+ useContext(PerspectiveOnboardingContext);diff --git a/src/renderer/containers/DialogsRoot.tsx b/src/renderer/containers/DialogsRoot.tsxindex fd70c5959..ecde6ae6e 100644--- a/src/renderer/containers/DialogsRoot.tsx+++ b/src/renderer/containers/DialogsRoot.tsx@@ -32,6 +32,7 @@ import { MoveOrCopyFilesDialogContextProvider } from '-/components/dialogs/hooksimport { NewAudioDialogContextProvider } from '-/components/dialogs/hooks/NewAudioDialogContextProvider';import { NewFileDialogContextProvider } from '-/components/dialogs/hooks/NewFileDialogContextProvider';import { OnboardingDialogContextProvider } from '-/components/dialogs/hooks/OnboardingDialogContextProvider';+import { PerspectiveOnboardingContextProvider } from '-/components/dialogs/hooks/PerspectiveOnboardingContextProvider';import { ProTeaserDialogContextProvider } from '-/components/dialogs/hooks/ProTeaserDialogContextProvider';import { ProgressDialogContextProvider } from '-/components/dialogs/hooks/ProgressDialogContextProvider';import { ResolveConflictContextProvider } from '-/components/dialogs/hooks/ResolveConflictContextProvider';@@ -51,6 +52,12 @@ const providers = [MoveOrCopyFilesDialogContextProvider,CreateDirectoryDialogContextProvider,ProgressDialogContextProvider,+ // PerspectiveOnboardingContextProvider must wrap SettingsDialogContextProvider+ // so the "Show intro" button rendered inside the Settings dialog can call+ // openPerspectiveOnboarding(). React Context respects the React tree (not+ // the DOM), and the Settings dialog's children are descendants of whichever+ // providers wrap it from the outside.+ PerspectiveOnboardingContextProvider,SettingsDialogContextProvider,NewFileDialogContextProvider,NewAudioDialogContextProvider,diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.jsonindex c53ea6d90..97bb619c6 100644--- a/src/renderer/locales/en/core.json+++ b/src/renderer/locales/en/core.json@@ -80,6 +80,7 @@"perspectivesSettingsHelp": "Choose which perspectives are available in the perspective switcher. Disabled perspectives stay hidden until you re-enable them here.","perspectivesConfiguredByExtConfig": "The available perspectives are configured by your administrator and cannot be changed here.","cannotDisableLastPerspective": "At least one perspective must remain enabled.",+ "showPerspectiveIntro": "Show intro","enableDevMode": "Enable Developer Mode","hideProFeatures": "Hide Pro Features","autoSaveDescription": "Auto-save description changes",diff --git a/src/renderer/perspectives/PerspectiveErrorBoundary.tsx b/src/renderer/perspectives/PerspectiveErrorBoundary.tsxnew file mode 100644index 000000000..f279ea6d6--- /dev/null+++ b/src/renderer/perspectives/PerspectiveErrorBoundary.tsx@@ -0,0 +1,77 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2026-present TagSpaces GmbH+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import Alert from '@mui/material/Alert';+import Box from '@mui/material/Box';+import Typography from '@mui/material/Typography';+import React from 'react';++type Props = {+ perspectiveId: string;+ context: 'render' | 'onboarding';+ children: React.ReactNode;+};++type State = {+ hasError: boolean;+ error?: Error;+};++// Isolates failures from external (package-shipped) perspective code so a+// crashing perspective component or onboarding body cannot take down the+// host renderer. Built-in perspectives are part of the bundle and treated+// as fully trusted; this boundary is specifically for code that ships in+// node_modules/@tagspaces/extensions/* and node_modules/@tagspacespro/extensions/*.+export class PerspectiveErrorBoundary extends React.Component<Props, State> {+ state: State = { hasError: false };++ static getDerivedStateFromError(error: Error): State {+ return { hasError: true, error };+ }++ componentDidCatch(error: Error, info: React.ErrorInfo) {+ console.error(+ `Perspective "${this.props.perspectiveId}" (${this.props.context}) failed:`,+ error,+ info,+ );+ }++ render() {+ if (!this.state.hasError) return this.props.children;+ const message =+ this.state.error?.message || 'Unknown error while rendering perspective.';+ return (+ <Box sx={{ padding: 2 }} data-tid="perspectiveErrorBoundaryTID">+ <Alert severity="error">+ <Typography variant="subtitle1" sx={{ fontWeight: 'bold' }}>+ {this.props.context === 'onboarding'+ ? 'Onboarding failed to load'+ : 'Perspective failed to load'}+ </Typography>+ <Typography variant="body2">{message}</Typography>+ <Typography variant="caption" sx={{ display: 'block', marginTop: 1 }}>+ Perspective: {this.props.perspectiveId}+ </Typography>+ </Alert>+ </Box>+ );+ }+}++export default PerspectiveErrorBoundary;diff --git a/src/renderer/perspectives/index.tsx b/src/renderer/perspectives/index.tsxindex c826eccf1..f251b5090 100644--- a/src/renderer/perspectives/index.tsx+++ b/src/renderer/perspectives/index.tsx@@ -17,11 +17,16 @@*/import CalendarPerspectiveIcon from '@mui/icons-material/CalendarMonth';import GalleryPerspectiveIcon from '@mui/icons-material/Camera';+import ExtensionIcon from '@mui/icons-material/Extension';import FolderVizPerspectiveIcon from '@mui/icons-material/Hub';import MapiquePerspectiveIcon from '@mui/icons-material/Map';import KanbanPerspectiveIcon from '@mui/icons-material/ViewKanban';import ListPerspectiveIcon from '@mui/icons-material/ViewList';import GridPerspectiveIcon from '@mui/icons-material/ViewModule';+import {+ externalPerspectiveLoaders,+ externalPerspectives,+} from '-/extension-config';export const PerspectiveIDs = {UNSPECIFIED: 'unspecified',@@ -106,8 +111,31 @@ export type PerspectiveMeta = {beta: boolean;icon: React.ReactNode;title: string;+ // External-perspective fields. Built-in perspectives leave these unset.+ external?: boolean;+ componentExport?: string;+ onboardingExport?: string | null;};+// Build registry entries for any external perspectives discovered at build+// time by scripts/generateExtensionsConfig.ts. The accompanying loader map+// (externalPerspectiveLoaders) drives the dynamic-import branch in+// RenderPerspective.tsx, and the onboarding flag drives the per-perspective+// onboarding wrapper.+const ExternalPerspectiveMetas: PerspectiveMeta[] = externalPerspectives+ .filter((ext) => externalPerspectiveLoaders[ext.id] !== undefined)+ .map((ext) => ({+ id: ext.id,+ key: ext.key,+ pro: ext.pro === true,+ beta: ext.beta === true,+ icon: <ExtensionIcon />,+ title: ext.title,+ external: true,+ componentExport: ext.componentExport,+ onboardingExport: ext.onboardingExport,+ }));+export const AvailablePerspectives: PerspectiveMeta[] = [GridPerspectiveMeta,ListPerspectiveMeta,@@ -116,12 +144,67 @@ export const AvailablePerspectives: PerspectiveMeta[] = [KanbanPerspectiveMeta,FolderVizPerspectiveMeta,CalendarPerspectiveMeta,+ ...ExternalPerspectiveMetas,];export const DefaultEnabledPerspectives: string[] = AvailablePerspectives.map((p) => p.id,);+export function getPerspectiveMeta(+ perspectiveId: string,+): PerspectiveMeta | undefined {+ return AvailablePerspectives.find((p) => p.id === perspectiveId);+}++// Onboarding capability is only known for external perspectives today —+// they declare an onboardingExport in their tsextension manifest. Built-in+// perspectives don't ship onboarding screens. Also guards on the loader+// being present in the build-time generated map so a stale registry entry+// without a matching loader can't slip through.+export function perspectiveHasOnboarding(perspectiveId: string): boolean {+ const meta = getPerspectiveMeta(perspectiveId);+ if (!meta || !meta.external || !meta.onboardingExport) return false;+ return externalPerspectiveLoaders[perspectiveId] !== undefined;+}++// Cheap predicate: does this perspective have a build-time loader for its+// main component? Used as a synchronous gate before constructing a+// React.lazy thunk, so callers can short-circuit without invoking the+// loader (which would kick off a chunk fetch and leak an unhandled+// promise if the import later rejects).+export function hasExternalPerspectiveComponent(+ perspectiveId: string,+): boolean {+ const meta = getPerspectiveMeta(perspectiveId);+ if (!meta || !meta.external || !meta.componentExport) return false;+ return externalPerspectiveLoaders[perspectiveId] !== undefined;+}++// Returns a React.lazy-compatible loader for the perspective's main+// component. Reuses the build-time generated import() loader.+export function loadExternalPerspectiveComponent(+ perspectiveId: string,+): Promise<{ default: any }> | undefined {+ const meta = getPerspectiveMeta(perspectiveId);+ if (!meta || !meta.external || !meta.componentExport) return undefined;+ const loader = externalPerspectiveLoaders[perspectiveId];+ if (!loader) return undefined;+ return loader().then((mod: any) => ({ default: mod[meta.componentExport] }));+}++// Returns a React.lazy-compatible loader for the perspective's onboarding+// component, if it has one.+export function loadExternalPerspectiveOnboarding(+ perspectiveId: string,+): Promise<{ default: any }> | undefined {+ const meta = getPerspectiveMeta(perspectiveId);+ if (!meta || !meta.external || !meta.onboardingExport) return undefined;+ const loader = externalPerspectiveLoaders[perspectiveId];+ if (!loader) return undefined;+ return loader().then((mod: any) => ({ default: mod[meta.onboardingExport] }));+}+export function getVisiblePerspectives(enabledPerspectives: string[],hideProFeatures: boolean,diff --git a/src/renderer/reducers/index.ts b/src/renderer/reducers/index.tsindex bc241900b..f3f18123e 100644--- a/src/renderer/reducers/index.ts+++ b/src/renderer/reducers/index.ts@@ -91,9 +91,12 @@ function configureApp(extConfigObj) {// When set, this is authoritative on every app load — the Settings tab// toggles become read-only and end-user preferences in// state.settings.enabledPerspectives are ignored. Unknown IDs are silently- // dropped by getVisiblePerspectives at render time.+ // dropped by getVisiblePerspectives at render time. Frozen so a buggy+ // reducer or component can't mutate the deployer-pinned whitelist —+ // matches how externalLocations / externalSearches are treated below.if (Array.isArray(extConfigObj.ExtEnabledPerspectives)) {AppConfig.ExtEnabledPerspectives = extConfigObj.ExtEnabledPerspectives;+ Object.freeze(AppConfig.ExtEnabledPerspectives);}AppConfig.ExtLightThemeLightColor =extConfigObj.ExtLightThemeLightColor ?? AppConfig.ExtLightThemeLightColor; // do not apply currentlydiff --git a/src/renderer/reducers/settings.ts b/src/renderer/reducers/settings.tsindex 615ddc51a..ef8e18990 100644--- a/src/renderer/reducers/settings.ts+++ b/src/renderer/reducers/settings.ts@@ -112,8 +112,7 @@ export const types = {SET_AUTO_SAVE_DESCRIPTION: 'SETTINGS/SET_AUTO_SAVE_DESCRIPTION',SET_PERSPECTIVE_ENABLED: 'SETTINGS/SET_PERSPECTIVE_ENABLED',SET_ENABLED_PERSPECTIVES: 'SETTINGS/SET_ENABLED_PERSPECTIVES',- MARK_PERSPECTIVE_ONBOARDING_SEEN:- 'SETTINGS/MARK_PERSPECTIVE_ONBOARDING_SEEN',+ MARK_PERSPECTIVE_ONBOARDING_SEEN: 'SETTINGS/MARK_PERSPECTIVE_ONBOARDING_SEEN',RESET_PERSPECTIVE_ONBOARDING: 'SETTINGS/RESET_PERSPECTIVE_ONBOARDING',};diff --git a/tests/e2e/perspective-config-locked.pw.e2e.js b/tests/e2e/perspective-config-locked.pw.e2e.jsnew file mode 100644index 000000000..d7fcd884f--- /dev/null+++ b/tests/e2e/perspective-config-locked.pw.e2e.js@@ -0,0 +1,143 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces GmbH+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++/*+ * E2E coverage for the configurable-perspectives feature (PR2 — extconfig+ * lock). Lives in its own file because Playwright restarts the app per+ * file when a new extconfig is needed; the locked path can't share a+ * worker with the user-toggle tests in perspective-config.pw.e2e.js.+ */+import { expect, test } from './fixtures';+import {+ clickOn,+ expectElementExist,+ getGridFileSelector,+} from './general.helpers';+import { startTestingApp, stopApp } from './hook';+import { defaultLocationName } from './location.helpers';+import { clearDataStorage } from './welcome.helpers';++// extconfig-perspectives-locked.js whitelists ['grid', 'list'] via+// ExtEnabledPerspectives, so the Settings tab is read-only and the+// switcher must hide every other perspective regardless of any value+// that may be persisted in localStorage.+test.beforeAll(async ({ isWeb, isS3, webServerPort }, testInfo) => {+ await startTestingApp(+ { isWeb, isS3, webServerPort, testInfo },+ 'extconfig-perspectives-locked.js',+ );+});++test.afterAll(async () => {+ await stopApp();+});++test.afterEach(async () => {+ await clearDataStorage();+});++test.beforeEach(async () => {+ // ExtLocations injects the location from the extconfig — just open it.+ await clickOn('[data-tid=location_' + defaultLocationName + ']');+ await expectElementExist(getGridFileSelector('empty_folder'), true, 15000);+});++test.describe('TST73 - extconfig-locked perspectives', () => {+ test('TST7301 - Switcher only shows whitelisted perspectives [web,s3,electron]', async () => {+ // Whitelisted IDs are visible.+ await expectElementExist(+ '[data-tid=openDefaultPerspective]',+ true,+ 5000,+ );+ await expectElementExist(+ '[data-tid=openListPerspective]',+ true,+ 5000,+ );+ // Non-whitelisted Pro perspectives must NOT be in the switcher,+ // even in a Pro build where they would normally appear.+ await expectElementExist(+ '[data-tid=openGalleryPerspective]',+ false,+ 2000,+ );+ await expectElementExist(+ '[data-tid=openKanbanPerspective]',+ false,+ 2000,+ );+ });++ test('TST7302 - Settings switches are disabled (read-only) [web,s3,electron]', async () => {+ await clickOn('[data-tid=settings]');+ await clickOn('[data-tid=perspectivesSettingsDialog]');++ // The Grid switch is in the whitelist but should still be locked+ // because extconfig owns the entire array.+ const gridInput = await global.client.$(+ '[data-tid=enablePerspective_grid] input',+ );+ expect(gridInput).toBeTruthy();+ expect(await gridInput.isDisabled()).toBeTruthy();++ const listInput = await global.client.$(+ '[data-tid=enablePerspective_list] input',+ );+ expect(listInput).toBeTruthy();+ expect(await listInput.isDisabled()).toBeTruthy();++ await clickOn('[data-tid=closeSettingsDialog]');+ });++ test('TST7303 - User toggles do not stick across reload when extconfig locks [web,s3,electron]', async () => {+ // Even though the UI prevents toggling, verify the read path: open+ // the Settings tab and confirm both whitelist members report as+ // checked. extconfig is the source of truth, so anything previously+ // persisted in localStorage is overridden on read.+ await clickOn('[data-tid=settings]');+ await clickOn('[data-tid=perspectivesSettingsDialog]');++ expect(+ await global.client.isChecked(+ '[data-tid=enablePerspective_grid] input',+ ),+ ).toBeTruthy();+ expect(+ await global.client.isChecked(+ '[data-tid=enablePerspective_list] input',+ ),+ ).toBeTruthy();++ // Non-whitelisted Pro entries that ARE rendered (because hasPro &&+ // !hideProFeatures) should be unchecked, since extconfig didn't+ // include them.+ const galleryRow = await global.client.$(+ '[data-tid=perspectiveRow_gallery]',+ );+ if (galleryRow) {+ expect(+ await global.client.isChecked(+ '[data-tid=enablePerspective_gallery] input',+ ),+ ).toBeFalsy();+ }++ await clickOn('[data-tid=closeSettingsDialog]');+ });+});diff --git a/tests/e2e/perspective-config.pw.e2e.js b/tests/e2e/perspective-config.pw.e2e.jsnew file mode 100644index 000000000..f190c40f4--- /dev/null+++ b/tests/e2e/perspective-config.pw.e2e.js@@ -0,0 +1,342 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces GmbH+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++/*+ * E2E coverage for the configurable-perspectives feature.+ *+ * PR1: dedicated Perspectives tab in Settings, switcher filtering by+ * enabledPerspectives, fallback when the active perspective is+ * disabled, guard against disabling every perspective.+ * PR3: external (package-shipped) perspective rendering and the+ * per-perspective onboarding dialog. PR3 tests are tagged [_pro]+ * and additionally probe for the dummy timeline-perspective —+ * they self-skip if the build doesn't include it (the package is+ * excluded from the default Pro release; only present locally with+ * `npm run link4dev` in extensions-pro).+ *+ * PR2 (extconfig lock) lives in perspective-config-locked.pw.e2e.js+ * because that file needs a different extconfig and Playwright doesn't+ * support per-test extconfig swaps within a single worker.+ */+import { expect, test } from './fixtures';+import {+ clickOn,+ clickOnIfVisible,+ expectElementExist,+ getGridFileSelector,+} from './general.helpers';+import { startTestingApp, stopApp } from './hook';+import {+ createPwLocation,+ createS3Location,+ defaultLocationName,+} from './location.helpers';+import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';++test.beforeAll(async ({ isWeb, isS3, webServerPort }, testInfo) => {+ if (isS3) {+ await startTestingApp({ isWeb, isS3, webServerPort, testInfo });+ await closeWelcomePlaywright();+ } else {+ await startTestingApp(+ { isWeb, isS3, webServerPort, testInfo },+ 'extconfig.js',+ );+ }+});++test.afterAll(async () => {+ await stopApp();+});++test.afterEach(async () => {+ // Each test toggles perspectives in Settings; clear localStorage so the+ // next test starts from the default-all-enabled state.+ await clearDataStorage();+});++test.beforeEach(async ({ isS3, testDataDir }) => {+ if (isS3) {+ await createS3Location('', defaultLocationName, true);+ } else {+ await createPwLocation(testDataDir, defaultLocationName, true);+ }+ await clickOn('[data-tid=location_' + defaultLocationName + ']');+ await expectElementExist(getGridFileSelector('empty_folder'), true, 15000);+});++// Helpers — local to this file because they're specific to the new+// Perspectives Settings tab UX.++async function openPerspectivesSettings() {+ await clickOn('[data-tid=settings]');+ await clickOn('[data-tid=perspectivesSettingsDialog]');+}++async function closeSettings() {+ await clickOn('[data-tid=closeSettingsDialog]');+}++async function setPerspectiveEnabled(perspectiveId, enabled) {+ // setChecked is the right tool for MUI Switch — it is idempotent and+ // dispatches both the click and the resulting change event.+ await global.client.setChecked(+ '[data-tid=enablePerspective_' + perspectiveId + '] input',+ enabled,+ );+}++async function isPerspectiveSwitchChecked(perspectiveId) {+ return await global.client.isChecked(+ '[data-tid=enablePerspective_' + perspectiveId + '] input',+ );+}++async function timelineIsRegistered() {+ // The toolbar button only renders when the timeline perspective is in+ // visiblePerspectives, which only happens when the build picked up the+ // dummy via extension-config.ts. Probe the toolbar (visible whenever a+ // location is open) so this works without needing Settings open. Short+ // timeout so missing-build cases self-skip fast.+ try {+ await global.client.waitForSelector(+ '[data-tid=openTimelinePerspective]',+ { state: 'visible', timeout: 1500 },+ );+ return true;+ } catch (e) {+ return false;+ }+}++test.describe('TST71 - Configurable Perspectives', () => {+ test('TST7101 - Perspectives Settings tab opens and lists built-ins [web,s3,electron]', async () => {+ await openPerspectivesSettings();++ // The two free built-ins are always present in any build.+ await expectElementExist(+ '[data-tid=perspectiveRow_grid]',+ true,+ 5000,+ );+ await expectElementExist(+ '[data-tid=perspectiveRow_list]',+ true,+ 5000,+ );++ // Both are enabled by default after a fresh clearDataStorage.+ expect(await isPerspectiveSwitchChecked('grid')).toBeTruthy();+ expect(await isPerspectiveSwitchChecked('list')).toBeTruthy();++ await closeSettings();+ });++ test('TST7102 - Toggling a perspective off hides it from the switcher [web,s3,electron]', async () => {+ // Sanity: the List toggle button is in the toolbar before we touch anything.+ await expectElementExist(+ '[data-tid=openListPerspective]',+ true,+ 5000,+ );++ await openPerspectivesSettings();+ await setPerspectiveEnabled('list', false);+ expect(await isPerspectiveSwitchChecked('list')).toBeFalsy();+ await closeSettings();++ // List button should now be gone from the switcher.+ await expectElementExist(+ '[data-tid=openListPerspective]',+ false,+ 3000,+ );++ // Re-enable and verify it comes back.+ await openPerspectivesSettings();+ await setPerspectiveEnabled('list', true);+ expect(await isPerspectiveSwitchChecked('list')).toBeTruthy();+ await closeSettings();++ await expectElementExist(+ '[data-tid=openListPerspective]',+ true,+ 5000,+ );+ });++ test('TST7103 - Active perspective falls back when disabled [web,s3,electron]', async () => {+ // Switch to List, confirm it became active.+ await clickOn('[data-tid=openListPerspective]');+ await expectElementExist(+ '[data-tid=listPerspectiveContainer]',+ true,+ 5000,+ );++ // Disable List from Settings.+ await openPerspectivesSettings();+ await setPerspectiveEnabled('list', false);+ await closeSettings();++ // Fallback effect should route us to Grid (the first remaining enabled).+ await expectElementExist(+ '[data-tid=gridPerspectiveContainer]',+ true,+ 5000,+ );+ await expectElementExist(+ '[data-tid=listPerspectiveContainer]',+ false,+ 3000,+ );++ // Restore default state for the next test in this file (electron tests+ // don't reload between cases, so redux changes survive afterEach's+ // localStorage clear).+ await openPerspectivesSettings();+ await setPerspectiveEnabled('list', true);+ await closeSettings();+ });++ test('TST7104 - Cannot disable the last enabled perspective [web,s3,electron]', async () => {+ await openPerspectivesSettings();++ // Discover all perspective rows currently rendered. This is dynamic+ // on purpose — Pro builds with link4dev'd extensions add external+ // perspectives (e.g. timeline-perspective) that would survive a+ // hardcoded list and prevent Grid from being the last enabled one.+ const rowIds = await global.client.$$eval(+ '[data-tid^=perspectiveRow_]',+ (els) =>+ els+ .map((el) => el.getAttribute('data-tid'))+ .filter(Boolean)+ .map((tid) => tid.replace('perspectiveRow_', '')),+ );+ const others = rowIds.filter((id) => id !== 'grid');++ // Disable every other-than-grid row that is currently enabled and+ // whose switch is interactive (Pro-locked switches are read-only in+ // Lite builds).+ for (const id of others) {+ const input = await global.client.$(+ '[data-tid=enablePerspective_' + id + '] input',+ );+ if (!input) continue;+ if (await input.isDisabled()) continue;+ if (await input.isChecked()) {+ await setPerspectiveEnabled(id, false);+ }+ }++ // Grid should now be the only enabled perspective — verify by+ // re-reading the DOM.+ for (const id of others) {+ const input = await global.client.$(+ '[data-tid=enablePerspective_' + id + '] input',+ );+ if (!input) continue;+ if (await input.isDisabled()) continue;+ expect(await input.isChecked()).toBeFalsy();+ }++ // The handler refuses to dispatch when the user tries to disable the+ // last enabled perspective. Using a plain click here (not setChecked)+ // because setChecked would loop waiting for the input to actually+ // flip — and it never will.+ await global.client.click('[data-tid=enablePerspective_grid] input');+ // Give React a tick to re-render with the unchanged state.+ await global.client.waitForTimeout(300);++ // Grid switch is still on because the dispatch was suppressed.+ expect(await isPerspectiveSwitchChecked('grid')).toBeTruthy();++ await closeSettings();++ // Grid is still in the switcher.+ await expectElementExist(+ '[data-tid=openDefaultPerspective]',+ true,+ 3000,+ );++ // Restore: re-enable everything we disabled so the next test starts+ // clean (electron tests share an in-memory redux store across cases).+ await openPerspectivesSettings();+ for (const id of others) {+ const input = await global.client.$(+ '[data-tid=enablePerspective_' + id + '] input',+ );+ if (!input) continue;+ if (await input.isDisabled()) continue;+ if (!(await input.isChecked())) {+ await setPerspectiveEnabled(id, true);+ }+ }+ await closeSettings();+ });+});++test.describe('TST72 - External perspective + onboarding', () => {+ // Single end-to-end scenario that exercises rendering + auto-onboarding+ // + Show intro in one pass. Splitting these into separate tests would+ // be more granular but unreliable: in-memory redux state (especially+ // seenPerspectiveOnboardings and currentPerspective) survives the+ // afterEach localStorage clear because electron tests don't reload+ // between cases. Sequencing here keeps the assertions independent of+ // any prior test's leftover state.+ test('TST7201 - Render, auto-onboard, persist seen, manual reopen [web,s3,electron,_pro]', async () => {+ if (!(await timelineIsRegistered())) {+ test.skip(+ true,+ 'Timeline dummy not present in this build — run `npm run link4dev` in extensions-pro and rebuild.',+ );+ return;+ }++ // Step 1 — switching into timeline renders the dummy and auto-opens+ // the onboarding dialog (first-time auto-trigger; seenOnboardings+ // does not yet contain "timeline").+ await clickOn('[data-tid=openTimelinePerspective]');+ await expectElementExist('[data-tid=timelinePerspectiveTID]', true, 8000);+ await expectElementExist('[data-tid=timelineOnboardingTID]', true, 8000);++ // Step 2 — closing the dialog persists markPerspectiveOnboardingSeen.+ await clickOn('[data-tid=timelineOnboardingDoneTID]');+ await expectElementExist('[data-tid=timelineOnboardingTID]', false, 3000);++ // Step 3 — switching away to Grid and back must NOT re-trigger the+ // dialog (auto-trigger respects the seen flag).+ await clickOn('[data-tid=openDefaultPerspective]');+ await expectElementExist('[data-tid=gridPerspectiveContainer]', true, 5000);+ await clickOn('[data-tid=openTimelinePerspective]');+ await expectElementExist('[data-tid=timelinePerspectiveTID]', true, 5000);+ await expectElementExist('[data-tid=timelineOnboardingTID]', false, 3000);++ // Step 4 — Settings → Perspectives → Show intro must clear the seen+ // flag and reopen the onboarding dialog stacked above Settings.+ await openPerspectivesSettings();+ await clickOn('[data-tid=showPerspectiveIntro_timeline]');+ await expectElementExist('[data-tid=timelineOnboardingTID]', true, 5000);++ // Cleanup: dismiss the intro (re-marks seen) and the Settings dialog.+ await clickOn('[data-tid=closePerspectiveOnboardingTID]');+ await clickOnIfVisible('[data-tid=closeSettingsDialog]');+ });+});