Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Seed portal access from bootstrap roster

rcourtman4379f3a84007
diff --git a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
index c24a8721d8..06f7d840e2 100644
--- a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
+++ b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
@@ -200,56 +200,60 @@ 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 remove
controls should appear only when that exact access job is active.
-26. `Billing` must default to hosted billing plus explicit self-hosted job
+26. The first hosted `Access` render must come from bootstrap-owned roster
+ truth, not a fetch-first placeholder. The portal bootstrap/runtime
+ contract must carry the current hosted roster snapshot so `Access` opens
+ as a real review surface before any later refresh or mutation follow-up.
+27. `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. When no hosted account exists, `Billing` must lead
directly with the self-hosted job picker instead of front-loading an
empty hosted-billing block.
-27. `Support` must stay honest to account shape. Self-hosted-only accounts
+28. `Support` must stay honest to account shape. Self-hosted-only accounts
must reduce `Support` to the billing escalation path only; hosted
workspace or access failure routes and task buttons must not render
without hosted accounts.
-28. The portal bootstrap/runtime contract must carry explicit truth for
+29. The portal bootstrap/runtime contract must carry explicit truth for
whether self-hosted commercial history is relevant to the signed-in
account. Hosted-only accounts must not render self-hosted licenses,
refunds, privacy utilities, or self-hosted escalation copy by default.
-29. Hosted view-only users must see permission-honest task copy. `Workspaces`,
+30. Hosted view-only users must see permission-honest task copy. `Workspaces`,
`Access`, and hosted `Billing` may not advertise create, roster-mutation,
or hosted-billing actions when the current account role cannot perform
them; those surfaces must say that an owner or admin is required.
-30. The compact account-context strip must also stay permission-honest. It
+31. The compact account-context strip must also stay permission-honest. It
must describe what the current user can actually do on the account, not
restate the account's full hosted capability set when access or billing
changes require an owner or admin.
-31. Hosted `Support` must stay permission-honest too. View-only hosted users
+32. Hosted `Support` must stay permission-honest too. View-only hosted users
may be sent back to `Workspaces`, `Access`, or `Billing` only as review
and owner/admin handoff paths; `Support` must not imply they can perform
hosted lifecycle, access-mutation, or hosted-billing changes themselves
before escalation.
-32. `Overview` must keep billing cues honest to account shape and permission.
+33. `Overview` must keep billing cues honest to account shape and permission.
Hosted-only accounts may not mention self-hosted billing utilities by
default, and hosted view-only roles must say when owner/admin authority is
still required to open hosted billing.
-33. User-facing role labels must stay on product vocabulary. The portal may
+34. User-facing role labels must stay on product vocabulary. The portal may
describe account role as `Owner`, `Admin`, `Tech`, or `Read-only`, but it
must not leak internal identifiers such as `read_only` or legacy aliases
such as `member`.
-34. `Overview` must also keep `Next action` permission-honest for hosted
+35. `Overview` must also keep `Next action` permission-honest for hosted
view-only accounts. When no workspace is ready, the primary route must
stay on reviewable `Workspaces` or `Access` surfaces before any blocked
hosted billing or owner/admin-only mutation path.
-35. Task surfaces must keep failure copy on owned user jobs. The portal may
+36. Task surfaces must keep failure copy on owned user jobs. The portal may
not leak raw transport strings such as `Network error.` into `Access`,
`Workspaces`, or `Billing`; each failure must stay on the task-specific
action the user was trying to complete.
-36. `Overview` must keep `Ready` honest when no hosted workspace exists yet.
+37. `Overview` must keep `Ready` honest when no hosted workspace exists yet.
Hosted accounts with zero workspaces may not tell the user to review
current workspace state; they must say that nothing is ready yet and that
the first hosted workspace still needs owner/admin creation before routine
work can start.
-37. `Overview` must keep `Needs attention` honest when only suspended
+38. `Overview` must keep `Needs attention` honest when only suspended
workspaces remain. The shell may not imply active work is ready merely
because a suspended workspace exists; suspended-only states must say that
no active workspace is ready for routine use right now.
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index ff44de9062..8a6702a27e 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -185,6 +185,7 @@ Own canonical runtime payload shapes between backend and frontend.
18. Monitoring command-trigger clients open-coding `parseOptionalAPIResponse(response, { success: true }, ...)` success-envelope fallbacks instead of using a canonical shared success-envelope helper
19. Governed frontend API clients open-coding `try/catch` wrappers around `apiFetchJSON(...)` just to map `402` or `404` into `[]`, `{ plans: [] }`, or `null` instead of using canonical shared API-error-status fallback helpers
20. Backend config/settings handlers pointing operator guidance at GitHub `main` docs when the running build already ships that guidance locally under `/docs/`
+21. Telemetry preview or reset endpoints returning payloads that drift from the exact server-owned telemetry runtime contract instead of reusing the same source-of-truth snapshot and install-ID state the background sender uses
## Completion Obligations
@@ -293,7 +294,11 @@ runtime rule now also applies to `Access`: the hosted roster is the default
surface, and invite, role-change, or remove controls only appear when the
matching access job is active. When `can_manage` is false, that same roster
must stay a review surface rather than rendering a third action column full of
-fake disabled row state. `Billing` follows the same shared runtime
+fake disabled row state. That same typed bootstrap/runtime contract must also
+ship the current hosted roster snapshot in the portal bootstrap payload so the
+first `Access` render is a real review surface rather than a fetch-first or
+error-first placeholder; later member API reads remain refresh and mutation
+follow-through. `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. The same
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 264fc21d36..9a9582e5b4 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -859,7 +859,11 @@ create-workspace job is active. `Access` follows the same rule: the hosted
roster must be the default state, while invite, role-change, and remove
controls appear only when that exact access job is active, and a hosted
view-only roster must stay a review surface instead of a row-by-row action
-table with fake disabled action state. `Billing` follows
+table with fake disabled action state. That same task-first `Access` contract
+must also start from bootstrap-owned roster truth: the first hosted roster
+render must come from the portal bootstrap payload itself, with later member
+API reads reserved for refresh and mutation follow-through instead of
+placeholder-first rendering. `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
diff --git a/internal/cloudcp/portal/bootstrap.go b/internal/cloudcp/portal/bootstrap.go
index 7076f4b34b..cd88a6110e 100644
--- a/internal/cloudcp/portal/bootstrap.go
+++ b/internal/cloudcp/portal/bootstrap.go
@@ -16,6 +16,13 @@ type BootstrapWorkspace struct {
CreatedAt string `json:"created_at"`
}
+type BootstrapMember struct {
+ UserID string `json:"user_id"`
+ Email string `json:"email"`
+ Role string `json:"role"`
+ CreatedAt string `json:"created_at,omitempty"`
+}
+
type BootstrapAccount struct {
ID string `json:"id"`
Kind string `json:"kind"`
@@ -25,6 +32,7 @@ type BootstrapAccount struct {
CanManage bool `json:"can_manage"`
HasBilling bool `json:"has_billing"`
Workspaces []BootstrapWorkspace `json:"workspaces"`
+ Members []BootstrapMember `json:"members"`
}
type BootstrapData struct {
@@ -72,6 +80,19 @@ func BuildBootstrapData(authenticated bool, email string, accounts []portalPageA
CreatedAt: workspace.CreatedAt.UTC().Format(time.RFC3339),
})
}
+ members := make([]BootstrapMember, 0, len(account.Members))
+ for _, member := range account.Members {
+ createdAt := ""
+ if !member.CreatedAt.IsZero() {
+ createdAt = member.CreatedAt.UTC().Format(time.RFC3339)
+ }
+ members = append(members, BootstrapMember{
+ UserID: member.UserID,
+ Email: member.Email,
+ Role: string(member.Role),
+ CreatedAt: createdAt,
+ })
+ }
bootstrapAccounts = append(bootstrapAccounts, BootstrapAccount{
ID: account.ID,
Kind: account.Kind,
@@ -81,6 +102,7 @@ func BuildBootstrapData(authenticated bool, email string, accounts []portalPageA
CanManage: account.CanManage,
HasBilling: account.HasBilling,
Workspaces: workspaces,
+ Members: members,
})
}
diff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.json
index 590a725c31..ee97d1579d 100644
--- a/internal/cloudcp/portal/dist/build_manifest.json
+++ b/internal/cloudcp/portal/dist/build_manifest.json
@@ -1,5 +1,5 @@
{
- "source_hash": "187fd85844db24178a14cfc69113eaf92dddd85f57cdef1a82a86d70268bacc9",
+ "source_hash": "e610c850356380a4b964ccafee42ab51270cd73bd456f7acf2ae51fb49ef09cf",
"build_inputs": [
"package.json",
"tsconfig.json",
diff --git a/internal/cloudcp/portal/dist/portal_app.js b/internal/cloudcp/portal/dist/portal_app.js
index 51b0d3460f..77466156c8 100644
--- a/internal/cloudcp/portal/dist/portal_app.js
+++ b/internal/cloudcp/portal/dist/portal_app.js
@@ -757,6 +757,27 @@
}
return accountState.byAccountID[accountID];
}
+ function clonePortalAccessMembers(members) {
+ var cloned = [];
+ for (var i = 0; i < members.length; i += 1) {
+ cloned.push({
+ email: members[i].email,
+ role: members[i].role,
+ user_id: members[i].user_id,
+ created_at: members[i].created_at
+ });
+ }
+ return cloned;
+ }
+ function syncPortalAccountStateBootstrap(accountState, accounts) {
+ for (var i = 0; i < accounts.length; i += 1) {
+ var account = accounts[i];
+ var entry = ensurePortalAccountUIEntry(accountState, account.id);
+ entry.accessQuery.status = "ready";
+ entry.accessQuery.error = "";
+ entry.accessQuery.data = clonePortalAccessMembers(account.members || []);
+ }
+ }
function createPortalBillingState() {
return {
openBillingPanelID: "",
@@ -2558,6 +2579,7 @@
function createPortalStore(bootstrapDefaults, initialBootstrap) {
var bootstrapState = normalizeBootstrap(bootstrapDefaults, initialBootstrap);
var accountState = createPortalAccountState();
+ syncPortalAccountStateBootstrap(accountState, bootstrapState.accounts || []);
var loginState = createPortalLoginState();
var shellState = createPortalShellState();
var billingState = createPortalBillingState();
@@ -2591,6 +2613,7 @@
},
setBootstrap: function(nextBootstrap) {
bootstrapState = normalizeBootstrap(bootstrapDefaults, nextBootstrap);
+ syncPortalAccountStateBootstrap(accountState, bootstrapState.accounts || []);
syncLoginStateBootstrapEmail(loginState, bootstrapState.email || "");
syncBillingStateBootstrapEmail(billingState, bootstrapState.email || "");
notify(bootstrapSubscribers);
@@ -2655,7 +2678,30 @@
};
}
function normalizeAccounts(accounts) {
- return Array.isArray(accounts) ? accounts : [];
+ if (!Array.isArray(accounts)) {
+ return [];
+ }
+ return accounts.map(function(account) {
+ return {
+ ...account,
+ workspaces: normalizeWorkspaces(account && Array.isArray(account.workspaces) ? account.workspaces : []),
+ members: normalizeMembers(account && Array.isArray(account.members) ? account.members : [])
+ };
+ });
+ }
+ function normalizeWorkspaces(workspaces) {
+ return workspaces.map(function(workspace) {
+ return {
+ ...workspace
+ };
+ });
+ }
+ function normalizeMembers(members) {
+ return members.map(function(member) {
+ return {
+ ...member
+ };
+ });
}
// src/runtime.ts
diff --git a/internal/cloudcp/portal/frontend/src/account_runtime.test.ts b/internal/cloudcp/portal/frontend/src/account_runtime.test.ts
index e0732e8391..6c2aa59c73 100644
--- a/internal/cloudcp/portal/frontend/src/account_runtime.test.ts
+++ b/internal/cloudcp/portal/frontend/src/account_runtime.test.ts
@@ -122,6 +122,7 @@ describe('account runtime', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [{
id: 'ws_2',
display_name: 'Alpha Workspace',
@@ -204,6 +205,7 @@ describe('account runtime', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [{
id: 'ws_2',
display_name: 'Alpha Workspace',
diff --git a/internal/cloudcp/portal/frontend/src/account_view.test.ts b/internal/cloudcp/portal/frontend/src/account_view.test.ts
index be3cf6849f..46e1250ccb 100644
--- a/internal/cloudcp/portal/frontend/src/account_view.test.ts
+++ b/internal/cloudcp/portal/frontend/src/account_view.test.ts
@@ -32,6 +32,16 @@ describe('account view', function() {
});
function createAccount(overrides: Partial<PortalAccountSummary> = {}): PortalAccountSummary {
+ var defaultWorkspaces = [
+ {
+ id: 'ws_1',
+ display_name: 'Alpha Workspace',
+ state: 'active',
+ healthy: true,
+ health_status: 'healthy' as const,
+ created_at: '2026-03-26T10:00:00Z',
+ },
+ ];
return {
id: 'acct_1',
name: 'Acme MSP',
@@ -40,17 +50,9 @@ describe('account view', function() {
role: 'owner',
can_manage: true,
has_billing: true,
- workspaces: [
- {
- id: 'ws_1',
- display_name: 'Alpha Workspace',
- state: 'active',
- healthy: true,
- health_status: 'healthy',
- created_at: '2026-03-26T10:00:00Z',
- },
- ],
...overrides,
+ members: overrides.members || [],
+ workspaces: overrides.workspaces || defaultWorkspaces,
};
}
diff --git a/internal/cloudcp/portal/frontend/src/app.test.ts b/internal/cloudcp/portal/frontend/src/app.test.ts
index b6013bf5da..da21c3b5ad 100644
--- a/internal/cloudcp/portal/frontend/src/app.test.ts
+++ b/internal/cloudcp/portal/frontend/src/app.test.ts
@@ -94,6 +94,7 @@ describe('portal app', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [],
},
],
@@ -172,6 +173,7 @@ describe('portal app', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [],
},
],
@@ -224,6 +226,7 @@ describe('portal app', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [],
},
];
@@ -304,7 +307,7 @@ describe('portal app', function() {
expect(document.getElementById('retrieve-inline-status')?.textContent).toContain('License retrieved successfully.');
});
- it('loads team membership through the real authenticated account shell', async function() {
+ it('renders the hosted access roster from bootstrap through the real authenticated account shell', async function() {
var accounts = [
{
id: 'acct_1',
@@ -314,6 +317,9 @@ describe('portal app', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [
+ { email: '[email protected]', role: 'owner', user_id: 'u_1' },
+ ],
workspaces: [],
},
];
@@ -327,10 +333,7 @@ describe('portal app', function() {
authenticated: true,
accounts: accounts,
- }))
- .mockResolvedValueOnce(jsonResponse([
- { email: '[email protected]', role: 'owner', user_id: 'u_1' },
- ]));
+ }));
vi.stubGlobal('fetch', fetchMock);
var app = installPortalApp({
@@ -342,7 +345,7 @@ describe('portal app', function() {
document.querySelector('[data-shell-action="activate-section"][data-shell-section="access"]')?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
await flushAsync();
- expect(fetchMock).toHaveBeenNthCalledWith(2, '/api/accounts/acct_1/members');
+ expect(fetchMock).toHaveBeenCalledTimes(1);
expect(document.getElementById('access-section-acct_1')?.classList.contains('visible')).toBe(true);
expect(document.getElementById('access-list-acct_1')?.textContent).toContain('[email protected]');
});
diff --git a/internal/cloudcp/portal/frontend/src/shell.test.ts b/internal/cloudcp/portal/frontend/src/shell.test.ts
index 84ef406592..c94c1d5acf 100644
--- a/internal/cloudcp/portal/frontend/src/shell.test.ts
+++ b/internal/cloudcp/portal/frontend/src/shell.test.ts
@@ -40,6 +40,7 @@ describe('shell runtime', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [],
},
],
diff --git a/internal/cloudcp/portal/frontend/src/shell_view.test.ts b/internal/cloudcp/portal/frontend/src/shell_view.test.ts
index 4f1aa249c3..e922c07388 100644
--- a/internal/cloudcp/portal/frontend/src/shell_view.test.ts
+++ b/internal/cloudcp/portal/frontend/src/shell_view.test.ts
@@ -97,6 +97,7 @@ describe('shell view', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [
{
id: 'ws_active',
@@ -241,6 +242,7 @@ describe('shell view', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [
{
id: 'ws_mixed',
@@ -283,6 +285,7 @@ describe('shell view', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [
{
id: 'ws_nav',
@@ -325,6 +328,7 @@ describe('shell view', function() {
role: 'admin',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [
{
id: 'ws_context',
@@ -361,6 +365,7 @@ describe('shell view', function() {
role: 'tech',
can_manage: false,
has_billing: true,
+ members: [],
workspaces: [
{
id: 'ws_ro',
@@ -430,6 +435,7 @@ describe('shell view', function() {
role: 'read_only',
can_manage: false,
has_billing: true,
+ members: [],
workspaces: [
{
id: 'ws_view',
@@ -464,6 +470,7 @@ describe('shell view', function() {
role: 'read_only',
can_manage: false,
has_billing: true,
+ members: [],
workspaces: [],
},
],
@@ -491,6 +498,7 @@ describe('shell view', function() {
role: 'read_only',
can_manage: false,
has_billing: true,
+ members: [],
workspaces: [],
},
],
@@ -516,6 +524,7 @@ describe('shell view', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [],
},
],
@@ -541,6 +550,7 @@ describe('shell view', function() {
role: 'read_only',
can_manage: false,
has_billing: true,
+ members: [],
workspaces: [
{
id: 'ws_view_suspended',
@@ -576,6 +586,7 @@ describe('shell view', function() {
role: 'read_only',
can_manage: false,
has_billing: true,
+ members: [],
workspaces: [
{
id: 'ws_view_suspended',
@@ -679,6 +690,7 @@ describe('shell view', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [
{
id: 'ws_suspended',
diff --git a/internal/cloudcp/portal/frontend/src/state.ts b/internal/cloudcp/portal/frontend/src/state.ts
index d70b014c9f..7888e469f4 100644
--- a/internal/cloudcp/portal/frontend/src/state.ts
+++ b/internal/cloudcp/portal/frontend/src/state.ts
@@ -1,6 +1,7 @@
import type {
PortalMutationState,
PortalAccountState,
+ PortalAccountSummary,
PortalAccountUIEntry,
PortalLoginState,
PortalShellState,
@@ -86,6 +87,29 @@ export function ensurePortalAccountUIEntry(accountState: PortalAccountState, acc
return accountState.byAccountID[accountID];
}
+function clonePortalAccessMembers(members: PortalAccessMember[]): PortalAccessMember[] {
+ var cloned = [] as PortalAccessMember[];
+ for (var i = 0; i < members.length; i += 1) {
+ cloned.push({
+ email: members[i].email,
+ role: members[i].role,
+ user_id: members[i].user_id,
+ created_at: members[i].created_at,
+ });
+ }
+ return cloned;
+}
+
+export function syncPortalAccountStateBootstrap(accountState: PortalAccountState, accounts: PortalAccountSummary[]): void {
+ for (var i = 0; i < accounts.length; i += 1) {
+ var account = accounts[i];
+ var entry = ensurePortalAccountUIEntry(accountState, account.id);
+ entry.accessQuery.status = 'ready';
+ entry.accessQuery.error = '';
+ entry.accessQuery.data = clonePortalAccessMembers(account.members || []);
+ }
+}
+
export function createPortalBillingState(): PortalBillingState {
return {
openBillingPanelID: '',
diff --git a/internal/cloudcp/portal/frontend/src/store.test.ts b/internal/cloudcp/portal/frontend/src/store.test.ts
index a867821d5b..25083cbd34 100644
--- a/internal/cloudcp/portal/frontend/src/store.test.ts
+++ b/internal/cloudcp/portal/frontend/src/store.test.ts
@@ -42,6 +42,7 @@ describe('portal store', function() {
role: 'owner',
can_manage: true,
has_billing: true,
+ members: [],
workspaces: [],
},
],
@@ -76,6 +77,59 @@ describe('portal store', function() {
expect(listener).toHaveBeenCalledTimes(1);
});
+ it('seeds hosted access state from the bootstrap roster snapshot', function() {
+ var store = createPortalStore(bootstrapDefaults, {
+ authenticated: true,
+ email: '[email protected]',
+ accounts: [
+ {
+ id: 'acct_1',
+ name: 'Acme MSP',
+ kind: 'msp',
+ kind_label: 'MSP',
+ role: 'owner',
+ can_manage: true,
+ has_billing: true,
+ members: [
+ { email: '[email protected]', role: 'owner', user_id: 'u_1', created_at: '2026-03-28T10:00:00Z' },
+ ],
+ workspaces: [],
+ },
+ ],
+ });
+
+ var entry = store.getAccountState().byAccountID.acct_1;
+ expect(entry.accessQuery.status).toBe('ready');
+ expect(entry.accessQuery.error).toBe('');
+ expect(entry.accessQuery.data).toEqual([
+ { email: '[email protected]', role: 'owner', user_id: 'u_1', created_at: '2026-03-28T10:00:00Z' },
+ ]);
+
+ store.setBootstrap({
+ authenticated: true,
+ email: '[email protected]',
+ accounts: [
+ {
+ id: 'acct_1',
+ name: 'Acme MSP',
+ kind: 'msp',
+ kind_label: 'MSP',
+ role: 'owner',
+ can_manage: true,
+ has_billing: true,
+ members: [
+ { email: '[email protected]', role: 'admin', user_id: 'u_2', created_at: '2026-03-28T11:00:00Z' },
+ ],
+ workspaces: [],
+ },
+ ],
+ });
+
+ expect(store.getAccountState().byAccountID.acct_1.accessQuery.data).toEqual([
+ { email: '[email protected]', role: 'admin', user_id: 'u_2', created_at: '2026-03-28T11:00:00Z' },
+ ]);
+ });
+
it('keeps login and service state in the same owned store with selective notifications', function() {
var store = createPortalStore(bootstrapDefaults, null);
var loginListener = vi.fn();
diff --git a/internal/cloudcp/portal/frontend/src/store.ts b/internal/cloudcp/portal/frontend/src/store.ts
index 27d2292156..1cd0eb8aae 100644
--- a/internal/cloudcp/portal/frontend/src/store.ts
+++ b/internal/cloudcp/portal/frontend/src/store.ts
@@ -3,10 +3,21 @@ import {
createPortalLoginState,
createPortalShellState,
createPortalBillingState,
+ syncPortalAccountStateBootstrap,
syncLoginStateBootstrapEmail,
syncBillingStateBootstrapEmail,
} from './state';
-import type { PortalAccountState, PortalBootstrapData, PortalLoginState, PortalBillingState, PortalShellSection, PortalShellState } from './types';
+import type {
+ PortalAccessMember,
+ PortalAccountState,
+ PortalAccountSummary,
+ PortalBootstrapData,
+ PortalLoginState,
+ PortalBillingState,
+ PortalShellSection,
+ PortalShellState,
+ PortalWorkspaceSummary,
+} from './types';
interface MutationOptions {
notify?: boolean;
@@ -56,6 +67,7 @@ export function createPortalStore(
): PortalStore {
var bootstrapState = normalizeBootstrap(bootstrapDefaults, initialBootstrap);
var accountState = createPortalAccountState();
+ syncPortalAccountStateBootstrap(accountState, bootstrapState.accounts || []);
var loginState = createPortalLoginState();
var shellState = createPortalShellState();
var billingState = createPortalBillingState();
@@ -91,6 +103,7 @@ export function createPortalStore(
},
setBootstrap: function(nextBootstrap) {
bootstrapState = normalizeBootstrap(bootstrapDefaults, nextBootstrap);
+ syncPortalAccountStateBootstrap(accountState, bootstrapState.accounts || []);
syncLoginStateBootstrapEmail(loginState, bootstrapState.email || '');
syncBillingStateBootstrapEmail(billingState, bootstrapState.email || '');
notify(bootstrapSubscribers);
@@ -156,5 +169,30 @@ export function createPortalStore(
}
function normalizeAccounts(accounts: Partial<PortalBootstrapData>['accounts']): PortalBootstrapData['accounts'] {
- return Array.isArray(accounts) ? accounts : [];
+ if (!Array.isArray(accounts)) {
+ return [];
+ }
+ return accounts.map(function(account) {
+ return {
+ ...(account as PortalAccountSummary),
+ workspaces: normalizeWorkspaces(account && Array.isArray(account.workspaces) ? account.workspaces : []),
+ members: normalizeMembers(account && Array.isArray(account.members) ? account.members : []),
+ };
+ });
+}
+
+function normalizeWorkspaces(workspaces: PortalWorkspaceSummary[]): PortalWorkspaceSummary[] {
+ return workspaces.map(function(workspace) {
+ return {
+ ...(workspace as PortalWorkspaceSummary),
+ };
+ });
+}
+
+function normalizeMembers(members: PortalAccessMember[]): PortalAccessMember[] {
+ return members.map(function(member) {
+ return {
+ ...(member as PortalAccessMember),
+ };
+ });
}
diff --git a/internal/cloudcp/portal/frontend/src/types.ts b/internal/cloudcp/portal/frontend/src/types.ts
index 8a5e26e3c2..d4f68ab940 100644
--- a/internal/cloudcp/portal/frontend/src/types.ts
+++ b/internal/cloudcp/portal/frontend/src/types.ts
@@ -8,6 +8,13 @@ export interface PortalWorkspaceSummary {
created_at?: string;
}
+export interface PortalAccessMember {
+ email: string;
+ role: string;
+ user_id: string;
+ created_at?: string;
+}
+
export interface PortalAccountSummary {
id: string;
name: string;
@@ -17,6 +24,7 @@ export interface PortalAccountSummary {
can_manage: boolean;
has_billing: boolean;
workspaces: PortalWorkspaceSummary[];
+ members: PortalAccessMember[];
}
export interface PortalBootstrapData {
@@ -43,12 +51,6 @@ export interface PortalLoginState {
successMessage: string;
}
-export interface PortalAccessMember {
- email: string;
- role: string;
- user_id: string;
-}
-
export type AsyncStatus = 'idle' | 'loading' | 'ready' | 'error';
export interface PortalQueryState<T> {
diff --git a/internal/cloudcp/portal/handlers_test.go b/internal/cloudcp/portal/handlers_test.go
index ebe6824624..7d6a1dfc49 100644
--- a/internal/cloudcp/portal/handlers_test.go
+++ b/internal/cloudcp/portal/handlers_test.go
@@ -831,6 +831,7 @@ func TestPortalPageTemplate_AccountServicesRendered(t *testing.T) {
func TestBuildPortalBootstrapJSON_Contract(t *testing.T) {
lastHealthCheck := time.Date(2026, 3, 27, 9, 0, 0, 0, time.UTC)
+ memberCreatedAt := time.Date(2026, 3, 27, 8, 30, 0, 0, time.UTC)
bootstrapJSON, err := MarshalBootstrapJSON(BuildBootstrapData(true, "[email protected]", []portalPageAccount{
{
ID: "a_test",
@@ -840,6 +841,14 @@ func TestBuildPortalBootstrapJSON_Contract(t *testing.T) {
Role: "owner",
CanManage: true,
HasBilling: true,
+ Members: []portalPageMember{
+ {
+ UserID: "u_owner",
+ Email: "[email protected]",
+ Role: registry.MemberRoleOwner,
+ CreatedAt: memberCreatedAt,
+ },
+ },
Workspaces: []portalPageWorkspace{
{
ID: "t_one",
@@ -909,6 +918,23 @@ func TestBuildPortalBootstrapJSON_Contract(t *testing.T) {
if got := account["can_manage"]; got != true {
t.Fatalf("account can_manage = %#v", got)
}
+ members, ok := account["members"].([]any)
+ if !ok || len(members) != 1 {
+ t.Fatalf("members = %#v, want one member", account["members"])
+ }
+ member, ok := members[0].(map[string]any)
+ if !ok {
+ t.Fatalf("member payload = %#v", members[0])
+ }
+ if got := member["email"]; got != "[email protected]" {
+ t.Fatalf("member email = %#v", got)
+ }
+ if got := member["role"]; got != "owner" {
+ t.Fatalf("member role = %#v", got)
+ }
+ if got := member["created_at"]; got != "2026-03-27T08:30:00Z" {
+ t.Fatalf("member created_at = %#v", got)
+ }
workspaces, ok := account["workspaces"].([]any)
if !ok || len(workspaces) != 1 {
@@ -982,6 +1008,17 @@ func TestHandlePortalBootstrap_Success(t *testing.T) {
if !ok {
t.Fatalf("account = %#v", accounts[0])
}
+ members, ok := account["members"].([]any)
+ if !ok || len(members) != 1 {
+ t.Fatalf("members = %#v", account["members"])
+ }
+ member, ok := members[0].(map[string]any)
+ if !ok {
+ t.Fatalf("member = %#v", members[0])
+ }
+ if got := member["email"]; got != "[email protected]" {
+ t.Fatalf("member email = %#v", got)
+ }
workspaces, ok := account["workspaces"].([]any)
if !ok || len(workspaces) != 1 {
t.Fatalf("workspaces = %#v", account["workspaces"])
diff --git a/internal/cloudcp/portal/page.go b/internal/cloudcp/portal/page.go
index f9316adffc..4f206355fd 100644
--- a/internal/cloudcp/portal/page.go
+++ b/internal/cloudcp/portal/page.go
@@ -23,6 +23,13 @@ type portalPageWorkspace struct {
CreatedAt time.Time
}
+type portalPageMember struct {
+ UserID string
+ Email string
+ Role registry.MemberRole
+ CreatedAt time.Time
+}
+
// portalPageAccount holds per-account display data including the user's role.
type portalPageAccount struct {
ID string
@@ -33,6 +40,7 @@ type portalPageAccount struct {
CanManage bool // owner or admin
HasBilling bool // true when a Stripe customer exists for the account
Workspaces []portalPageWorkspace
+ Members []portalPageMember
}
// portalPageData is passed to the portal HTML template.
@@ -143,6 +151,11 @@ func loadPortalAccountsForUser(reg *registry.TenantRegistry, userID string) ([]p
log.Error().Err(err).Str("account_id", accountID).Msg("cloudcp.portal.page: list tenants")
continue
}
+ members, err := loadPortalAccountMembers(reg, accountID)
+ if err != nil {
+ log.Error().Err(err).Str("account_id", accountID).Msg("cloudcp.portal.page: list members")
+ continue
+ }
workspaces := make([]portalPageWorkspace, 0, len(tenants))
for _, t := range tenants {
@@ -184,12 +197,45 @@ func loadPortalAccountsForUser(reg *registry.TenantRegistry, userID string) ([]p
CanManage: m.Role == registry.MemberRoleOwner || m.Role == registry.MemberRoleAdmin,
HasBilling: hasBilling,
Workspaces: workspaces,
+ Members: members,
})
}
return accounts, nil
}
+func loadPortalAccountMembers(reg *registry.TenantRegistry, accountID string) ([]portalPageMember, error) {
+ memberships, err := reg.ListMembersByAccount(accountID)
+ if err != nil {
+ return nil, err
+ }
+ if memberships == nil {
+ return []portalPageMember{}, nil
+ }
+
+ members := make([]portalPageMember, 0, len(memberships))
+ for _, membership := range memberships {
+ if membership == nil {
+ continue
+ }
+ user, err := reg.GetUser(membership.UserID)
+ if err != nil {
+ return nil, err
+ }
+ if user == nil {
+ return nil, errors.New("portal member user not found")
+ }
+ members = append(members, portalPageMember{
+ UserID: membership.UserID,
+ Email: user.Email,
+ Role: membership.Role,
+ CreatedAt: membership.CreatedAt,
+ })
+ }
+
+ return members, nil
+}
+
func workspaceHealthStatus(healthy bool, lastHealthCheck *time.Time) string {
if healthy {
return "healthy"