From 5b2b7ac1e91f1703653f9f43cd285587b0ddaccb Mon Sep 17 00:00:00 2001 From: shubhook Date: Tue, 20 Oct 2026 23:20:24 +0530 Subject: [PATCH 1/6] Simplify new-bot: refine profile, six colors, optional Claude, then intro Create is name, look, what it should do, and Runs on only when Claude Code is ready. bots.refine turns the description into title and instructions through the agent runtime; create then posts the shared intro chips. Co-authored-by: Cursor --- apps/api/src/app.ts | 1 + apps/api/src/bot-refine.test.ts | 44 +++++ apps/api/src/bot-refine.ts | 81 +++++++++ apps/api/src/router.ts | 24 ++- apps/mobile/app/new.tsx | 134 +++++++++++---- apps/web/e2e/helpers.ts | 12 +- apps/web/e2e/new-bot-ux.spec.ts | 70 +++++--- apps/web/src/pages/Shell.tsx | 10 +- .../web/src/pages/shell/create-bot-dialog.tsx | 155 +++++++++++------- packages/adapters/src/scripted-runtime.ts | 14 ++ packages/contracts/src/domain.ts | 15 ++ packages/contracts/src/rpc.ts | 4 + 12 files changed, 437 insertions(+), 127 deletions(-) create mode 100644 apps/api/src/bot-refine.test.ts create mode 100644 apps/api/src/bot-refine.ts diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts index ea051302..c17b21e8 100644 --- a/apps/api/src/app.ts +++ b/apps/api/src/app.ts @@ -430,6 +430,7 @@ export async function createApp( sandbox, memory, home, + runtime, secrets, oauthLogins, integrationSettings, diff --git a/apps/api/src/bot-refine.test.ts b/apps/api/src/bot-refine.test.ts new file mode 100644 index 00000000..2c88c3ae --- /dev/null +++ b/apps/api/src/bot-refine.test.ts @@ -0,0 +1,44 @@ +import { ScriptedAgentRuntime } from "@milo/adapters"; +import { describe, expect, it } from "vitest"; +import { + buildRefinePrompt, + fallbackRefine, + parseRefineReply, + refineBotProfile, +} from "./bot-refine.js"; + +describe("bot refine", () => { + it("builds a prompt the scripted runtime can match", () => { + expect(buildRefinePrompt("Scout", "Find travel deals")).toContain("milo refine bot profile"); + expect(buildRefinePrompt("Scout", "Find travel deals")).toContain("Name: Scout"); + }); + + it("falls back when the reply is not JSON", () => { + expect(parseRefineReply("sorry", "Scout", "Find travel deals.")).toEqual( + fallbackRefine("Scout", "Find travel deals."), + ); + }); + + it("parses a JSON reply", () => { + expect( + parseRefineReply( + 'Here you go:\n{"title":"Travel finder","instructions":"Hunt deals daily."}\n', + "Scout", + "Find travel deals", + ), + ).toEqual({ + title: "Travel finder", + instructions: "Hunt deals daily.", + }); + }); + + it("runs through the scripted runtime", async () => { + const refined = await refineBotProfile( + new ScriptedAgentRuntime(), + { name: "Scout", description: "Find travel deals every morning." }, + { provider: "scripted", id: "scripted" }, + ); + expect(refined.title.length).toBeGreaterThan(0); + expect(refined.instructions).toContain("Find travel deals"); + }); +}); diff --git a/apps/api/src/bot-refine.ts b/apps/api/src/bot-refine.ts new file mode 100644 index 00000000..d0e04539 --- /dev/null +++ b/apps/api/src/bot-refine.ts @@ -0,0 +1,81 @@ +import { randomUUID } from "node:crypto"; +import type { AgentRuntime } from "@milo/adapter-kit"; +import { + BOT_INSTRUCTIONS_MAX_LENGTH, + BOT_TITLE_MAX_LENGTH, + type RefineBotOutput, +} from "@milo/contracts"; + +/** Marker the scripted runtime matches so offline tests stay deterministic. */ +export const REFINE_PROMPT_MARKER = "milo refine bot profile"; + +/** + * One place for the refine prompt. The model returns JSON only: + * `{"title":"…","instructions":"…"}`. + */ +export function buildRefinePrompt(name: string, description: string): string { + return `${REFINE_PROMPT_MARKER} +Name: ${name} +Description: ${description || "(none)"} +--- +Reply with JSON only, no markdown: {"title":"","instructions":""}. +Keep title under 80 characters. Instructions should be concrete and actionable.`; +} + +export function fallbackRefine(name: string, description: string): RefineBotOutput { + const trimmed = description.trim(); + const title = (trimmed.split(/[.!\n]/)[0] ?? "").trim().slice(0, 80) || name; + return { + title: title.slice(0, BOT_TITLE_MAX_LENGTH), + instructions: (trimmed || `You are ${name}. Help with whatever is asked.`).slice( + 0, + BOT_INSTRUCTIONS_MAX_LENGTH, + ), + }; +} + +export function parseRefineReply( + text: string, + name: string, + description: string, +): RefineBotOutput { + const match = text.match(/\{[\s\S]*\}/); + if (!match) return fallbackRefine(name, description); + try { + const parsed = JSON.parse(match[0]) as { title?: unknown; instructions?: unknown }; + const title = + typeof parsed.title === "string" ? parsed.title.trim().slice(0, BOT_TITLE_MAX_LENGTH) : ""; + const instructions = + typeof parsed.instructions === "string" + ? parsed.instructions.trim().slice(0, BOT_INSTRUCTIONS_MAX_LENGTH) + : ""; + if (!title || !instructions) return fallbackRefine(name, description); + return { title, instructions }; + } catch { + return fallbackRefine(name, description); + } +} + +/** Run the refine prompt through the agent runtime and parse the reply. */ +export async function refineBotProfile( + runtime: AgentRuntime, + input: { name: string; description: string }, + model: { provider: string; id: string }, +): Promise { + const prompt = buildRefinePrompt(input.name, input.description); + let text = ""; + for await (const event of runtime.run({ + botId: "refine", + threadId: "refine", + runId: randomUUID(), + prompt, + instructions: "You refine bot profiles. Reply with JSON only.", + history: [], + tools: [], + model, + })) { + if (event.type === "text" && event.text) text += event.text; + if (event.type === "done" && event.text) text = event.text; + } + return parseRefineReply(text, input.name, input.description); +} diff --git a/apps/api/src/router.ts b/apps/api/src/router.ts index 62df81ea..f3945728 100644 --- a/apps/api/src/router.ts +++ b/apps/api/src/router.ts @@ -2,6 +2,7 @@ import { createHash, randomBytes, randomUUID } from "node:crypto"; import type { AdapterContext, AgentHomeStore, + AgentRuntime, ArtifactStore, ConnectorCatalogItem, JobPublisher, @@ -198,6 +199,7 @@ import { import { getLogger } from "@milo/logging"; import { implement, ORPCError } from "@orpc/server"; import { deleteAgentSecret, listAgentSecrets, putAgentSecret } from "./agent-secrets.js"; +import { refineBotProfile } from "./bot-refine.js"; import { createAgentSkillsService } from "./agent-skills.js"; import { aiConsentStatus, allowAiConsent } from "./ai-consent.js"; import { @@ -542,6 +544,8 @@ export interface RouterDeps { sandbox: SandboxProvider; memory: MemoryStore; home: AgentHomeStore; + /** Used by bots.refine for a short profile pass before create. */ + runtime: AgentRuntime; secrets: EncryptedSecretStore; oauthLogins: PiOAuthLogins; /** Live Codex catalog seam; defaults to the shared per-process cache. */ @@ -1406,11 +1410,27 @@ export function createRouter(deps: RouterDeps) { } catch (error) { throw mapSpaceLifecycleError(error); } - await enqueueBotIntroRun(deps, context.actor, bot).catch((error) => { - getLogger().error("bot intro run enqueue", error); + // Fixed intro with idea chips; the model-driven intro run is unused since v0. + await introduce(onboardingDeps, context.actor, bot.id).catch((error) => { + getLogger().error("bot intro", error); }); return bot; }), + refine: authed.bots.refine.handler(async ({ context, input }) => { + const managed = await selectRuntimeModel( + deps.prisma, + context.actor, + runtimeModel(deps.env.agentRuntime), + ); + const model = managed + ? { provider: managed.provider, id: managed.id } + : { provider: "scripted", id: "scripted" }; + return refineBotProfile( + deps.runtime, + { name: input.name, description: input.description }, + model, + ); + }), duplicate: authed.bots.duplicate.handler(async ({ context, input }) => { const source = await repos.getBot(context.actor, input.botId); const duplicate = await repos diff --git a/apps/mobile/app/new.tsx b/apps/mobile/app/new.tsx index 44973066..5939475f 100644 --- a/apps/mobile/app/new.tsx +++ b/apps/mobile/app/new.tsx @@ -1,28 +1,40 @@ import { BOT_DESCRIPTION_MAX_LENGTH, BOT_NAME_MAX_LENGTH, - BOT_TITLE_MAX_LENGTH, - type ComputerMode, - normalizeCreateBotProfile, + type AgentStatus, } from "@milo/contracts"; +import { BOT_PALETTE_COLORS } from "@milo/core"; import { Stack, useRouter } from "expo-router"; -import { useState } from "react"; -import { Pressable, ScrollView, Text, TextInput } from "react-native"; -import { ComputerModePicker } from "../components/computer-mode-picker"; +import { useEffect, useState } from "react"; +import { Pressable, ScrollView, Text, TextInput, View } from "react-native"; import { type MobileBot, rpc } from "../lib/api"; import { useI18n } from "../lib/i18n"; import { useMobileTokens } from "../lib/native"; +type RunsOn = "chatgpt" | "claude"; + +function claudeReady(status: AgentStatus | null): boolean { + return Boolean(status?.installed && status.loggedIn); +} + export default function NewBot() { const { t } = useI18n(); const tokens = useMobileTokens(); const router = useRouter(); const [name, setName] = useState(""); - const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); - const [computerMode, setComputerMode] = useState("team"); + const [color, setColor] = useState(BOT_PALETTE_COLORS[0]!); + const [provider, setProvider] = useState("chatgpt"); + const [agentStatus, setAgentStatus] = useState(null); const [error, setError] = useState(null); const [pending, setPending] = useState(false); + const showRunsOn = claudeReady(agentStatus); + + useEffect(() => { + void rpc("agent/status") + .then(setAgentStatus) + .catch(() => setAgentStatus(null)); + }, []); function close() { if (router.canDismiss()) { @@ -40,11 +52,30 @@ export default function NewBot() { if (!name.trim() || pending) return; setPending(true); setError(null); + const trimmedName = name.trim(); + const trimmedDescription = description.trim(); try { + let title = ""; + let instructions = trimmedDescription; + try { + const refined = await rpc<{ title: string; instructions: string }>("bots/refine", { + name: trimmedName, + description: trimmedDescription, + }); + title = refined.title; + instructions = refined.instructions; + } catch { + // Create still works with the raw description when refine fails. + } + const usesClaude = showRunsOn && provider === "claude"; const bot = await rpc("bots/create", { - ...normalizeCreateBotProfile({ name, title, description }), + name: trimmedName, + title, + description: trimmedDescription, + instructions, notifyOnFinish: true, - computerMode, + color: `${color}::shape_0`, + ...(usesClaude ? { modelProvider: "claude-code", modelId: "sonnet" } : {}), }); router.replace({ pathname: "/thread", params: { botId: bot.id, name: bot.name } }); } catch (err) { @@ -93,30 +124,13 @@ export default function NewBot() { }} /> - {t("Title")} - - - - {t("Description")} + {t("What should it do?")} - + + {t("Color")} + + + {BOT_PALETTE_COLORS.map((swatch) => { + const selected = color.toLowerCase() === swatch.toLowerCase(); + return ( + setColor(swatch)} + accessibilityRole="button" + accessibilityState={{ selected }} + accessibilityLabel={swatch} + style={{ + width: 32, + height: 32, + borderRadius: 16, + backgroundColor: swatch, + borderWidth: selected ? 2 : 1, + borderColor: selected ? tokens.foreground : tokens.border, + }} + /> + ); + })} + + {showRunsOn ? ( + <> + + {t("Runs on")} + + + {( + [ + { id: "chatgpt", label: t("ChatGPT") }, + { id: "claude", label: t("Claude") }, + ] as const + ).map((option) => { + const selected = provider === option.id; + return ( + setProvider(option.id)} + accessibilityRole="button" + accessibilityState={{ selected }} + style={{ + flex: 1, + padding: 12, + borderRadius: 11, + borderWidth: 1, + borderColor: selected ? tokens.foreground : tokens.border, + backgroundColor: selected ? tokens.muted : tokens.card, + alignItems: "center", + }} + > + {option.label} + + ); + })} + + + ) : null} {error ? {error} : null} void create()} diff --git a/apps/web/e2e/helpers.ts b/apps/web/e2e/helpers.ts index 1dd8201c..93f23826 100644 --- a/apps/web/e2e/helpers.ts +++ b/apps/web/e2e/helpers.ts @@ -123,25 +123,15 @@ export async function createBotFromPicker( page: Page, options: { name?: string; - title?: string; description?: string; - computerMode?: "team" | "dedicated"; } = {}, ) { const name = options.name ?? "New Bot"; await openNewBot(page); const form = page.getByTestId("create-bot-form"); await form.locator("label:has-text('Name') input").fill(name); - if (options.title != null) { - await form.locator("label:has-text('Title') input").fill(options.title); - } if (options.description != null) { - await form.locator("label:has-text('What this bot is for') textarea").fill(options.description); - } - if (options.computerMode === "dedicated") { - await form.getByTestId("create-bot-private").click(); - } else if (options.computerMode === "team") { - await form.getByTestId("create-bot-team").click(); + await form.locator("label:has-text('What should it do?') textarea").fill(options.description); } await form.getByRole("button", { name: "Create", exact: true }).click(); await page.waitForURL(/\/app\/[^/]+$/); diff --git a/apps/web/e2e/new-bot-ux.spec.ts b/apps/web/e2e/new-bot-ux.spec.ts index 1920b07b..cc91825a 100644 --- a/apps/web/e2e/new-bot-ux.spec.ts +++ b/apps/web/e2e/new-bot-ux.spec.ts @@ -4,11 +4,10 @@ import { completeOnboarding, createBotFromPicker, openNewBot, - rpc, signup, } from "./helpers"; -test("+ opens the form, then an empty chat; sidebar collapses", async ({ page }, testInfo) => { +test("+ opens the form, then an intro chat; sidebar collapses", async ({ page }, testInfo) => { const stamp = Date.now(); await signup(page, `new-bot-ux-${stamp}@rakazo.test`, "password12", "New Bot UX"); await completeOnboarding(page); @@ -21,8 +20,10 @@ test("+ opens the form, then an empty chat; sidebar collapses", async ({ page }, await expect(form).toBeVisible(); await expect(page.getByTestId("side-panel")).toHaveAttribute("data-panel", "closed"); await expect(form.locator("label:has-text('Name') input")).toBeVisible(); - await expect(form.locator("label:has-text('Title') input")).toBeVisible(); - await expect(form.locator("label:has-text('What this bot is for') textarea")).toBeVisible(); + await expect(form.locator("label:has-text('What should it do?') textarea")).toBeVisible(); + await expect(form.locator("label:has-text('Title')")).toHaveCount(0); + await expect(form.getByTestId("create-bot-computer")).toHaveCount(0); + await expect(form.getByTestId("create-bot-runs-on")).toHaveCount(0); for (const starter of ["Inbox", "Research", "Design", "Expenses"]) { await expect(form.getByRole("button", { name: starter, exact: true })).toBeVisible(); } @@ -35,18 +36,22 @@ test("+ opens the form, then an empty chat; sidebar collapses", async ({ page }, await expect( page.getByRole("dialog").locator('.rakazo-bot-avatar[data-shape="squircle"]'), ).toBeVisible(); - await expect(form.getByTestId("create-bot-computer")).toBeVisible(); - await expect(form.getByTestId("create-bot-team")).toBeVisible(); - await expect(form.getByTestId("create-bot-private")).toBeVisible(); await captureScreenshot(page, testInfo, "create-bot-form"); await form.locator("label:has-text('Name') input").fill("New Bot"); + await form + .locator("label:has-text('What should it do?') textarea") + .fill("Help with research briefs."); await form.getByRole("button", { name: "Create", exact: true }).click(); await page.waitForURL(/\/app\/[^/]+$/); await expect(page.getByPlaceholder("Message New Bot")).toBeVisible(); await expect(page.getByTestId("side-panel")).toHaveAttribute("data-panel", "closed"); + await expect( + page.getByText(/Hi, I'm New Bot\. I run on your own subscription/, { exact: false }), + ).toBeVisible(); + await expect(page.getByTestId("suggestion-chips")).toBeVisible(); await expect(page.getByText("What do you want me on first?", { exact: true })).toHaveCount(0); - await captureScreenshot(page, testInfo, "create-chat-sidepanel-closed"); + await captureScreenshot(page, testInfo, "create-chat-intro"); await page.getByTestId("minimize-bots-sidebar").click(); await expect(page.getByTestId("bots-sidebar")).toHaveAttribute("data-collapsed", "true"); @@ -62,7 +67,6 @@ test("+ opens the form, then an empty chat; sidebar collapses", async ({ page }, await page.getByTestId("minimize-bots-sidebar").click(); await expect(page.getByTestId("bots-sidebar")).toHaveAttribute("data-collapsed", "true"); - // The edge slides to the window edge; grab it only once it has settled there. await expect.poll(async () => (await edge.boundingBox())?.x).toBe(0); const box = await edge.boundingBox(); @@ -75,20 +79,47 @@ test("+ opens the form, then an empty chat; sidebar collapses", async ({ page }, await captureScreenshot(page, testInfo, "bots-sidebar-expanded"); }); -test("plus picker can create a Private computer bot", async ({ page }, testInfo) => { +test("new bot skips the old focus card", async ({ page }) => { + const stamp = Date.now(); + await signup(page, `focus-gone-${stamp}@rakazo.test`, "password12", "Focus Gone"); + await completeOnboarding(page); + + await createBotFromPicker(page, { description: "Keep my calendar clear." }); + await expect(page.getByPlaceholder("Message New Bot")).toBeVisible(); + await expect(page.getByText("What do you want me on first?", { exact: true })).toHaveCount(0); + await expect(page.getByTestId("suggestion-chips")).toBeVisible(); +}); + +test("Runs on appears only when Claude Code is ready", async ({ page }) => { const stamp = Date.now(); - await signup(page, `new-bot-private-${stamp}@rakazo.test`, "password12", "New Bot Private"); + await signup(page, `runs-on-${stamp}@rakazo.test`, "password12", "Runs On"); await completeOnboarding(page); await page.goto("/app"); await page.waitForURL(/\/app\/[^/]+$/); - await createBotFromPicker(page, { computerMode: "dedicated" }); - await expect(page.getByPlaceholder("Message New Bot")).toBeVisible(); - await captureScreenshot(page, testInfo, "create-private-computer-bot"); + await openNewBot(page); + await expect(page.getByTestId("create-bot-runs-on")).toHaveCount(0); + await page.getByRole("button", { name: "Cancel new bot" }).click(); - const botId = page.url().split("/").pop()!; - const bots = await rpc>(page, "bots/list", {}); - expect(bots.find((bot) => bot.id === botId)?.computerMode).toBe("dedicated"); + await page.route("**/rpc/agent/status", (route) => + route.fulfill({ + json: { + json: { + agent: "claude-code", + installed: true, + version: "1.0.0", + loggedIn: true, + platform: "darwin", + chatgpt: true, + }, + }, + }), + ); + await openNewBot(page); + const form = page.getByTestId("create-bot-form"); + await expect(form.getByTestId("create-bot-runs-on")).toBeVisible(); + await expect(form.getByTestId("create-bot-chatgpt")).toBeVisible(); + await expect(form.getByTestId("create-bot-claude")).toBeVisible(); }); test("second bot from plus opens create form before persist", async ({ page }, testInfo) => { @@ -102,10 +133,7 @@ test("second bot from plus opens create form before persist", async ({ page }, t const form = page.getByTestId("create-bot-form"); await expect(form).toBeVisible(); await form.locator("label:has-text('Name') input").fill("Researcher"); - await form.locator("label:has-text('Title') input").fill("Finds sources"); - await form - .locator("label:has-text('What this bot is for') textarea") - .fill("Briefs from the web."); + await form.locator("label:has-text('What should it do?') textarea").fill("Briefs from the web."); await captureScreenshot(page, testInfo, "second-bot-create-form"); const create = page.waitForResponse( diff --git a/apps/web/src/pages/Shell.tsx b/apps/web/src/pages/Shell.tsx index eb5e9fd4..6114f0a3 100644 --- a/apps/web/src/pages/Shell.tsx +++ b/apps/web/src/pages/Shell.tsx @@ -28,7 +28,6 @@ import { canReactToThreadMessage, MESSAGE_REACTIONS, type MessageReaction, - normalizeCreateBotProfile, } from "@milo/contracts"; import { attachmentsForThread, @@ -2390,11 +2389,16 @@ export function ShellPage({ view }: { view?: ShellView } = {}) { } async function createBot(input: CreateBotInputDraft) { + const usesClaude = input.modelProvider === "claude"; const bot = await rpc.bots.create({ - ...normalizeCreateBotProfile(input), + name: input.name, + title: input.title, + description: input.description, + instructions: input.instructions || input.description, notifyOnFinish: true, color: input.color, - computerMode: input.computerMode, + // ChatGPT is the default runtime path; only Claude needs an explicit override. + ...(usesClaude ? { modelProvider: "claude-code", modelId: "sonnet" } : {}), }); setBots((current) => current.some((item) => item.id === bot.id) ? current : [bot, ...current], diff --git a/apps/web/src/pages/shell/create-bot-dialog.tsx b/apps/web/src/pages/shell/create-bot-dialog.tsx index 3b59d8f9..970ab815 100644 --- a/apps/web/src/pages/shell/create-bot-dialog.tsx +++ b/apps/web/src/pages/shell/create-bot-dialog.tsx @@ -1,10 +1,7 @@ import { Trans, useLingui } from "@lingui/react/macro"; -import type { ComputerMode } from "@milo/contracts"; -import { - BOT_DESCRIPTION_MAX_LENGTH, - BOT_NAME_MAX_LENGTH, - BOT_TITLE_MAX_LENGTH, -} from "@milo/contracts"; +import type { AgentStatus } from "@milo/contracts"; +import { BOT_DESCRIPTION_MAX_LENGTH, BOT_NAME_MAX_LENGTH } from "@milo/contracts"; +import { BOT_PALETTE_COLORS } from "@milo/core"; import { BotAvatar, Button, @@ -17,24 +14,33 @@ import { Textarea, } from "@milo/ui-web"; import { X } from "lucide-react"; -import { useId, useState } from "react"; +import { useEffect, useId, useState } from "react"; import { BotColorChoices, BotShapeChoices } from "../../components/BotAvatarChoices"; +import { Shimmer } from "../../components/ai/primitives"; import { SegmentedControl } from "../../components/SegmentedControl"; import { createBotStarters } from "../../lib/create-bot-starters"; +import { rpc } from "../../lib/rpc"; + +export type CreateBotProvider = "chatgpt" | "claude"; export type CreateBotInputDraft = { name: string; title: string; description: string; + instructions: string; color: string; - computerMode: ComputerMode; + modelProvider: CreateBotProvider; }; const labelClass = "flex flex-col gap-1.5 text-small font-medium text-muted-foreground"; +function claudeReady(status: AgentStatus | null): boolean { + return Boolean(status?.installed && status.loggedIn); +} + /** - * New bot: a live avatar preview beside the form. Starter chips fill the form with - * client-side presets; nothing about them is stored. + * New bot: name, look, optional Runs on, and what it should do. Starter chips + * prefill the form; Create refines then persists. */ export function CreateBotDialog({ open, @@ -50,26 +56,58 @@ export function CreateBotDialog({ const starters = createBotStarters(); const [starter, setStarter] = useState(null); const [name, setName] = useState(""); - const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [shapeIndex, setShapeIndex] = useState(0); - const [color, setColor] = useState(starters[0]!.color); - const [computerMode, setComputerMode] = useState("team"); + const [color, setColor] = useState(BOT_PALETTE_COLORS[0] ?? starters[0]!.color); + const [provider, setProvider] = useState("chatgpt"); + const [agentStatus, setAgentStatus] = useState(null); const [submitting, setSubmitting] = useState(false); const [error, setError] = useState(null); const avatar = `${color}::shape_${shapeIndex}`; + const showRunsOn = claudeReady(agentStatus); + + useEffect(() => { + if (!open) return; + let active = true; + void rpc.agent + .status() + .then((status) => { + if (active) setAgentStatus(status); + }) + .catch(() => { + if (active) setAgentStatus(null); + }); + return () => { + active = false; + }; + }, [open]); async function handleSubmit() { if (!name.trim() || submitting) return; setError(null); setSubmitting(true); + const trimmedName = name.trim(); + const trimmedDescription = description.trim(); try { + let title = ""; + let instructions = trimmedDescription; + try { + const refined = await rpc.bots.refine({ + name: trimmedName, + description: trimmedDescription, + }); + title = refined.title; + instructions = refined.instructions; + } catch { + // Create still works with the raw description when refine fails. + } await onCreate({ - name: name.trim(), - title: title.trim(), - description: description.trim(), + name: trimmedName, + title, + description: trimmedDescription, + instructions, color: avatar, - computerMode, + modelProvider: showRunsOn ? provider : "chatgpt", }); } catch (err) { setError(err instanceof Error ? err.message : t`Could not create bot`); @@ -92,9 +130,6 @@ export function CreateBotDialog({ {name.trim() || t`New bot`} - {title.trim() ? ( - {title} - ) : null}
{ setStarter(item.id); setName(item.name); - setTitle(item.title); setDescription(item.description); setShapeIndex(item.shapeIndex); setColor(item.color); @@ -150,30 +184,18 @@ export function CreateBotDialog({

) : null} -
- - -
+