fix(onboarding): correct resume steps and skip agent-waiting flash when agent is connected

This commit is contained in:
Théo LAGACHE
2026-06-19 12:04:48 +02:00
parent d5aa90a7d9
commit a140492688
2 changed files with 27 additions and 13 deletions
+19 -11
View File
@@ -57,12 +57,13 @@ export async function resolveOnboardingState(): Promise<ResolvedOnboardingState>
const orgData = { id: org.id, name: org.name };
const [notifierChannels, storageChannels, agents, project] = await Promise.all([
getOrganizationChannels(org.id),
getOrganizationStorageChannels(org.id),
getOrganizationAgents(org.id),
getOrganizationProject(org.id),
]);
const [notifierChannels, storageChannels, agents, project] =
await Promise.all([
getOrganizationChannels(org.id),
getOrganizationStorageChannels(org.id),
getOrganizationAgents(org.id),
getOrganizationProject(org.id),
]);
const notifiers = notifierChannels.map((n) => ({
id: n.id,
@@ -106,13 +107,20 @@ export async function resolveOnboardingState(): Promise<ResolvedOnboardingState>
agents: agentData,
databases,
...(project
? { project: { id: project.id, name: project.name, description: "", databaseIds: [] } }
? {
project: {
id: project.id,
name: project.name,
description: "",
databaseIds: [],
},
}
: {}),
};
if (notifiers.length === 0) {
meta.resumeStepId = "invite-members";
return { stepId: "invite-members", flowData: fullData };
meta.resumeStepId = "notifier";
return { stepId: "notifier", flowData: fullData };
}
if (storages.length === 0) {
@@ -121,8 +129,8 @@ export async function resolveOnboardingState(): Promise<ResolvedOnboardingState>
}
if (!agents || agents.length === 0) {
meta.resumeStepId = "defaults";
return { stepId: "defaults", flowData: fullData };
meta.resumeStepId = "agent-create";
return { stepId: "agent-create", flowData: fullData };
}
if (!project) {
@@ -9,7 +9,7 @@ import type { OnboardingAgent } from "@/features/onboarding/types";
export const StepAgentWaiting = () => {
const { next, state } = useOnboarding();
const agents = (state?.context.flowData.agents ?? []) as OnboardingAgent[];
const { data } = useAgentStatus();
const { data, isLoading } = useAgentStatus();
useEffect(() => {
if (data?.connected) {
@@ -17,11 +17,17 @@ export const StepAgentWaiting = () => {
}
}, [data?.connected, next]);
// Don't render until the first fetch completes — if the agent is already
// connected, next() fires before the spinner is ever displayed.
if (isLoading) return null;
return (
<div className="flex flex-col items-center justify-center gap-4 h-full text-center">
<Loader2 className="size-10 animate-spin text-primary" />
<h1 className="text-xl font-semibold">Waiting for your agent</h1>
<p className="text-sm text-muted-foreground">Checking connectivity every 3 seconds</p>
<p className="text-sm text-muted-foreground">
Checking connectivity every 3 seconds
</p>
{agents.length > 0 && (
<p className="text-xs text-muted-foreground">Agent: {agents[0].name}</p>
)}