Skip to content

An open-source, faster Devin alternative

TypeScript

Polish getting started layouts

Igor Zalutskibf246d5195bb
diff --git a/web/src/components/manual-agent-form.tsx b/web/src/components/manual-agent-form.tsx
index 0eab2ad1..6310ba5f 100644
--- a/web/src/components/manual-agent-form.tsx
+++ b/web/src/components/manual-agent-form.tsx
@@ -14,6 +14,7 @@ import {
runtimeOptions,
withModelGroups,
} from '@/lib/runtimes'
+import { cn } from '@/lib/utils'
const NEW_CRED = '__new__'
const MANAGED = 'managed'
@@ -64,7 +65,28 @@ function randomAgentName(): string {
const DEFAULT_PROMPT =
'You are a helpful AI assistant working in a sandboxed computer. Complete tasks end to end, use the tools available to you, and keep your answers clear and concise. When something is ambiguous, make a sensible assumption and say so.'
-export function ManualAgentForm({ onCancel }: { onCancel: () => void }) {
+function FormSectionHeading({
+ title,
+ description,
+}: {
+ title: string
+ description: string
+}) {
+ return (
+ <div className="space-y-1">
+ <h3 className="text-sm font-semibold">{title}</h3>
+ <p className="text-muted-foreground text-sm leading-5">{description}</p>
+ </div>
+ )
+}
+
+export function ManualAgentForm({
+ onCancel,
+ layout = 'stacked',
+}: {
+ onCancel: () => void
+ layout?: 'stacked' | 'wide'
+}) {
const queryClient = useQueryClient()
const navigate = useNavigate()
const { data: credentials } = useQuery({
@@ -170,107 +192,140 @@ export function ManualAgentForm({ onCancel }: { onCancel: () => void }) {
name.trim().length > 0 &&
prompt.trim().length > 0 &&
(selectedCredChoice !== NEW_CRED || newCredKey.trim().length > 0)
+ const wide = layout === 'wide'
return (
<form
- className="space-y-4"
+ className="space-y-6"
onSubmit={(event) => {
event.preventDefault()
if (canCreate) createMutation.mutate()
}}
>
- <Field label="Name" htmlFor="agent-name">
- <Input
- id="agent-name"
- value={name}
- onChange={(event) => setName(event.target.value)}
- placeholder="e.g. PR Reviewer"
- />
- </Field>
- <Field
- label="Prompt"
- htmlFor="agent-prompt"
- description="The system prompt that defines how the agent behaves."
+ <div
+ className={cn(
+ 'grid gap-6',
+ wide && 'lg:grid-cols-[minmax(0,1.2fr)_minmax(20rem,0.8fr)] lg:gap-0',
+ )}
>
- <Textarea
- id="agent-prompt"
- value={prompt}
- onChange={(event) => setPrompt(event.target.value)}
- placeholder="You are a meticulous code reviewer…"
- className="min-h-28"
- />
- </Field>
- <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
- <Field
- label="Runtime"
- htmlFor="agent-runtime"
- description="The engine, fixed once created."
- >
- <Select
- id="agent-runtime"
- value={runtime}
- onValueChange={onRuntimeChange}
- options={runtimeOptions}
+ <div className={cn('space-y-5', wide && 'lg:pr-8')}>
+ <FormSectionHeading
+ title="Instructions"
+ description="Name the agent and describe how it should behave."
/>
- </Field>
- <Field
- label="Model"
- htmlFor="agent-model"
- description={`Models for the ${rt.label} runtime.`}
- >
- <Select
- key={runtime}
- id="agent-model"
- value={model}
- onValueChange={onModelChange}
- options={withModelGroups(rt.models)}
- />
- </Field>
- </div>
- <Field
- label="Credential"
- htmlFor="agent-cred"
- description={
- selectedCredChoice === MANAGED
- ? 'Run via OpenComputer, billed to your credits. No key needed.'
- : `The ${provider} key this agent runs on (matches the model). Reuse one from Credentials, or add a new one here.`
- }
- >
- <Select
- key={provider}
- id="agent-cred"
- value={selectedCredChoice}
- onValueChange={setCredChoice}
- options={credOptions}
- placeholder="Choose a credential"
- />
- </Field>
- {selectedCredChoice === NEW_CRED ? (
- <div className="border-border bg-panel-2 grid grid-cols-1 gap-4 rounded-md border p-3 sm:grid-cols-2">
- <Field label="Credential name" htmlFor="new-cred-name">
+ <Field label="Name" htmlFor="agent-name">
<Input
- id="new-cred-name"
- value={newCredName}
- onChange={(event) => setNewCredName(event.target.value)}
- placeholder="e.g. Production"
+ id="agent-name"
+ value={name}
+ onChange={(event) => setName(event.target.value)}
+ placeholder="e.g. PR Reviewer"
/>
</Field>
<Field
- label={keyField.keyLabel}
- htmlFor="new-cred-key"
- description="Encrypted in a dedicated secret store."
+ label="System prompt"
+ htmlFor="agent-prompt"
+ description="The instructions applied to every session."
>
- <Input
- id="new-cred-key"
- type="password"
- value={newCredKey}
- onChange={(event) => setNewCredKey(event.target.value)}
- placeholder={keyField.keyPlaceholder}
+ <Textarea
+ id="agent-prompt"
+ value={prompt}
+ onChange={(event) => setPrompt(event.target.value)}
+ placeholder="You are a meticulous code reviewer…"
+ className={cn(wide ? 'min-h-44' : 'min-h-28')}
/>
</Field>
</div>
- ) : null}
- <div className="flex flex-col-reverse justify-end gap-2 pt-2 sm:flex-row">
+
+ <div
+ className={cn(
+ 'space-y-5 border-t pt-6',
+ wide && 'lg:border-t-0 lg:border-l lg:pt-0 lg:pl-8',
+ )}
+ >
+ <FormSectionHeading
+ title="Runtime"
+ description="Choose how the agent runs and which model it uses."
+ />
+ <div
+ className={cn('grid grid-cols-1 gap-4', !wide && 'sm:grid-cols-2')}
+ >
+ <Field
+ label="Runtime"
+ htmlFor="agent-runtime"
+ description="The engine, fixed once created."
+ >
+ <Select
+ id="agent-runtime"
+ value={runtime}
+ onValueChange={onRuntimeChange}
+ options={runtimeOptions}
+ />
+ </Field>
+ <Field
+ label="Model"
+ htmlFor="agent-model"
+ description={`Models for the ${rt.label} runtime.`}
+ >
+ <Select
+ key={runtime}
+ id="agent-model"
+ value={model}
+ onValueChange={onModelChange}
+ options={withModelGroups(rt.models)}
+ />
+ </Field>
+ </div>
+ <Field
+ label="Credential"
+ htmlFor="agent-cred"
+ description={
+ selectedCredChoice === MANAGED
+ ? 'Run via OpenComputer, billed to your credits. No key needed.'
+ : `The ${provider} key this agent runs on (matches the model). Reuse one from Credentials, or add a new one here.`
+ }
+ >
+ <Select
+ key={provider}
+ id="agent-cred"
+ value={selectedCredChoice}
+ onValueChange={setCredChoice}
+ options={credOptions}
+ placeholder="Choose a credential"
+ />
+ </Field>
+ {selectedCredChoice === NEW_CRED ? (
+ <div
+ className={cn(
+ 'border-border bg-panel-2 grid grid-cols-1 gap-4 rounded-md border p-3',
+ !wide && 'sm:grid-cols-2',
+ )}
+ >
+ <Field label="Credential name" htmlFor="new-cred-name">
+ <Input
+ id="new-cred-name"
+ value={newCredName}
+ onChange={(event) => setNewCredName(event.target.value)}
+ placeholder="e.g. Production"
+ />
+ </Field>
+ <Field
+ label={keyField.keyLabel}
+ htmlFor="new-cred-key"
+ description="Encrypted in a dedicated secret store."
+ >
+ <Input
+ id="new-cred-key"
+ type="password"
+ value={newCredKey}
+ onChange={(event) => setNewCredKey(event.target.value)}
+ placeholder={keyField.keyPlaceholder}
+ />
+ </Field>
+ </div>
+ ) : null}
+ </div>
+ </div>
+ <div className="flex flex-col-reverse justify-end gap-2 border-t pt-4 sm:flex-row">
<Button
type="button"
variant="ghost"
diff --git a/web/src/pages/Dashboard.tsx b/web/src/pages/Dashboard.tsx
index 5ba556da..9077cb11 100644
--- a/web/src/pages/Dashboard.tsx
+++ b/web/src/pages/Dashboard.tsx
@@ -42,20 +42,17 @@ import { useTransientFlag } from '@/lib/use-transient-flag'
import { cn } from '@/lib/utils'
import { RepositoryImportPanel, RepositoryStarterGuide } from './AgentNew'
-const SANDBOX_API_CODE = `import { Sandbox } from "@opencomputer/sdk";
-
-const sandbox = await Sandbox.create();
-const result = await sandbox.commands.run("python3 --version");
+const SANDBOX_API_CODE = `const sandbox = await Sandbox.create();
+const result =
+ await sandbox.commands.run("uname -a");
console.log(result.stdout);
await sandbox.kill();`
-const SESSION_API_CODE = `import { OpenComputer } from "@opencomputer/sdk";
-
-const oc = new OpenComputer({ apiKey: process.env.OPENCOMPUTER_API_KEY! });
+const SESSION_API_CODE = `const oc = new OpenComputer({ apiKey });
const session = await oc.sessions.create({
agent: "agt_...",
- input: "Triage the latest support requests.",
+ input: "Triage support requests.",
});`
type StartDirection = 'github' | 'prompt' | 'api'
@@ -64,19 +61,19 @@ const START_DIRECTIONS = [
{
id: 'github',
title: 'Agent from GitHub',
- description: 'Import Flue code and deploy automatically when you push.',
+ description: 'Deploy a repository.',
icon: GithubMark,
},
{
id: 'prompt',
title: 'Agent from a prompt',
- description: 'Define the agent directly in the dashboard.',
+ description: 'Define its behavior.',
icon: Bot,
},
{
id: 'api',
title: 'Build with the API',
- description: 'Create sandboxes and durable sessions with the SDK.',
+ description: 'Durable sessions & sandboxes.',
icon: Code2,
},
] as const
@@ -459,8 +456,8 @@ export function GettingStarted() {
aria-labelledby="start-tab-github"
className="mt-8"
>
- <div className="grid items-start gap-5 xl:grid-cols-[minmax(0,42rem)_17rem] xl:gap-8">
- <div className="min-w-0">
+ <div className="grid items-start gap-6 xl:grid-cols-3">
+ <div className="min-w-0 xl:col-span-2">
<RepositoryImportPanel />
</div>
<RepositoryStarterGuide />
@@ -473,20 +470,23 @@ export function GettingStarted() {
id="start-panel-prompt"
role="tabpanel"
aria-labelledby="start-tab-prompt"
- className="mt-8 max-w-2xl"
+ className="mt-8"
>
<Panel>
<PanelHeader>
<div>
<PanelTitle>Define the agent</PanelTitle>
<PanelDescription className="mt-1">
- Set its instructions, runtime, model, and credential. Connect
+ Create a durable agent from its system prompt. You can connect
Slack after creation.
</PanelDescription>
</div>
</PanelHeader>
<PanelContent>
- <ManualAgentForm onCancel={() => selectDirection('github')} />
+ <ManualAgentForm
+ layout="wide"
+ onCancel={() => selectDirection('github')}
+ />
</PanelContent>
</Panel>
</section>
@@ -578,7 +578,7 @@ export function GettingStarted() {
<ApiExample
icon={MessagesSquare}
title="Durable agent sessions"
- description="Start a durable run for an agent, then stream and steer its event log."
+ description="Start and steer a durable agent run."
code={SESSION_API_CODE}
docs="https://docs.opencomputer.dev/agent-sessions/quickstart"
docsLabel="Open sessions quickstart"
@@ -587,7 +587,7 @@ export function GettingStarted() {
<ApiExample
icon={Boxes}
title="Sandboxes"
- description="Create isolated computers and control their files, commands, processes, and network."
+ description="Run commands in an isolated computer."
code={SANDBOX_API_CODE}
docs="https://docs.opencomputer.dev/quickstart"
docsLabel="Open sandbox quickstart"
@@ -627,7 +627,7 @@ function ApiExample({
}
return (
- <article className={className}>
+ <article className={cn('min-w-0', className)}>
<div className="flex items-start gap-3">
<span className="bg-secondary mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md">
<Icon className="text-muted-foreground size-4" aria-hidden />
diff --git a/web/src/pages/getting-started.test.tsx b/web/src/pages/getting-started.test.tsx
index b463ceea..99777754 100644
--- a/web/src/pages/getting-started.test.tsx
+++ b/web/src/pages/getting-started.test.tsx
@@ -55,11 +55,14 @@ describe('getting started', () => {
expect(markup).toContain('Agent from GitHub')
expect(markup).toContain('Agent from a prompt')
expect(markup).toContain('Build with the API')
+ expect(markup).toContain('Durable sessions &amp; sandboxes.')
expect(markup).toMatch(/id="start-tab-github"[^>]*aria-selected="true"/)
expect(markup).toContain('example/flue-starter')
expect(markup).toContain('Choose repository')
expect(markup).not.toContain('API key ready')
- expect(markup).not.toContain('Set its instructions, runtime, model')
+ expect(markup).not.toContain(
+ 'Create a durable agent from its system prompt',
+ )
expect(markup).not.toContain('Get started')
expect(markup).not.toContain('free credits')
expect(markup).not.toContain('Claude Opus')
@@ -77,6 +80,8 @@ describe('getting started', () => {
expect(markup).not.toContain('oc.agents.create')
expect(markup).toContain('Open sessions quickstart')
expect(markup).toContain('Open sandbox quickstart')
+ expect(markup).toContain('Start and steer a durable agent run.')
+ expect(markup).toContain('Run commands in an isolated computer.')
expect(markup.indexOf('oc.sessions.create')).toBeLessThan(
markup.indexOf('Sandbox.create()'),
)
@@ -86,9 +91,9 @@ describe('getting started', () => {
const markup = renderGettingStarted('/?start=prompt')
expect(markup).toContain('Define the agent')
- expect(markup).toContain(
- 'Set its instructions, runtime, model, and credential',
- )
+ expect(markup).toContain('Create a durable agent from its system prompt')
+ expect(markup).toContain('Instructions')
+ expect(markup).toContain('Runtime')
expect(markup).toContain('Create agent')
expect(markup).not.toContain('Choose repository')
})