The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): preflight provider before new bot intro (#122066)
brooklyn!31427d7f4b67
diff --git a/apps/desktop/src/plugins/hermes-bots/create-agent-lazy-profile.test.tsx b/apps/desktop/src/plugins/hermes-bots/create-agent-lazy-profile.test.tsxindex a59f3864d68..1e96d5598b6 100644--- a/apps/desktop/src/plugins/hermes-bots/create-agent-lazy-profile.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/create-agent-lazy-profile.test.tsx@@ -101,13 +101,17 @@ function withQueryClient(children: ReactNode) {)}-async function renderDialog(hasCapabilitiesView: boolean) {+async function renderDialog(hasCapabilitiesView: boolean, onConfigureModel?: (bot: RosterRow) => void) {mocks.hasCapabilitiesView.value = hasCapabilitiesViewvi.resetModules()const { CreateAgentDialog } = await import('./create-dialog')- const view = render(withQueryClient(<CreateAgentDialog onClose={() => undefined} open roster={roster} />))+ const view = render(+ withQueryClient(+ <CreateAgentDialog onClose={() => undefined} onConfigureModel={onConfigureModel} open roster={roster} />+ )+ )fireEvent.change(screen.getByPlaceholderText('inbox-triage'), { target: { value: 'inbox-triage' } })fireEvent.click(screen.getByRole('button', { name: /Advanced/ }))@@ -256,6 +260,8 @@ describe('materializing the draft profile', () => {'default'])fireEvent.click(screen.getByRole('option', { name: /Fresh profile/ }))+ // Shared keys live on the TARGET machine, and the label says which.+ screen.getByText('Share keys & accounts with the default profile on Studio')fireEvent.click(screen.getByRole('button', { name: 'Create Bot' }))@@ -289,6 +295,75 @@ describe('materializing the draft profile', () => {})})+describe('provider readiness before the intro turn', () => {+ const notReady = { error: 'No usable credentials found for openrouter.', ok: false }++ it('keeps the bot, skips the intro, and offers model setup when its provider is not ready', async () => {+ const base = mocks.request.getMockImplementation()!+ mocks.request.mockImplementation(async (method: string, params?: unknown) =>+ method === 'setup.runtime_check' ? notReady : base(method, params)+ )+ const onConfigureModel = vi.fn()++ await renderDialog(true, onConfigureModel)+ fireEvent.click(screen.getByRole('button', { name: 'Create Bot' }))++ await waitFor(() => expect(mocks.createCanonicalChat).toHaveBeenCalledWith('inbox-triage', { kickoff: false }))+ expect(mocks.request).toHaveBeenCalledWith('setup.runtime_check', { profile: 'inbox-triage' })+ expect(createCalls()).toHaveLength(1)++ const toast = mocks.notify.mock.calls.at(-1)![0]++ expect(toast).toMatchObject({+ detail: notReady.error,+ kind: 'warning',+ title: 'Bot "Inbox Triage" created'+ })+ toast.action.onClick()+ expect(onConfigureModel).toHaveBeenCalledWith(expect.objectContaining({ name: 'inbox-triage' }))+ })++ it('runs the intro when the provider check passes', async () => {+ const base = mocks.request.getMockImplementation()!+ mocks.request.mockImplementation(async (method: string, params?: unknown) =>+ method === 'setup.runtime_check' ? { ok: true } : base(method, params)+ )++ await renderDialog(true)+ fireEvent.click(screen.getByRole('button', { name: 'Create Bot' }))++ await waitFor(() => expect(mocks.createCanonicalChat).toHaveBeenCalledWith('inbox-triage', { kickoff: true }))+ expect(mocks.notify).toHaveBeenLastCalledWith({ kind: 'success', message: 'Bot "Inbox Triage" created' })+ })++ it('checks a remote bot on its own machine and warns without an editor shortcut', async () => {+ mocks.connections.mockResolvedValue([+ { id: 'local', label: 'This Mac' },+ { id: 'studio', label: 'Studio' }+ ])+ mocks.requestProfile.mockImplementation(async () => notReady)++ await renderDialog(true, vi.fn())+ await screen.findByText('Create on')+ fireEvent.click(controlUnder('Create on'))+ fireEvent.click(await screen.findByRole('option', { name: 'Studio' }))+ fireEvent.click(screen.getByRole('button', { name: 'Create Bot' }))++ await waitFor(() =>+ expect(mocks.notify).toHaveBeenLastCalledWith(+ expect.objectContaining({ kind: 'warning', title: 'Bot "Inbox Triage" created on Studio' })+ )+ )+ expect(mocks.requestProfile).toHaveBeenCalledWith(+ expect.objectContaining({ connectionId: 'studio' }),+ 'setup.runtime_check',+ { profile: 'inbox-triage' }+ )+ expect(mocks.notify.mock.calls.at(-1)![0].action).toBeUndefined()+ expect(mocks.request).not.toHaveBeenCalledWith('setup.runtime_check', expect.anything())+ })+})+describe('the clone-from default', () => {it('regression: reset restores the mounted default, not "fresh profile"', async () => {await renderDialog(true)diff --git a/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx b/apps/desktop/src/plugins/hermes-bots/create-dialog.tsxindex 7a556ebdac9..00e2fb2bb20 100644--- a/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx+++ b/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx@@ -111,11 +111,13 @@ interface CapabilityCatalog {}interface CreateAgentDialogProps {onClose: () => void+ /** Opens the editor for a just-created local bot whose model is not ready. */+ onConfigureModel?: (bot: RosterRow) => voidopen: booleanroster: RosterRow[]}-export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogProps) {+export function CreateAgentDialog({ open, onClose, onConfigureModel, roster }: CreateAgentDialogProps) {const { t } = useI18n()const b = useBots()const [name, setName] = useState('')@@ -211,6 +213,7 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPrconst [busy, setBusy] = useState(false)const [error, setError] = useState<null | string>(null)const { slug, title: botTitle } = botProfileIdentity(name, title)+ const descriptionText = [botTitle, description].filter(Boolean).join(' — ')const valid = slug.length > 0 && NAME_RE.test(slug)// Once the draft profile is materialized (Capabilities tab / MCP setup) it@@ -382,7 +385,6 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPrreturn null}- const descriptionText = [botTitle, description].filter(Boolean).join(' — ')await requestForTarget('profiles.create', {name: slug,description: descriptionText,@@ -514,12 +516,38 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPrreturn}- host.notify({- kind: 'success',- message: remoteTarget- ? b.editor.createdOn(displayName({ name: slug, title: botTitle }), targetLabel)- : b.editor.created(displayName({ name: slug, title: botTitle }))- })+ // The intro turn is a real model call. Probe the new profile's route+ // first so a bot whose machine has no usable credential lands as+ // "created, needs a model" instead of a doomed "No LLM provider" turn.+ // Only an explicit `ok: false` counts; older gateways proceed as before.+ const readiness = await requestForTarget<{ error?: string; ok?: boolean }>('setup.runtime_check', {+ profile: slugCreated+ }).catch(() => null)++ const needsModel = readiness?.ok === false+ const who = displayName({ name: slug, title: botTitle })+ const createdMessage = remoteTarget ? b.editor.createdOn(who, targetLabel) : b.editor.created(who)++ const bot: RosterRow = {+ name: slugCreated,+ description: descriptionText,+ title: botTitle,+ ...(remoteTarget ? { connectionId: targetConnection, remoteSource: true } : {})+ }++ host.notify(+ needsModel+ ? {+ kind: 'warning',+ title: createdMessage,+ message: b.editor.needsModel,+ detail: readiness?.error,+ ...(!remoteTarget && onConfigureModel+ ? { action: { label: b.editor.configureModel, onClick: () => onConfigureModel(bot) } }+ : {})+ }+ : { kind: 'success', message: createdMessage }+ )const wasRemote = remoteTargetreset()onClose()@@ -545,7 +573,7 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPr// Agent creation. Click-path resolution (openBotCanonicalChat) mints// silently so a resolution miss never burns a turn (ScottFive).const sid = await createCanonicalChat(slug, {- kickoff: true+ kickoff: !needsModel})if (!sid && typeof host.newChat === 'function') {@@ -783,7 +811,7 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPr)}<label className="flex items-center gap-2 text-xs text-(--ui-text-secondary)"><Checkbox checked={shareAuth} onCheckedChange={value => setShareAuth(Boolean(value))} />- {b.editor.shareKeys}+ {remoteTarget ? b.editor.shareKeysOn(targetLabel) : b.editor.shareKeys}</label><div className="pl-6 pt-0.5 text-[0.7rem] leading-5 text-(--ui-text-tertiary)">{b.editor.shareKeysHint}diff --git a/apps/desktop/src/plugins/hermes-bots/i18n.ts b/apps/desktop/src/plugins/hermes-bots/i18n.tsindex 878322e5f1d..ea116ee5af4 100644--- a/apps/desktop/src/plugins/hermes-bots/i18n.ts+++ b/apps/desktop/src/plugins/hermes-bots/i18n.ts@@ -66,7 +66,10 @@ type BotsMessages = {inheritedModel: stringsoul: stringshareKeys: string+ shareKeysOn: (target: string) => stringshareKeysHint: string+ needsModel: string+ configureModel: stringcreateEmpty: stringnameTakenHint: stringnameFirstHint: string@@ -503,8 +506,12 @@ const en: BotsMessages = {inheritedModel: 'inherited from launch profile',soul: 'SOUL.md (optional — replaces the generated persona)',shareKeys: 'Share keys & accounts with the main profile',+ shareKeysOn: target => `Share keys & accounts with the default profile on ${target}`,shareKeysHint:'Subscriptions, OAuth logins, and API keys stay shared (not copied), so token refreshes never invalidate each other. Uncheck for an isolated snapshot copy.',+ needsModel:+ 'No model provider is ready for it yet, so it skipped its introduction. Pick a provider and model under Advanced.',+ configureModel: 'Configure model',createEmpty: 'Create empty (skip bundled skills)',nameTakenHint: 'That name is taken — pick another before configuring capabilities.',nameFirstHint: 'Name the bot first — a draft profile is created when you open this tab (discarded if you cancel).',@@ -928,8 +935,12 @@ const ja: BotsMessages = {inheritedModel: '起動時のプロファイルから継承',soul: 'SOUL.md(任意 — 生成された人格を置き換えます)',shareKeys: 'メインプロファイルとキー・アカウントを共有',+ shareKeysOn: target => `${target} の default プロファイルとキー・アカウントを共有`,shareKeysHint:'サブスクリプション、OAuth ログイン、API キーをコピーせず共有するため、トークン更新で互いに無効になりません。チェックを外すと独立したスナップショットをコピーします。',+ needsModel:+ 'まだ使用できるモデルプロバイダーがないため、自己紹介をスキップしました。「詳細設定」でプロバイダーとモデルを選んでください。',+ configureModel: 'モデルを設定',createEmpty: '空のプロファイルを作成(同梱スキルを除外)',nameTakenHint: 'その名前は使用済みです。機能を設定する前に別の名前を選んでください。',nameFirstHint:@@ -1354,8 +1365,11 @@ const zh: BotsMessages = {inheritedModel: '继承启动时的配置档案',soul: 'SOUL.md(可选,将替换生成的人格)',shareKeys: '与主配置档案共享密钥和账户',+ shareKeysOn: target => `与 ${target} 上的 default 配置档案共享密钥和账户`,shareKeysHint:'订阅、OAuth 登录和 API 密钥保持共享而非复制,令牌刷新不会使另一方失效。取消勾选则创建隔离的快照副本。',+ needsModel: '它还没有可用的模型提供商,因此跳过了自我介绍。请在“高级”中选择提供商和模型。',+ configureModel: '配置模型',createEmpty: '创建空配置(跳过内置技能)',nameTakenHint: '此名称已被占用,请先选择其他名称再配置能力。',nameFirstHint: '请先为机器人命名,打开此标签页时将创建草稿配置档案(取消时会丢弃)。',@@ -1767,8 +1781,11 @@ const zhHant: BotsMessages = {inheritedModel: '繼承啟動時的設定檔',soul: 'SOUL.md(選填,將取代產生的人格)',shareKeys: '與主要設定檔共用金鑰和帳戶',+ shareKeysOn: target => `與 ${target} 上的 default 設定檔共用金鑰和帳戶`,shareKeysHint:'訂閱、OAuth 登入和 API 金鑰保持共用而非複製,權杖更新不會使另一方失效。取消勾選則建立隔離的快照副本。',+ needsModel: '它還沒有可用的模型提供者,因此略過了自我介紹。請在「進階」中選擇提供者和模型。',+ configureModel: '設定模型',createEmpty: '建立空白設定(略過內建技能)',nameTakenHint: '此名稱已被使用,請先選擇其他名稱再設定功能。',nameFirstHint: '請先為機器人命名,開啟此分頁時將建立草稿設定檔(取消時會捨棄)。',diff --git a/apps/desktop/src/plugins/hermes-bots/roster-pane-dialogs.tsx b/apps/desktop/src/plugins/hermes-bots/roster-pane-dialogs.tsxindex 804fe000523..9d126a551eb 100644--- a/apps/desktop/src/plugins/hermes-bots/roster-pane-dialogs.tsx+++ b/apps/desktop/src/plugins/hermes-bots/roster-pane-dialogs.tsx@@ -61,6 +61,7 @@ export function renderRosterDialogs({setCreateOpen(false)void refetch()}}+ onConfigureModel={setEditing}open={createOpen}roster={activeSourceRoster}/>