Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat: require explicit models for OpenCode bots

Gusa9f97900c40d
diff --git a/src/shared/src/community/bot-model.ts b/src/shared/src/community/bot-model.ts
index 7a6559853..25b8877f2 100644
--- a/src/shared/src/community/bot-model.ts
+++ b/src/shared/src/community/bot-model.ts
@@ -14,6 +14,10 @@
import type { ModelConfig } from "../runtime-config";
+export function requiresExplicitModel(runtime: string | null | undefined): boolean {
+ return runtime === "opencode";
+}
+
/** Select sentinel for "Default (the runtime's own default)". */
export const MODEL_SELECT_DEFAULT = "__default__";
/** Select sentinel for "Custom…" (reveals a free-text input). */
diff --git a/src/shared/src/index.ts b/src/shared/src/index.ts
index ba9c433a5..25c6f6ea4 100644
--- a/src/shared/src/index.ts
+++ b/src/shared/src/index.ts
@@ -532,6 +532,7 @@ export { resolveReasoningEffort } from "./community/bot-reasoning-effort";
export {
MODEL_SELECT_DEFAULT,
MODEL_SELECT_CUSTOM,
+ requiresExplicitModel,
resolveModelConfig,
formatModelLabel,
modelSelectState,
diff --git a/src/web/src/app/api/community/bots/[id]/route.test.ts b/src/web/src/app/api/community/bots/[id]/route.test.ts
index 98f3f4ea6..c2b05ab1f 100644
--- a/src/web/src/app/api/community/bots/[id]/route.test.ts
+++ b/src/web/src/app/api/community/bots/[id]/route.test.ts
@@ -184,6 +184,41 @@ describe("PATCH /api/community/bots/[id]", () => {
)
})
+ it.each([
+ { storedRuntime: "opencode", storedModel: null, body: { name: "New" } },
+ { storedRuntime: "opencode", storedModel: "provider/old", body: { model: null } },
+ { storedRuntime: "claude", storedModel: "opus", body: { runtime: "opencode" } },
+ { storedRuntime: "claude", storedModel: "opus", body: { runtime: "opencode", model: null } },
+ ])("rejects an effective OpenCode configuration without a model: %j", async ({ storedRuntime, storedModel, body }) => {
+ mockGetBotOwnedBy.mockResolvedValue({ id: "b1", runtime: storedRuntime, modelName: storedModel })
+ const res = await PATCH(patchReq(body), ctx)
+ expect(res.status).toBe(400)
+ expect(mockUpdateBot).not.toHaveBeenCalled()
+ expect(mockUpdateBotRuntimeConfig).not.toHaveBeenCalled()
+ expect(mockPushBotEventToMachine).not.toHaveBeenCalled()
+ expect(mockPushAgentModelSwitchToMachine).not.toHaveBeenCalled()
+ expect(mockPushAgentProviderSwitchToMachine).not.toHaveBeenCalled()
+ })
+
+ it("preserves a named OpenCode model on a profile-only edit without restarting", async () => {
+ mockGetBotOwnedBy.mockResolvedValue({ id: "b1", name: "Old", runtime: "opencode", modelName: "provider/custom" })
+ const res = await PATCH(patchReq({ description: "Updated" }), ctx)
+ expect(res.status).toBe(200)
+ expect((await res.json()).bot.modelName).toBe("provider/custom")
+ expect(mockUpdateBot).toHaveBeenCalled()
+ expect(mockUpdateBotRuntimeConfig).not.toHaveBeenCalled()
+ expect(mockPushAgentModelSwitchToMachine).not.toHaveBeenCalled()
+ })
+
+ it("switches to OpenCode with an explicit custom model absent from its catalog", async () => {
+ mockGetMachineForOwner.mockResolvedValue({ id: "mac1", availableRuntimes: [{ id: "opencode", status: "healthy" }] })
+ mockPushAgentProviderSwitchToMachine.mockResolvedValue({ sent: 1, deliveryError: false })
+ const res = await PATCH(patchReq({ runtime: "opencode", model: "provider/custom" }), ctx)
+ expect(res.status).toBe(200)
+ expect(mockUpdateBotRuntimeConfig).toHaveBeenCalledWith(expect.anything(), "b1", "u1", expect.objectContaining({ runtime: "opencode", modelName: "provider/custom" }))
+ expect(mockPushAgentProviderSwitchToMachine).toHaveBeenCalledWith(expect.anything(), "mac1", expect.objectContaining({ config: expect.objectContaining({ model: { kind: "named", name: "provider/custom" } }) }))
+ })
+
it("persists an inactive bot profile change without re-adding it to the daemon roster", async () => {
mockGetBotOwnedBy.mockResolvedValue({
id: "b1", name: "Old", description: "old desc", machineId: "mac1", ownerUserId: "u1",
diff --git a/src/web/src/app/api/community/bots/[id]/route.ts b/src/web/src/app/api/community/bots/[id]/route.ts
index 7c118d6f8..b9a40e2fd 100644
--- a/src/web/src/app/api/community/bots/[id]/route.ts
+++ b/src/web/src/app/api/community/bots/[id]/route.ts
@@ -16,6 +16,7 @@ import {
formatHandle,
createLogger,
resolveReasoningEffort,
+ requiresExplicitModel,
} from "@alook/shared"
import { getDb } from "@/lib/db"
import { withAuth } from "@/lib/middleware/auth"
@@ -77,6 +78,10 @@ export const PATCH = withAuth(async (req: NextRequest, ctx) => {
? null
: undefined
const modelChanged = nextModel !== undefined && nextModel !== (before.modelName ?? null)
+ const storedModel = nextModel !== undefined ? nextModel : (before.modelName ?? null)
+ if (requiresExplicitModel(targetRuntime) && !storedModel?.trim()) {
+ return writeError("Choose a model before saving", 400)
+ }
const restartChanged = runtimeChanged || modelChanged
const configRequested = restartChanged || "reasoningEffort" in body
let runtimeDescriptor: import("@alook/shared").CommunityMachineRuntime | null = null
@@ -98,7 +103,6 @@ export const PATCH = withAuth(async (req: NextRequest, ctx) => {
return writeError(`runtime ${targetRuntime} is currently unavailable on this machine`, 400)
}
}
- const storedModel = nextModel !== undefined ? nextModel : (before.modelName ?? null)
const requestedEffort = "reasoningEffort" in body
? (body.reasoningEffort ?? null)
: before.reasoningEffort
diff --git a/src/web/src/app/api/community/bots/route.test.ts b/src/web/src/app/api/community/bots/route.test.ts
index 06bd86575..7491fea9c 100644
--- a/src/web/src/app/api/community/bots/route.test.ts
+++ b/src/web/src/app/api/community/bots/route.test.ts
@@ -149,6 +149,21 @@ describe("POST /api/community/bots — model", () => {
)
})
+ it.each([undefined, null, "", " "])("rejects OpenCode model %s before creating or dispatching", async (model) => {
+ const res = await POST(postReq(base(model, "opencode")), ctx)
+ expect(res.status).toBe(400)
+ expect(mockCreateBot).not.toHaveBeenCalled()
+ expect(mockPushBotEventToMachine).not.toHaveBeenCalled()
+ })
+
+ it("creates OpenCode with an explicit custom model absent from its catalog", async () => {
+ mockGetMachineForOwner.mockResolvedValue({ id: "mac1", availableRuntimes: [{ id: "opencode", status: "healthy" }] })
+ const res = await POST(postReq(base("provider/custom", "opencode")), ctx)
+ expect(res.status).toBe(201)
+ expect((await res.json()).bot.modelName).toBe("provider/custom")
+ expect(mockCreateBot).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ modelName: "provider/custom" }))
+ })
+
it("keeps same-owner sibling auto-friendship after removing server audit writes", async () => {
mockListBotsForOwner.mockResolvedValue([{ id: "b1" }, { id: "b2" }])
diff --git a/src/web/src/app/api/community/bots/route.ts b/src/web/src/app/api/community/bots/route.ts
index 504aa2743..7140d900f 100644
--- a/src/web/src/app/api/community/bots/route.ts
+++ b/src/web/src/app/api/community/bots/route.ts
@@ -8,6 +8,7 @@ import {
utcDayKey,
utcDayKeyDaysAgo,
resolveReasoningEffort,
+ requiresExplicitModel,
} from "@alook/shared"
import { getDb } from "@/lib/db"
import { withAuth } from "@/lib/middleware/auth"
@@ -92,6 +93,9 @@ export const GET = withAuth(async (_req, ctx) => {
export const POST = withAuth(async (req: NextRequest, ctx) => {
const [body, err] = await parseBody(req, CommunityBotCreateRequestSchema)
if (err) return err
+ if (requiresExplicitModel(body.runtime) && !body.model?.trim()) {
+ return writeError("Choose a model before saving", 400)
+ }
const db = getDb(ctx.env.DB)
diff --git a/src/web/src/components/community/bots/bot-form-validation.ts b/src/web/src/components/community/bots/bot-form-validation.ts
index 60f68984f..eb5c32166 100644
--- a/src/web/src/components/community/bots/bot-form-validation.ts
+++ b/src/web/src/components/community/bots/bot-form-validation.ts
@@ -1,19 +1,24 @@
+import { requiresExplicitModel } from "@alook/shared"
+
export interface BotCreateRequiredFields {
name: string
machineId: string
runtime: string
+ model: string | null
}
export interface BotCreateFieldErrors {
name?: string
machineId?: string
runtime?: string
+ model?: string
}
export function validateBotCreateFields({
name,
machineId,
runtime,
+ model,
}: BotCreateRequiredFields): BotCreateFieldErrors {
const errors: BotCreateFieldErrors = {}
@@ -26,21 +31,17 @@ export function validateBotCreateFields({
if (!runtime) {
errors.runtime = "Pick a runtime"
}
+ errors.model = validateBotModel(model, runtime)
return errors
}
export function hasBotCreateFieldErrors(errors: BotCreateFieldErrors): boolean {
- return Boolean(errors.name || errors.machineId || errors.runtime)
+ return Boolean(errors.name || errors.machineId || errors.runtime || errors.model)
}
-/**
- * Validate a picked model value (the `string | null` the ModelField emits). A
- * `Custom…` selection that was left empty resolves to `null` (Default), which
- * is valid; the only failure is a name over the server's 100-char cap. Returns
- * an error message, or undefined when the model is acceptable.
- */
-export function validateBotModel(model: string | null): string | undefined {
+export function validateBotModel(model: string | null, runtime?: string): string | undefined {
+ if (requiresExplicitModel(runtime) && !model?.trim()) return "Choose a model before saving"
if (model === null) return undefined
if (model.trim().length === 0) return "Enter a model name"
if (model.length > 100) return "Model name must be 100 characters or fewer"
diff --git a/src/web/src/components/community/bots/bot-runtime-fields.tsx b/src/web/src/components/community/bots/bot-runtime-fields.tsx
index 09ca708e3..3e9ecddba 100644
--- a/src/web/src/components/community/bots/bot-runtime-fields.tsx
+++ b/src/web/src/components/community/bots/bot-runtime-fields.tsx
@@ -31,6 +31,7 @@ export function BotRuntimeFields({
runtimeOptionClassName,
modelClassName,
runtimeError,
+ modelError,
disableUnhealthyOptions = false,
}: {
options: BotRuntimeOption[]
@@ -47,6 +48,7 @@ export function BotRuntimeFields({
runtimeOptionClassName?: (runtime: string) => string | undefined
modelClassName?: string
runtimeError?: string
+ modelError?: string
disableUnhealthyOptions?: boolean
}) {
const selectedRuntime = options.find((option) => option.id === runtime) ?? null
@@ -114,7 +116,7 @@ export function BotRuntimeFields({
</div>
{runtime ? (
<div data-motion-target={modelMotionTarget} className={cn("flex flex-col gap-4", modelClassName)}>
- <ModelField runtime={selectedRuntime} value={model} onChange={onModelChange} />
+ <ModelField runtime={selectedRuntime} value={model} onChange={onModelChange} error={modelError} />
<ReasoningEffortField
runtime={selectedRuntime}
model={model}
diff --git a/src/web/src/components/community/bots/create-bot-sheet.dom.test.ts b/src/web/src/components/community/bots/create-bot-sheet.dom.test.ts
index be83141e7..68b95b6c2 100644
--- a/src/web/src/components/community/bots/create-bot-sheet.dom.test.ts
+++ b/src/web/src/components/community/bots/create-bot-sheet.dom.test.ts
@@ -11,6 +11,15 @@ import {
firstOnlineMachineId,
} from "./create-bot-sheet"
import type { CommunityMachineSummary, RuntimeReasoningCatalog } from "@alook/shared"
+import { hasBotCreateFieldErrors, validateBotCreateFields } from "./bot-form-validation"
+
+it("guards programmatic create submissions while preserving other backend defaults", () => {
+ for (const [runtime, model, invalid] of [["opencode", null, true], ["opencode", " ", true], ["opencode", "provider/custom", false], ["codex", null, false]] as const) {
+ const errors = validateBotCreateFields({ name: "Bot", machineId: "mac", runtime, model })
+ expect(hasBotCreateFieldErrors(errors)).toBe(invalid)
+ expect(errors.model).toBe(invalid ? "Choose a model before saving" : undefined)
+ }
+})
function machine(over: Partial<CommunityMachineSummary>): CommunityMachineSummary {
return {
@@ -179,7 +188,7 @@ function checkedValue(renderer: ReturnType<typeof rtlRender>, name: string): str
return radios(renderer, name).find((r) => r.checked)?.value ?? null
}
-function render(props: { avatarSeed?: string } = {}) {
+function render(props: { avatarSeed?: string; guided?: boolean } = {}) {
return rtlRender(
React.createElement(CreateBotSheet, { open: true, onOpenChange: vi.fn(), ...props }),
)
@@ -201,6 +210,24 @@ describe("CreateBotSheet — auto-select defaults", () => {
expect(botFormFieldsRenders.at(-1)?.avatarDraft.image).toBe("avatar:beam:guide-face-7")
})
+ it.each([false, true])("requires an explicit OpenCode model, including guided creation=%s", async (guided) => {
+ useMachinesMock.mockReturnValue({ machines: [machine({ id: "mac", availableRuntimes: [{
+ id: "opencode", status: "healthy", reasoning: {
+ updateMode: "unsupported", defaultModelId: "provider/picked", models: [{ id: "provider/picked", supportedReasoningEfforts: [] }],
+ },
+ }] })] })
+ const renderer = render({ guided })
+ const create = renderer.getByRole("button", { name: "Create bot" })
+ expect(renderer.getByTestId("set-model")).toBeInTheDocument()
+ expect(create).toBeDisabled()
+ fireEvent.click(create)
+ expect(createMutateAsync).not.toHaveBeenCalled()
+ fireEvent.click(renderer.getByTestId("set-model"))
+ expect(create).toBeEnabled()
+ await act(async () => { fireEvent.click(create); await Promise.resolve() })
+ expect(createMutateAsync).toHaveBeenCalledWith(expect.objectContaining({ runtime: "opencode", model: "provider/picked" }))
+ })
+
it("pre-checks the machine and runtime with one online machine + one healthy runtime", () => {
const selectedMachine = machine({
id: "mac",
diff --git a/src/web/src/components/community/bots/create-bot-sheet.tsx b/src/web/src/components/community/bots/create-bot-sheet.tsx
index 54ca4af06..b4eee7e99 100644
--- a/src/web/src/components/community/bots/create-bot-sheet.tsx
+++ b/src/web/src/components/community/bots/create-bot-sheet.tsx
@@ -11,6 +11,7 @@ import { toast } from "sonner"
import { toastApiError } from "@/lib/api/client"
import {
isPresenceOnline,
+ requiresExplicitModel,
type CommunityMachineSummary,
type ReasoningEffort,
} from "@alook/shared"
@@ -109,6 +110,7 @@ export function CreateBotSheet({
const runtimeOptions = useMemo(() => normalizeRuntimes(selectedMachine), [selectedMachine])
const singleTechnicalDefault =
guided &&
+ !requiresExplicitModel(runtime) &&
Boolean(selectedMachine && runtime) &&
machines.filter((machine) => isPresenceOnline(machine.status)).length === 1 &&
runtimeOptions.filter((option) => !option.unhealthy).length === 1
@@ -170,7 +172,7 @@ export function CreateBotSheet({
// so drop any selected model back to Default.
setModel(null)
setReasoningEffort(null)
- setFieldErrors((prev) => ({ ...prev, machineId: undefined }))
+ setFieldErrors((prev) => ({ ...prev, machineId: undefined, model: undefined }))
}
function selectRuntime(id: string) {
@@ -182,7 +184,7 @@ export function CreateBotSheet({
if (["create-command", "avatar-command"].some((kind) => client.isMutating({ mutationKey: [...communityKeys.bots(), kind], exact: true, predicate: (mutation) => (mutation.state.variables as { input?: { assertActive?: { signal: AbortSignal } } }).input?.assertActive?.signal === source.signal }) > 0)) return
const assert = source.capture()
assert()
- const nextErrors = validateBotCreateFields({ name, machineId, runtime })
+ const nextErrors = validateBotCreateFields({ name, machineId, runtime, model })
setFieldErrors(nextErrors)
if (hasBotCreateFieldErrors(nextErrors)) return
@@ -236,7 +238,7 @@ export function CreateBotSheet({
<Button variant="outline" onClick={requestClose}>
Cancel
</Button>
- <Button onClick={submit} disabled={create.isPending || uploadBotAvatar.isPending}>
+ <Button onClick={submit} disabled={create.isPending || uploadBotAvatar.isPending || (requiresExplicitModel(runtime) && !model?.trim())}>
{create.isPending ? "Creating…" : "Create bot"}
</Button>
</>
@@ -332,10 +334,11 @@ export function CreateBotSheet({
daemonVersion={selectedMachine?.daemonVersion}
reasoningEffort={reasoningEffort}
onRuntimeChange={selectRuntime}
- onModelChange={setModel}
+ onModelChange={(next) => { setModel(next); setFieldErrors((prev) => ({ ...prev, model: undefined })) }}
onReasoningEffortChange={setReasoningEffort}
radioName="bot-runtime"
runtimeError={fieldErrors.runtime}
+ modelError={fieldErrors.model}
disableUnhealthyOptions
/>
</div>
diff --git a/src/web/src/components/community/bots/edit-bot-sheet.dom.test.ts b/src/web/src/components/community/bots/edit-bot-sheet.dom.test.ts
index a91adae42..59029566e 100644
--- a/src/web/src/components/community/bots/edit-bot-sheet.dom.test.ts
+++ b/src/web/src/components/community/bots/edit-bot-sheet.dom.test.ts
@@ -255,6 +255,36 @@ describe("EditBotSheet — model switch toast (online-only)", () => {
expect(toastSuccess.mock.calls.join(" ")).not.toMatch(/offline|next wake|applies when/i)
})
+ it("blocks an unconfigured OpenCode bot until a model is explicitly picked", async () => {
+ updateMutateAsync.mockResolvedValue({ bot: { ...BOT, runtime: "opencode" } })
+ const renderer = renderSheet({ ...BOT, runtime: "opencode" })
+ expect(saveButton(renderer)).toBeDisabled()
+ fireEvent.click(saveButton(renderer))
+ expect(updateMutateAsync).not.toHaveBeenCalled()
+ fireEvent.click(renderer.getByTestId("set-model"))
+ expect(saveButton(renderer)).toBeEnabled()
+ act(() => { fireEvent.click(saveButton(renderer)) })
+ await flush()
+ expect(updateMutateAsync).toHaveBeenCalledWith(expect.objectContaining({ model: "claude-sonnet-4-6" }))
+ })
+
+ it("requires a fresh model before confirming a switch into OpenCode and restores Default on switching back", () => {
+ useMachinesMock.mockReturnValue({ machines: [{ id: "mac1", availableRuntimes: [
+ { id: "claude", status: "healthy" }, { id: "opencode", status: "healthy" },
+ ] }] })
+ const renderer = renderSheet({ ...BOT, modelName: "opus" })
+ pickRuntime(renderer, "opencode")
+ expect(saveButton(renderer)).toBeDisabled()
+ fireEvent.click(saveButton(renderer))
+ expect(renderer.queryByTestId("provider-confirm")).not.toBeInTheDocument()
+ expect(updateMutateAsync).not.toHaveBeenCalled()
+ fireEvent.click(renderer.getByTestId("set-model"))
+ fireEvent.click(saveButton(renderer))
+ expect(renderer.getByTestId("provider-confirm")).toBeInTheDocument()
+ pickRuntime(renderer, "claude")
+ expect(saveButton(renderer)).toBeEnabled()
+ })
+
it("PATCH failure → toastApiError, no success toast", async () => {
updateMutateAsync.mockRejectedValue(new Error("Bot offline"))
const renderer = renderSheet()
diff --git a/src/web/src/components/community/bots/edit-bot-sheet.tsx b/src/web/src/components/community/bots/edit-bot-sheet.tsx
index 804fb4fe9..c140109e8 100644
--- a/src/web/src/components/community/bots/edit-bot-sheet.tsx
+++ b/src/web/src/components/community/bots/edit-bot-sheet.tsx
@@ -33,7 +33,7 @@ import { BotRuntimeFields } from "./bot-runtime-fields"
import { validateBotModel } from "./bot-form-validation"
import { uniqueNamesGenerator, names } from "unique-names-generator"
import { normalizeRuntimes } from "./create-bot-sheet"
-import type { ReasoningEffort } from "@alook/shared"
+import { requiresExplicitModel, type ReasoningEffort } from "@alook/shared"
function draftFromBot(bot: BotSummary): AvatarDraft {
if (isPhotoAvatarUrl(bot.image)) return { kind: "photo", file: null, previewUrl: bot.image! }
@@ -117,7 +117,7 @@ const [avatarDraft, setAvatarDraft] = useAtom(useCreateAtom<AvatarDraft>(((): Av
setNameError("Name is required")
return
}
- const modelError = validateBotModel(model)
+ const modelError = validateBotModel(model, runtime)
if (modelError) {
toast.error(modelError)
return
@@ -186,6 +186,11 @@ const [avatarDraft, setAvatarDraft] = useAtom(useCreateAtom<AvatarDraft>(((): Av
setNameError("Name is required")
return
}
+ const modelError = validateBotModel(model, runtime)
+ if (modelError) {
+ toast.error(modelError)
+ return
+ }
if (runtime !== bot.runtime) {
setConfirmProviderSwitch(true)
return
@@ -206,7 +211,7 @@ const [avatarDraft, setAvatarDraft] = useAtom(useCreateAtom<AvatarDraft>(((): Av
<Button variant="outline" onClick={requestClose}>
Cancel
</Button>
- <Button onClick={submit} disabled={update.isPending || uploadBotAvatar.isPending || !bot}>
+ <Button onClick={submit} disabled={update.isPending || uploadBotAvatar.isPending || !bot || (requiresExplicitModel(runtime) && !model?.trim())}>
{update.isPending ? "Saving…" : "Save"}
</Button>
</>
diff --git a/src/web/src/components/community/bots/model-field-select.dom.test.tsx b/src/web/src/components/community/bots/model-field-select.dom.test.tsx
index a14e39da0..341bec43f 100644
--- a/src/web/src/components/community/bots/model-field-select.dom.test.tsx
+++ b/src/web/src/components/community/bots/model-field-select.dom.test.tsx
@@ -16,6 +16,27 @@ const runtime = {
}
describe("ModelField with the real Select", () => {
+ it.each([true, false])("requires OpenCode selection with a catalog=%s and keeps empty Custom editable", async (catalog) => {
+ const selectedRuntime = { ...runtime, id: "opencode", reasoning: catalog ? runtime.reasoning : undefined }
+ function Controlled() {
+ const [value, setValue] = React.useState<string | null>(null)
+ return <ModelField runtime={selectedRuntime} value={value} onChange={setValue} />
+ }
+ render(<Controlled />)
+ const trigger = screen.getByTestId("bot-model-select")
+ expect(trigger).toHaveTextContent("Select a model")
+ expect(trigger).toHaveAttribute("aria-required", "true")
+ await act(async () => { fireEvent.click(trigger) })
+ expect(screen.queryByRole("option", { name: /Default/ })).not.toBeInTheDocument()
+ await act(async () => { fireEvent.click(screen.getByRole("option", { name: "Custom…" })) })
+ const input = screen.getByRole("textbox", { name: "Custom model" })
+ await act(async () => { fireEvent.change(input, { target: { value: "provider/custom" } }) })
+ expect(input).toHaveValue("provider/custom")
+ await act(async () => { fireEvent.change(input, { target: { value: " " } }) })
+ expect(input).toBeInTheDocument()
+ expect(trigger).toHaveTextContent("Custom…")
+ })
+
it("filters an edited model without changing its selection", async () => {
const onChange = vi.fn()
render(<ModelField runtime={runtime} value="gemini-3.1-pro-high" onChange={onChange} />)
diff --git a/src/web/src/components/community/bots/model-field.dom.test.ts b/src/web/src/components/community/bots/model-field.dom.test.ts
index 780aad8a2..3b79744d3 100644
--- a/src/web/src/components/community/bots/model-field.dom.test.ts
+++ b/src/web/src/components/community/bots/model-field.dom.test.ts
@@ -253,17 +253,17 @@ describe("ModelField", () => {
const models = Array.from({ length: 598 }, (_, index) => `provider/model-${index}`)
const onChange = vi.fn()
const renderer = render({ runtime: runtime("opencode", models), value: null, onChange })
- expect(itemValues(renderer)).toEqual(["__default__", "__custom__", ...models])
+ expect(itemValues(renderer)).toEqual(["__custom__", ...models])
const filter = renderer.getByTestId("bot-model-filter-input")
fireEvent.change(filter, { target: { value: "model-597" } })
- expect(itemValues(renderer)).toEqual(["__default__", "__custom__", models[597]])
+ expect(itemValues(renderer)).toEqual(["__custom__", models[597]])
act(() => selectCalls.at(-1)!.onValueChange(models[597]))
expect(onChange).toHaveBeenLastCalledWith(models[597])
fireEvent.change(filter, { target: { value: "not-in-catalog" } })
- expect(itemValues(renderer)).toEqual(["__default__", "__custom__"])
+ expect(itemValues(renderer)).toEqual(["__custom__"])
expect(renderer.getByRole("status")).toHaveTextContent("No matching models")
})
diff --git a/src/web/src/components/community/bots/model-field.tsx b/src/web/src/components/community/bots/model-field.tsx
index cfc6198d2..38a3075b8 100644
--- a/src/web/src/components/community/bots/model-field.tsx
+++ b/src/web/src/components/community/bots/model-field.tsx
@@ -1,12 +1,13 @@
"use client"
import { useAtom, useCreateAtom } from "@tanstack/react-store";
-import { useEffect, useMemo } from "react"
+import { useEffect, useId, useMemo } from "react"
import {
modelSelectState,
modelNameFromSelect,
MODEL_SELECT_DEFAULT,
MODEL_SELECT_CUSTOM,
+ requiresExplicitModel,
} from "@alook/shared"
import type { CommunityMachineRuntime } from "@alook/shared"
import { Label } from "@/components/ui/label"
@@ -20,10 +21,6 @@ import {
import { BotSelectMenuContent, BotSelectMenuItem } from "./bot-select-menu"
/**
- * Per-bot model picker. A `Select` over `[Default, Custom…, ...catalog]` plus a
- * conditionally-rendered custom text input. All model-name ↔ Select translation
- * goes through the shared `bot-model` helpers — never ad-hoc string logic.
- *
* The picker keeps its OWN Select/custom-text state rather than deriving purely
* from `value`, because "Custom… selected with an empty name" and "Default" both
* map to a `null` stored value — only local state can tell them apart, so the
@@ -37,12 +34,16 @@ export function ModelField({
value,
onChange,
disabled,
+ error,
}: {
runtime: Pick<CommunityMachineRuntime, "id" | "reasoning"> | null
value: string | null
onChange: (v: string | null) => void
disabled?: boolean
+ error?: string
}) {
+ const hintId = useId()
+ const required = requiresExplicitModel(runtime?.id)
const models = useMemo(
() => runtime?.reasoning?.models
.filter((model) => model.id !== MODEL_SELECT_DEFAULT && model.id !== MODEL_SELECT_CUSTOM) ?? [],
@@ -70,6 +71,7 @@ export function ModelField({
const isCustom = selectValue === MODEL_SELECT_CUSTOM
const defaultLabel = runtime ? `Default (${runtime.id}'s own default)` : "Default"
+ const placeholder = required ? "Select a model" : defaultLabel
const normalizedFilter = filterQuery.trim().toLowerCase()
const filteredModels = normalizedFilter
? models.filter((model) => model.id.toLowerCase().includes(normalizedFilter)
@@ -81,7 +83,7 @@ export function ModelField({
// (value === label) but leaks the `__default__` / `__custom__` sentinels.
// Same pattern as runtime-select.tsx.
const items = [
- { value: MODEL_SELECT_DEFAULT, label: defaultLabel },
+ ...(!required ? [{ value: MODEL_SELECT_DEFAULT, label: defaultLabel }] : []),
{ value: MODEL_SELECT_CUSTOM, label: "Custom…" },
...models.map((model) => ({
value: model.id,
@@ -93,10 +95,10 @@ export function ModelField({
return (
<div className="flex flex-col gap-2">
- <Label className="text-xs text-muted-foreground">Model</Label>
+ <Label className="text-xs text-muted-foreground">{required ? "Model (required)" : "Model"}</Label>
<Select
items={items}
- value={selectValue}
+ value={required && selectValue === MODEL_SELECT_DEFAULT ? null : selectValue}
onValueChange={(next: string | null, details) => {
if (details.reason === "none" && normalizedFilter && modelIds.includes(selectValue)) {
details.cancel()
@@ -118,14 +120,18 @@ export function ModelField({
>
<SelectTrigger
data-testid="bot-model-select"
+ aria-label="Model"
+ aria-required={required}
+ aria-describedby={required || error ? hintId : undefined}
+ aria-invalid={Boolean(error)}
className="w-full data-[size=default]:h-11 sm:data-[size=default]:h-8"
>
- <SelectValue placeholder={defaultLabel} />
+ <SelectValue placeholder={placeholder} />
</SelectTrigger>
<BotSelectMenuContent className="overflow-y-hidden">
{modelIds.length === 0 ? (
<>
- <BotSelectMenuItem value={MODEL_SELECT_DEFAULT}>{defaultLabel}</BotSelectMenuItem>
+ {!required && <BotSelectMenuItem value={MODEL_SELECT_DEFAULT}>{defaultLabel}</BotSelectMenuItem>}
<BotSelectMenuItem value={MODEL_SELECT_CUSTOM}>Custom…</BotSelectMenuItem>
</>
) : (
@@ -158,7 +164,7 @@ export function ModelField({
className="h-10 font-mono sm:h-8"
/>
</div>
- <BotSelectMenuItem value={MODEL_SELECT_DEFAULT}>{defaultLabel}</BotSelectMenuItem>
+ {!required && <BotSelectMenuItem value={MODEL_SELECT_DEFAULT}>{defaultLabel}</BotSelectMenuItem>}
<BotSelectMenuItem value={MODEL_SELECT_CUSTOM}>Custom…</BotSelectMenuItem>
<SelectSeparator className="mx-1 my-1.5" />
</div>
@@ -193,6 +199,10 @@ export function ModelField({
{isCustom && (
<Input
data-testid="bot-model-custom-input"
+ aria-label="Custom model"
+ aria-required={required}
+ aria-describedby={required || error ? hintId : undefined}
+ aria-invalid={Boolean(error)}
value={customName}
disabled={disabled}
placeholder="e.g. provider/model-id"
@@ -205,6 +215,7 @@ export function ModelField({
className="h-11 font-mono sm:h-8"
/>
)}
+ {(required || error) && <p id={hintId} role={error ? "alert" : undefined} className={error ? "text-xs text-destructive" : "text-xs text-muted-foreground"}>{error ?? "Choose a model before saving."}</p>}
</div>
)
}
diff --git a/src/web/src/components/community/onboarding/community-onboarding-form.navigation.dom.test.ts b/src/web/src/components/community/onboarding/community-onboarding-form.navigation.dom.test.ts
index 8295a8057..90b951982 100644
--- a/src/web/src/components/community/onboarding/community-onboarding-form.navigation.dom.test.ts
+++ b/src/web/src/components/community/onboarding/community-onboarding-form.navigation.dom.test.ts
@@ -50,23 +50,27 @@ vi.mock("./initialize-community-onboarding", () => ({
initializeCommunityOnboarding: (...args: unknown[]) => mocks.initialize(...args),
}))
vi.mock("./onboarding-machine-dialog", () => ({
- OnboardingMachineDialog: ({ onChooseAnotherHarness }: {
+ OnboardingMachineDialog: ({ onChooseAnotherHarness, onConnected }: {
onChooseAnotherHarness: () => void
- }) => createElement("button", {
+ onConnected: (id: string) => void
+ }) => createElement("div", {}, createElement("button", {
"data-testid": "recover-harness",
onClick: onChooseAnotherHarness,
- }),
+ }), createElement("button", { onClick: () => onConnected("machine-1") }, "Machine connected")),
}))
vi.mock("./onboarding-select-dialog", () => ({
- OnboardingSelectDialog: ({ value, onValueChange }: {
+ OnboardingSelectDialog: ({ value, onValueChange, onSubmit }: {
value: string
onValueChange: (value: string) => void
- }) => createElement("button", {
+ onSubmit: (value: string) => void
+ }) => createElement("div", {}, createElement("button", {
"data-testid": "select-harness",
"data-value": value,
onClick: () => onValueChange("codex"),
- }),
+ }), createElement("button", { onClick: () => onSubmit("developer") }, "Finish setup")),
}))
+vi.mock("@/hooks/community/use-machines", () => ({ useMachines: () => ({ machines: [] }) }))
+vi.mock("../bots/model-field", () => ({ ModelField: ({ value, onChange }: { value: string | null; onChange: (value: string | null) => void }) => createElement("input", { "aria-label": "Model", value: value ?? "", onChange: (event: React.ChangeEvent<HTMLInputElement>) => onChange(event.target.value || null) }) }))
vi.mock("./onboarding-status-dialog", () => ({
OnboardingStatusDialog: ({ status, onContinue }: {
status: string
@@ -142,4 +146,25 @@ describe("CommunityOnboardingForm room navigation", () => {
rendered.rerender(createElement(CommunityOnboardingForm))
expect(screen.getByTestId("select-harness")).toHaveAttribute("data-value", "")
})
+
+ it("blocks OpenCode setup until a model is chosen and passes it to initialization", async () => {
+ mocks.state = { status: "active", stage: "model", machineId: "machine-1", harness: "opencode" }
+ render(createElement(CommunityOnboardingForm))
+ expect(screen.getByRole("button", { name: "Continue" })).toBeDisabled()
+ fireEvent.click(screen.getByRole("button", { name: "Continue" }))
+ expect(mocks.initialize).not.toHaveBeenCalled()
+ fireEvent.change(screen.getByRole("textbox", { name: "Model" }), { target: { value: "custom/model" } })
+ fireEvent.click(screen.getByRole("button", { name: "Continue" }))
+ expect(mocks.initialize).not.toHaveBeenCalled()
+ fireEvent.click(screen.getByRole("button", { name: "Finish setup" }))
+ await waitFor(() => expect(mocks.initialize).toHaveBeenCalledWith(expect.objectContaining({ runtime: "opencode", model: "custom/model" })))
+ })
+
+ it.each(["codex", "opencode"])("routes a connected %s machine through only its required steps", (harness) => {
+ mocks.state = { status: "active", stage: "machine", harness }
+ render(createElement(CommunityOnboardingForm))
+ fireEvent.click(screen.getByRole("button", { name: "Machine connected" }))
+ expect(owner.runtime.ui.get().onboardingState?.stage).toBe(harness === "opencode" ? "model" : "identity")
+ expect(screen.queryByRole("textbox", { name: "Model" }) !== null).toBe(harness === "opencode")
+ })
})
diff --git a/src/web/src/components/community/onboarding/community-onboarding-form.tsx b/src/web/src/components/community/onboarding/community-onboarding-form.tsx
index 8e0eedbd0..069c00e3e 100644
--- a/src/web/src/components/community/onboarding/community-onboarding-form.tsx
+++ b/src/web/src/components/community/onboarding/community-onboarding-form.tsx
@@ -24,6 +24,9 @@ import { tid } from "@/lib/community/testids"
import { useCurrentUser } from "@/contexts/community/current-user"
import { OnboardingSelectDialog } from "./onboarding-select-dialog"
import { OnboardingStatusDialog } from "./onboarding-status-dialog"
+import { requiresExplicitModel } from "@alook/shared"
+import { useMachines } from "@/hooks/community/use-machines"
+import { OnboardingModelDialog } from "./onboarding-model-dialog"
function harnessLabel(value?: string) {
return ONBOARDING_HARNESSES.find((option) => option.value === value)?.label ?? "your harness"
@@ -35,11 +38,17 @@ export function CommunityOnboardingForm() {
const currentUser = useCurrentUser()
const state = useCommunityOnboarding()
const queryClient = useQueryClient(), origin = useCommunityMutationOrigin()
- const journeyIdentity = JSON.stringify([state?.machineId, state?.harness, state?.identity])
+ const journeyIdentity = JSON.stringify([state?.machineId, state?.harness, state?.identity, state?.model])
const source = useCommunityViewSource(`onboarding:${journeyIdentity}`, state?.stage === "initializing")
const [harness, setHarness] = useAtom(useCreateAtom(""))
const [identity, setIdentity] = useAtom(useCreateAtom(""))
const [customIdentity, setCustomIdentity] = useAtom(useCreateAtom(""))
+ const [model, setModel] = useAtom(useCreateAtom<string | null>(null))
+ const requiredModel = requiresExplicitModel(state?.harness)
+ const totalSteps = requiredModel ? 4 : 3
+ const { machines } = useMachines({ enabled: state?.stage === "model" })
+ const selectedRuntime = machines.find((machine) => machine.id === state?.machineId)?.availableRuntimes.find((runtime) => runtime.id === state?.harness)
+ useEffect(() => { setModel(null) }, [state?.machineId, state?.harness, setModel])
const commandKey = ["community", "onboarding-initialization", journeyIdentity] as const
const pending = useMutationState({ filters: { mutationKey: commandKey, status: "pending" }, select: (mutation) => mutation.mutationId })
const initialization = useMutation({ meta: { observabilityAction: "community.onboarding.initialize" },
@@ -47,7 +56,7 @@ export function CommunityOnboardingForm() {
scope: { id: JSON.stringify(commandKey) },
mutationFn: async ({ token, profileSnapshot, assert, input }: ReturnType<typeof origin.begin> & {
assert: ReturnType<typeof source.capture>
- input: { machineId: string; runtime: string; identity: string; userName: string; userDiscriminator?: string }
+ input: { machineId: string; runtime: string; model?: string | null; identity: string; userName: string; userDiscriminator?: string }
}) => {
assert()
const original = readCommunityOnboardingState(communityRuntime)
@@ -120,7 +129,7 @@ export function CommunityOnboardingForm() {
try {
await mutateInitialization({
...original, assert,
- input: { machineId: state.machineId, runtime: state.harness, identity: state.identity, userName: currentUser.name, userDiscriminator: currentUser.discriminator },
+ input: { machineId: state.machineId, runtime: state.harness, model: state.model, identity: state.identity, userName: currentUser.name, userDiscriminator: currentUser.discriminator },
})
} catch {}
}, [pending.length, state, origin, source, mutateInitialization, currentUser.name, currentUser.discriminator])
@@ -138,7 +147,7 @@ export function CommunityOnboardingForm() {
<OnboardingSelectDialog
open
onOpenChange={() => undefined}
- step={{ current: 1, total: 3 }}
+ step={{ current: 1, total: totalSteps }}
stepLabel="Your harness"
title="Which harness do you already use?"
description="Pick the setup that already runs your bots."
@@ -161,8 +170,9 @@ export function CommunityOnboardingForm() {
open
harness={state.harness ?? ""}
harnessLabel={harnessLabel(state.harness)}
+ totalSteps={totalSteps}
onConnected={(machineId) => {
- advanceCommunityOnboarding(communityRuntime, "machine", "identity", { machineId })
+ advanceCommunityOnboarding(communityRuntime, "machine", requiredModel ? "model" : "identity", { machineId, model: null })
}}
onChooseAnotherHarness={() => {
setHarness("")
@@ -175,12 +185,16 @@ export function CommunityOnboardingForm() {
)
}
+ if (state.stage === "model") {
+ return <OnboardingModelDialog runtime={selectedRuntime ?? { id: state.harness! }} model={model} onModelChange={setModel} onContinue={() => advanceCommunityOnboarding(communityRuntime, "model", "identity", { model })} />
+ }
+
if (state.stage === "identity") {
return (
<OnboardingSelectDialog
open
onOpenChange={() => undefined}
- step={{ current: 3, total: 3 }}
+ step={{ current: totalSteps, total: totalSteps }}
stepLabel="About you"
title="Which best describes you?"
description="We’ll shape the room around your work."
@@ -209,6 +223,7 @@ export function CommunityOnboardingForm() {
if (state.stage === "initializing") {
return (
<OnboardingStatusDialog
+ totalSteps={totalSteps}
status={initializationStatus === "idle" ? "loading" : initializationStatus}
currentStep={initializationStep}
checkpoint={initializationCheckpoint}
diff --git a/src/web/src/components/community/onboarding/initialize-community-onboarding.test.ts b/src/web/src/components/community/onboarding/initialize-community-onboarding.test.ts
index 67c537d6a..d2e00f67e 100644
--- a/src/web/src/components/community/onboarding/initialize-community-onboarding.test.ts
+++ b/src/web/src/components/community/onboarding/initialize-community-onboarding.test.ts
@@ -64,7 +64,8 @@ describe("initializeCommunityOnboarding", () => {
.mockReturnValueOnce("avatar:beam:avatar-c")
})
- it("creates the three-bot development pack with one shared backend and distinct wake prompts", async () => {
+ it.each(["codex", "opencode"])("creates the three-bot development pack with %s and distinct wake prompts", async (runtime) => {
+ const model = runtime === "opencode" ? "custom/absent-from-catalog" : undefined
const pack = resolveStarterPack("developer")
apiFetch
.mockResolvedValueOnce({ bot: { id: "bot-lin", discriminator: "0001" } })
@@ -88,7 +89,8 @@ describe("initializeCommunityOnboarding", () => {
const checkpoints: OnboardingInitializationCheckpoint[] = []
const result = await initializeCommunityOnboarding({
machineId: "machine-1",
- runtime: "codex",
+ runtime,
+ model,
identity: "developer",
userName: "Ada Lovelace",
userDiscriminator: "0042",
@@ -125,7 +127,8 @@ describe("initializeCommunityOnboarding", () => {
name: template.name,
description: template.publicBio,
machineId: "machine-1",
- runtime: "codex",
+ runtime,
+ ...(model ? { model } : {}),
image: `avatar:beam:avatar-${String.fromCharCode(97 + index)}`,
}),
}))
@@ -158,6 +161,11 @@ describe("initializeCommunityOnboarding", () => {
})
})
+ it.each([undefined, null, " "])("rejects missing OpenCode model %j before creating resources", async (model) => {
+ await expect(initializeCommunityOnboarding({ machineId: "machine-1", runtime: "opencode", model, identity: "developer", userName: "Ada" })).rejects.toThrow("Choose a model before saving")
+ expect(apiFetch).not.toHaveBeenCalled()
+ })
+
it("uses a simple random-named Lead and Doer for a custom role", async () => {
apiFetch
.mockResolvedValueOnce({ bot: { id: "bot-a", discriminator: "0001" } })
diff --git a/src/web/src/components/community/onboarding/initialize-community-onboarding.ts b/src/web/src/components/community/onboarding/initialize-community-onboarding.ts
index c5ea67138..d22426670 100644
--- a/src/web/src/components/community/onboarding/initialize-community-onboarding.ts
+++ b/src/web/src/components/community/onboarding/initialize-community-onboarding.ts
@@ -3,7 +3,7 @@ import type { OnboardingInitializedBot, OnboardingInitializationStep, Onboarding
export type { OnboardingInitializationStep, OnboardingInitializationCheckpoint, OnboardingInitializationResult } from "@/lib/community/models/onboarding"
import { randomBeamAvatar } from "@/lib/avatar/seed-url"
import { randomBotName } from "@/lib/community/bot-random-name"
-import { formatHandle, MAX_SERVER_NAME_LENGTH, slugify } from "@alook/shared"
+import { formatHandle, MAX_SERVER_NAME_LENGTH, requiresExplicitModel, slugify } from "@alook/shared"
import { resolveStarterPack, starterPackWakePrompt, type StarterPackBotIdentity } from "./starter-packs"
@@ -59,6 +59,7 @@ function ownerHandle(userName: string, discriminator?: string) {
export async function initializeCommunityOnboarding({
machineId,
runtime,
+ model,
identity,
userName,
userDiscriminator,
@@ -69,6 +70,7 @@ export async function initializeCommunityOnboarding({
}: {
machineId: string
runtime: string
+ model?: string | null
identity: string
userName: string
userDiscriminator?: string
@@ -84,6 +86,7 @@ export async function initializeCommunityOnboarding({
}
}): Promise<OnboardingInitializationResult> {
services.assert()
+ if (requiresExplicitModel(runtime) && !model?.trim()) throw new Error("Choose a model before saving")
let progress = checkpoint
const save = (next: OnboardingInitializationCheckpoint) => {
services.assert()
@@ -105,6 +108,7 @@ export async function initializeCommunityOnboarding({
description: template.publicBio,
machineId,
runtime,
+ ...(model ? { model } : {}),
image,
}),
})
diff --git a/src/web/src/components/community/onboarding/onboarding-machine-dialog.tsx b/src/web/src/components/community/onboarding/onboarding-machine-dialog.tsx
index e7f8b733e..4cfd0d744 100644
--- a/src/web/src/components/community/onboarding/onboarding-machine-dialog.tsx
+++ b/src/web/src/components/community/onboarding/onboarding-machine-dialog.tsx
@@ -31,6 +31,7 @@ export function OnboardingMachineDialog({
open,
harness,
harnessLabel,
+ totalSteps = 3,
onConnected,
onChooseAnotherHarness,
onManageMachines,
@@ -40,6 +41,7 @@ export function OnboardingMachineDialog({
open: boolean
harness: string
harnessLabel: string
+ totalSteps?: number
onConnected: (machineId: string) => void
onChooseAnotherHarness: () => void
onManageMachines: () => void
@@ -174,11 +176,11 @@ export function OnboardingMachineDialog({
className="max-h-[calc(100dvh-2rem)] gap-0 overflow-y-auto border-0 p-0 shadow-(--e2) ring-0 thin-scrollbar sm:max-w-lg"
>
<DialogHeader className="gap-4 px-4 pt-4 pb-4 sm:px-6 sm:pt-6 sm:pb-6">
- <div className="grid grid-cols-3 gap-1" aria-label="Step 2 of 3">
- {[1, 2, 3].map((step) => (
+ <div className="flex gap-1" aria-label={`Step 2 of ${totalSteps}`}>
+ {Array.from({ length: totalSteps }, (_, index) => index + 1).map((step) => (
<span
key={step}
- className={step <= 2 ? "h-1 rounded-full bg-primary" : "h-1 rounded-full bg-muted"}
+ className={step <= 2 ? "h-1 flex-1 rounded-full bg-primary" : "h-1 flex-1 rounded-full bg-muted"}
/>
))}
</div>
diff --git a/src/web/src/components/community/onboarding/onboarding-model-dialog.tsx b/src/web/src/components/community/onboarding/onboarding-model-dialog.tsx
new file mode 100644
index 000000000..cc3f87a6d
--- /dev/null
+++ b/src/web/src/components/community/onboarding/onboarding-model-dialog.tsx
@@ -0,0 +1,43 @@
+"use client"
+
+import type { CommunityMachineRuntime } from "@alook/shared"
+import { Button } from "@/components/ui/button"
+import { ProviderLogo } from "@/components/provider-logo"
+import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"
+import { ModelField } from "../bots/model-field"
+import { validateBotModel } from "../bots/bot-form-validation"
+import { ONBOARDING_HARNESSES } from "./onboarding-form-options"
+
+export function OnboardingModelDialog({ runtime, model, onModelChange, onContinue }: {
+ runtime: Pick<CommunityMachineRuntime, "id" | "reasoning">
+ model: string | null
+ onModelChange: (model: string | null) => void
+ onContinue: () => void
+}) {
+ const error = validateBotModel(model, runtime.id)
+ const backendLabel = ONBOARDING_HARNESSES.find((option) => option.value === runtime.id)?.label ?? runtime.id
+ return (
+ <Dialog open>
+ <DialogContent showCloseButton={false} overlayClassName="bg-black/20 supports-backdrop-filter:backdrop-blur-sm" className="max-h-[calc(100dvh-2rem)] gap-0 overflow-y-auto border-0 p-0 shadow-(--e2) ring-0 thin-scrollbar sm:max-w-md">
+ <form onSubmit={(event) => { event.preventDefault(); if (!error) onContinue() }}>
+ <DialogHeader className="gap-4 px-4 pt-4 pb-4 sm:px-6 sm:pt-6 sm:pb-6">
+ <div className="flex gap-1.5" aria-label="Step 3 of 4">
+ {[1, 2, 3, 4].map((step) => <span key={step} className={step <= 3 ? "h-1.5 flex-1 rounded-full bg-primary" : "h-1.5 flex-1 rounded-full bg-muted"} />)}
+ </div>
+ <DialogTitle className="flex flex-wrap items-center gap-x-2 text-2xl leading-tight font-semibold tracking-tight">
+ <span>Choose a model for your</span>
+ <span className="inline-flex items-center gap-2 whitespace-nowrap"><ProviderLogo provider={runtime.id} className="size-5" />{backendLabel}</span>
+ </DialogTitle>
+ <DialogDescription>Your team’s bots will use this model. You can change it for each bot later.</DialogDescription>
+ </DialogHeader>
+ <div className="px-4 pb-4 sm:px-6 sm:pb-6">
+ <ModelField runtime={runtime} value={model} onChange={onModelChange} error={model ? error : undefined} />
+ </div>
+ <DialogFooter className="m-0 rounded-none border-0 bg-transparent px-4 py-4 sm:px-6">
+ <Button type="submit" className="h-11 min-h-11 w-full sm:h-9 sm:min-h-9 sm:w-auto" disabled={Boolean(error)}>Continue</Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/src/web/src/components/community/onboarding/onboarding-select-dialog.tsx b/src/web/src/components/community/onboarding/onboarding-select-dialog.tsx
index 2a5c00b37..9e2a51e9e 100644
--- a/src/web/src/components/community/onboarding/onboarding-select-dialog.tsx
+++ b/src/web/src/components/community/onboarding/onboarding-select-dialog.tsx
@@ -337,7 +337,7 @@ export function OnboardingSelectDialog({
) : null}
<Button
type="submit"
- className="h-11 w-full sm:h-9 sm:w-auto"
+ className="h-11 min-h-11 w-full sm:h-9 sm:min-h-9 sm:w-auto"
disabled={!canSubmit || locked}
>
{status === "loading" ? (
diff --git a/src/web/src/components/community/onboarding/onboarding-status-dialog.tsx b/src/web/src/components/community/onboarding/onboarding-status-dialog.tsx
index 8f4b1a116..ea56a2ac2 100644
--- a/src/web/src/components/community/onboarding/onboarding-status-dialog.tsx
+++ b/src/web/src/components/community/onboarding/onboarding-status-dialog.tsx
@@ -27,6 +27,7 @@ import {
export function OnboardingStatusDialog({
status,
+ totalSteps = 3,
currentStep,
checkpoint = {},
detail,
@@ -34,6 +35,7 @@ export function OnboardingStatusDialog({
onContinue,
}: {
status: "loading" | "error" | "success"
+ totalSteps?: number
currentStep: OnboardingInitializationStep
checkpoint?: OnboardingInitializationCheckpoint
detail: string
@@ -58,10 +60,8 @@ export function OnboardingStatusDialog({
aria-busy={status === "loading"}
>
<DialogHeader className="gap-4 px-4 pt-4 pb-4 sm:px-6 sm:pt-6 sm:pb-6">
- <div className="grid grid-cols-3 gap-1" aria-label="Step 3 of 3">
- <span className="h-1 rounded-full bg-(--te)" />
- <span className="h-1 rounded-full bg-(--ti)" />
- <span className="h-1 rounded-full bg-(--tc)" />
+ <div className="flex gap-1" aria-label={`Step ${totalSteps} of ${totalSteps}`}>
+ {Array.from({ length: totalSteps }, (_, index) => <span key={index} className={["h-1 flex-1 rounded-full bg-(--te)", "h-1 flex-1 rounded-full bg-(--ti)", "h-1 flex-1 rounded-full bg-(--tc)"][index % 3]} />)}
</div>
<div className="flex flex-col gap-2">
<DialogTitle className="flex flex-wrap items-center gap-x-2 text-2xl leading-tight font-semibold tracking-tight">
diff --git a/src/web/src/lib/analytics.ts b/src/web/src/lib/analytics.ts
index 979b636ad..063940e73 100644
--- a/src/web/src/lib/analytics.ts
+++ b/src/web/src/lib/analytics.ts
@@ -165,6 +165,7 @@ export function trackGithubOutboundClicked(surface: GithubOutboundSurface) {
export type CommunityOnboardingStage =
| "harness"
| "machine"
+ | "model"
| "identity"
| "initializing"
| "bot"
diff --git a/src/web/src/lib/community-onboarding.ts b/src/web/src/lib/community-onboarding.ts
index b4cdb20b3..2f22d2522 100644
--- a/src/web/src/lib/community-onboarding.ts
+++ b/src/web/src/lib/community-onboarding.ts
@@ -15,6 +15,7 @@ import {
type JourneyResources = {
harness?: string;
machineId?: string;
+ model?: string | null;
identity?: string;
botId?: string;
dmId?: string;