Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/fix-org-health-agent-count-stub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

Fix org profile page always showing "Register an agent to start integrating" CTA by replacing the hardcoded `agentCount = 0` stub in `assembleOrgHealth` with a real query against `member_profiles.agents`. Orgs with registered agents will now correctly see their tech-integration health score reflect actual registrations and will no longer see the spurious onboarding CTA.
13 changes: 11 additions & 2 deletions server/src/services/org-health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,17 @@ export async function assembleOrgHealth(orgId: string): Promise<OrgHealth> {
return [];
}),

// Agent count — no org-scoped agents table yet; always 0 until one exists
Promise.resolve(0),
// Count all registered agents across org member profiles, regardless of visibility.
// "Any agent registered" is the threshold — visibility tier is not the gate here.
query<{ total: string }>(
`SELECT COALESCE(SUM(COALESCE(jsonb_array_length(agents), 0)), 0) AS total
FROM member_profiles
WHERE workos_organization_id = $1`,
[orgId]
).then(r => parseInt(r.rows[0]?.total || '0', 10)).catch(err => {
logger.error({ err, orgId }, 'Failed to fetch agent count');
return 0;
}),

// Leadership roles across all org members
query<{ count: string }>(
Expand Down
Loading