Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion agentex-ui/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import { connection } from 'next/server';

import { AgentexUIRoot } from '@/components/agentex-ui-root';
import { AgentexProvider } from '@/components/providers';
import { parseBooleanEnv } from '@/lib/env-utils';

export default async function RootPage() {
await connection();
Comment thread
jromualdez-scale marked this conversation as resolved.

const sgpAppURL = process.env.NEXT_PUBLIC_SGP_APP_URL ?? '';
const authEnabled = !!process.env.AGENTEX_UI_AUTH_PROVIDER_ID;
const agentRunSchedulesEnabled = parseBooleanEnv(
process.env.ENABLE_AGENT_RUN_SCHEDULES,
'ENABLE_AGENT_RUN_SCHEDULES'
);
// The account picker needs the platform API (accounts come from /api/user-info).
const accountsEnabled = !!(
process.env.SGP_API_URL ?? process.env.NEXT_PUBLIC_SGP_APP_URL
Expand All @@ -19,7 +24,7 @@ export default async function RootPage() {
accountsEnabled={accountsEnabled}
sgpAppURL={sgpAppURL}
>
<AgentexUIRoot />
<AgentexUIRoot agentRunSchedulesEnabled={agentRunSchedulesEnabled} />
</AgentexProvider>
);
}
12 changes: 10 additions & 2 deletions agentex-ui/components/agentex-ui-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ import {
useSafeSearchParams,
} from '@/hooks/use-safe-search-params';

export function AgentexUIRoot() {
type AgentexUIRootProps = {
agentRunSchedulesEnabled: boolean;
};

export function AgentexUIRoot({
agentRunSchedulesEnabled,
}: AgentexUIRootProps) {
const { agentName, taskID, sgpAccountID, updateParams } =
useSafeSearchParams();
const [isTracesSidebarOpen, setIsTracesSidebarOpen] = useState(false);
Expand Down Expand Up @@ -84,6 +90,7 @@ export function AgentexUIRoot() {
(taskId: string | null) => {
updateParams({
[SearchParamKey.TASK_ID]: taskId,
[SearchParamKey.VIEW]: null,
});
},
[updateParams]
Expand Down Expand Up @@ -115,8 +122,9 @@ export function AgentexUIRoot() {
return (
<>
<div className="fixed inset-0 flex w-full">
<TaskSidebar />
<TaskSidebar agentRunSchedulesEnabled={agentRunSchedulesEnabled} />
<PrimaryContent
agentRunSchedulesEnabled={agentRunSchedulesEnabled}
isTracesSidebarOpen={isTracesSidebarOpen}
toggleTracesSidebar={() =>
setIsTracesSidebarOpen(!isTracesSidebarOpen)
Expand Down
63 changes: 37 additions & 26 deletions agentex-ui/components/primary-content/primary-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ import { ArrowDown } from 'lucide-react';
import { ChatView } from '@/components/primary-content/chat-view';
import { HomeView } from '@/components/primary-content/home-view';
import { PromptInput } from '@/components/primary-content/prompt-input';
import { ScheduledTasksPage } from '@/components/scheduled-tasks/scheduled-tasks-page';
import { IconButton } from '@/components/ui/icon-button';
import { useSafeSearchParams } from '@/hooks/use-safe-search-params';
import { AppView, useSafeSearchParams } from '@/hooks/use-safe-search-params';

type ContentAreaProps = {
agentRunSchedulesEnabled: boolean;
isTracesSidebarOpen: boolean;
toggleTracesSidebar: () => void;
};

export function PrimaryContent({
agentRunSchedulesEnabled,
isTracesSidebarOpen,
toggleTracesSidebar,
}: ContentAreaProps) {
const { taskID } = useSafeSearchParams();
const { taskID, view } = useSafeSearchParams();
const isScheduledTasksView =
agentRunSchedulesEnabled && view === AppView.SCHEDULED_TASKS;

const [prompt, setPrompt] = useState<string>('');
const [showScrollButton, setShowScrollButton] = useState(false);
Expand Down Expand Up @@ -56,20 +61,24 @@ export function PrimaryContent({
}, [scrollContainerRef]);

useEffect(() => {
if (scrollContainerRef.current && taskID) {
if (scrollContainerRef.current && taskID && !isScheduledTasksView) {
setTimeout(() => {
scrollToBottom();
}, 150);
}
}, [scrollToBottom, taskID]);
}, [scrollToBottom, taskID, isScheduledTasksView]);

return (
<motion.div
layout
className={`relative flex h-full flex-1 flex-col ${!taskID ? 'justify-center' : 'justify-between'}`}
className={`relative flex h-full flex-1 flex-col ${
!taskID && !isScheduledTasksView ? 'justify-center' : 'justify-between'
}`}
transition={{ duration: 0.25, ease: 'easeInOut' }}
>
{taskID ? (
{isScheduledTasksView ? (
<ScheduledTasksPage />
) : taskID ? (
<ChatView
taskID={taskID}
isTracesSidebarOpen={isTracesSidebarOpen}
Expand All @@ -81,26 +90,28 @@ export function PrimaryContent({
<HomeView />
)}

<motion.div
layout="position"
className="relative flex w-full justify-center px-4 py-4 sm:px-6 md:px-8"
transition={{
layout: {
type: 'spring',
damping: 40,
stiffness: 300,
mass: 0.8,
},
}}
>
<AnimatePresence>
{taskID && showScrollButton && (
<ScrollToBottomButton scrollToBottom={scrollToBottom} />
)}
</AnimatePresence>

<PromptInput prompt={prompt} setPrompt={setPrompt} />
</motion.div>
{!isScheduledTasksView && (
<motion.div
layout="position"
className="relative flex w-full justify-center px-4 py-4 sm:px-6 md:px-8"
transition={{
layout: {
type: 'spring',
damping: 40,
stiffness: 300,
mass: 0.8,
},
}}
>
<AnimatePresence>
{taskID && showScrollButton && (
<ScrollToBottomButton scrollToBottom={scrollToBottom} />
)}
</AnimatePresence>

<PromptInput prompt={prompt} setPrompt={setPrompt} />
</motion.div>
)}
</motion.div>
);
}
Expand Down
Loading
Loading