Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Check surviving settings links without requiring removed controls
pulse-triage[bot]f0e4ba77220d
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.jsonindex 6e1c31a48a..8ece7830f1 100644--- a/frontend-modern/scripts/shared-template-registry.json+++ b/frontend-modern/scripts/shared-template-registry.json@@ -1579,7 +1579,6 @@},"requiredConsumers": [{ "path": "src/components/Settings/AIProviderConfigurationSection.tsx" },- { "path": "src/components/Settings/AIRuntimeControlsSection.tsx" },{ "path": "src/components/Settings/AISettingsDialogs.tsx" },{ "path": "src/components/Settings/APITokenManager.tsx" },{ "path": "src/components/Settings/AgentIntegrationsPanel.tsx" },diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.tsindex a6065308aa..029eecd4dd 100644--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts@@ -4,6 +4,7 @@ import solidPreset from 'babel-preset-solid';import { readFileSync } from 'node:fs';import { join } from 'node:path';import { describe, expect, it } from 'vitest';+import { settingsDocumentationLinkViolations } from './__tests__/settingsDocumentationLinkContract';import calloutCardSource from '@/components/shared/CalloutCard.tsx?raw';import emptyStateSource from '@/components/shared/EmptyState.tsx?raw';import inlineNoticeSource from '@/components/shared/InlineNotice.tsx?raw';@@ -1844,7 +1845,6 @@ describe('shared primitive guardrails', () => {expect(registeredRule?.canonical?.export).toBe('ExternalTextLink');expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual(['src/components/Settings/AIProviderConfigurationSection.tsx',- 'src/components/Settings/AIRuntimeControlsSection.tsx','src/components/Settings/AISettingsDialogs.tsx','src/components/Settings/APITokenManager.tsx','src/components/Settings/AgentIntegrationsPanel.tsx',@@ -1883,9 +1883,11 @@ describe('shared primitive guardrails', () => {expect(externalTextLinkSource).toContain('EXTERNAL_TEXT_LINK_REL');expect(externalTextLinkSource).toContain('target="_blank"');expect(externalTextLinkSource).toContain('rel={getExternalTextLinkRel');+ // Removing an optional control may remove its whole documentation link.+ // Check the surviving JSX without requiring that obsolete control back.+ expect(settingsDocumentationLinkViolations(aiRuntimeControlsSectionSource)).toEqual([]);for (const source of [aiProviderConfigurationSectionSource,- aiRuntimeControlsSectionSource,aiSettingsDialogsSource,apiTokenManagerSource,agentIntegrationsPanelSource,diff --git a/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.test.ts b/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.test.tsnew file mode 100644index 0000000000..a2c7485d7a--- /dev/null+++ b/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.test.ts@@ -0,0 +1,75 @@+import { describe, expect, it } from 'vitest';+import { settingsDocumentationLinkViolations } from './settingsDocumentationLinkContract';++const valid = `+ import { ExternalTextLink } from '@/components/shared/ExternalTextLink';+ import { TERMS_DOC_URL } from '@/utils/docsLinks';+ export const Terms = () => <ExternalTextLink href={TERMS_DOC_URL}>Terms of Service</ExternalTextLink>;+`;++describe('surviving settings documentation link contract', () => {+ it('accepts an actual shared link to shipped Terms', () => {+ expect(settingsDocumentationLinkViolations(valid)).toEqual([]);+ });++ it('accepts legitimate removal of the whole link and its imports', () => {+ expect(+ settingsDocumentationLinkViolations('export const Settings = () => <p>Ask first</p>;'),+ ).toEqual([]);+ });++ it('resolves aliased shared imports instead of requiring literal symbol mentions', () => {+ expect(+ settingsDocumentationLinkViolations(+ valid+ .replace('import { ExternalTextLink }', 'import { ExternalTextLink as TextLink }')+ .replaceAll('<ExternalTextLink', '<TextLink')+ .replaceAll('</ExternalTextLink', '</TextLink'),+ ),+ ).toEqual([]);+ });++ it.each([+ [+ 'raw Terms anchor',+ valid.replaceAll('<ExternalTextLink', '<a').replaceAll('</ExternalTextLink', '</a'),+ ],+ ['wrong local route', valid.replace('href={TERMS_DOC_URL}', 'href="/docs/PRIVACY"')],+ [+ 'unpublished GitHub route',+ valid.replace(+ 'href={TERMS_DOC_URL}',+ 'href="https://github.com/rcourtman/Pulse/blob/main/TERMS.md"',+ ),+ ],+ [+ 'opener opt-out',+ valid.replace('href={TERMS_DOC_URL}', 'href={TERMS_DOC_URL} preserveOpener={true}'),+ ],+ [+ 'raw target override',+ valid.replace('href={TERMS_DOC_URL}', 'href={TERMS_DOC_URL} target="_blank"'),+ ],+ [+ 'untrusted primitive',+ valid.replace('@/components/shared/ExternalTextLink', './ExternalTextLink'),+ ],+ [+ 'comment instead of import',+ valid.replace(+ "import { ExternalTextLink } from '@/components/shared/ExternalTextLink';",+ '// ExternalTextLink',+ ),+ ],+ [+ 'dangling Terms import',+ "import { TERMS_DOC_URL } from '@/utils/docsLinks'; export const Settings = () => <p>No link</p>;",+ ],+ [+ 'raw new-tab link with expression target',+ 'export const Settings = () => <a href="https://example.invalid" target={"_blank"}>Docs</a>;',+ ],+ ])('rejects %s rather than accepting symbol-only coverage', (_name, source) => {+ expect(settingsDocumentationLinkViolations(source)).not.toEqual([]);+ });+});diff --git a/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.ts b/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.tsnew file mode 100644index 0000000000..4ce5f20278--- /dev/null+++ b/frontend-modern/src/components/shared/__tests__/settingsDocumentationLinkContract.ts@@ -0,0 +1,81 @@+import ts from 'typescript';++// Inspect surviving JSX, not symbol mentions: removing a whole link is valid,+// but leaving an import or comment must not conceal a raw or misdirected link.+export function settingsDocumentationLinkViolations(source: string): string[] {+ const file = ts.createSourceFile(+ 'settings.tsx',+ source,+ ts.ScriptTarget.Latest,+ true,+ ts.ScriptKind.TSX,+ );+ const imports = new Map<string, { module: string; symbol: string }>();+ const violations: string[] = [];+ let termsLinks = 0;++ for (const statement of file.statements) {+ if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier))+ continue;+ const bindings = statement.importClause?.namedBindings;+ if (!bindings || !ts.isNamedImports(bindings)) continue;+ for (const binding of bindings.elements) {+ imports.set(binding.name.text, {+ module: statement.moduleSpecifier.text,+ symbol: (binding.propertyName ?? binding.name).text,+ });+ }+ }++ const visit = (node: ts.Node): void => {+ if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {+ const name = node.tagName.getText(file);+ const imported = imports.get(name);+ if (name === 'a')+ violations.push('Settings documentation text links must use ExternalTextLink');+ if (name === 'ExternalTextLink' || imported?.symbol === 'ExternalTextLink') {+ if (imported?.module !== '@/components/shared/ExternalTextLink') {+ violations.push('ExternalTextLink must come from the shared primitive');+ }+ const attributes = node.attributes.properties.filter(ts.isJsxAttribute);+ if (+ attributes.some((attribute) =>+ ['preserveOpener', 'rel', 'target'].includes(attribute.name.getText(file)),+ )+ ) {+ violations.push('Documentation links must keep shared new-tab safety');+ }+ const href = attributes.find(+ (attribute) => attribute.name.getText(file) === 'href',+ )?.initializer;+ const identifier =+ href && ts.isJsxExpression(href) && href.expression && ts.isIdentifier(href.expression)+ ? href.expression.text+ : undefined;+ const hrefImport = identifier ? imports.get(identifier) : undefined;+ const label =+ ts.isJsxOpeningElement(node) && ts.isJsxElement(node.parent)+ ? node.parent.children+ .map((child) => child.getText(file))+ .join(' ')+ .replace(/\s+/g, ' ')+ : '';+ if (/Terms(?: of Service)?/.test(label) || hrefImport?.symbol === 'TERMS_DOC_URL') {+ termsLinks += 1;+ if (hrefImport?.symbol !== 'TERMS_DOC_URL' || hrefImport.module !== '@/utils/docsLinks') {+ violations.push('Surviving Terms links must use the shipped TERMS_DOC_URL');+ }+ }+ }+ }+ ts.forEachChild(node, visit);+ };+ visit(file);+ if (+ [...imports.values()].some((binding) => binding.symbol === 'TERMS_DOC_URL') &&+ termsLinks === 0+ ) {+ violations.push('A Terms import alone does not establish a surviving documentation link');+ }+ return violations;+}diff --git a/frontend-modern/src/utils/__tests__/docsLinks.test.ts b/frontend-modern/src/utils/__tests__/docsLinks.test.tsindex d3d82df9c1..a829a4f6df 100644--- a/frontend-modern/src/utils/__tests__/docsLinks.test.ts+++ b/frontend-modern/src/utils/__tests__/docsLinks.test.ts@@ -23,6 +23,7 @@ import selfHostedCommercialRecoverySectionSource from '@/components/Settings/Selimport securityWarningSource from '@/components/SecurityWarning.tsx?raw';import { DIAGNOSTICS_PANEL_COPY } from '@/utils/diagnosticsPresentation';import { renderDocMarkdown } from '@/features/docs/docMarkdown';+import { settingsDocumentationLinkViolations } from '@/components/shared/__tests__/settingsDocumentationLinkContract';const __filename = fileURLToPath(import.meta.url);const __dirname = path.dirname(__filename);@@ -844,7 +845,9 @@ describe('docsLinks', () => {expect(securityWarningSource).not.toContain('https://github.com/rcourtman/Pulse/blob/main/docs/',);- expect(aiRuntimeControlsSectionSource).toContain('TERMS_DOC_URL');+ // This section may remove its only Terms link with the control it explains.+ // Any surviving link must still use the shared primitive and shipped route.+ expect(settingsDocumentationLinkViolations(aiRuntimeControlsSectionSource)).toEqual([]);expect(aiRuntimeControlsSectionSource).not.toContain('https://github.com/rcourtman/Pulse/blob/main/TERMS.md',);