Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add tab selector for raw logs when in dev mode
Vasek Mlejnskya8f1565ecec2
diff --git a/components/Editor/Logs/DeployButton.tsx b/components/Editor/RightSidebar/DeployButton.tsxsimilarity index 100%rename from components/Editor/Logs/DeployButton.tsxrename to components/Editor/RightSidebar/DeployButton.tsxdiff --git a/components/Editor/RightSidebar/Logs.tsx b/components/Editor/RightSidebar/Logs.tsxnew file mode 100644index 000000000..3695a2e94--- /dev/null+++ b/components/Editor/RightSidebar/Logs.tsx@@ -0,0 +1,112 @@+import {+ useEffect,+ useState,+} from 'react'+import hljs from 'highlight.js'+import ReactMarkdown from 'react-markdown'++import Text from 'components/Text'+import { useTabs } from 'components/Tabs/useTabs'+import Tabs from 'components/Tabs'+import { Log } from 'db/types'++export interface Props {+ logs?: Log[]+ logsRaw?: string+}++function Logs({+ logs,+ logsRaw,+}: Props) {+ const [selectedTab, setSelectedTab] = useState(0)+ const [tabsProps] = useState({+ tabs: [+ {+ label: 'Pretty',+ id: 'pretty',+ },+ {+ label: 'Raw',+ id: 'raw',+ },+ ]+ })++ const tabsCss = useTabs(tabsProps)++ useEffect(function highlightCode() {+ if (selectedTab === 1) {+ hljs.highlightAll()+ }+ }, [logs, selectedTab])++ return (+ <div className="+ max-w-full+ flex+ flex-col+ overflow-auto+ ">+ <div className="+ flex+ items-center+ justify-between+ border-b+ py-2+ ">+ <Text+ text="Logs"+ size={Text.size.S2}+ className="+ uppercase+ text-slate-400+ font-semibold+ px-4+ "+ />++ {process.env.NODE_ENV === 'development' && (+ <Tabs+ {...tabsCss.tabProps}+ selectedTabIndex={selectedTab}+ setSelectedTab={setSelectedTab}+ />+ )}+ </div>++ <div+ className="+ flex-1+ overflow-auto+ text-xs+ tracking-wide+ font-sans+ whitespace-pre-wrap+ space-y-4+ p-4+ ">+ {selectedTab === 0 && (+ <>+ {logs?.map((l, i) =>+ <ReactMarkdown key={i}>+ {l}+ </ReactMarkdown>+ )}+ </>+ )}+ {selectedTab === 1 && (+ <>+ {logsRaw &&+ <ReactMarkdown>+ {logsRaw}+ </ReactMarkdown>+ }+ </>+ )}+ </div>+ </div>+ )+}++export default Logsdiff --git a/components/Editor/Logs/index.tsx b/components/Editor/RightSidebar/index.tsxsimilarity index 82%rename from components/Editor/Logs/index.tsxrename to components/Editor/RightSidebar/index.tsxindex 162af3aa5..8b8c62e03 100644--- a/components/Editor/Logs/index.tsx+++ b/components/Editor/RightSidebar/index.tsx@@ -1,11 +1,9 @@import {- useEffect,- // useState,useCallback,} from 'react'-import hljs from 'highlight.js'-import ReactMarkdown from 'react-markdown'import { deployment_state } from '@prisma/client'+import Link from 'next/link'+import { Check, X } from 'lucide-react'import { Log } from 'db/types'import { useStateStore } from 'state/StoreProvider'@@ -14,8 +12,7 @@ import Text from 'components/Text'import Button from 'components/Button'import DeployButton from './DeployButton'-import Link from 'next/link'-import { Check, X } from 'lucide-react'+import Logs from './Logs'export interface Props {logs?: Log[]@@ -26,7 +23,7 @@ export interface Props {isInitializingDeploy?: boolean}-function Logs({+function RightSidebar({logs,logsRaw,deploy,@@ -57,9 +54,6 @@ function Logs({setEnvs(newEnvs)}, [envs, setEnvs])- useEffect(function highlightCode() {- hljs.highlightAll()- }, [logs])return (<Sidebar@@ -201,48 +195,12 @@ function Logs({onClick={addNewEnv}/></div>- <div className="- max-w-full- flex- flex-col- overflow-auto- ">- <Text- text="Logs"- size={Text.size.S2}- className="- uppercase- text-slate-400- font-semibold- px-4- py-2- "- />- <div- className="- flex-1- overflow-auto- text-xs- tracking-wide- font-sans- whitespace-pre-wrap- space-y-4- p-4- ">- {logsRaw &&- <ReactMarkdown>- {logsRaw}- </ReactMarkdown>- }- {/* {logs?.map((l, i) =>- <ReactMarkdown key={i}>- {l}- </ReactMarkdown>- )} */}- </div>- </div>+ <Logs+ logs={logs}+ logsRaw={logsRaw}+ /></Sidebar>)}-export default Logs+export default RightSidebardiff --git a/components/Editor/index.tsx b/components/Editor/index.tsxindex 2153bb7be..c0d4cca1f 100644--- a/components/Editor/index.tsx+++ b/components/Editor/index.tsx@@ -14,7 +14,7 @@ import Block from 'components/Block'import ConnectionLine from './ConnectionLine'import AddBlockButton from './AddBlockButton'-import Logs from './Logs'+import RightSidebar from './RightSidebar'import Routes from './Routes'import Link from 'next/link'@@ -221,7 +221,7 @@ function Editor({ project }: Props) {</Link>}</div>- <Logs+ <RightSidebardeployStatus={deployment?.state}isInitializingDeploy={isInitializingDeploy}logs={logs}diff --git a/components/Tabs/index.tsx b/components/Tabs/index.tsxindex 3ac7dac4d..1ee68a225 100644--- a/components/Tabs/index.tsx+++ b/components/Tabs/index.tsx@@ -100,7 +100,6 @@ function Tab({items-centerrelativez-0- py-2"onPointerLeave={onLeaveTabs}>@@ -110,24 +109,29 @@ function Tab({key={i}className={clsx(`text-sm- relative- rounded-md- flex- items-center- h-8- px-2- lg:px-4- z-20- bg-transparent- text-sm- font-medium- text-gray-600/80- cursor-pointer- select-none- transition-colors+ relative+ rounded-md+ flex+ items-center+ justify-center+ h-8+ px-2+ lg:px-4+ z-20+ bg-transparent+ text-sm+ font-medium+ cursor-pointer+ select-none+ transition-colors+ border-green-800+ w-[80px]`,{- 'text-[#8C24D5]': hoveredTabIndex === i || selectedTabIndex === i,+ 'text-slate-400': hoveredTabIndex !== i && selectedTabIndex !== i,+ },+ {+ 'text-green-800': hoveredTabIndex === i || selectedTabIndex === i,})}ref={(el) => (buttonRefs[i] = el)}@@ -146,22 +150,22 @@ function Tab({top-0left-0rounded-md- bg-gray-200+ bg-green-400transition-[width]"style={hoverStyles}/>- {/* <div+ <divclassName="absolutez-10bottom-0left-0h-0.5- bg-slate-500+ bg-green-800"style={selectStyles}- /> */}+ /></nav>)}