Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Add logs props to home page

Tomas Valenta157e06ed604c
diff --git a/components/DashboardHome.tsx b/components/DashboardHome.tsx
index 5dc6e5b18..55bad3157 100644
--- a/components/DashboardHome.tsx
+++ b/components/DashboardHome.tsx
@@ -1,19 +1,15 @@
-import {
- useState,
-} from 'react'
-
-
import { useRouter } from 'next/router'
import { usePostHog } from 'posthog-js/react'
import { useSupabaseClient } from '@supabase/auth-helpers-react'
-import { deployments, projects } from 'db/prisma'
+import { projects } from 'db/prisma'
import AgentList from 'components/AgentList'
import AgentRunsList from 'components/AgentRunsList'
+import { LogFile } from 'utils/agentLogs'
export interface Props {
- projects: (projects & { deployments: deployments[] })[]
+ projects: (projects & { logs: LogFile[] })[]
}
function DashboardHome({
@@ -21,7 +17,6 @@ function DashboardHome({
}: Props) {
const supabaseClient = useSupabaseClient()
const router = useRouter()
- const [isSidebarOpen, setIsSidebarOpen] = useState(false)
const posthog = usePostHog()
const view = router.query.view as string | undefined
@@ -39,30 +34,16 @@ function DashboardHome({
router.push(`/?view=runs&projectID=${projectID}`, undefined, { shallow: true })
}
- const projectsWithDeployments = projects
- .filter(p => {
- if (p.deployments.length !== 1) return false
-
- const deployment = p.deployments[0]
- const auth = deployment.auth as any
- if (!auth) return false
- return deployment.enabled
- })
- .map(p => ({
- project: p,
- deployment: p.deployments[0],
- }))
-
return (
<>
{view === 'deployed' ? (
<AgentList
- agents={projectsWithDeployments}
+ agents={projectsWithLogs}
onSelectAgent={selectAgent}
/>
) : view === 'runs' ? (
<AgentRunsList
- allDeployedAgents={projectsWithDeployments}
+ allDeployedAgents={projectsWithLogs}
initialSelectedAgentID={selectedAgentInstanceID}
/>
) : view === 'logs' ? (
diff --git a/pages/index.tsx b/pages/index.tsx
index ad422b09e..80c9fc6d3 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -1,9 +1,10 @@
import type { GetServerSideProps, Redirect } from 'next'
import { createServerSupabaseClient } from '@supabase/auth-helpers-nextjs'
-import { deployments, prisma, projects } from 'db/prisma'
+import { logs, prisma, projects } from 'db/prisma'
import { serverCreds } from 'db/credentials'
import DashboardHome from 'components/DashboardHome'
+import { LogFile, RawFileLog } from 'utils/agentLogs'
export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {
const supabase = createServerSupabaseClient(ctx, serverCreds)
@@ -34,7 +35,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {
created_at: 'desc',
},
include: {
- deployments: true,
+ logs: true,
},
},
},
@@ -102,13 +103,30 @@ export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {
}
export interface Props {
- projects: (projects & { deployments: deployments[] })[]
+ projects: (projects & { logs: logs[] })[]
}
function Home({ projects }: Props) {
+ const projectWithLogs = projects
+ .map<projects & { logs: LogFile[] }>(p => {
+ return {
+ ...p,
+ logs: p
+ .logs
+ .filter(l => l.data !== null && l.data.length > 0)
+ .map<LogFile>(l => {
+ const log = l.data[0] as unknown as RawFileLog
+ return {
+ id: l.id,
+ name: log.filename,
+ }
+ })
+ }
+ })
+
return (
<DashboardHome
- projects={projects}
+ projects={projectWithLogs}
/>
)
}
diff --git a/utils/agentLogs.ts b/utils/agentLogs.ts
index 446449483..8c548ac0a 100644
--- a/utils/agentLogs.ts
+++ b/utils/agentLogs.ts
@@ -1,3 +1,8 @@
+export interface RawFileLog {
+ filename: string
+ content: string
+}
+
export interface LogFile {
id: string
name: string