Revert: fix(frontend): Fix Input value mixup on Library page & broken marketplace on no onboarding data

This commit is contained in:
Zamil Majdy
2025-04-15 21:28:43 +02:00
parent 7cf0c6fe46
commit 3ccbc31705
12 changed files with 41 additions and 37 deletions

View File

@@ -82,12 +82,12 @@ export default function AgentRunsPage(): React.ReactElement {
// Reward user for viewing results of their onboarding agent
useEffect(() => {
if (!state || !selectedRun || state.completedSteps?.includes("GET_RESULTS"))
if (!state || !selectedRun || state.completedSteps.includes("GET_RESULTS"))
return;
if (selectedRun.id === state.onboardingAgentExecutionId) {
updateState({
completedSteps: [...(state.completedSteps || []), "GET_RESULTS"],
completedSteps: [...state.completedSteps, "GET_RESULTS"],
});
}
}, [selectedRun, state]);

View File

@@ -35,7 +35,7 @@ async function shouldShowOnboarding() {
const api = new BackendAPI();
return (
!(await api.isOnboardingEnabled()) ||
(await api.getUserOnboarding()).completedSteps?.includes("CONGRATS")
(await api.getUserOnboarding()).completedSteps.includes("CONGRATS")
);
}

View File

@@ -119,9 +119,9 @@ export default function Page() {
return;
}
const integrations = state.integrations?.includes(name)
? state.integrations?.filter((i) => i !== name)
: [...(state.integrations || []), name];
const integrations = state.integrations.includes(name)
? state.integrations.filter((i) => i !== name)
: [...state.integrations, name];
updateState({ integrations });
},
@@ -145,7 +145,7 @@ export default function Page() {
</OnboardingText>
<OnboardingGrid
elements={services}
selected={state?.integrations || []}
selected={state?.integrations}
onSelect={switchIntegration}
/>
<OnboardingText className="mt-12" variant="subheader">
@@ -167,7 +167,7 @@ export default function Page() {
className="mb-2"
href="/onboarding/4-agent"
disabled={
state?.integrations?.length === 0 &&
state?.integrations.length === 0 &&
isEmptyOrWhitespace(state.otherIntegrations)
}
>

View File

@@ -11,18 +11,18 @@ export default async function OnboardingPage() {
const onboarding = await api.getUserOnboarding();
// CONGRATS is the last step in intro onboarding
if (onboarding.completedSteps?.includes("CONGRATS")) redirect("/marketplace");
else if (onboarding.completedSteps?.includes("AGENT_INPUT"))
if (onboarding.completedSteps.includes("CONGRATS")) redirect("/marketplace");
else if (onboarding.completedSteps.includes("AGENT_INPUT"))
redirect("/onboarding/6-congrats");
else if (onboarding.completedSteps?.includes("AGENT_NEW_RUN"))
else if (onboarding.completedSteps.includes("AGENT_NEW_RUN"))
redirect("/onboarding/5-run");
else if (onboarding.completedSteps?.includes("AGENT_CHOICE"))
else if (onboarding.completedSteps.includes("AGENT_CHOICE"))
redirect("/onboarding/5-agent");
else if (onboarding.completedSteps?.includes("INTEGRATIONS"))
else if (onboarding.completedSteps.includes("INTEGRATIONS"))
redirect("/onboarding/4-agent");
else if (onboarding.completedSteps?.includes("USAGE_REASON"))
else if (onboarding.completedSteps.includes("USAGE_REASON"))
redirect("/onboarding/3-services");
else if (onboarding.completedSteps?.includes("WELCOME"))
else if (onboarding.completedSteps.includes("WELCOME"))
redirect("/onboarding/2-reason");
redirect("/onboarding/1-welcome");

View File

@@ -258,7 +258,11 @@ export default function AgentRunDetailsView({
Object.entries(agentRunInputs).map(([key, { title, value }]) => (
<div key={key} className="flex flex-col gap-1.5">
<label className="text-sm font-medium">{title || key}</label>
<Input value={value} className="rounded-full" disabled />
<Input
defaultValue={value}
className="rounded-full"
disabled
/>
</div>
))
) : (

View File

@@ -35,7 +35,7 @@ export default function AgentRunDraftView({
.then((newRun) => onRun(newRun.graph_exec_id))
.catch(toastOnFail("execute agent"));
// Mark run agent onboarding step as completed
if (state?.completedSteps?.includes("MARKETPLACE_ADD_AGENT")) {
if (state?.completedSteps.includes("MARKETPLACE_ADD_AGENT")) {
completeStep("MARKETPLACE_RUN_AGENT");
}
}, [api, graph, inputValues, onRun, state]);

View File

@@ -109,7 +109,11 @@ export default function AgentScheduleDetailsView({
Object.entries(agentRunInputs).map(([key, { title, value }]) => (
<div key={key} className="flex flex-col gap-1.5">
<label className="text-sm font-medium">{title || key}</label>
<Input value={value} className="rounded-full" disabled />
<Input
defaultValue={value}
className="rounded-full"
disabled
/>
</div>
))
) : (

View File

@@ -39,8 +39,8 @@ export default function Wallet() {
useEffect(() => {
// Check if there are any completed tasks (state?.completedTasks) that
// are not in the state?.notified array and play confetti if so
const pending = (state?.completedSteps || [])
.filter((step) => !state?.notified?.includes(step))
const pending = state?.completedSteps
.filter((step) => !state?.notified.includes(step))
// Ignore steps that are not relevant for notifications
.filter(
(step) =>

View File

@@ -141,7 +141,7 @@ export function TaskGroups() {
groups.forEach((group) => {
const groupCompleted = isGroupCompleted(group);
// Check if the last task in the group is completed
const alreadyCelebrated = state?.notified?.includes(
const alreadyCelebrated = state?.notified.includes(
group.tasks[group.tasks.length - 1].id,
);
@@ -167,11 +167,7 @@ export function TaskGroups() {
group.tasks.forEach((task) => {
const el = refs.current[task.id];
if (
el &&
isTaskCompleted(task) &&
!state?.notified?.includes(task.id)
) {
if (el && isTaskCompleted(task) && !state?.notified.includes(task.id)) {
party.confetti(el, {
count: 40,
spread: 120,

View File

@@ -33,12 +33,12 @@ export function useOnboarding(step?: number, completeStep?: OnboardingStep) {
if (
!completeStep ||
!context.state ||
context.state.completedSteps?.includes(completeStep)
context.state.completedSteps.includes(completeStep)
)
return;
context.updateState({
completedSteps: [...(context.state.completedSteps || []), completeStep],
completedSteps: [...context.state.completedSteps, completeStep],
});
}, [completeStep, context.state, context.updateState]);
@@ -76,7 +76,7 @@ export default function OnboardingProvider({
// Redirect outside onboarding if completed
// If user did CONGRATS step, that means they completed introductory onboarding
if (
onboarding.completedSteps?.includes("CONGRATS") &&
onboarding.completedSteps.includes("CONGRATS") &&
pathname.startsWith("/onboarding") &&
!pathname.startsWith("/onboarding/reset")
) {
@@ -115,10 +115,10 @@ export default function OnboardingProvider({
const completeStep = useCallback(
(step: OnboardingStep) => {
if (!state || state.completedSteps?.includes(step)) return;
if (!state || state.completedSteps.includes(step)) return;
updateState({
completedSteps: [...(state.completedSteps || []), step],
completedSteps: [...state.completedSteps, step],
});
},
[api, state],

View File

@@ -578,7 +578,7 @@ export default function useAgentGraph(
path.set("flowVersion", savedAgent.version.toString());
path.set("flowExecutionID", graphExecution.graph_exec_id);
router.push(`${pathname}?${path.toString()}`);
if (state?.completedSteps?.includes("BUILDER_SAVE_AGENT")) {
if (state?.completedSteps.includes("BUILDER_SAVE_AGENT")) {
completeStep("BUILDER_RUN_AGENT");
}
})

View File

@@ -811,12 +811,12 @@ export type OnboardingStep =
| "BUILDER_RUN_AGENT";
export interface UserOnboarding {
completedSteps: OnboardingStep[] | null;
notificationDot: boolean | null;
notified: OnboardingStep[] | null;
rewardedFor: OnboardingStep[] | null;
completedSteps: OnboardingStep[];
notificationDot: boolean;
notified: OnboardingStep[];
rewardedFor: OnboardingStep[];
usageReason: string | null;
integrations: string[] | null;
integrations: string[];
otherIntegrations: string | null;
selectedStoreListingVersionId: string | null;
agentInput: { [key: string]: string | number } | null;