Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

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

Zamil Majdy3ccbc317051a
diff --git a/autogpt_platform/frontend/src/app/library/agents/[id]/page.tsx b/autogpt_platform/frontend/src/app/library/agents/[id]/page.tsx
index 3672cbf842..a5da0f0158 100644
--- a/autogpt_platform/frontend/src/app/library/agents/[id]/page.tsx
+++ b/autogpt_platform/frontend/src/app/library/agents/[id]/page.tsx
@@ -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]);
diff --git a/autogpt_platform/frontend/src/app/login/actions.ts b/autogpt_platform/frontend/src/app/login/actions.ts
index 4701bc3e09..635f85fc12 100644
--- a/autogpt_platform/frontend/src/app/login/actions.ts
+++ b/autogpt_platform/frontend/src/app/login/actions.ts
@@ -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")
);
}
diff --git a/autogpt_platform/frontend/src/app/onboarding/3-services/page.tsx b/autogpt_platform/frontend/src/app/onboarding/3-services/page.tsx
index 659460380d..979d97d025 100644
--- a/autogpt_platform/frontend/src/app/onboarding/3-services/page.tsx
+++ b/autogpt_platform/frontend/src/app/onboarding/3-services/page.tsx
@@ -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)
}
>
diff --git a/autogpt_platform/frontend/src/app/onboarding/page.tsx b/autogpt_platform/frontend/src/app/onboarding/page.tsx
index 35b8c90840..6df8d0dedf 100644
--- a/autogpt_platform/frontend/src/app/onboarding/page.tsx
+++ b/autogpt_platform/frontend/src/app/onboarding/page.tsx
@@ -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");
diff --git a/autogpt_platform/frontend/src/components/agents/agent-run-details-view.tsx b/autogpt_platform/frontend/src/components/agents/agent-run-details-view.tsx
index 920b08e5d4..061c5811cb 100644
--- a/autogpt_platform/frontend/src/components/agents/agent-run-details-view.tsx
+++ b/autogpt_platform/frontend/src/components/agents/agent-run-details-view.tsx
@@ -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>
))
) : (
diff --git a/autogpt_platform/frontend/src/components/agents/agent-run-draft-view.tsx b/autogpt_platform/frontend/src/components/agents/agent-run-draft-view.tsx
index d72b19b0f7..db87661193 100644
--- a/autogpt_platform/frontend/src/components/agents/agent-run-draft-view.tsx
+++ b/autogpt_platform/frontend/src/components/agents/agent-run-draft-view.tsx
@@ -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]);
diff --git a/autogpt_platform/frontend/src/components/agents/agent-schedule-details-view.tsx b/autogpt_platform/frontend/src/components/agents/agent-schedule-details-view.tsx
index 13d8775f04..4ee4a23cf5 100644
--- a/autogpt_platform/frontend/src/components/agents/agent-schedule-details-view.tsx
+++ b/autogpt_platform/frontend/src/components/agents/agent-schedule-details-view.tsx
@@ -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>
))
) : (
diff --git a/autogpt_platform/frontend/src/components/agptui/Wallet.tsx b/autogpt_platform/frontend/src/components/agptui/Wallet.tsx
index ae1a463ee9..d4111365e7 100644
--- a/autogpt_platform/frontend/src/components/agptui/Wallet.tsx
+++ b/autogpt_platform/frontend/src/components/agptui/Wallet.tsx
@@ -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) =>
diff --git a/autogpt_platform/frontend/src/components/onboarding/WalletTaskGroups.tsx b/autogpt_platform/frontend/src/components/onboarding/WalletTaskGroups.tsx
index 403d78ce11..c63712fc9e 100644
--- a/autogpt_platform/frontend/src/components/onboarding/WalletTaskGroups.tsx
+++ b/autogpt_platform/frontend/src/components/onboarding/WalletTaskGroups.tsx
@@ -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,
diff --git a/autogpt_platform/frontend/src/components/onboarding/onboarding-provider.tsx b/autogpt_platform/frontend/src/components/onboarding/onboarding-provider.tsx
index 525095ae1a..36519fd3dc 100644
--- a/autogpt_platform/frontend/src/components/onboarding/onboarding-provider.tsx
+++ b/autogpt_platform/frontend/src/components/onboarding/onboarding-provider.tsx
@@ -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],
diff --git a/autogpt_platform/frontend/src/hooks/useAgentGraph.tsx b/autogpt_platform/frontend/src/hooks/useAgentGraph.tsx
index ce47648384..94d3729a6e 100644
--- a/autogpt_platform/frontend/src/hooks/useAgentGraph.tsx
+++ b/autogpt_platform/frontend/src/hooks/useAgentGraph.tsx
@@ -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");
}
})
diff --git a/autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts b/autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts
index 72bf2e7d77..ea8f63380f 100644
--- a/autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts
+++ b/autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts
@@ -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;