Skip to content

armgit / E2B

Public Imported from GitHub
0

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

commit

Vasek Mlejnsky9f1c7992fdd6
diff --git a/components/Editor/RouteEditor/PromptEditor.tsx b/components/Editor/RouteEditor/PromptEditor.tsx
index 34b237a8c..82796aa5a 100644
--- a/components/Editor/RouteEditor/PromptEditor.tsx
+++ b/components/Editor/RouteEditor/PromptEditor.tsx
@@ -1,27 +1,45 @@
import { EditorContent } from '@tiptap/react'
+import Text from 'components/Text'
import { Block } from 'state/store'
import useDocEditor from 'hooks/useDocEditor'
export interface Props {
+ title?: string
+ placeholder?: string
onChange: (value: string) => void
block: Block
}
-function PromptEditor({ onChange, block }: Props) {
+function PromptEditor({
+ title,
+ onChange,
+ block,
+ placeholder,
+}: Props) {
const editor = useDocEditor({
initialContent: block.prompt,
onContentChange: onChange,
+ placeholder,
})
return (
<div className="
- flex
- w-full
- pt-6
- border-t
- border-slate-200
+ flex
+ flex-col
+ space-y-2
+ self-stretch
+ pb-6
+ border-b
+ border-slate-200
">
+ {title &&
+ <Text
+ className="font-semibold text-slate-400"
+ size={Text.size.S1}
+ text={title}
+ />
+ }
<EditorContent
editor={editor}
className="
diff --git a/components/Editor/RouteEditor/RequestBodyEditor.tsx b/components/Editor/RouteEditor/RequestBodyEditor.tsx
index d37293f6c..91cb306e9 100644
--- a/components/Editor/RouteEditor/RequestBodyEditor.tsx
+++ b/components/Editor/RouteEditor/RequestBodyEditor.tsx
@@ -2,6 +2,7 @@ import clsx from 'clsx'
import TextareaAutosize from 'react-textarea-autosize'
import { Block } from 'state/store'
+import Text from 'components/Text'
export interface Props {
onChange: (value: string) => void
@@ -14,17 +15,26 @@ function RequestBodyEditor({
}: Props) {
return (
<div className="
+ self-stretch
flex
flex-col
items-start
+ pb-6
+ border-b
+ border-slate-200
">
+ <Text
+ className="mb-2 font-semibold text-slate-400"
+ size={Text.size.S1}
+ text="Define the incoming request payload"
+ />
<div className="
self-stretch
rounded-t-lg
font-mono
select-none
text-slate-300
- text-xs
+ text-sm
">
{'{'}
</div>
@@ -34,7 +44,7 @@ function RequestBodyEditor({
autoCorrect="off"
spellCheck="false"
name="block"
- placeholder="fieldName: Type"
+ placeholder="email: string"
value={block.prompt}
onChange={e => onChange(e.target.value)}
className={clsx(
@@ -59,7 +69,7 @@ function RequestBodyEditor({
font-mono
select-none
text-slate-300
- text-xs
+ text-sm
">
{'}'}
</div>
diff --git a/components/Editor/RouteEditor/index.tsx b/components/Editor/RouteEditor/index.tsx
index 0ddfe8b4c..d11140dfc 100644
--- a/components/Editor/RouteEditor/index.tsx
+++ b/components/Editor/RouteEditor/index.tsx
@@ -29,7 +29,7 @@ function RouteEditor({ route }: Props) {
<div className="
text-slate-400
self-center
- ">
+ ">
No route selected
</div>
}
@@ -40,30 +40,28 @@ function RouteEditor({ route }: Props) {
items-start
space-y-8
">
- {requestBodyBlock &&
- <RequestBodyEditor
- block={requestBodyBlock}
- onChange={updateRequestBodyBlock}
- />
- }
{promptBlock1 &&
<PromptEditor
+ title="What will this route do?"
+ placeholder="This is an API endpoint that ..."
block={promptBlock1}
onChange={updatePromptBlock1}
/>
}
+ {requestBodyBlock &&
+ <RequestBodyEditor
+ block={requestBodyBlock}
+ onChange={updateRequestBodyBlock}
+ />
+ }
{promptBlock2 &&
<PromptEditor
+ title="Step-by-step implementation"
+ placeholder="1. Check if the incoming `email` is not empty ..."
block={promptBlock2}
onChange={updatePromptBlock2}
/>
}
- {promptBlock3 &&
- <PromptEditor
- block={promptBlock3}
- onChange={updatePromptBlock3}
- />
- }
</div>
}
</div >
diff --git a/hooks/useBlock.ts b/hooks/useBlock.ts
index 122c139ba..ffe9e07f0 100644
--- a/hooks/useBlock.ts
+++ b/hooks/useBlock.ts
@@ -30,7 +30,7 @@ function useBlock(blockType: BlockType, position: number, route?: Route): [Block
if (route?.id && blockIdx !== undefined && blockIdx !== -1) {
changeBlock(route.id, blockIdx, { prompt })
}
- }, [blockIdx, route?.id])
+ }, [blockIdx, route?.id, changeBlock])
return [block, setBlock]
}
diff --git a/hooks/useDocEditor.ts b/hooks/useDocEditor.ts
index 5fc790e87..dc072c535 100644
--- a/hooks/useDocEditor.ts
+++ b/hooks/useDocEditor.ts
@@ -19,15 +19,12 @@ const extensions = [
codeBlock: false,
dropcursor: false,
hardBreak: false,
- heading: false,
+ // heading: false,
horizontalRule: false,
italic: false,
- listItem: false,
+ // listItem: false,
strike: false,
- orderedList: false,
- }),
- Placeholder.configure({
- placeholder: "All You Need Is English",
+ // orderedList: false,
}),
SlashCommand,
]
@@ -49,9 +46,11 @@ export function getPromptText(structuredProse: string) {
function useDocEditor({
initialContent,
onContentChange,
+ placeholder,
}: {
initialContent: string,
onContentChange: (content: string) => void,
+ placeholder?: string
}) {
const [editor, setEditor] = useState<Editor | null>(null)
@@ -70,7 +69,17 @@ function useDocEditor({
'spellcheck': 'false',
},
},
- extensions,
+ extensions: [
+ ...extensions,
+ Placeholder.configure({
+ placeholder: ({ editor }) => {
+ if (!editor.getText()) {
+ return placeholder || ''
+ }
+ return ''
+ }
+ }),
+ ],
})
// Override default browser Ctrl/Cmd+S shortcut.
diff --git a/pages/_app.tsx b/pages/_app.tsx
index d496008ef..53b611936 100644
--- a/pages/_app.tsx
+++ b/pages/_app.tsx
@@ -1,5 +1,5 @@
import type { AppProps } from 'next/app'
-import { Inter, JetBrains_Mono } from 'next/font/google'
+import { Inter } from 'next/font/google'
import { createBrowserSupabaseClient } from '@supabase/auth-helpers-nextjs'
import { SessionContextProvider, Session } from '@supabase/auth-helpers-react'
import { useState } from 'react'
@@ -18,11 +18,6 @@ const inter = Inter({
variable: '--font-inter',
})
-const jetBrains = JetBrains_Mono({
- subsets: ['latin'],
- variable: '--font-jet-brains',
-})
-
function App({ Component, pageProps }: AppProps<{ initialSession: Session, project?: projects }>) {
const router = useRouter()
const [supabaseClient] = useState(() => createBrowserSupabaseClient<Database>())
@@ -33,10 +28,9 @@ function App({ Component, pageProps }: AppProps<{ initialSession: Session, proje
return (
<main className={clsx(
inter.variable,
- jetBrains.variable,
'font-sans',
'flex',
- 'h-inherit',
+ 'h-full',
'w-full',
'flex-1',
'flex-col',
diff --git a/tailwind.config.js b/tailwind.config.js
index 974a081af..5f0086de0 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -8,7 +8,6 @@ module.exports = {
extend: {
fontFamily: {
sans: ['var(--font-inter)', ...fontFamily.sans],
- mono: ['var(--font-jet-brains)', ...fontFamily.mono],
},
spacing: {
120: '30rem',