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.
fix(frontend/copilot): always-visible credentials, inputs, and login prompts (#12194)
Ubbea18ffd0b21c7
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/CreateAgent/components/MiniGame/MiniGame.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/MiniGame/MiniGame.tsxsimilarity index 100%rename from autogpt_platform/frontend/src/app/(platform)/copilot/tools/CreateAgent/components/MiniGame/MiniGame.tsxrename to autogpt_platform/frontend/src/app/(platform)/copilot/components/MiniGame/MiniGame.tsxdiff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/CreateAgent/components/MiniGame/assets/sparkles.png b/autogpt_platform/frontend/src/app/(platform)/copilot/components/MiniGame/assets/sparkles.pngsimilarity index 100%rename from autogpt_platform/frontend/src/app/(platform)/copilot/tools/CreateAgent/components/MiniGame/assets/sparkles.pngrename to autogpt_platform/frontend/src/app/(platform)/copilot/components/MiniGame/assets/sparkles.pngdiff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/CreateAgent/components/MiniGame/useMiniGame.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/MiniGame/useMiniGame.tssimilarity index 100%rename from autogpt_platform/frontend/src/app/(platform)/copilot/tools/CreateAgent/components/MiniGame/useMiniGame.tsrename to autogpt_platform/frontend/src/app/(platform)/copilot/components/MiniGame/useMiniGame.tsdiff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/styleguide/page.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/styleguide/page.tsxindex 8a35f939ca..fc3941b409 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/styleguide/page.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/styleguide/page.tsx@@ -11,6 +11,11 @@ import {MessageResponse,} from "@/components/ai-elements/message";import { Text } from "@/components/atoms/Text/Text";+import {+ CredentialsProvidersContext,+ type CredentialsProviderData,+ type CredentialsProvidersContextType,+} from "@/providers/agent-credentials/credentials-provider";import { CopilotChatActionsProvider } from "../components/CopilotChatActionsProvider/CopilotChatActionsProvider";import { CreateAgentTool } from "../tools/CreateAgent/CreateAgent";import { EditAgentTool } from "../tools/EditAgent/EditAgent";@@ -97,6 +102,65 @@ function uid() {return `sg-${++_id}`;}+// ---------------------------------------------------------------------------+// Mock credential providers for setup-requirements demos+// ---------------------------------------------------------------------------++const noop = () => Promise.reject(new Error("Styleguide mock"));++function makeMockProvider(+ provider: string,+ providerName: string,+ savedCredentials: CredentialsProviderData["savedCredentials"] = [],+): CredentialsProviderData {+ return {+ provider,+ providerName,+ savedCredentials,+ isSystemProvider: false,+ oAuthCallback: noop as CredentialsProviderData["oAuthCallback"],+ mcpOAuthCallback: noop as CredentialsProviderData["mcpOAuthCallback"],+ createAPIKeyCredentials:+ noop as CredentialsProviderData["createAPIKeyCredentials"],+ createUserPasswordCredentials:+ noop as CredentialsProviderData["createUserPasswordCredentials"],+ createHostScopedCredentials:+ noop as CredentialsProviderData["createHostScopedCredentials"],+ deleteCredentials: noop as CredentialsProviderData["deleteCredentials"],+ };+}++/**+ * Provider context where the user already has saved credentials+ * so the credential picker shows a selection list.+ */+const MOCK_PROVIDERS_WITH_CREDENTIALS: CredentialsProvidersContextType = {+ google: makeMockProvider("google", "Google", [+ {+ id: "cred-google-1",+ provider: "google",+ type: "oauth2",+ title: "[email protected]",+ scopes: ["email", "calendar"],+ },+ {+ id: "cred-google-2",+ provider: "google",+ type: "oauth2",+ title: "[email protected]",+ scopes: ["email", "calendar"],+ },+ ]),+};++/**+ * Provider context where the user has NO saved credentials,+ * so the credential picker shows an "add new" flow.+ */+const MOCK_PROVIDERS_WITHOUT_CREDENTIALS: CredentialsProvidersContextType = {+ openweathermap: makeMockProvider("openweathermap", "OpenWeatherMap"),+};+// ---------------------------------------------------------------------------// Page// ---------------------------------------------------------------------------@@ -554,45 +618,80 @@ export default function StyleguidePage() {/></SubSection>- <SubSection label="Output available (setup requirements)">- <RunBlockTool- part={{- type: "tool-run_block",- toolCallId: uid(),- state: "output-available",- input: { block_id: "weather-block-123" },- output: {- type: ResponseType.setup_requirements,- message:- "This block requires API credentials to run. Please configure them below.",- setup_info: {- agent_name: "Weather Agent",- requirements: {- inputs: [- {- name: "city",- title: "City",- type: "string",- required: true,- description: "The city to get weather for",+ <SubSection label="Setup requirements — no credentials (add new)">+ <CredentialsProvidersContext.Provider+ value={MOCK_PROVIDERS_WITHOUT_CREDENTIALS}+ >+ <RunBlockTool+ part={{+ type: "tool-run_block",+ toolCallId: uid(),+ state: "output-available",+ input: { block_id: "weather-block-123" },+ output: {+ type: ResponseType.setup_requirements,+ message:+ "This block requires API credentials to run. Please configure them below.",+ setup_info: {+ agent_id: "agent-weather-1",+ agent_name: "Weather Agent",+ requirements: {+ inputs: [+ {+ name: "city",+ title: "City",+ type: "string",+ required: true,+ description: "The city to get weather for",+ },+ ],+ },+ user_readiness: {+ missing_credentials: {+ openweathermap_key: {+ provider: "openweathermap",+ types: ["api_key"],+ },},- ],+ },},- user_readiness: {- missing_credentials: {- openweathermap: {- provider: "openweathermap",- credentials_type: "api_key",- title: "OpenWeatherMap API Key",- description:- "Required to access weather data. Get your key at openweathermap.org",+ },+ }}+ />+ </CredentialsProvidersContext.Provider>+ </SubSection>++ <SubSection label="Setup requirements — has credentials (pick from list)">+ <CredentialsProvidersContext.Provider+ value={MOCK_PROVIDERS_WITH_CREDENTIALS}+ >+ <RunBlockTool+ part={{+ type: "tool-run_block",+ toolCallId: uid(),+ state: "output-available",+ input: { block_id: "calendar-block-456" },+ output: {+ type: ResponseType.setup_requirements,+ message:+ "This block requires Google credentials. Pick an account below or connect a new one.",+ setup_info: {+ agent_id: "agent-calendar-1",+ agent_name: "Calendar Agent",+ user_readiness: {+ missing_credentials: {+ google_oauth: {+ provider: "google",+ types: ["oauth2"],+ scopes: ["email", "calendar"],+ },},},},},- },- }}- />+ }}+ />+ </CredentialsProvidersContext.Provider></SubSection><SubSection label="Output available (error)">@@ -849,34 +948,71 @@ export default function StyleguidePage() {/></SubSection>- <SubSection label="Output available (setup requirements)">- <RunAgentTool- part={{- type: "tool-run_agent",- toolCallId: uid(),- state: "output-available",- input: { username_agent_slug: "creator/my-agent" },- output: {- type: ResponseType.setup_requirements,- message: "This agent requires additional setup.",- setup_info: {- agent_name: "YouTube Summarizer",- requirements: {},- user_readiness: {- missing_credentials: {- youtube_api: {- provider: "youtube",- credentials_type: "api_key",- title: "YouTube Data API Key",- description:- "Required to access YouTube video data.",+ <SubSection label="Setup requirements — no credentials (add new)">+ <CredentialsProvidersContext.Provider+ value={MOCK_PROVIDERS_WITHOUT_CREDENTIALS}+ >+ <RunAgentTool+ part={{+ type: "tool-run_agent",+ toolCallId: uid(),+ state: "output-available",+ input: { username_agent_slug: "creator/weather-agent" },+ output: {+ type: ResponseType.setup_requirements,+ message:+ "This agent requires an API key. Add your credentials below.",+ setup_info: {+ agent_id: "agent-weather-1",+ agent_name: "Weather Agent",+ requirements: {},+ user_readiness: {+ missing_credentials: {+ openweathermap_key: {+ provider: "openweathermap",+ types: ["api_key"],+ },},},},},- },- }}- />+ }}+ />+ </CredentialsProvidersContext.Provider>+ </SubSection>++ <SubSection label="Setup requirements — has credentials (pick from list)">+ <CredentialsProvidersContext.Provider+ value={MOCK_PROVIDERS_WITH_CREDENTIALS}+ >+ <RunAgentTool+ part={{+ type: "tool-run_agent",+ toolCallId: uid(),+ state: "output-available",+ input: { username_agent_slug: "creator/calendar-agent" },+ output: {+ type: ResponseType.setup_requirements,+ message:+ "This agent needs Google credentials. Pick an account or connect a new one.",+ setup_info: {+ agent_id: "agent-calendar-1",+ agent_name: "Google Calendar Agent",+ requirements: {},+ user_readiness: {+ missing_credentials: {+ google_oauth: {+ provider: "google",+ types: ["oauth2"],+ scopes: ["email", "calendar"],+ },+ },+ },+ },+ },+ }}+ />+ </CredentialsProvidersContext.Provider></SubSection><SubSection label="Output available (need login)">diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/CreateAgent/CreateAgent.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/CreateAgent/CreateAgent.tsxindex 7741647f70..bcf1f2df65 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/CreateAgent/CreateAgent.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/CreateAgent/CreateAgent.tsx@@ -16,7 +16,6 @@ import {ContentCardDescription,ContentCodeBlock,ContentGrid,- ContentHint,ContentMessage,} from "../../components/ToolAccordion/AccordionContent";import { ToolAccordion } from "../../components/ToolAccordion/ToolAccordion";@@ -24,8 +23,8 @@ import {ClarificationQuestionsCard,ClarifyingQuestion,} from "./components/ClarificationQuestionsCard";-import sparklesImg from "./components/MiniGame/assets/sparkles.png";-import { MiniGame } from "./components/MiniGame/MiniGame";+import sparklesImg from "../../components/MiniGame/assets/sparkles.png";+import { MiniGame } from "../../components/MiniGame/MiniGame";import { SuggestedGoalCard } from "./components/SuggestedGoalCard";import {AccordionIcon,@@ -93,9 +92,7 @@ function getAccordionMeta(output: CreateAgentToolOutput) {) {return {icon,- title:- "Creating agent, this may take a few minutes. Play while you wait.",- expanded: true,+ title: output.message || "Agent creation started",};}return {@@ -169,15 +166,22 @@ export function CreateAgentTool({ part }: Props) {/></div>+ {isStreaming && (+ <ToolAccordion+ icon={<AccordionIcon />}+ title="Creating agent, this may take a few minutes. Play while you wait."+ expanded+ >+ <ContentGrid>+ <MiniGame />+ </ContentGrid>+ </ToolAccordion>+ )}+{hasExpandableContent && output && (<ToolAccordion {...getAccordionMeta(output)}>- {isOperating && (- <ContentGrid>- <MiniGame />- <ContentHint>- This could take a few minutes — play while you wait!- </ContentHint>- </ContentGrid>+ {isOperating && output.message && (+ <ContentMessage>{output.message}</ContentMessage>)}{isAgentSavedOutput(output) && (diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/EditAgent/EditAgent.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/EditAgent/EditAgent.tsxindex 40bccd6c61..49814de9db 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/EditAgent/EditAgent.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/EditAgent/EditAgent.tsx@@ -4,17 +4,15 @@ import { WarningDiamondIcon } from "@phosphor-icons/react";import type { ToolUIPart } from "ai";import { useCopilotChatActions } from "../../components/CopilotChatActionsProvider/useCopilotChatActions";import { MorphingTextAnimation } from "../../components/MorphingTextAnimation/MorphingTextAnimation";-import { OrbitLoader } from "../../components/OrbitLoader/OrbitLoader";import {ContentCardDescription,ContentCodeBlock,ContentGrid,- ContentHint,ContentLink,ContentMessage,} from "../../components/ToolAccordion/AccordionContent";import { ToolAccordion } from "../../components/ToolAccordion/ToolAccordion";-import { MiniGame } from "../CreateAgent/components/MiniGame/MiniGame";+import { MiniGame } from "../../components/MiniGame/MiniGame";import {ClarificationQuestionsCard,ClarifyingQuestion,@@ -81,9 +79,8 @@ function getAccordionMeta(output: EditAgentToolOutput): {isOperationInProgressOutput(output)) {return {- icon: <OrbitLoader size={32} />,- title: "Editing agent, this may take a few minutes. Play while you wait.",- expanded: true,+ icon,+ title: output.message || "Agent editing started",};}return {@@ -148,15 +145,22 @@ export function EditAgentTool({ part }: Props) {/></div>+ {isStreaming && (+ <ToolAccordion+ icon={<AccordionIcon />}+ title="Editing agent, this may take a few minutes. Play while you wait."+ expanded+ >+ <ContentGrid>+ <MiniGame />+ </ContentGrid>+ </ToolAccordion>+ )}+{hasExpandableContent && output && (<ToolAccordion {...getAccordionMeta(output)}>- {isOperating && (- <ContentGrid>- <MiniGame />- <ContentHint>- This could take a few minutes — play while you wait!- </ContentHint>- </ContentGrid>+ {isOperating && output.message && (+ <ContentMessage>{output.message}</ContentMessage>)}{isAgentSavedOutput(output) && (diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunAgent/RunAgent.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunAgent/RunAgent.tsxindex 835c04d5a0..f84fbfab8b 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunAgent/RunAgent.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunAgent/RunAgent.tsx@@ -9,7 +9,7 @@ import {ContentHint,ContentMessage,} from "../../components/ToolAccordion/AccordionContent";-import { MiniGame } from "../CreateAgent/components/MiniGame/MiniGame";+import { MiniGame } from "../../components/MiniGame/MiniGame";import {getAccordionMeta,getAnimationText,@@ -47,14 +47,25 @@ export function RunAgentTool({ part }: Props) {const isError =part.state === "output-error" ||(!!output && isRunAgentErrorOutput(output));+ const isOutputAvailable = part.state === "output-available" && !!output;++ const setupRequirementsOutput =+ isOutputAvailable && isRunAgentSetupRequirementsOutput(output)+ ? output+ : null;++ const agentDetailsOutput =+ isOutputAvailable && isRunAgentAgentDetailsOutput(output) ? output : null;++ const needLoginOutput =+ isOutputAvailable && isRunAgentNeedLoginOutput(output) ? output : null;+const hasExpandableContent =- part.state === "output-available" &&- !!output &&- (isRunAgentExecutionStartedOutput(output) ||- isRunAgentAgentDetailsOutput(output) ||- isRunAgentSetupRequirementsOutput(output) ||- isRunAgentNeedLoginOutput(output) ||- isRunAgentErrorOutput(output));+ isOutputAvailable &&+ !setupRequirementsOutput &&+ !agentDetailsOutput &&+ !needLoginOutput &&+ (isRunAgentExecutionStartedOutput(output) || isRunAgentErrorOutput(output));return (<div className="py-2">@@ -81,24 +92,30 @@ export function RunAgentTool({ part }: Props) {</ToolAccordion>)}+ {setupRequirementsOutput && (+ <div className="mt-2">+ <SetupRequirementsCard output={setupRequirementsOutput} />+ </div>+ )}++ {agentDetailsOutput && (+ <div className="mt-2">+ <AgentDetailsCard output={agentDetailsOutput} />+ </div>+ )}++ {needLoginOutput && (+ <div className="mt-2">+ <ContentMessage>{needLoginOutput.message}</ContentMessage>+ </div>+ )}+{hasExpandableContent && output && (<ToolAccordion {...getAccordionMeta(output)}>{isRunAgentExecutionStartedOutput(output) && (<ExecutionStartedCard output={output} />)}- {isRunAgentAgentDetailsOutput(output) && (- <AgentDetailsCard output={output} />- )}-- {isRunAgentSetupRequirementsOutput(output) && (- <SetupRequirementsCard output={output} />- )}-- {isRunAgentNeedLoginOutput(output) && (- <ContentMessage>{output.message}</ContentMessage>- )}-{isRunAgentErrorOutput(output) && <ErrorCard output={output} />}</ToolAccordion>)}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunAgent/components/SetupRequirementsCard/SetupRequirementsCard.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunAgent/components/SetupRequirementsCard/SetupRequirementsCard.tsxindex c6d116e62a..e61744ba50 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunAgent/components/SetupRequirementsCard/SetupRequirementsCard.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunAgent/components/SetupRequirementsCard/SetupRequirementsCard.tsx@@ -1,10 +1,11 @@"use client";-import { useState } from "react";-import { CredentialsGroupedView } from "@/components/contextual/CredentialsInput/components/CredentialsGroupedView/CredentialsGroupedView";+import type { SetupRequirementsResponse } from "@/app/api/__generated__/models/setupRequirementsResponse";import { Button } from "@/components/atoms/Button/Button";+import { Text } from "@/components/atoms/Text/Text";+import { CredentialsGroupedView } from "@/components/contextual/CredentialsInput/components/CredentialsGroupedView/CredentialsGroupedView";import type { CredentialsMetaInput } from "@/lib/autogpt-server-api/types";-import type { SetupRequirementsResponse } from "@/app/api/__generated__/models/setupRequirementsResponse";+import { useState } from "react";import { useCopilotChatActions } from "../../../../components/CopilotChatActionsProvider/useCopilotChatActions";import {ContentBadge,@@ -38,40 +39,40 @@ export function SetupRequirementsCard({ output }: Props) {setInputCredentials((prev) => ({ ...prev, [key]: value }));}- const isAllComplete =- credentialFields.length > 0 &&+ const needsCredentials = credentialFields.length > 0;+ const isAllCredentialsComplete =+ needsCredentials &&[...requiredCredentials].every((key) => !!inputCredentials[key]);+ const canProceed =+ !hasSent && (!needsCredentials || isAllCredentialsComplete);+function handleProceed() {setHasSent(true);- onSend(- "I've configured the required credentials. Please check if everything is ready and proceed with running the agent.",- );+ const message = needsCredentials+ ? "I've configured the required credentials. Please check if everything is ready and proceed with running the agent."+ : "Please proceed with running the agent.";+ onSend(message);}return (<div className="grid gap-2"><ContentMessage>{output.message}</ContentMessage>- {credentialFields.length > 0 && (+ {needsCredentials && (<div className="rounded-2xl border bg-background p-3">- <CredentialsGroupedView- credentialFields={credentialFields}- requiredCredentials={requiredCredentials}- inputCredentials={inputCredentials}- inputValues={{}}- onCredentialChange={handleCredentialChange}- />- {isAllComplete && !hasSent && (- <Button- variant="primary"- size="small"- className="mt-3 w-full"- onClick={handleProceed}- >- Proceed- </Button>- )}+ <Text variant="small" className="w-fit border-b text-zinc-500">+ Agent credentials+ </Text>+ <div className="mt-6">+ <CredentialsGroupedView+ credentialFields={credentialFields}+ requiredCredentials={requiredCredentials}+ inputCredentials={inputCredentials}+ inputValues={{}}+ onCredentialChange={handleCredentialChange}+ />+ </div></div>)}@@ -100,6 +101,18 @@ export function SetupRequirementsCard({ output }: Props) {</div></div>)}++ {(needsCredentials || expectedInputs.length > 0) && (+ <Button+ variant="primary"+ size="small"+ className="mt-4 w-fit"+ disabled={!canProceed}+ onClick={handleProceed}+ >+ Proceed+ </Button>+ )}</div>);}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/RunBlock.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/RunBlock.tsxindex 6e2cbe90d7..d1c0ce6b0a 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/RunBlock.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/RunBlock.tsx@@ -39,12 +39,19 @@ export function RunBlockTool({ part }: Props) {const isError =part.state === "output-error" ||(!!output && isRunBlockErrorOutput(output));+ const setupRequirementsOutput =+ part.state === "output-available" &&+ output &&+ isRunBlockSetupRequirementsOutput(output)+ ? output+ : null;+const hasExpandableContent =part.state === "output-available" &&!!output &&+ !setupRequirementsOutput &&(isRunBlockBlockOutput(output) ||isRunBlockDetailsOutput(output) ||- isRunBlockSetupRequirementsOutput(output) ||isRunBlockErrorOutput(output));return (@@ -57,6 +64,12 @@ export function RunBlockTool({ part }: Props) {/></div>+ {setupRequirementsOutput && (+ <div className="mt-2">+ <SetupRequirementsCard output={setupRequirementsOutput} />+ </div>+ )}+{hasExpandableContent && output && (<ToolAccordion {...getAccordionMeta(output)}>{isRunBlockBlockOutput(output) && <BlockOutputCard output={output} />}@@ -65,10 +78,6 @@ export function RunBlockTool({ part }: Props) {<BlockDetailsCard output={output} />)}- {isRunBlockSetupRequirementsOutput(output) && (- <SetupRequirementsCard output={output} />- )}-{isRunBlockErrorOutput(output) && <ErrorCard output={output} />}</ToolAccordion>)}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsxindex e98fea2850..f718b876f0 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/tools/RunBlock/components/SetupRequirementsCard/SetupRequirementsCard.tsx@@ -6,15 +6,9 @@ import { Text } from "@/components/atoms/Text/Text";import { CredentialsGroupedView } from "@/components/contextual/CredentialsInput/components/CredentialsGroupedView/CredentialsGroupedView";import { FormRenderer } from "@/components/renderers/InputRenderer/FormRenderer";import type { CredentialsMetaInput } from "@/lib/autogpt-server-api/types";-import { AnimatePresence, motion } from "framer-motion";import { useState } from "react";import { useCopilotChatActions } from "../../../../components/CopilotChatActionsProvider/useCopilotChatActions";-import {- ContentBadge,- ContentCardDescription,- ContentCardTitle,- ContentMessage,-} from "../../../../components/ToolAccordion/AccordionContent";+import { ContentMessage } from "../../../../components/ToolAccordion/AccordionContent";import {buildExpectedInputsSchema,coerceCredentialFields,@@ -31,10 +25,8 @@ export function SetupRequirementsCard({ output }: Props) {const [inputCredentials, setInputCredentials] = useState<Record<string, CredentialsMetaInput | undefined>>({});- const [hasSentCredentials, setHasSentCredentials] = useState(false);-- const [showInputForm, setShowInputForm] = useState(false);const [inputValues, setInputValues] = useState<Record<string, unknown>>({});+ const [hasSent, setHasSent] = useState(false);const { credentialFields, requiredCredentials } = coerceCredentialFields(output.setup_info.user_readiness?.missing_credentials,@@ -50,27 +42,49 @@ export function SetupRequirementsCard({ output }: Props) {setInputCredentials((prev) => ({ ...prev, [key]: value }));}+ const needsCredentials = credentialFields.length > 0;const isAllCredentialsComplete =- credentialFields.length > 0 &&+ needsCredentials &&[...requiredCredentials].every((key) => !!inputCredentials[key]);- function handleProceedCredentials() {- setHasSentCredentials(true);- onSend(- "I've configured the required credentials. Please re-run the block now.",- );- }-- function handleRunWithInputs() {- const nonEmpty = Object.fromEntries(- Object.entries(inputValues).filter(- ([, v]) => v !== undefined && v !== null && v !== "",- ),- );- onSend(- `Run the block with these inputs: ${JSON.stringify(nonEmpty, null, 2)}`,- );- setShowInputForm(false);+ const needsInputs = inputSchema !== null;+ const requiredInputNames = expectedInputs+ .filter((i) => i.required)+ .map((i) => i.name);+ const isAllInputsComplete =+ needsInputs &&+ requiredInputNames.every((name) => {+ const v = inputValues[name];+ return v !== undefined && v !== null && v !== "";+ });++ const canRun =+ !hasSent &&+ (!needsCredentials || isAllCredentialsComplete) &&+ (!needsInputs || isAllInputsComplete);++ function handleRun() {+ setHasSent(true);++ const parts: string[] = [];+ if (needsCredentials) {+ parts.push("I've configured the required credentials.");+ }++ if (needsInputs) {+ const nonEmpty = Object.fromEntries(+ Object.entries(inputValues).filter(+ ([, v]) => v !== undefined && v !== null && v !== "",+ ),+ );+ parts.push(+ `Run the block with these inputs: ${JSON.stringify(nonEmpty, null, 2)}`,+ );+ } else {+ parts.push("Please re-run the block now.");+ }++ onSend(parts.join(" "));setInputValues({});}@@ -78,119 +92,54 @@ export function SetupRequirementsCard({ output }: Props) {<div className="grid gap-2"><ContentMessage>{output.message}</ContentMessage>- {credentialFields.length > 0 && (+ {needsCredentials && (<div className="rounded-2xl border bg-background p-3">- <CredentialsGroupedView- credentialFields={credentialFields}- requiredCredentials={requiredCredentials}- inputCredentials={inputCredentials}- inputValues={{}}- onCredentialChange={handleCredentialChange}- />- {isAllCredentialsComplete && !hasSentCredentials && (- <Button- variant="primary"- size="small"- className="mt-3 w-full"- onClick={handleProceedCredentials}- >- Proceed- </Button>- )}+ <Text variant="small" className="w-fit border-b text-zinc-500">+ Block credentials+ </Text>+ <div className="mt-6">+ <CredentialsGroupedView+ credentialFields={credentialFields}+ requiredCredentials={requiredCredentials}+ inputCredentials={inputCredentials}+ inputValues={{}}+ onCredentialChange={handleCredentialChange}+ />+ </div></div>)}{inputSchema && (- <div className="flex gap-2 pt-2">- <Button- variant="outline"- size="small"- className="w-fit"- onClick={() => setShowInputForm((prev) => !prev)}- >- {showInputForm ? "Hide inputs" : "Fill in inputs"}- </Button>+ <div className="rounded-2xl border bg-background p-3 pt-4">+ <Text variant="small" className="w-fit border-b text-zinc-500">+ Block inputs+ </Text>+ <FormRenderer+ jsonSchema={inputSchema}+ className="mb-3 mt-3"+ handleChange={(v) => setInputValues(v.formData ?? {})}+ uiSchema={{+ "ui:submitButtonOptions": { norender: true },+ }}+ initialValues={inputValues}+ formContext={{+ showHandles: false,+ size: "small",+ }}+ /></div>)}- <AnimatePresence initial={false}>- {showInputForm && inputSchema && (- <motion.div- initial={{ height: 0, opacity: 0, filter: "blur(6px)" }}- animate={{ height: "auto", opacity: 1, filter: "blur(0px)" }}- exit={{ height: 0, opacity: 0, filter: "blur(6px)" }}- transition={{- height: { type: "spring", bounce: 0.15, duration: 0.5 },- opacity: { duration: 0.25 },- filter: { duration: 0.2 },- }}- className="overflow-hidden"- style={{ willChange: "height, opacity, filter" }}- >- <div className="rounded-2xl border bg-background p-3 pt-4">- <Text variant="body-medium">Block inputs</Text>- <FormRenderer- jsonSchema={inputSchema}- handleChange={(v) => setInputValues(v.formData ?? {})}- uiSchema={{- "ui:submitButtonOptions": { norender: true },- }}- initialValues={inputValues}- formContext={{- showHandles: false,- size: "small",- }}- />- <div className="-mt-8 flex gap-2">- <Button- variant="primary"- size="small"- className="w-fit"- onClick={handleRunWithInputs}- >- Run- </Button>- <Button- variant="secondary"- size="small"- className="w-fit"- onClick={() => {- setShowInputForm(false);- setInputValues({});- }}- >- Cancel- </Button>- </div>- </div>- </motion.div>- )}- </AnimatePresence>-- {expectedInputs.length > 0 && !inputSchema && (- <div className="rounded-2xl border bg-background p-3">- <ContentCardTitle className="text-xs">- Expected inputs- </ContentCardTitle>- <div className="mt-2 grid gap-2">- {expectedInputs.map((input) => (- <div key={input.name} className="rounded-xl border p-2">- <div className="flex items-center justify-between gap-2">- <ContentCardTitle className="text-xs">- {input.title}- </ContentCardTitle>- <ContentBadge>- {input.required ? "Required" : "Optional"}- </ContentBadge>- </div>- <ContentCardDescription className="mt-1">- {input.name} • {input.type}- {input.description ? ` \u2022 ${input.description}` : ""}- </ContentCardDescription>- </div>- ))}- </div>- </div>+ {(needsCredentials || needsInputs) && (+ <Button+ variant="primary"+ size="small"+ className="w-fit"+ disabled={!canRun}+ onClick={handleRun}+ >+ Proceed+ </Button>)}</div>);diff --git a/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/CredentialsFlatView/CredentialsFlatView.tsx b/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/CredentialsFlatView/CredentialsFlatView.tsxindex 4d220a5359..9457ae5732 100644--- a/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/CredentialsFlatView/CredentialsFlatView.tsx+++ b/autogpt_platform/frontend/src/components/contextual/CredentialsInput/components/CredentialsFlatView/CredentialsFlatView.tsx@@ -119,7 +119,7 @@ export function CredentialsFlatView({) : (!readOnly && (<Button- variant="secondary"+ variant="primary"size="small"onClick={onAddCredential}className="w-fit"diff --git a/autogpt_platform/frontend/src/components/renderers/InputRenderer/FormRenderer.tsx b/autogpt_platform/frontend/src/components/renderers/InputRenderer/FormRenderer.tsxindex c3a20d8cd2..31386f63ca 100644--- a/autogpt_platform/frontend/src/components/renderers/InputRenderer/FormRenderer.tsx+++ b/autogpt_platform/frontend/src/components/renderers/InputRenderer/FormRenderer.tsx@@ -1,10 +1,11 @@+import { cn } from "@/lib/utils";import { RJSFSchema } from "@rjsf/utils";-import { preprocessInputSchema } from "./utils/input-schema-pre-processor";import { useMemo } from "react";-import { customValidator } from "./utils/custom-validator";import Form from "./registry";import { ExtendedFormContextType } from "./types";+import { customValidator } from "./utils/custom-validator";import { generateUiSchemaForCustomFields } from "./utils/generate-ui-schema";+import { preprocessInputSchema } from "./utils/input-schema-pre-processor";type FormRendererProps = {jsonSchema: RJSFSchema;@@ -12,15 +13,17 @@ type FormRendererProps = {uiSchema: any;initialValues: any;formContext: ExtendedFormContextType;+ className?: string;};-export const FormRenderer = ({+export function FormRenderer({jsonSchema,handleChange,uiSchema,initialValues,formContext,-}: FormRendererProps) => {+ className,+}: FormRendererProps) {const preprocessedSchema = useMemo(() => {return preprocessInputSchema(jsonSchema);}, [jsonSchema]);@@ -31,7 +34,10 @@ export const FormRenderer = ({}, [preprocessedSchema, uiSchema]);return (- <div className={"mb-6 mt-4"} data-tutorial-id="input-handles">+ <div+ className={cn("mb-6 mt-4", className)}+ data-tutorial-id="input-handles"+ ><FormformContext={formContext}idPrefix="agpt"@@ -45,4 +51,4 @@ export const FormRenderer = ({/></div>);-};+}