page.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use client';
  2. import React, { useEffect } from "react";
  3. import ASide from "./components/ASide";
  4. import Flow from "./components/Flow";
  5. import Header from "./components/Header";
  6. import NodeRender from "./components/NodeRender";
  7. import { trpc } from "@/lib/trpc";
  8. import { useQuery } from '@tanstack/react-query'
  9. import { useSearchParam } from 'react-use';
  10. import { useSession, signIn, signOut } from "next-auth/react"
  11. import { useAtom, useSetAtom, useAtomValue } from "jotai";
  12. import { flowModelAtom, flowModelRecordAtom } from "./store";
  13. const RunAgentFlow = () => {
  14. const multiAgentId = useSearchParam('multiAgentId')
  15. if (!multiAgentId) {
  16. // FIXME redirect to 404
  17. }
  18. const flowModelRecordQuery = trpc.flowModel.byId.useQuery({ multiAgentId })
  19. if (flowModelRecordQuery.isError) {
  20. // FIXME redirect to 500
  21. }
  22. const setFlowModelRecord = useSetAtom(flowModelRecordAtom)
  23. useEffect(() => {
  24. setFlowModelRecord(flowModelRecordQuery.data)
  25. }, [flowModelRecordQuery.data])
  26. return (
  27. <main className="flex h-screen overflow-hidden flex-col items-stretch justify-between p-2 gap-2">
  28. <Header></Header>
  29. <div className="flex align-stretch flex-1 gap-2 overflow-hidden">
  30. <div className="flex-1 flex flex-col align-stretch min-w-0 gap-2">
  31. <Flow></Flow>
  32. <NodeRender></NodeRender>
  33. </div>
  34. <ASide></ASide>
  35. </div>
  36. </main>
  37. )
  38. }
  39. export default React.memo(RunAgentFlow)