fix(onboarding): Prevent frontend errors when less than 2 agents are returned

This commit is contained in:
seer-by-sentry[bot]
2025-10-28 09:16:13 +00:00
committed by GitHub
parent b31d60276a
commit 4cb42a2e9c
2 changed files with 22 additions and 11 deletions

View File

@@ -315,6 +315,11 @@ async def get_recommended_agents(user_id: str) -> list[StoreAgentDetails]:
agent_points.sort(key=lambda x: x[1], reverse=True)
recommended_agents = [agent for agent, _ in agent_points[:2]]
# Only return agents if we have at least 2
# This prevents the frontend from trying to display a partial selection
if len(recommended_agents) < 2:
return []
return [
StoreAgentDetails(
store_listing_version_id=agent.storeListingVersionId,

View File

@@ -66,12 +66,15 @@ export default function Page() {
agents[0]?.store_listing_version_id
: false
}
onClick={() =>
updateState({
selectedStoreListingVersionId: agents[0].store_listing_version_id,
agentInput: {},
})
}
onClick={() => {
if (agents[0]) {
updateState({
selectedStoreListingVersionId:
agents[0].store_listing_version_id,
agentInput: {},
});
}
}}
/>
<OnboardingAgentCard
agent={agents[1]}
@@ -81,11 +84,14 @@ export default function Page() {
agents[1]?.store_listing_version_id
: false
}
onClick={() =>
updateState({
selectedStoreListingVersionId: agents[1].store_listing_version_id,
})
}
onClick={() => {
if (agents[1]) {
updateState({
selectedStoreListingVersionId:
agents[1].store_listing_version_id,
});
}
}}
/>
</div>