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
Make billing task-driven
rcourtmand88f2e501ab5
diff --git a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.mdindex 4c5f1e87ad..8c8bd5e907 100644--- a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md+++ b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md@@ -184,6 +184,11 @@ Core rules:25. `Access` must default to the hosted roster plus explicit job entry points,not a permanently open mutation rail. Invite, role-change, and removecontrols should appear only when that exact access job is active.+26. `Billing` must default to hosted billing plus explicit self-hosted job+ entry points, not an always-open billing dashboard. Self-hosted billing,+ license, refund, and privacy panels should appear only when that exact+ billing job is active, and opening one on phone widths must reveal the+ active panel in-frame.## Screen Model@@ -218,7 +223,8 @@ Each signed-in state should render:5. an explicit `Billing` area that leads with hosted billing when applicableand nests self-hosted commercial utilities only when relevant`Billing` should default to a single obvious task picker, not a broad- dashboard of overlapping billing explanations.+ dashboard of overlapping billing explanations, and the active self-hosted+ task panel should stay hidden until the user opens that exact billing job.6. a `Support` area that is present only as an escalation path`Support` should collapse to failed-path routing plus the minimum escalationpacket needed for handoff.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 3da7676d9e..63ff83af9b 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -283,7 +283,10 @@ create-workspace job is active, rather than rendering a default idlelifecycle explainer before the user has picked a task. The same task-firstruntime rule now also applies to `Access`: the hosted roster is the defaultsurface, and invite, role-change, or remove controls only appear when the-matching access job is active.+matching access job is active. `Billing` follows the same shared runtime+contract: hosted billing remains the default primary path, self-hosted billing+jobs open one panel at a time, and the runtime must reveal the active billing+panel on phone-width layouts instead of leaving it offscreen.plus a package-local `tsc --noEmit` gate, so future account-shell work shouldextend the typed source boundary instead of reviving opaque global runtimeobjects, document-wide render events, or untyped embedded asset edits.diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex dfbe7fc6a3..47522f6b98 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -837,7 +837,11 @@ workspace list plus the real task entry points rather than an idle lifecycleessay; the lifecycle rail should appear only when a lifecycle orcreate-workspace job is active. `Access` follows the same rule: the hostedroster must be the default state, while invite, role-change, and remove-controls appear only when that exact access job is active. Until that+controls appear only when that exact access job is active. `Billing` follows+the same task-first rule: hosted billing leads when present, the self-hosted+billing, license, refund, and privacy paths reduce to explicit job pickers,+and the active self-hosted billing panel must stay hidden until that exact job+is opened and then be revealed in-frame on narrow layouts. Until thatcandidate lane lands, newcommercial account work must extend the governed Pulse account shape ratherthan spawning additional one-off recovery or billing pages.diff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.jsonindex 477efcbee8..a5ba102707 100644--- a/internal/cloudcp/portal/dist/build_manifest.json+++ b/internal/cloudcp/portal/dist/build_manifest.json@@ -1,5 +1,5 @@{- "source_hash": "32735365beff496cbfb64b485b1a89d40dcd459e036a09ead2bfe337370c6dda",+ "source_hash": "527e64b3ea61ad459d0dab71d0debb325570ee48455668632561762f51c77250","build_inputs": ["package.json","tsconfig.json",diff --git a/internal/cloudcp/portal/dist/portal_app.css b/internal/cloudcp/portal/dist/portal_app.cssindex 5a379a06fd..a500bd71a9 100644--- a/internal/cloudcp/portal/dist/portal_app.css+++ b/internal/cloudcp/portal/dist/portal_app.css@@ -2298,34 +2298,37 @@ header .logout-btn:hover,}.billing-shell {display: grid;- grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);- gap: 12px;+ grid-template-columns: minmax(0, 1fr);+ gap: 14px;align-items: start;padding: 12px;border: 1px solid var(--line);border-radius: 12px;background: #fff;}+.billing-shell-job-open {+ grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);+}.billing-shell-main,-.billing-shell-sidebar {+.billing-shell-detail {display: flex;flex-direction: column;gap: 8px;}-.billing-shell-sidebar-head,+.billing-shell-main-head,.billing-inline-support {padding: 11px 12px;border: 1px solid var(--line);border-radius: 12px;background: var(--panel-strong);}-.billing-shell-sidebar-head h3 {+.billing-shell-main-head h3 {margin: 4px 0 0;font-size: 16px;line-height: 1.08;letter-spacing: -0.03em;}-.billing-shell-sidebar-head p,+.billing-shell-main-head p,.billing-inline-support p {margin: 5px 0 0;font-size: 11px;@@ -2381,6 +2384,33 @@ header .logout-btn:hover,box-shadow: none;overflow: hidden;}+.billing-task-header {+ display: flex;+ align-items: flex-start;+ justify-content: space-between;+ gap: 12px;+ padding-bottom: 12px;+ border-bottom: 1px solid var(--line);+}+.billing-task-header h3 {+ margin: 4px 0 0;+ font-size: 18px;+ line-height: 1.04;+ letter-spacing: -0.03em;+}+.billing-task-header p {+ margin: 8px 0 0;+ max-width: 560px;+ font-size: 13px;+ line-height: 1.55;+ color: var(--ink-soft);+}+.billing-task-body {+ display: flex;+ flex-direction: column;+ gap: 14px;+ margin-top: 14px;+}.billing-brief-card {padding: 16px;border: 1px solid var(--line);@@ -2554,12 +2584,6 @@ header .logout-btn:hover,.billing-panel.visible.auth-panel {display: block;}-.billing-panel-empty {- display: none;-}-.billing-panel-empty.visible {- display: block;-}.billing-empty-points {display: grid;grid-template-columns: repeat(2, minmax(0, 1fr));@@ -3036,7 +3060,8 @@ header .logout-btn:hover,.workspace-management-header,.access-management-header,.billing-header,- .billing-action-tags {+ .billing-action-tags,+ .billing-task-header {flex-direction: column;align-items: flex-start;}diff --git a/internal/cloudcp/portal/dist/portal_app.js b/internal/cloudcp/portal/dist/portal_app.jsindex f17dc88d07..4ee57d20a9 100644--- a/internal/cloudcp/portal/dist/portal_app.js+++ b/internal/cloudcp/portal/dist/portal_app.js@@ -1288,7 +1288,15 @@}function focusElement2(id) {var el = getElement3(id);- if (el) el.focus();+ if (!el) return;+ if (typeof el.focus === "function") {+ try {+ el.focus({ preventScroll: true });+ return;+ } catch (_) {+ el.focus();+ }+ }}function setVisible(id, visible) {var el = getElement3(id);@@ -1321,15 +1329,23 @@button.textContent = label;}function renderOpenBillingPanels(openBillingPanelID) {+ var shell = document.querySelector(".billing-shell");+ var detailShell = getElement3("billing-detail-shell");var panels = ["manage-billing-panel", "retrieve-billing-panel", "refund-billing-panel", "data-billing-panel"];- var emptyPanel = getElement3("billing-panel-empty");- if (emptyPanel) {- emptyPanel.classList.toggle("visible", !openBillingPanelID);+ var hasOpenPanel = !!openBillingPanelID;+ if (shell) {+ shell.classList.toggle("billing-shell-job-open", hasOpenPanel);+ shell.classList.toggle("billing-shell-idle", !hasOpenPanel);+ }+ if (detailShell) {+ detailShell.hidden = !hasOpenPanel;}for (var i = 0; i < panels.length; i++) {var panel = getElement3(panels[i]);if (!panel) continue;- panel.classList.toggle("visible", panels[i] === openBillingPanelID);+ var isActive = panels[i] === openBillingPanelID;+ panel.hidden = !isActive;+ panel.classList.toggle("visible", isActive);}var billingButtons = document.querySelectorAll('[data-account-billing-action="open-billing-panel"]');for (var j = 0; j < billingButtons.length; j += 1) {@@ -1338,24 +1354,39 @@if (!row) continue;row.classList.toggle("active", button.getAttribute("data-account-billing-panel") === openBillingPanelID);}+ if (hasOpenPanel && detailShell) {+ var reveal = function() {+ if (typeof detailShell.scrollIntoView !== "function") return;+ var rect = detailShell.getBoundingClientRect();+ if (rect.top >= 0 && rect.top <= window.innerHeight - 72 && rect.bottom > 0) {+ return;+ }+ detailShell.scrollIntoView({ block: "start", inline: "nearest" });+ };+ if (typeof window.requestAnimationFrame === "function") {+ window.requestAnimationFrame(reveal);+ return;+ }+ reveal();+ }}function renderRefundPanel(refundState, bootstrap) {var root = getElement3("refund-billing-root");if (!root) return;var refundSupportURL = (bootstrap.public_site_url || "") + "/refund.html?email=" + encodeURIComponent(refundState.emailValue || "");- root.innerHTML = '<h3>Refund requests</h3><p>Process an eligible self-serve refund for a self-hosted purchase. This revokes the associated license immediately.</p><div class="warning"><strong>Warning:</strong> completing a refund immediately revokes the affected license. This should only be used when the refund window and commercial contract allow it.</div><div class="form-group"><label for="refund-inline-email">Email address</label><input type="email" id="refund-inline-email" value="' + escapeAttribute(refundState.emailValue || "") + '" autocomplete="email" data-account-billing-input="refund-email"></div><div class="form-group"><label for="refund-inline-token">License key</label><input type="text" id="refund-inline-token" value="' + escapeAttribute(refundState.tokenValue || "") + '" placeholder="pulse_xxxxx" data-account-billing-input="refund-token"></div><div class="form-actions"><button class="btn-danger" type="button" id="refund-inline-submit" data-account-billing-action="refund-inline-submit">Process Refund</button></div><div class="helper-text">If this purchase is not eligible for self-serve refund, use the public support path instead: <a href="' + escapeAttribute(refundSupportURL) + '">open refund support page</a>.</div><div class="billing-status" id="refund-inline-status"></div>';+ root.innerHTML = '<p>Process an eligible self-serve refund for a self-hosted purchase. This revokes the associated license immediately.</p><div class="warning"><strong>Warning:</strong> completing a refund immediately revokes the affected license. This should only be used when the refund window and commercial contract allow it.</div><div class="form-group"><label for="refund-inline-email">Email address</label><input type="email" id="refund-inline-email" value="' + escapeAttribute(refundState.emailValue || "") + '" autocomplete="email" data-account-billing-input="refund-email"></div><div class="form-group"><label for="refund-inline-token">License key</label><input type="text" id="refund-inline-token" value="' + escapeAttribute(refundState.tokenValue || "") + '" placeholder="pulse_xxxxx" data-account-billing-input="refund-token"></div><div class="form-actions"><button class="btn-danger" type="button" id="refund-inline-submit" data-account-billing-action="refund-inline-submit">Process Refund</button></div><div class="helper-text">If this purchase is not eligible for self-serve refund, use the public support path instead: <a href="' + escapeAttribute(refundSupportURL) + '">open refund support page</a>.</div><div class="billing-status" id="refund-inline-status"></div>';}function renderManagePanel(flowState) {var root = getElement3("manage-billing-root");if (!root) return;- root.innerHTML = '<h3>Manage subscriptions</h3><p>Request a verification code for the commercial email, then open the Stripe customer portal for billing changes, invoices, and subscription actions.</p><div id="manage-inline-step1"><div class="form-group"><label for="manage-inline-email">Email address</label><input type="email" id="manage-inline-email" value="' + escapeAttribute(flowState.emailValue || "") + '" autocomplete="email" data-account-billing-input="manage-email"></div><div class="form-actions"><button class="btn-primary" type="button" id="manage-inline-request" data-account-billing-action="manage-inline-request">Send Verification Code</button></div></div><div id="manage-inline-step2"' + (flowState.step2Visible ? "" : " hidden") + '><div class="form-group"><label for="manage-inline-code">Verification code</label><input type="text" id="manage-inline-code" value="' + escapeAttribute(flowState.codeValue || "") + '" inputmode="numeric" pattern="[0-9]{6}" placeholder="123456" data-account-billing-input="manage-code"></div><div class="form-actions"><button class="btn-primary" type="button" id="manage-inline-confirm" data-account-billing-action="manage-inline-confirm">Open Customer Portal</button></div><div class="helper-text">Need a new code? <a href="#" id="manage-inline-resend" data-account-billing-action="manage-inline-resend">Send again</a></div></div><div class="billing-status" id="manage-inline-status"></div>';+ root.innerHTML = '<p>Request a verification code for the commercial email, then open the Stripe customer portal for billing changes, invoices, and subscription actions.</p><div id="manage-inline-step1"><div class="form-group"><label for="manage-inline-email">Email address</label><input type="email" id="manage-inline-email" value="' + escapeAttribute(flowState.emailValue || "") + '" autocomplete="email" data-account-billing-input="manage-email"></div><div class="form-actions"><button class="btn-primary" type="button" id="manage-inline-request" data-account-billing-action="manage-inline-request">Send Verification Code</button></div></div><div id="manage-inline-step2"' + (flowState.step2Visible ? "" : " hidden") + '><div class="form-group"><label for="manage-inline-code">Verification code</label><input type="text" id="manage-inline-code" value="' + escapeAttribute(flowState.codeValue || "") + '" inputmode="numeric" pattern="[0-9]{6}" placeholder="123456" data-account-billing-input="manage-code"></div><div class="form-actions"><button class="btn-primary" type="button" id="manage-inline-confirm" data-account-billing-action="manage-inline-confirm">Open Customer Portal</button></div><div class="helper-text">Need a new code? <a href="#" id="manage-inline-resend" data-account-billing-action="manage-inline-resend">Send again</a></div></div><div class="billing-status" id="manage-inline-status"></div>';}function renderRetrievePanel(flowState) {var root = getElement3("retrieve-billing-root");if (!root) return;var result = flowState.result;var invoiceURL = result && result.invoice_url ? result.invoice_url : "#";- root.innerHTML = '<h3>Retrieve licenses</h3><p>Request a verification code for the commercial email, then reveal the current active self-hosted license without leaving Pulse Account.</p><div id="retrieve-inline-step1"><div class="form-group"><label for="retrieve-inline-email">Email address</label><input type="email" id="retrieve-inline-email" value="' + escapeAttribute(flowState.emailValue || "") + '" autocomplete="email" data-account-billing-input="retrieve-email"></div><div class="form-actions"><button class="btn-primary" type="button" id="retrieve-inline-request" data-account-billing-action="retrieve-inline-request">Send Verification Code</button></div></div><div id="retrieve-inline-step2"' + (flowState.step2Visible ? "" : " hidden") + '><div class="form-group"><label for="retrieve-inline-code">Verification code</label><input type="text" id="retrieve-inline-code" value="' + escapeAttribute(flowState.codeValue || "") + '" inputmode="numeric" pattern="[0-9]{6}" placeholder="123456" data-account-billing-input="retrieve-code"></div><div class="form-actions"><button class="btn-primary" type="button" id="retrieve-inline-confirm" data-account-billing-action="retrieve-inline-confirm">Show License</button><button class="btn-secondary" type="button" id="retrieve-inline-copy" data-account-billing-action="retrieve-inline-copy"' + (result ? "" : " hidden") + '>Copy License Key</button><a class="btn-secondary" id="retrieve-inline-invoice" href="' + escapeAttribute(invoiceURL) + '" target="_blank" rel="noopener"' + (result && result.invoice_url ? "" : " hidden") + '>View Invoice</a></div><div class="helper-text">Use the latest active self-hosted license for this commercial email.</div></div><div class="billing-status" id="retrieve-inline-status"></div><div id="retrieve-inline-result" class="billing-result"' + (result ? "" : " hidden") + '><label for="retrieve-inline-token">License key</label><textarea id="retrieve-inline-token" readonly>' + escapeText(result ? result.token : "") + '</textarea><div class="result-grid"><div><div class="result-meta-label">Plan</div><div class="result-meta-value" id="retrieve-inline-tier">' + escapeText(result ? result.tier : "") + '</div></div><div><div class="result-meta-label">Issued</div><div class="result-meta-value" id="retrieve-inline-issued">' + escapeText(result ? new Date(result.issued_at).toLocaleString() : "") + '</div></div><div><div class="result-meta-label">Expires</div><div class="result-meta-value" id="retrieve-inline-expires">' + escapeText(result ? result.expires_at ? new Date(result.expires_at).toLocaleString() : "Does not expire" : "") + '</div></div><div><div class="result-meta-label">Purchase Email</div><div class="result-meta-value" id="retrieve-inline-email-value">' + escapeText(result ? result.email : "") + "</div></div></div></div>";+ root.innerHTML = '<p>Request a verification code for the commercial email, then reveal the current active self-hosted license without leaving Pulse Account.</p><div id="retrieve-inline-step1"><div class="form-group"><label for="retrieve-inline-email">Email address</label><input type="email" id="retrieve-inline-email" value="' + escapeAttribute(flowState.emailValue || "") + '" autocomplete="email" data-account-billing-input="retrieve-email"></div><div class="form-actions"><button class="btn-primary" type="button" id="retrieve-inline-request" data-account-billing-action="retrieve-inline-request">Send Verification Code</button></div></div><div id="retrieve-inline-step2"' + (flowState.step2Visible ? "" : " hidden") + '><div class="form-group"><label for="retrieve-inline-code">Verification code</label><input type="text" id="retrieve-inline-code" value="' + escapeAttribute(flowState.codeValue || "") + '" inputmode="numeric" pattern="[0-9]{6}" placeholder="123456" data-account-billing-input="retrieve-code"></div><div class="form-actions"><button class="btn-primary" type="button" id="retrieve-inline-confirm" data-account-billing-action="retrieve-inline-confirm">Show License</button><button class="btn-secondary" type="button" id="retrieve-inline-copy" data-account-billing-action="retrieve-inline-copy"' + (result ? "" : " hidden") + '>Copy License Key</button><a class="btn-secondary" id="retrieve-inline-invoice" href="' + escapeAttribute(invoiceURL) + '" target="_blank" rel="noopener"' + (result && result.invoice_url ? "" : " hidden") + '>View Invoice</a></div><div class="helper-text">Use the latest active self-hosted license for this commercial email.</div></div><div class="billing-status" id="retrieve-inline-status"></div><div id="retrieve-inline-result" class="billing-result"' + (result ? "" : " hidden") + '><label for="retrieve-inline-token">License key</label><textarea id="retrieve-inline-token" readonly>' + escapeText(result ? result.token : "") + '</textarea><div class="result-grid"><div><div class="result-meta-label">Plan</div><div class="result-meta-value" id="retrieve-inline-tier">' + escapeText(result ? result.tier : "") + '</div></div><div><div class="result-meta-label">Issued</div><div class="result-meta-value" id="retrieve-inline-issued">' + escapeText(result ? new Date(result.issued_at).toLocaleString() : "") + '</div></div><div><div class="result-meta-label">Expires</div><div class="result-meta-value" id="retrieve-inline-expires">' + escapeText(result ? result.expires_at ? new Date(result.expires_at).toLocaleString() : "Does not expire" : "") + '</div></div><div><div class="result-meta-label">Purchase Email</div><div class="result-meta-value" id="retrieve-inline-email-value">' + escapeText(result ? result.email : "") + "</div></div></div></div>";}function renderExportPanel(flowState) {var root = getElement3("data-export-root");@@ -1374,6 +1405,20 @@// src/billing_controller.tsfunction installBillingController(deps) {+ function revealBillingPanelWhenReady(panelID) {+ var reveal = function() {+ var panel = document.getElementById(panelID);+ if (!panel || panel.hidden || typeof panel.scrollIntoView !== "function") return;+ panel.scrollIntoView({ block: "start", inline: "nearest" });+ };+ if (typeof window.requestAnimationFrame === "function") {+ window.requestAnimationFrame(function() {+ window.requestAnimationFrame(reveal);+ });+ return;+ }+ reveal();+ }document.addEventListener("click", function(event) {var target = asHTMLElement3(event.target)?.closest("[data-account-billing-action]");if (!target) return;@@ -1385,7 +1430,18 @@event.preventDefault();deps.setShellSection("billing");deps.toggleBillingPanel(panelID);+ if (typeof target.blur === "function") {+ target.blur();+ }deps.focusElement(focusID);+ if (panelID) {+ revealBillingPanelWhenReady(panelID);+ }+ return;+ case "clear-billing-panel":+ event.preventDefault();+ deps.setShellSection("billing");+ deps.clearBillingPanel();return;case "manage-inline-request":event.preventDefault();@@ -1477,6 +1533,11 @@toggleBillingPanelState(billingState, panelID);});}+ function clearBillingPanel() {+ updateBillingState(function(billingState) {+ billingState.openBillingPanelID = "";+ });+ }function renderFlow(flowID) {var flow = verificationFlows[flowID];if (!flow) return;@@ -1807,6 +1868,7 @@store.setActiveShellSection(section);},toggleBillingPanel,+ clearBillingPanel,focusElement: focusElement2,requestVerificationCode: function(flowID) {void requestVerificationCode(flowID);@@ -2190,6 +2252,9 @@return '<article class="billing-task-card"><div class="account-panel-kicker">Hosted billing</div><h3>' + escapeHTML(account.name) + '</h3><p>Invoices, payment methods, and hosted subscription changes for this account live here.</p><div class="billing-task-points"><div class="billing-task-point"><strong>Use when hosted billing is the job</strong><span>Keep workspace lifecycle work in Workspaces and access changes in Access.</span></div><div class="billing-task-point"><strong>Stay account-specific</strong><span>Open billing from the exact hosted account you want to change.</span></div></div><div class="billing-task-actions">' + actionHTML + "</div></article>";}).join("");}+ function renderBillingTaskPanel(title, copy, panelID, bodyHTML) {+ return '<section class="billing-panel" id="' + escapeAttr(panelID) + '" hidden><div class="billing-task-header"><div><div class="account-panel-kicker">Billing task</div><h3>' + escapeHTML(title) + "</h3><p>" + escapeHTML(copy) + '</p></div><button type="button" class="btn-secondary btn-compact" data-account-billing-action="clear-billing-panel">Close panel</button></div><div class="billing-task-body">' + bodyHTML + "</div></section>";+ }function renderSupportSection(context) {return '<section class="portal-support-panel"><div class="account-panel-kicker">Support</div><h2>Escalation only</h2><p>Use support only when the Workspaces, Access, or Billing path has already stopped you.</p>' + renderSectionContextChips(["Escalation only", "Bring context", context.bootstrap.support_email ? "Email" : "Support"]) + '<div class="portal-support-layout"><div class="portal-support-route-grid"><div class="portal-support-route-card"><div class="account-panel-kicker">Hosted path</div><h3>Workspace or access path failed</h3><p>Go back to the hosted task first. Escalate only when the same workspace or access path still cannot finish the job.</p><div class="portal-support-points"><div class="portal-support-point"><strong>Start from the same task</strong><span>Use Workspaces for lifecycle issues and Access for roster issues before you escalate.</span></div><div class="portal-support-point"><strong>Keep the hosted context intact</strong><span>Include the account, workspace, and failed action so support inherits the same request.</span></div></div><div class="portal-support-actions"><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="workspaces">Open workspaces</button><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="access">Open access</button><a class="portal-support-link" href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + '</a></div></div><div class="portal-support-route-card"><div class="account-panel-kicker">Billing path</div><h3>Billing path failed</h3><p>Use this route only after hosted billing or one self-hosted billing job has failed to complete cleanly.</p><div class="portal-support-points"><div class="portal-support-point"><strong>Name the billing job</strong><span>Say whether the failed path was hosted billing, licenses, refunds, or privacy.</span></div><div class="portal-support-point"><strong>Keep the request intact</strong><span>Bring the same account or billing email and the failed action instead of reopening the story.</span></div></div><div class="portal-support-actions"><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="billing">Open billing</button><a class="portal-support-link" href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + '</a></div></div></div><div class="portal-support-runbook"><div class="account-panel-kicker">What to send</div><h3>Keep the escalation short</h3><p>Support should inherit the same request, not reconstruct it from scratch.</p><div class="portal-support-runbook-list"><div class="portal-support-runbook-step"><strong>1. Failed path</strong><span>Say whether the blocked path was Workspaces, Access, hosted billing, licenses, refunds, or privacy.</span></div><div class="portal-support-runbook-step"><strong>2. Account or email</strong><span>Include the hosted account and workspace when relevant, or the commercial billing email for self-hosted work.</span></div><div class="portal-support-runbook-step"><strong>3. Failed action</strong><span>Name the exact button, form, or billing step that failed and what happened next.</span></div></div></div></div></section>';}@@ -2213,7 +2278,27 @@return '<div class="portal-shell" data-shell-section="' + activeSection + '"><div class="portal-shell-layout">' + renderShellNavigation(accounts, context.bootstrap.support_email || "", activeSection) + '<div class="portal-shell-main">' + (accounts.length === 1 ? renderAccountContextStrip(accounts[0]) : "") + '<section class="portal-content-panel portal-content-panel-overview">' + renderShellOverviewSection(context) + '<div id="accounts-root">' + hostedContent + '</div></section><section class="portal-content-panel portal-content-panel-billing billing-section" id="billing-section"><div class="billing-header"><div><div class="account-panel-kicker">Billing</div><h2>Billing</h2>' + renderSectionContextChips([hostedBillingCount > 0 ? "Hosted billing" : "No hosted billing","Self-hosted tools"- ]) + '</div><div class="billing-note">' + billingNote + '</div></div><div class="billing-overview-grid">' + renderHostedBillingCards(accounts) + '</div><div class="billing-shell"><aside class="billing-shell-sidebar"><div class="billing-shell-sidebar-head"><div class="account-panel-kicker">Self-hosted billing</div><h3>Pick the self-hosted job</h3><p>Use one path at a time for self-hosted billing, licenses, refunds, or privacy.</p></div><div class="billing-action-list">' + renderBillingActionRow("open-manage-billing", "Self-hosted billing", "Manage subscriptions", "Billing", "Open Stripe for self-hosted plan, invoice, and payment changes.", "manage-billing-panel", "manage-inline-email", ["Plan changes", "Invoices"]) + renderBillingActionRow("open-retrieve-billing", "Licenses", "Retrieve licenses", "Licenses", "Recover the latest active self-hosted license and invoice link.", "retrieve-billing-panel", "retrieve-inline-email", ["Latest active license", "Invoice lookup"]) + renderBillingActionRow("open-refund-billing", "Refunds", "Refund requests", "Refunds", "Request a self-serve refund when the purchase is still eligible.", "refund-billing-panel", "refund-inline-email", ["Eligibility check", "Revocation"]) + renderBillingActionRow("open-data-billing", "Privacy", "Data and privacy", "Privacy", "Request export or deletion for commercial account data.", "data-billing-panel", "data-export-email", ["Export", "Deletion"]) + '</div><div class="billing-inline-support"><div class="account-panel-kicker">Escalation only</div><h4>Use Support only after Billing fails</h4><p>Escalate with the same hosted billing action or self-hosted path and the exact failed step.</p><div class="billing-inline-support-actions"><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="support">Open support</button><a class="portal-support-link" href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + '</a></div></div></aside><div class="billing-shell-main"><div class="billing-detail-shell"><div class="billing-panel billing-panel-empty visible" id="billing-panel-empty"><div class="account-panel-kicker">Next action</div><h3>Choose one billing path</h3><p>Open the job you need. Use hosted billing above when it applies, and use these self-hosted paths only for self-hosted purchases.</p><div class="billing-empty-shell"><div class="billing-empty-primary"><div class="billing-empty-section billing-empty-section-compact"><div class="billing-empty-column-title">Available now</div><div class="billing-empty-flow-list"><div class="billing-empty-flow"><strong>Billing</strong><span>Manage self-hosted plans, invoices, and payment methods.</span></div><div class="billing-empty-flow"><strong>Licenses</strong><span>Recover the latest active self-hosted license and invoice link.</span></div><div class="billing-empty-flow"><strong>Refunds</strong><span>Check eligibility before revoking active self-hosted access.</span></div><div class="billing-empty-flow"><strong>Privacy</strong><span>Request export or deletion for commercial account data.</span></div></div></div></div><div class="billing-empty-side"><div class="billing-empty-section billing-empty-section-support"><div class="billing-empty-column-title">Escalation</div><div class="billing-empty-checklist"><div class="billing-empty-check"><strong>Use support last</strong><span>Only after hosted billing or one self-hosted path fails.</span></div><div class="billing-empty-check"><strong>Send the same request</strong><span>Include the billing path, account or commercial email, and the failed step.</span></div></div><div class="billing-empty-support">Need escalation for billing, refund, privacy, or license work? <a class="portal-support-link" href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + '</a></div><div class="billing-empty-actions"><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="support">Open support</button></div></div></div></div></div><div class="billing-panel" id="manage-billing-panel"><div id="manage-billing-root"></div></div><div class="billing-panel" id="retrieve-billing-panel"><div id="retrieve-billing-root"></div></div><div class="billing-panel" id="refund-billing-panel"><div id="refund-billing-root"></div></div><div class="billing-panel" id="data-billing-panel"><h3>Data and privacy</h3><p>Request export or deletion of the commercial data tied to an email address. Payment data held directly by Stripe still requires support handling.</p><div class="subsection"><div id="data-export-root"></div></div><div class="subsection"><div id="data-delete-root"></div></div><div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + '</a>.</div></div></div></div></div></section><section class="portal-content-panel portal-content-panel-support">' + renderSupportSection(context) + "</section></div></div></div>";+ ]) + '</div><div class="billing-note">' + billingNote + '</div></div><div class="billing-overview-grid">' + renderHostedBillingCards(accounts) + '</div><div class="billing-shell billing-shell-idle"><div class="billing-shell-main"><div class="billing-shell-main-head"><div class="account-panel-kicker">Self-hosted billing</div><h3>Pick the self-hosted job</h3><p>Use self-hosted billing only for self-hosted purchases. Open one path at a time when hosted billing does not apply.</p></div><div class="billing-action-list">' + renderBillingActionRow("open-manage-billing", "Self-hosted billing", "Manage subscriptions", "Billing", "Open Stripe for self-hosted plan, invoice, and payment changes.", "manage-billing-panel", "manage-inline-email", ["Plan changes", "Invoices"]) + renderBillingActionRow("open-retrieve-billing", "Licenses", "Retrieve licenses", "Licenses", "Recover the latest active self-hosted license and invoice link.", "retrieve-billing-panel", "retrieve-inline-email", ["Latest active license", "Invoice lookup"]) + renderBillingActionRow("open-refund-billing", "Refunds", "Refund requests", "Refunds", "Request a self-serve refund when the purchase is still eligible.", "refund-billing-panel", "refund-inline-email", ["Eligibility check", "Revocation"]) + renderBillingActionRow("open-data-billing", "Privacy", "Data and privacy", "Privacy", "Request export or deletion for commercial account data.", "data-billing-panel", "data-export-email", ["Export", "Deletion"]) + '</div><div class="billing-inline-support"><div class="account-panel-kicker">Escalation only</div><h4>Use Support only after Billing fails</h4><p>Escalate with the same hosted billing action or self-hosted path and the exact failed step.</p><div class="billing-inline-support-actions"><button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="support">Open support</button><a class="portal-support-link" href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + '</a></div></div></div><div class="billing-shell-detail" id="billing-detail-shell" hidden>' + renderBillingTaskPanel(+ "Manage subscriptions",+ "Open Stripe for self-hosted plan, invoice, and payment changes.",+ "manage-billing-panel",+ '<div id="manage-billing-root"></div>'+ ) + renderBillingTaskPanel(+ "Retrieve licenses",+ "Recover the latest active self-hosted license and invoice link.",+ "retrieve-billing-panel",+ '<div id="retrieve-billing-root"></div>'+ ) + renderBillingTaskPanel(+ "Refund requests",+ "Request a self-serve refund when the purchase is still eligible.",+ "refund-billing-panel",+ '<div id="refund-billing-root"></div>'+ ) + renderBillingTaskPanel(+ "Data and privacy",+ "Request export or deletion for commercial account data.",+ "data-billing-panel",+ '<div class="subsection"><div id="data-export-root"></div></div><div class="subsection"><div id="data-delete-root"></div></div><div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:' + escapeAttr(context.bootstrap.support_email || "") + '">' + escapeHTML(context.bootstrap.support_email || "") + "</a>.</div>"+ ) + '</div></div></section><section class="portal-content-panel portal-content-panel-support">' + renderSupportSection(context) + "</section></div></div></div>";}function renderSignedOutPortalHTML(context) {var statusHTML = "";diff --git a/internal/cloudcp/portal/frontend/src/billing.ts b/internal/cloudcp/portal/frontend/src/billing.tsindex f18f5cf800..8dda9f6207 100644--- a/internal/cloudcp/portal/frontend/src/billing.ts+++ b/internal/cloudcp/portal/frontend/src/billing.ts@@ -91,6 +91,12 @@ export function installBillingRuntime(deps: BillingRuntimeDeps): void {});}+ function clearBillingPanel() {+ updateBillingState(function(billingState) {+ billingState.openBillingPanelID = '';+ });+ }+function renderFlow(flowID: PortalBillingFlowID) {var flow = verificationFlows[flowID];if (!flow) return;@@ -432,6 +438,7 @@ export function installBillingRuntime(deps: BillingRuntimeDeps): void {store.setActiveShellSection(section);},toggleBillingPanel,+ clearBillingPanel,focusElement,requestVerificationCode: function(flowID) {void requestVerificationCode(flowID);diff --git a/internal/cloudcp/portal/frontend/src/billing_controller.test.ts b/internal/cloudcp/portal/frontend/src/billing_controller.test.tsindex 102df989c6..aae7dee66b 100644--- a/internal/cloudcp/portal/frontend/src/billing_controller.test.ts+++ b/internal/cloudcp/portal/frontend/src/billing_controller.test.ts@@ -9,9 +9,14 @@ describe('services controller', function() {});it('routes service actions to the matching handlers', function() {+ vi.stubGlobal('requestAnimationFrame', function(callback: FrameRequestCallback) {+ callback(0);+ return 1;+ });var deps = {setShellSection: vi.fn(),toggleBillingPanel: vi.fn(),+ clearBillingPanel: vi.fn(),focusElement: vi.fn(),requestVerificationCode: vi.fn(),resendVerificationCode: vi.fn(),@@ -26,16 +31,28 @@ describe('services controller', function() {document.body.innerHTML ='<button id="open" data-account-billing-action="open-billing-panel" data-account-billing-panel="retrieve-billing-panel" data-account-billing-focus="retrieve-inline-email">Open</button>' ++ '<button id="close" data-account-billing-action="clear-billing-panel">Close</button>' +'<button id="request" data-account-billing-action="manage-inline-request">Request</button>' +'<button id="resend" data-account-billing-action="data-delete-resend">Resend</button>' +'<button id="confirm" data-account-billing-action="retrieve-inline-confirm">Confirm</button>' +'<button id="copy" data-account-billing-action="retrieve-inline-copy">Copy</button>' +- '<button id="refund" data-account-billing-action="refund-inline-submit">Refund</button>';+ '<button id="refund" data-account-billing-action="refund-inline-submit">Refund</button>' ++ '<div id="retrieve-billing-panel"></div>';++ var scrollIntoView = vi.fn();+ Object.defineProperty(document.getElementById('retrieve-billing-panel') as HTMLElement, 'scrollIntoView', {+ value: scrollIntoView,+ configurable: true,+ });document.getElementById('open')?.dispatchEvent(new MouseEvent('click', { bubbles: true }));expect(deps.setShellSection).toHaveBeenCalledWith('billing');expect(deps.toggleBillingPanel).toHaveBeenCalledWith('retrieve-billing-panel');expect(deps.focusElement).toHaveBeenCalledWith('retrieve-inline-email');+ expect(scrollIntoView).toHaveBeenCalledWith({ block: 'start', inline: 'nearest' });++ document.getElementById('close')?.dispatchEvent(new MouseEvent('click', { bubbles: true }));+ expect(deps.clearBillingPanel).toHaveBeenCalled();document.getElementById('request')?.dispatchEvent(new MouseEvent('click', { bubbles: true }));expect(deps.requestVerificationCode).toHaveBeenCalledWith('manage');@@ -57,6 +74,7 @@ describe('services controller', function() {var deps = {setShellSection: vi.fn(),toggleBillingPanel: vi.fn(),+ clearBillingPanel: vi.fn(),focusElement: vi.fn(),requestVerificationCode: vi.fn(),resendVerificationCode: vi.fn(),diff --git a/internal/cloudcp/portal/frontend/src/billing_controller.ts b/internal/cloudcp/portal/frontend/src/billing_controller.tsindex 60102f8da0..95c1231b14 100644--- a/internal/cloudcp/portal/frontend/src/billing_controller.ts+++ b/internal/cloudcp/portal/frontend/src/billing_controller.ts@@ -3,6 +3,7 @@ import { asHTMLElement } from './billing_view';export interface BillingControllerDeps {setShellSection: (section: 'overview' | 'workspaces' | 'access' | 'billing' | 'support') => void;toggleBillingPanel: (panelID: string) => void;+ clearBillingPanel: () => void;focusElement: (id: string) => void;requestVerificationCode: (flowID: 'manage' | 'retrieve' | 'export' | 'delete') => void;resendVerificationCode: (flowID: 'manage' | 'export' | 'delete', event?: Event) => void;@@ -14,6 +15,21 @@ export interface BillingControllerDeps {}export function installBillingController(deps: BillingControllerDeps): void {+ function revealBillingPanelWhenReady(panelID: string): void {+ var reveal = function(): void {+ var panel = document.getElementById(panelID) as HTMLElement | null;+ if (!panel || panel.hidden || typeof panel.scrollIntoView !== 'function') return;+ panel.scrollIntoView({ block: 'start', inline: 'nearest' });+ };+ if (typeof window.requestAnimationFrame === 'function') {+ window.requestAnimationFrame(function() {+ window.requestAnimationFrame(reveal);+ });+ return;+ }+ reveal();+ }+document.addEventListener('click', function(event) {var target = asHTMLElement(event.target)?.closest('[data-account-billing-action]');if (!target) return;@@ -26,7 +42,19 @@ export function installBillingController(deps: BillingControllerDeps): void {event.preventDefault();deps.setShellSection('billing');deps.toggleBillingPanel(panelID);+ var targetElement = target as HTMLElement;+ if (typeof targetElement.blur === 'function') {+ targetElement.blur();+ }deps.focusElement(focusID);+ if (panelID) {+ revealBillingPanelWhenReady(panelID);+ }+ return;+ case 'clear-billing-panel':+ event.preventDefault();+ deps.setShellSection('billing');+ deps.clearBillingPanel();return;case 'manage-inline-request':event.preventDefault();diff --git a/internal/cloudcp/portal/frontend/src/billing_view.test.ts b/internal/cloudcp/portal/frontend/src/billing_view.test.tsindex 3617009c9a..9d064cedc0 100644--- a/internal/cloudcp/portal/frontend/src/billing_view.test.ts+++ b/internal/cloudcp/portal/frontend/src/billing_view.test.ts@@ -80,21 +80,29 @@ describe('services view', function() {it('toggles the visible service panel by id', function() {document.body.innerHTML =- '<div id="billing-panel-empty" class="billing-panel visible"></div>' ++ '<div class="billing-shell billing-shell-idle">' ++ '<div id="billing-detail-shell" hidden></div>' +'<article class="billing-action-row"><button data-account-billing-action="open-billing-panel" data-account-billing-panel="manage-billing-panel"></button></article>' +'<article class="billing-action-row"><button data-account-billing-action="open-billing-panel" data-account-billing-panel="retrieve-billing-panel"></button></article>' +- '<div id="manage-billing-panel" class="billing-panel"></div>' +- '<div id="retrieve-billing-panel" class="billing-panel"></div>' +- '<div id="refund-billing-panel" class="billing-panel"></div>' +- '<div id="data-billing-panel" class="billing-panel"></div>';+ '<div id="manage-billing-panel" class="billing-panel" hidden></div>' ++ '<div id="retrieve-billing-panel" class="billing-panel" hidden></div>' ++ '<div id="refund-billing-panel" class="billing-panel" hidden></div>' ++ '<div id="data-billing-panel" class="billing-panel" hidden></div>' ++ '</div>';renderOpenBillingPanels('retrieve-billing-panel');+ expect(document.querySelector('.billing-shell')?.classList.contains('billing-shell-job-open')).toBe(true);+ expect((document.getElementById('billing-detail-shell') as HTMLElement).hidden).toBe(false);expect(document.getElementById('retrieve-billing-panel')?.classList.contains('visible')).toBe(true);+ expect((document.getElementById('retrieve-billing-panel') as HTMLElement).hidden).toBe(false);expect(document.getElementById('manage-billing-panel')?.classList.contains('visible')).toBe(false);expect(document.getElementById('refund-billing-panel')?.classList.contains('visible')).toBe(false);- expect(document.getElementById('billing-panel-empty')?.classList.contains('visible')).toBe(false);expect(document.querySelectorAll('.billing-action-row.active')).toHaveLength(1);++ renderOpenBillingPanels('');+ expect(document.querySelector('.billing-shell')?.classList.contains('billing-shell-idle')).toBe(true);+ expect((document.getElementById('billing-detail-shell') as HTMLElement).hidden).toBe(true);});it('renders retrieve panel result state with invoice and token metadata', function() {diff --git a/internal/cloudcp/portal/frontend/src/billing_view.ts b/internal/cloudcp/portal/frontend/src/billing_view.tsindex 1b30be7c87..da69d783ef 100644--- a/internal/cloudcp/portal/frontend/src/billing_view.ts+++ b/internal/cloudcp/portal/frontend/src/billing_view.ts@@ -30,7 +30,15 @@ export function readValue(id: string): string {export function focusElement(id: string): void {var el = getElement<FormValueElement>(id);- if (el) el.focus();+ if (!el) return;+ if (typeof el.focus === 'function') {+ try {+ el.focus({ preventScroll: true });+ return;+ } catch (_) {+ el.focus();+ }+ }}export function setVisible(id: string, visible: boolean): void {@@ -68,15 +76,23 @@ export function renderButton(id: string | undefined, disabled: boolean, label: s}export function renderOpenBillingPanels(openBillingPanelID: string): void {+ var shell = document.querySelector('.billing-shell') as HTMLElement | null;+ var detailShell = getElement('billing-detail-shell');var panels = ['manage-billing-panel', 'retrieve-billing-panel', 'refund-billing-panel', 'data-billing-panel'];- var emptyPanel = getElement('billing-panel-empty');- if (emptyPanel) {- emptyPanel.classList.toggle('visible', !openBillingPanelID);+ var hasOpenPanel = !!openBillingPanelID;+ if (shell) {+ shell.classList.toggle('billing-shell-job-open', hasOpenPanel);+ shell.classList.toggle('billing-shell-idle', !hasOpenPanel);+ }+ if (detailShell) {+ detailShell.hidden = !hasOpenPanel;}for (var i = 0; i < panels.length; i++) {var panel = getElement(panels[i]);if (!panel) continue;- panel.classList.toggle('visible', panels[i] === openBillingPanelID);+ var isActive = panels[i] === openBillingPanelID;+ panel.hidden = !isActive;+ panel.classList.toggle('visible', isActive);}var billingButtons = document.querySelectorAll<HTMLElement>('[data-account-billing-action="open-billing-panel"]');for (var j = 0; j < billingButtons.length; j += 1) {@@ -85,6 +101,21 @@ export function renderOpenBillingPanels(openBillingPanelID: string): void {if (!row) continue;row.classList.toggle('active', button.getAttribute('data-account-billing-panel') === openBillingPanelID);}+ if (hasOpenPanel && detailShell) {+ var reveal = function(): void {+ if (typeof detailShell.scrollIntoView !== 'function') return;+ var rect = detailShell.getBoundingClientRect();+ if (rect.top >= 0 && rect.top <= window.innerHeight - 72 && rect.bottom > 0) {+ return;+ }+ detailShell.scrollIntoView({ block: 'start', inline: 'nearest' });+ };+ if (typeof window.requestAnimationFrame === 'function') {+ window.requestAnimationFrame(reveal);+ return;+ }+ reveal();+ }}export function renderRefundPanel(refundState: RefundState, bootstrap: PortalBootstrapData): void {@@ -92,7 +123,6 @@ export function renderRefundPanel(refundState: RefundState, bootstrap: PortalBooif (!root) return;var refundSupportURL = (bootstrap.public_site_url || '') + '/refund.html?email=' + encodeURIComponent(refundState.emailValue || '');root.innerHTML = '' +- '<h3>Refund requests</h3>' +'<p>Process an eligible self-serve refund for a self-hosted purchase. This revokes the associated license immediately.</p>' +'<div class="warning"><strong>Warning:</strong> completing a refund immediately revokes the affected license. This should only be used when the refund window and commercial contract allow it.</div>' +'<div class="form-group">' +@@ -114,7 +144,6 @@ export function renderManagePanel(flowState: VerificationFlowState): void {var root = getElement('manage-billing-root');if (!root) return;root.innerHTML = '' +- '<h3>Manage subscriptions</h3>' +'<p>Request a verification code for the commercial email, then open the Stripe customer portal for billing changes, invoices, and subscription actions.</p>' +'<div id="manage-inline-step1">' +'<div class="form-group">' +@@ -151,7 +180,6 @@ export function renderRetrievePanel(flowState: VerificationFlowState): void {} | null;var invoiceURL = result && result.invoice_url ? result.invoice_url : '#';root.innerHTML = '' +- '<h3>Retrieve licenses</h3>' +'<p>Request a verification code for the commercial email, then reveal the current active self-hosted license without leaving Pulse Account.</p>' +'<div id="retrieve-inline-step1">' +'<div class="form-group">' +diff --git a/internal/cloudcp/portal/frontend/src/shell_view.test.ts b/internal/cloudcp/portal/frontend/src/shell_view.test.tsindex 16d9855156..32e27c3b54 100644--- a/internal/cloudcp/portal/frontend/src/shell_view.test.ts+++ b/internal/cloudcp/portal/frontend/src/shell_view.test.ts@@ -206,8 +206,6 @@ describe('shell view', function() {expect(html).toContain('data-action="workspace-action"');expect(html).toContain('billing-action-row');expect(html).toContain('billing-action-button');- expect(html).toContain('id="billing-panel-empty"');- expect(html).toContain('Choose one billing path');expect(html).toContain('Hosted billing');expect(html).toContain('Self-hosted tools');expect(html).toContain('Self-hosted billing');@@ -215,10 +213,10 @@ describe('shell view', function() {expect(html).toContain('Use Support only after Billing fails');expect(html).toContain('Use hosted billing first when the request belongs to a hosted workspace account.');expect(html).toContain('Open support');- expect(html).toContain('Available now');- expect(html).toContain('Use support last');- expect(html).toContain('Send the same request');+ expect(html).toContain('Use self-hosted billing only for self-hosted purchases.');expect(html).toContain('id="open-retrieve-billing"');+ expect(html).toContain('id="billing-detail-shell" hidden');+ expect(html).toContain('data-account-billing-action="clear-billing-panel"');expect(html).toContain('id="data-billing-panel"');expect(html).toContain('>Billing<');expect(html).toContain('>Licenses<');diff --git a/internal/cloudcp/portal/frontend/src/shell_view.ts b/internal/cloudcp/portal/frontend/src/shell_view.tsindex b8a073f8ed..8a27a6d057 100644--- a/internal/cloudcp/portal/frontend/src/shell_view.ts+++ b/internal/cloudcp/portal/frontend/src/shell_view.ts@@ -1069,6 +1069,22 @@ function renderHostedBillingCards(accounts: PortalAccountSummary[]): string {}).join('');}+function renderBillingTaskPanel(title: string, copy: string, panelID: string, bodyHTML: string): string {+ return (+ '<section class="billing-panel" id="' + escapeAttr(panelID) + '" hidden>' ++ '<div class="billing-task-header">' ++ '<div>' ++ '<div class="account-panel-kicker">Billing task</div>' ++ '<h3>' + escapeHTML(title) + '</h3>' ++ '<p>' + escapeHTML(copy) + '</p>' ++ '</div>' ++ '<button type="button" class="btn-secondary btn-compact" data-account-billing-action="clear-billing-panel">Close panel</button>' ++ '</div>' ++ '<div class="billing-task-body">' + bodyHTML + '</div>' ++ '</section>'+ );+}+function renderSupportSection(context: ShellViewContext): string {return ('<section class="portal-support-panel">' +@@ -1183,12 +1199,12 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string'<div class="billing-note">' + billingNote + '</div>' +'</div>' +'<div class="billing-overview-grid">' + renderHostedBillingCards(accounts) + '</div>' +- '<div class="billing-shell">' +- '<aside class="billing-shell-sidebar">' +- '<div class="billing-shell-sidebar-head">' ++ '<div class="billing-shell billing-shell-idle">' ++ '<div class="billing-shell-main">' ++ '<div class="billing-shell-main-head">' +'<div class="account-panel-kicker">Self-hosted billing</div>' +'<h3>Pick the self-hosted job</h3>' +- '<p>Use one path at a time for self-hosted billing, licenses, refunds, or privacy.</p>' ++ '<p>Use self-hosted billing only for self-hosted purchases. Open one path at a time when hosted billing does not apply.</p>' +'</div>' +'<div class="billing-action-list">' +renderBillingActionRow('open-manage-billing', 'Self-hosted billing', 'Manage subscriptions', 'Billing', 'Open Stripe for self-hosted plan, invoice, and payment changes.', 'manage-billing-panel', 'manage-inline-email', ['Plan changes', 'Invoices']) +@@ -1209,59 +1225,38 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string'</a>' +'</div>' +'</div>' +- '</aside>' +- '<div class="billing-shell-main">' +- '<div class="billing-detail-shell">' +- '<div class="billing-panel billing-panel-empty visible" id="billing-panel-empty">' +- '<div class="account-panel-kicker">Next action</div>' +- '<h3>Choose one billing path</h3>' +- '<p>Open the job you need. Use hosted billing above when it applies, and use these self-hosted paths only for self-hosted purchases.</p>' +- '<div class="billing-empty-shell">' +- '<div class="billing-empty-primary">' +- '<div class="billing-empty-section billing-empty-section-compact">' +- '<div class="billing-empty-column-title">Available now</div>' +- '<div class="billing-empty-flow-list">' +- '<div class="billing-empty-flow"><strong>Billing</strong><span>Manage self-hosted plans, invoices, and payment methods.</span></div>' +- '<div class="billing-empty-flow"><strong>Licenses</strong><span>Recover the latest active self-hosted license and invoice link.</span></div>' +- '<div class="billing-empty-flow"><strong>Refunds</strong><span>Check eligibility before revoking active self-hosted access.</span></div>' +- '<div class="billing-empty-flow"><strong>Privacy</strong><span>Request export or deletion for commercial account data.</span></div>' +- '</div>' +- '</div>' +- '</div>' +- '<div class="billing-empty-side">' +- '<div class="billing-empty-section billing-empty-section-support">' +- '<div class="billing-empty-column-title">Escalation</div>' +- '<div class="billing-empty-checklist">' +- '<div class="billing-empty-check"><strong>Use support last</strong><span>Only after hosted billing or one self-hosted path fails.</span></div>' +- '<div class="billing-empty-check"><strong>Send the same request</strong><span>Include the billing path, account or commercial email, and the failed step.</span></div>' +- '</div>' +- '<div class="billing-empty-support">Need escalation for billing, refund, privacy, or license work? <a class="portal-support-link" href="mailto:' +- escapeAttr(context.bootstrap.support_email || '') +- '">' +- escapeHTML(context.bootstrap.support_email || '') +- '</a></div>' +- '<div class="billing-empty-actions">' +- '<button type="button" class="btn-secondary btn-compact" data-shell-action="activate-section" data-shell-section="support">Open support</button>' +- '</div>' +- '</div>' +- '</div>' +- '</div>' +- '</div>' +- '<div class="billing-panel" id="manage-billing-panel"><div id="manage-billing-root"></div></div>' +- '<div class="billing-panel" id="retrieve-billing-panel"><div id="retrieve-billing-root"></div></div>' +- '<div class="billing-panel" id="refund-billing-panel"><div id="refund-billing-root"></div></div>' +- '<div class="billing-panel" id="data-billing-panel">' +- '<h3>Data and privacy</h3>' +- '<p>Request export or deletion of the commercial data tied to an email address. Payment data held directly by Stripe still requires support handling.</p>' +- '<div class="subsection"><div id="data-export-root"></div></div>' +- '<div class="subsection"><div id="data-delete-root"></div></div>' +- '<div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:' +- escapeAttr(context.bootstrap.support_email || '') +- '">' +- escapeHTML(context.bootstrap.support_email || '') +- '</a>.</div>' +- '</div>' +- '</div>' ++ '</div>' ++ '<div class="billing-shell-detail" id="billing-detail-shell" hidden>' ++ renderBillingTaskPanel(+ 'Manage subscriptions',+ 'Open Stripe for self-hosted plan, invoice, and payment changes.',+ 'manage-billing-panel',+ '<div id="manage-billing-root"></div>'+ ) ++ renderBillingTaskPanel(+ 'Retrieve licenses',+ 'Recover the latest active self-hosted license and invoice link.',+ 'retrieve-billing-panel',+ '<div id="retrieve-billing-root"></div>'+ ) ++ renderBillingTaskPanel(+ 'Refund requests',+ 'Request a self-serve refund when the purchase is still eligible.',+ 'refund-billing-panel',+ '<div id="refund-billing-root"></div>'+ ) ++ renderBillingTaskPanel(+ 'Data and privacy',+ 'Request export or deletion for commercial account data.',+ 'data-billing-panel',+ '<div class="subsection"><div id="data-export-root"></div></div>' ++ '<div class="subsection"><div id="data-delete-root"></div></div>' ++ '<div class="helper-text">Payment-card data stays with Stripe. For Stripe deletion support, contact <a href="mailto:' ++ escapeAttr(context.bootstrap.support_email || '') ++ '">' ++ escapeHTML(context.bootstrap.support_email || '') ++ '</a>.</div>'+ ) +'</div>' +'</div>' +'</section>' +diff --git a/internal/cloudcp/portal/frontend/src/styles.css b/internal/cloudcp/portal/frontend/src/styles.cssindex 5e899e82d2..140191c027 100644--- a/internal/cloudcp/portal/frontend/src/styles.css+++ b/internal/cloudcp/portal/frontend/src/styles.css@@ -2493,8 +2493,8 @@ header .logout-btn:hover,.billing-shell {display: grid;- grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);- gap: 12px;+ grid-template-columns: minmax(0, 1fr);+ gap: 14px;align-items: start;padding: 12px;border: 1px solid var(--line);@@ -2502,14 +2502,18 @@ header .logout-btn:hover,background: #fff;}+.billing-shell-job-open {+ grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);+}+.billing-shell-main,-.billing-shell-sidebar {+.billing-shell-detail {display: flex;flex-direction: column;gap: 8px;}-.billing-shell-sidebar-head,+.billing-shell-main-head,.billing-inline-support {padding: 11px 12px;border: 1px solid var(--line);@@ -2517,14 +2521,14 @@ header .logout-btn:hover,background: var(--panel-strong);}-.billing-shell-sidebar-head h3 {+.billing-shell-main-head h3 {margin: 4px 0 0;font-size: 16px;line-height: 1.08;letter-spacing: -0.03em;}-.billing-shell-sidebar-head p,+.billing-shell-main-head p,.billing-inline-support p {margin: 5px 0 0;font-size: 11px;@@ -2589,6 +2593,37 @@ header .logout-btn:hover,overflow: hidden;}+.billing-task-header {+ display: flex;+ align-items: flex-start;+ justify-content: space-between;+ gap: 12px;+ padding-bottom: 12px;+ border-bottom: 1px solid var(--line);+}++.billing-task-header h3 {+ margin: 4px 0 0;+ font-size: 18px;+ line-height: 1.04;+ letter-spacing: -0.03em;+}++.billing-task-header p {+ margin: 8px 0 0;+ max-width: 560px;+ font-size: 13px;+ line-height: 1.55;+ color: var(--ink-soft);+}++.billing-task-body {+ display: flex;+ flex-direction: column;+ gap: 14px;+ margin-top: 14px;+}+.billing-brief-card {padding: 16px;border: 1px solid var(--line);@@ -2782,14 +2817,6 @@ header .logout-btn:hover,display: block;}-.billing-panel-empty {- display: none;-}--.billing-panel-empty.visible {- display: block;-}-.billing-empty-points {display: grid;grid-template-columns: repeat(2, minmax(0, 1fr));@@ -3355,7 +3382,8 @@ header .logout-btn:hover,.workspace-management-header,.access-management-header,.billing-header,- .billing-action-tags {+ .billing-action-tags,+ .billing-task-header {flex-direction: column;align-items: flex-start;}