fix(server): org profile page always shows "Register an agent" CTA when agents exist#4258
Draft
fix(server): org profile page always shows "Register an agent" CTA when agents exist#4258
Conversation
…f hardcoded 0 Resolves the "Register an agent" CTA appearing on the org profile page even when agents are already registered. The agentCount in assembleOrgHealth was stubbed as Promise.resolve(0) with a TODO comment; this replaces it with a real query against member_profiles.agents (JSONB array, added in migration 014_agent_configs). The double COALESCE handles nullable agents columns on older rows and the case where no profile row exists yet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4255
assembleOrgHealthinserver/src/services/org-health.tscontained a stub that returned a hardcoded0for the agent count:The agents table does exist — agents are stored as a JSONB array in
member_profiles.agents(added in migration014_agent_configs.sql). BecauseagentCountwas always0,suggestActions()always fired the "Register an agent to start integrating" CTA, regardless of how many agents the org had registered.This PR replaces the stub with a query that counts all agents across the org's member profile:
The double
COALESCEhandles: (inner)agentscolumn beingNULLon older rows; (outer) no matching profile row at all. Error path falls back to0(preserving the previous behavior on DB failure).Visibility is intentionally not filtered — "has the org registered any agent" is the correct semantic for the CTA gate; a
privateagent is still a registered agent.Non-breaking justification: server-side service change only; no schema, API, or protocol surface affected. Existing callers of
assembleOrgHealthreceive a more accuratesuggested_actionsarray (theregister_agentaction is correctly absent when agents exist).Pre-PR review:
Session: https://claude.ai/code/session_01MGmeJKgbaF39WEmwEuDRQY
Generated by Claude Code