Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Improve sidebar menu and menu sections [WIP]
Tomas Valentae551e0357310
diff --git a/components/Editor/Sidebar/Context.tsx b/components/Editor/Sidebar/Context.tsxindex ceb24f9ed..e33fad2c4 100644--- a/components/Editor/Sidebar/Context.tsx+++ b/components/Editor/Sidebar/Context.tsx@@ -1,4 +1,6 @@import Text from 'components/Text'+import { html2markdown } from 'editor/schema'+import { useMemo } from 'react'import { useStateStore } from 'state/StoreProvider'export interface Props {@@ -8,18 +10,30 @@ function Context({}: Props) {const [selector] = useStateStore()-+ const routes = selector.use.routes()+ const references = useMemo(() => routes+ .flatMap(r => r.blocks)+ .filter(b => b.type === 'Instructions' || b.type === 'Description')+ .flatMap(b => {+ const [, references] = html2markdown(b.content)+ return references+ }).filter((reference, index, self) =>+ index === self.findIndex((r) => (+ r.type === reference.type && r.value === reference.value+ ))+ )+ , [routes])return (<div className="max-w-fullflexflex-col- bg-slate-50overflow-hidden- ">+ "><div className="flex+ bg-slate-50items-centerjustify-betweenborder-b@@ -36,7 +50,21 @@ function Context({px-4"/>-+ </div>+ <div className="+ flex+ flex-1+ flex-col+ space-y-2+ ">+ {references.map(r =>+ <div+ key={r.type + '/' + r.value}+ >+ {r.type}+ {r.value}+ </div>+ )}</div></div>)diff --git a/components/Editor/Sidebar/Envs.tsx b/components/Editor/Sidebar/Envs.tsxindex eb031c1f8..ec441ef9b 100644--- a/components/Editor/Sidebar/Envs.tsx+++ b/components/Editor/Sidebar/Envs.tsx@@ -33,31 +33,47 @@ function Envs() {max-w-fullflexflex-col- border-b- p-4space-y-4">- <Text- text="Envs"- size={Text.size.S2}- className="- uppercase- text-slate-400- font-semibold- "- />- {envs.map((env, idx) =>- <div- key={idx}+ <div className="+ flex+ bg-slate-50+ items-center+ justify-between+ border-b+ py-3.5+ pr-4+ ">+ <Text+ text="Envs"+ size={Text.size.S2}className="+ uppercase+ text-slate-400+ font-semibold+ px-4+ "+ />+ </div>+ <div className="+ flex+ flex-col+ p-4+ space-y-4+ "+ >+ {envs.map((env, idx) =>+ <div+ key={idx}+ className="flexitems-centerjustify-evenlyspace-x-2"- >- <input- className="+ >+ <input+ className="flex-1p-1.5text-xs@@ -67,17 +83,17 @@ function Envs() {outline-nonefocus:border-green-800"- type="text"- autoCapitalize="off"- autoCorrect="off"- autoComplete="off"- spellCheck="false"- placeholder="KEY"- value={env.key}- onChange={event => handleEnvKeyChange(event, idx)}- />- <input- className="+ type="text"+ autoCapitalize="off"+ autoCorrect="off"+ autoComplete="off"+ spellCheck="false"+ placeholder="KEY"+ value={env.key}+ onChange={event => handleEnvKeyChange(event, idx)}+ />+ <input+ className="flex-1p-1.5text-xs@@ -87,27 +103,28 @@ function Envs() {outline-nonefocus:border-green-800"- placeholder="VALUE"- type="text"- autoCapitalize="off"- autoCorrect="off"- autoComplete="off"- spellCheck="false"- value={env.value}- onChange={event => handleEnvValueChange(event, idx)}- />- {envs.length > 1 &&- <Button- text="Delete"- onClick={() => deleteEnv(idx)}+ placeholder="VALUE"+ type="text"+ autoCapitalize="off"+ autoCorrect="off"+ autoComplete="off"+ spellCheck="false"+ value={env.value}+ onChange={event => handleEnvValueChange(event, idx)}/>- }- </div>- )}- <Button- text="Add another"- onClick={addNewEnv}- />+ {envs.length > 1 &&+ <Button+ text="Delete"+ onClick={() => deleteEnv(idx)}+ />+ }+ </div>+ )}+ <Button+ text="Add another"+ onClick={addNewEnv}+ />+ </div></div>)}diff --git a/components/Editor/Sidebar/index.tsx b/components/Editor/Sidebar/index.tsxindex efdc48c6c..1fb9a77ef 100644--- a/components/Editor/Sidebar/index.tsx+++ b/components/Editor/Sidebar/index.tsx@@ -27,6 +27,8 @@ export enum MenuSection {Deploy = 'Deploy',}++const apiHost = process.env.NODE_ENV === 'development'? 'http://localhost:49155': 'https://ai-api-service-7d2cl2hooq-uc.a.run.app'diff --git a/components/Editor/index.tsx b/components/Editor/index.tsxindex 08f5672f7..7bbadde90 100644--- a/components/Editor/index.tsx+++ b/components/Editor/index.tsx@@ -2,12 +2,29 @@ import { useCallback, useEffect, useRef, useState } from 'react'import { projects } from '@prisma/client'import Splitter, { GutterTheme } from '@devbookhq/splitter'import { useLocalStorage } from 'usehooks-ts'+import { Code, Box, Server, Lock } from 'lucide-react'import { useStateStore } from 'state/StoreProvider'import Routes from './Routes'import Sidebar, { MenuSection } from './Sidebar'import RouteEditor from './RouteEditor'+import clsx from 'clsx'+++const menuIconSize = '18px'+function getMenuSelectionIcon(selection: MenuSection) {+ switch (selection) {+ case MenuSection.Agent:+ return <Code size={menuIconSize} />+ case MenuSection.Context:+ return <Box size={menuIconSize} />+ case MenuSection.Deploy:+ return <Server size={menuIconSize} />+ case MenuSection.Envs:+ return <Lock size={menuIconSize} />+ }+}export interface Props {project: projects@@ -95,23 +112,41 @@ function Editor({ project }: Props) {/></Splitter><div className="- w-16+ w-14flex- py-4+ py-2text-smborder-lbg-whiteflex-col- space-y-2+ space-y-4items-center">{Object.values(MenuSection).map(m =><buttonkey={m}+ className={clsx(`+ hover:text-slate-600+ transition-all+ text-xs+ items-center+ justify-center+ flex+ flex-col+ space-y-1+ `,+ {+ 'text-slate-400': selectedMenuSection !== m,+ 'text-slate-600': selectedMenuSection === m,+ }+ )}onClick={() => setSelectedMenuSection(m)}>- {m.toString()}+ {getMenuSelectionIcon(m)}+ <span>+ {m.toString()}+ </span></button>)}</div>