Skip to content

Commit

Permalink
Merge branch 'master' into zamilmajdy/open-1884-note-block-changed-to…
Browse files Browse the repository at this point in the history
…-normal-when-its-saved-or-executed
  • Loading branch information
majdyz authored Sep 25, 2024
2 parents 8f754bd + 3a1574e commit 7723298
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 18 deletions.
3 changes: 3 additions & 0 deletions autogpt_platform/frontend/src/app/login/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export async function signup(values: z.infer<typeof loginFormSchema>) {
const { data, error } = await supabase.auth.signUp(values);

if (error) {
if (error.message.includes("P0001")) {
return "Please join our waitlist for your turn: https://agpt.co/waitlist";
}
return error.message;
}

Expand Down
44 changes: 26 additions & 18 deletions autogpt_platform/frontend/src/components/Flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
IconUndo2,
IconRedo2,
IconSquare,
IconOutput,
} from "@/components/ui/icons";
import { startTutorial } from "./tutorial";
import useAgentGraph from "@/hooks/useAgentGraph";
Expand All @@ -49,6 +48,7 @@ import { LogOut } from "lucide-react";
import RunnerUIWrapper, {
RunnerUIWrapperRef,
} from "@/components/RunnerUIWrapper";
import PrimaryActionBar from "@/components/PrimaryActionButton";

// This is for the history, this is the minimum distance a block must move before it is logged
// It helps to prevent spamming the history with small movements especially when pressing on a input in a block
Expand Down Expand Up @@ -557,23 +557,6 @@ const FlowEditor: React.FC<{
icon: <IconRedo2 />,
onClick: handleRedo,
},
{
label: !savedAgent
? "Please save the agent to run"
: !isRunning
? "Run"
: "Stop",
icon: !isRunning ? <IconPlay /> : <IconSquare />,
onClick: !isRunning
? () => runnerUIRef.current?.runOrOpenInput()
: requestStopRun,
disabled: !savedAgent,
},
{
label: "Runner Output",
icon: <LogOut size={18} strokeWidth={1.8} />,
onClick: () => runnerUIRef.current?.openRunnerOutput(),
},
];

return (
Expand Down Expand Up @@ -614,6 +597,31 @@ const FlowEditor: React.FC<{
onNameChange={setAgentName}
/>
</ControlPanel>
<PrimaryActionBar
onClickAgentOutputs={() => runnerUIRef.current?.openRunnerOutput()}
onClickRunAgent={() => {
if (!savedAgent) {
alert(
"Please save the agent to run, by clicking the save button in the left sidebar.",
);
return;
}
if (!isRunning) {
runnerUIRef.current?.runOrOpenInput();
} else {
requestStopRun();
}
}}
isRunning={isRunning}
requestStopRun={requestStopRun}
runAgentTooltip={
!savedAgent
? "Please save the agent to run"
: !isRunning
? "Run Agent"
: "Stop Agent"
}
/>
</ReactFlow>
</div>
<RunnerUIWrapper
Expand Down
75 changes: 75 additions & 0 deletions autogpt_platform/frontend/src/components/PrimaryActionButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from "react";
import { Button } from "./ui/button";
import { LogOut } from "lucide-react";
import { IconPlay, IconSquare } from "@/components/ui/icons";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";

interface PrimaryActionBarProps {
onClickAgentOutputs: () => void;
onClickRunAgent: () => void;
isRunning: boolean;
requestStopRun: () => void;
runAgentTooltip: string;
}

const PrimaryActionBar: React.FC<PrimaryActionBarProps> = ({
onClickAgentOutputs,
onClickRunAgent,
isRunning,
requestStopRun,
runAgentTooltip,
}) => {
const runButtonLabel = !isRunning ? "Run" : "Stop";

const runButtonIcon = !isRunning ? <IconPlay /> : <IconSquare />;

const runButtonOnClick = !isRunning ? onClickRunAgent : requestStopRun;

return (
<div className="absolute bottom-0 left-0 right-0 z-50 flex items-center justify-center p-4">
<div className={`flex gap-4`}>
<Tooltip key="ViewOutputs" delayDuration={500}>
<TooltipTrigger asChild>
<Button
className="flex items-center gap-2"
onClick={onClickAgentOutputs}
size="primary"
variant="outline"
>
<LogOut className="h-5 w-5" />
<span className="text-lg font-medium">Agent Outputs </span>
</Button>
</TooltipTrigger>
<TooltipContent>
<p>View agent outputs</p>
</TooltipContent>
</Tooltip>
<Tooltip key="RunAgent" delayDuration={500}>
<TooltipTrigger asChild>
<Button
className="flex items-center gap-2"
onClick={runButtonOnClick}
size="primary"
style={{
background: isRunning ? "#FFB3BA" : "#7544DF",
opacity: 1,
}}
>
{runButtonIcon}
<span className="text-lg font-medium">{runButtonLabel}</span>
</Button>
</TooltipTrigger>
<TooltipContent>
<p>{runAgentTooltip}</p>
</TooltipContent>
</Tooltip>
</div>
</div>
);
};

export default PrimaryActionBar;
1 change: 1 addition & 0 deletions autogpt_platform/frontend/src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const buttonVariants = cva(
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
primary: "h-14 w-44 rounded-2xl",
icon: "h-9 w-9",
},
},
Expand Down

0 comments on commit 7723298

Please sign in to comment.