-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release playground v2 #247
Merged
toyamarinyon
merged 9 commits into
giselles-ai:main
from
toyamarinyon:release-playground-v2
Dec 18, 2024
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8c18847
refactor(agents): Merge V2 agents view into main agents page
toyamarinyon 2ae3146
feat(canary): Remove playgroundV2 feature flag check
toyamarinyon 94c378c
feat(canary): Add team membership access control
toyamarinyon f9a0cef
refactor(playground): Remove V2 feature flags and redirect
toyamarinyon 412e09d
refactor: Move beta-proto to prev directory for legacy support
toyamarinyon cacb121
refactor(playground): Consolidate canary views into main path
toyamarinyon 44f8541
Merge branch 'main' into release-playground-v2
toyamarinyon 0addd53
[fix] Update agent list links to use main playground path
toyamarinyon f48dcad
Update app/(playground)/p/[agentId]/page.tsx
toyamarinyon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,66 @@ | ||
import { playgroundV2Flag } from "@/flags"; | ||
import { fetchCurrentUser } from "@/services/accounts"; | ||
import { createAgent, getAgents } from "@/services/agents"; | ||
import { CreateAgentButton } from "@/services/agents/components"; | ||
import { agents, db } from "@/drizzle"; | ||
import { fetchCurrentTeam } from "@/services/teams"; | ||
import { redirect } from "next/navigation"; | ||
import { Suspense } from "react"; | ||
|
||
type AgentListProps = { | ||
teamDbId: number; | ||
}; | ||
async function AgentList(props: AgentListProps) { | ||
const agents = await getAgents({ teamDbId: props.teamDbId }); | ||
import { and, eq, isNotNull } from "drizzle-orm"; | ||
import Link from "next/link"; | ||
import { type ReactNode, Suspense } from "react"; | ||
import { formatTimestamp } from "../../(playground)/p/[agentId]/lib/utils"; | ||
|
||
function DataList({ label, children }: { label: string; children: ReactNode }) { | ||
return ( | ||
<div className="flex flex-col gap-2"> | ||
{agents.map(({ id, name }) => ( | ||
<a key={id} className="flex border border-border p-4" href={`/p/${id}`}> | ||
{name ?? id} | ||
</a> | ||
))} | ||
<div className=" text-black-30"> | ||
<p className="text-[12px]">{label}</p> | ||
<div className="font-bold">{children}</div> | ||
</div> | ||
); | ||
} | ||
export default async function AgentListPage() { | ||
const enableV2 = await playgroundV2Flag(); | ||
if (enableV2) { | ||
return redirect("/agents-v2"); | ||
} | ||
const currentUser = await fetchCurrentUser(); | ||
|
||
async function AgentList() { | ||
const currentTeam = await fetchCurrentTeam(); | ||
async function createAgentAction() { | ||
"use server"; | ||
const agent = await createAgent({ | ||
teamDbId: currentTeam.dbId, | ||
creatorDbId: currentUser.dbId, | ||
}); | ||
redirect(`/p/${agent.id}`); | ||
const dbAgents = await db | ||
.select({ id: agents.id, name: agents.name, updatedAt: agents.updatedAt }) | ||
.from(agents) | ||
.where( | ||
and(eq(agents.teamDbId, currentTeam.dbId), isNotNull(agents.graphUrl)), | ||
); | ||
if (dbAgents.length === 0) { | ||
return ( | ||
<div className="flex justify-center items-center h-full"> | ||
<div className="grid gap-[12px] justify-center text-center"> | ||
<div>No agents found</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div className="container mt-8"> | ||
<section className="text-foreground"> | ||
<div className="flex flex-col gap-8"> | ||
<div className="flex justify-between"> | ||
<h1>Agents</h1> | ||
<CreateAgentButton createAgentAction={createAgentAction} /> | ||
<div className="grid gap-[16px] grid-cols-3"> | ||
{dbAgents.map((agent) => ( | ||
<Link href={`/p/${agent.id}/canary`} key={agent.id}> | ||
<div className="bg-gradient-to-br from-[hsla(187,79%,54%,0.2)] to-[hsla(207,100%,9%,0.2)] p-[18px] relative rounded-[8px]"> | ||
<div className="divide-y divide-black-70"> | ||
<div className="h-[60px]"> | ||
<p className="font-rosart text-black-30 text-[18px]"> | ||
{agent.name ?? "Unname Agent"} | ||
</p> | ||
</div> | ||
<div className="pt-[8px] grid grid-col-3"> | ||
<DataList label="Last updated"> | ||
{formatTimestamp.toRelativeTime( | ||
new Date(agent.updatedAt).getTime(), | ||
)} | ||
</DataList> | ||
</div> | ||
</div> | ||
<div className="absolute z-0 inset-0 border rounded-[8px] mask-fill bg-gradient-to-br bg-origin-border bg-clip-boarder border-transparent from-[hsla(192,73%,84%,0.5)] to-[hsla(192,60%,33%,0.4)]" /> | ||
</div> | ||
<Suspense fallback={<span>loading</span>}> | ||
<AgentList teamDbId={currentTeam.dbId} /> | ||
</Suspense> | ||
</div> | ||
</section> | ||
</Link> | ||
))} | ||
</div> | ||
); | ||
} | ||
export default function AgentListV2Page() { | ||
return ( | ||
<Suspense fallback={<p>loading...</p>}> | ||
<AgentList /> | ||
</Suspense> | ||
); | ||
} |
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@toyamarinyon I cannot open the agent page in
/agents
. Please check it and try your OAT.