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
refactor(cloudcp): own Pulse Account runtime coordination
rcourtman8834f71d1c29
diff --git a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.mdindex 7f5871f8b7..d399531bb0 100644--- a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md+++ b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md@@ -257,7 +257,9 @@ is embedded from `internal/cloudcp/portal/dist/`, and is guarded by`internal/cloudcp/portal/frontend_sync_test.go` plus the package-localtypecheck/build steps, so Pulse Account frontend work should extend that sourcetree and rebuild the committed bundle instead of editing embedded script or CSS-blobs directly.+blobs directly. Coordination between account-shell modules should stay inside+that owned runtime boundary as well, rather than drifting back to+document-wide custom events or browser-global runtime objects.### Post-lane follow-ondiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 77a89999cf..fedfa60bd6 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -221,7 +221,7 @@ sources and the committed embedded bundle cannot drift silently. The maintainedportal source tree now also owns explicit runtime/bootstrap type definitionsplus a package-local `tsc --noEmit` gate, so future account-shell work shouldextend the typed source boundary instead of reviving opaque global runtime-objects or untyped embedded asset edits.+objects, document-wide render events, or untyped embedded asset edits.Hosted Pulse Cloud tenant-org AI reads now also follow that same canonicalrule: `internal/api/ai_hosted_runtime.go`, `internal/api/ai_handlers.go`,`internal/api/ai_handler.go`, and `internal/api/hosted_billing_state.go`diff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.jsonindex 63182d796c..2709a55f70 100644--- a/internal/cloudcp/portal/dist/build_manifest.json+++ b/internal/cloudcp/portal/dist/build_manifest.json@@ -1,5 +1,5 @@{- "source_hash": "79525f2dc457afa11c45be4179e152100b2df66f42e6a0ea3b887bf2190a54d8",+ "source_hash": "0106a314ffe90647926e4c341d4d7ae4ff87f7129fd612459ebd6fd472b35241","build_inputs": ["package.json","tsconfig.json",diff --git a/internal/cloudcp/portal/dist/portal_app.js b/internal/cloudcp/portal/dist/portal_app.jsindex bfbb6c6fb6..671e9be8d8 100644--- a/internal/cloudcp/portal/dist/portal_app.js+++ b/internal/cloudcp/portal/dist/portal_app.js@@ -1,6 +1,5 @@(() => {// src/runtime.ts- var PORTAL_RENDER_EVENT = "pulse-account-render";function readEmbeddedBootstrap() {const bootstrapEl = document.getElementById("pulse-account-bootstrap");if (!bootstrapEl) {@@ -41,6 +40,7 @@return createAnonymousBootstrap(raw || {});}var bootstrapState = normalizeBootstrap(embeddedBootstrap);+ var renderSubscribers = /* @__PURE__ */ new Set();function getBootstrap() {return bootstrapState;}@@ -72,11 +72,16 @@function getPortalAPIBasePath() {return bootstrapState.portal_api_base_path;}- function dispatchPortalRender() {- document.dispatchEvent(new CustomEvent(PORTAL_RENDER_EVENT));+ function notifyPortalRender() {+ renderSubscribers.forEach((listener) => {+ listener();+ });}- function installRuntime(runtime) {- window.PulseAccountPortal = runtime;+ function subscribePortalRender(listener) {+ renderSubscribers.add(listener);+ return () => {+ renderSubscribers.delete(listener);+ };}// src/shell.ts@@ -197,7 +202,7 @@if (portalBootstrap.authenticated) {renderAccounts(portalBootstrap.accounts || []);}- dispatchPortalRender();+ notifyPortalRender();}function applyBootstrap(data) {portalBootstrap = setBootstrap(data || createAnonymousBootstrap());@@ -276,26 +281,6 @@loginState.sending = false;renderPortalApp();}- var portalRuntime = {- getBootstrap: function() {- return portalBootstrap;- },- getCommercialAPIBaseURL: function() {- return LICENSE_API_BASE;- },- getPortalPath: function() {- return PORTAL_PATH;- },- getAccountAPIBasePath: function() {- return ACCOUNT_API_BASE_PATH;- },- getPortalAPIBasePath: function() {- return PORTAL_API_BASE_PATH;- },- refreshBootstrap,- showToast- };- installRuntime(portalRuntime);document.addEventListener("click", function(event) {var portalActionEl = asHTMLElement(event.target)?.closest("[data-portal-action]");if (portalActionEl) {@@ -1126,7 +1111,7 @@renderAllFlows();}renderServiceRuntime();- document.addEventListener(PORTAL_RENDER_EVENT, renderServiceRuntime);+ subscribePortalRender(renderServiceRuntime);document.addEventListener("click", function(event) {var target = asHTMLElement2(event.target)?.closest("[data-account-service-action]");if (!target) return;diff --git a/internal/cloudcp/portal/frontend/src/runtime.ts b/internal/cloudcp/portal/frontend/src/runtime.tsindex 8fbfad1ce7..057f44e1ad 100644--- a/internal/cloudcp/portal/frontend/src/runtime.ts+++ b/internal/cloudcp/portal/frontend/src/runtime.ts@@ -1,6 +1,4 @@-import type { PortalBootstrapData, PortalRuntime } from './types';--export const PORTAL_RENDER_EVENT = 'pulse-account-render';+import type { PortalBootstrapData } from './types';function readEmbeddedBootstrap(): Partial<PortalBootstrapData> {const bootstrapEl = document.getElementById('pulse-account-bootstrap');@@ -48,6 +46,7 @@ export function normalizeBootstrap(raw: Partial<PortalBootstrapData> | null | un}let bootstrapState: PortalBootstrapData = normalizeBootstrap(embeddedBootstrap);+const renderSubscribers = new Set<() => void>();export function getBootstrap(): PortalBootstrapData {return bootstrapState;@@ -90,10 +89,15 @@ export function getPortalAPIBasePath(): string {return bootstrapState.portal_api_base_path;}-export function dispatchPortalRender(): void {- document.dispatchEvent(new CustomEvent(PORTAL_RENDER_EVENT));+export function notifyPortalRender(): void {+ renderSubscribers.forEach((listener) => {+ listener();+ });}-export function installRuntime(runtime: PortalRuntime): void {- window.PulseAccountPortal = runtime;+export function subscribePortalRender(listener: () => void): () => void {+ renderSubscribers.add(listener);+ return () => {+ renderSubscribers.delete(listener);+ };}diff --git a/internal/cloudcp/portal/frontend/src/services.ts b/internal/cloudcp/portal/frontend/src/services.tsindex 59ff6ae594..ea00cb5150 100644--- a/internal/cloudcp/portal/frontend/src/services.ts+++ b/internal/cloudcp/portal/frontend/src/services.ts@@ -1,4 +1,4 @@-import { PORTAL_RENDER_EVENT, getBootstrap, getCommercialAPIBaseURL as readCommercialAPIBaseURL } from './runtime';+import { getBootstrap, getCommercialAPIBaseURL as readCommercialAPIBaseURL, subscribePortalRender } from './runtime';import type { RefundState, ServiceStatus, VerificationFlowState } from './types';type FlowID = 'manage' | 'retrieve' | 'export' | 'delete';@@ -666,7 +666,7 @@ type FormValueElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectEleme}renderServiceRuntime();- document.addEventListener(PORTAL_RENDER_EVENT, renderServiceRuntime);+ subscribePortalRender(renderServiceRuntime);document.addEventListener('click', function(event) {var target = asHTMLElement(event.target)?.closest('[data-account-service-action]');diff --git a/internal/cloudcp/portal/frontend/src/shell.ts b/internal/cloudcp/portal/frontend/src/shell.tsindex 31b93e07df..d8c52d7a31 100644--- a/internal/cloudcp/portal/frontend/src/shell.ts+++ b/internal/cloudcp/portal/frontend/src/shell.ts@@ -1,6 +1,5 @@import {createAnonymousBootstrap,- dispatchPortalRender,getAccountAPIBasePath,getBootstrap,getBootstrapPath,@@ -10,10 +9,10 @@ import {getPortalAPIBasePath,getPortalPath,getSignupPath,- installRuntime,+ notifyPortalRender,setBootstrap,} from './runtime';-import type { PortalBootstrapData, PortalLoginState, PortalRuntime } from './types';+import type { PortalBootstrapData, PortalLoginState } from './types';var portalBootstrap: PortalBootstrapData = getBootstrap();var LICENSE_API_BASE = getCommercialAPIBaseURL();@@ -359,7 +358,7 @@ function renderPortalApp() {if (portalBootstrap.authenticated) {renderAccounts(portalBootstrap.accounts || []);}- dispatchPortalRender();+ notifyPortalRender();}function applyBootstrap(data) {@@ -448,27 +447,6 @@ async function sendMagicLink() {renderPortalApp();}-var portalRuntime: PortalRuntime = {- getBootstrap: function() {- return portalBootstrap;- },- getCommercialAPIBaseURL: function() {- return LICENSE_API_BASE;- },- getPortalPath: function() {- return PORTAL_PATH;- },- getAccountAPIBasePath: function() {- return ACCOUNT_API_BASE_PATH;- },- getPortalAPIBasePath: function() {- return PORTAL_API_BASE_PATH;- },- refreshBootstrap: refreshBootstrap,- showToast: showToast,-};-installRuntime(portalRuntime);-document.addEventListener('click', function(event) {var portalActionEl = asHTMLElement(event.target)?.closest('[data-portal-action]');if (portalActionEl) {diff --git a/internal/cloudcp/portal/frontend/src/types.ts b/internal/cloudcp/portal/frontend/src/types.tsindex 9d1f0346e6..c03590547d 100644--- a/internal/cloudcp/portal/frontend/src/types.ts+++ b/internal/cloudcp/portal/frontend/src/types.ts@@ -33,16 +33,6 @@ export interface PortalBootstrapData {accounts: PortalAccountSummary[];}-export interface PortalRuntime {- getBootstrap(): PortalBootstrapData;- getCommercialAPIBaseURL(): string;- getPortalPath(): string;- getAccountAPIBasePath(): string;- getPortalAPIBasePath(): string;- refreshBootstrap(): Promise<boolean>;- showToast(message: string, isError?: boolean): void;-}-export interface PortalLoginState {emailValue: string;sending: boolean;@@ -74,9 +64,3 @@ export interface RefundState {submitting: boolean;status: ServiceStatus;}--declare global {- interface Window {- PulseAccountPortal?: PortalRuntime;- }-}diff --git a/internal/cloudcp/portal/handlers_test.go b/internal/cloudcp/portal/handlers_test.goindex 77c114dd4e..821067264d 100644--- a/internal/cloudcp/portal/handlers_test.go+++ b/internal/cloudcp/portal/handlers_test.go@@ -816,6 +816,12 @@ func TestPortalPageTemplate_AccountServicesRendered(t *testing.T) {if strings.Contains(html, `assets/portal_shell.js`) || strings.Contains(html, `assets/portal_services.js`) || strings.Contains(html, `assets/portal.css`) {t.Errorf("expected portal runtime to load from the built dist bundle, not the old handwritten asset paths")}+ if strings.Contains(html, `window.PulseAccountPortal`) {+ t.Errorf("expected Pulse Account frontend coordination to stay module-owned, not revive a browser-global runtime")+ }+ if strings.Contains(html, `pulse-account-render`) {+ t.Errorf("expected Pulse Account frontend coordination to stay module-owned, not revive a document-wide render event")+ }if strings.Contains(html, `await fetch('/auth/logout'`) {t.Errorf("expected portal paths to be renderer-owned, not hardcoded in the asset")}