mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix(onboarding): correct resume steps and skip agent-waiting flash when agent is connected
This commit is contained in:
@@ -57,12 +57,13 @@ export async function resolveOnboardingState(): Promise<ResolvedOnboardingState>
|
|||||||
|
|
||||||
const orgData = { id: org.id, name: org.name };
|
const orgData = { id: org.id, name: org.name };
|
||||||
|
|
||||||
const [notifierChannels, storageChannels, agents, project] = await Promise.all([
|
const [notifierChannels, storageChannels, agents, project] =
|
||||||
getOrganizationChannels(org.id),
|
await Promise.all([
|
||||||
getOrganizationStorageChannels(org.id),
|
getOrganizationChannels(org.id),
|
||||||
getOrganizationAgents(org.id),
|
getOrganizationStorageChannels(org.id),
|
||||||
getOrganizationProject(org.id),
|
getOrganizationAgents(org.id),
|
||||||
]);
|
getOrganizationProject(org.id),
|
||||||
|
]);
|
||||||
|
|
||||||
const notifiers = notifierChannels.map((n) => ({
|
const notifiers = notifierChannels.map((n) => ({
|
||||||
id: n.id,
|
id: n.id,
|
||||||
@@ -106,13 +107,20 @@ export async function resolveOnboardingState(): Promise<ResolvedOnboardingState>
|
|||||||
agents: agentData,
|
agents: agentData,
|
||||||
databases,
|
databases,
|
||||||
...(project
|
...(project
|
||||||
? { project: { id: project.id, name: project.name, description: "", databaseIds: [] } }
|
? {
|
||||||
|
project: {
|
||||||
|
id: project.id,
|
||||||
|
name: project.name,
|
||||||
|
description: "",
|
||||||
|
databaseIds: [],
|
||||||
|
},
|
||||||
|
}
|
||||||
: {}),
|
: {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (notifiers.length === 0) {
|
if (notifiers.length === 0) {
|
||||||
meta.resumeStepId = "invite-members";
|
meta.resumeStepId = "notifier";
|
||||||
return { stepId: "invite-members", flowData: fullData };
|
return { stepId: "notifier", flowData: fullData };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storages.length === 0) {
|
if (storages.length === 0) {
|
||||||
@@ -121,8 +129,8 @@ export async function resolveOnboardingState(): Promise<ResolvedOnboardingState>
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!agents || agents.length === 0) {
|
if (!agents || agents.length === 0) {
|
||||||
meta.resumeStepId = "defaults";
|
meta.resumeStepId = "agent-create";
|
||||||
return { stepId: "defaults", flowData: fullData };
|
return { stepId: "agent-create", flowData: fullData };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!project) {
|
if (!project) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import type { OnboardingAgent } from "@/features/onboarding/types";
|
|||||||
export const StepAgentWaiting = () => {
|
export const StepAgentWaiting = () => {
|
||||||
const { next, state } = useOnboarding();
|
const { next, state } = useOnboarding();
|
||||||
const agents = (state?.context.flowData.agents ?? []) as OnboardingAgent[];
|
const agents = (state?.context.flowData.agents ?? []) as OnboardingAgent[];
|
||||||
const { data } = useAgentStatus();
|
const { data, isLoading } = useAgentStatus();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data?.connected) {
|
if (data?.connected) {
|
||||||
@@ -17,11 +17,17 @@ export const StepAgentWaiting = () => {
|
|||||||
}
|
}
|
||||||
}, [data?.connected, next]);
|
}, [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 (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center gap-4 h-full text-center">
|
<div className="flex flex-col items-center justify-center gap-4 h-full text-center">
|
||||||
<Loader2 className="size-10 animate-spin text-primary" />
|
<Loader2 className="size-10 animate-spin text-primary" />
|
||||||
<h1 className="text-xl font-semibold">Waiting for your agent</h1>
|
<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 && (
|
{agents.length > 0 && (
|
||||||
<p className="text-xs text-muted-foreground">Agent: {agents[0].name}</p>
|
<p className="text-xs text-muted-foreground">Agent: {agents[0].name}</p>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user