The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): New Bot's Capabilities tab loads when the name comes later, and gets real room
Tekniumb421302b1664
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 1e96d5598b6..d275af60c9b 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@@ -207,6 +207,20 @@ describe('materializing the draft profile', () => {expect(createCalls()).toHaveLength(1)})+ it('creates it once a name is typed AFTER the Capabilities tab was opened nameless', async () => {+ await renderDialog(true)+ fireEvent.change(screen.getByPlaceholderText('inbox-triage'), { target: { value: '' } })+ fireEvent.click(screen.getByRole('button', { name: 'Capabilities' }))+ await screen.findByText(/Name the bot first/)++ // Mid-word keystrokes must not each mint (and orphan) a draft.+ fireEvent.change(screen.getByPlaceholderText('inbox-triage'), { target: { value: 'late' } })+ fireEvent.change(screen.getByPlaceholderText('inbox-triage'), { target: { value: 'late-name' } })++ await waitFor(() => expect(mocks.skillsView.at(-1)).toMatchObject({ fixedProfile: 'late-name' }), { timeout: 3000 })+ expect(createCalls().map(([, params]) => params.name)).toEqual(['late-name'])+ })+it('pins a remote-target draft to the TARGET machine, not the active gateway', async () => {mocks.connections.mockResolvedValue([{ id: 'local', label: 'This Mac' },diff --git a/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx b/apps/desktop/src/plugins/hermes-bots/create-dialog.tsxindex 83b3154a4ac..a927811a9e7 100644--- a/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx+++ b/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx@@ -121,6 +121,58 @@ interface CreateAgentDialogProps {roster: RosterRow[]}+/** The live Capabilities surface needs a real profile. Materialize it whenever+ * the tab is showing a valid, untaken name that has no draft yet, not only on+ * the tab click: a user who opens the tab first and names the bot after (or+ * renames it) otherwise sat on a spinner forever. Debounced so typing a name+ * does not mint a draft per keystroke. */+function useCapabilitiesDraft(ready: boolean, slug: string, draft: null | string, materialize: () => void) {+ useEffect(() => {+ if (!ready || draft === slug) {+ return+ }++ const timer = window.setTimeout(materialize, 800)++ return () => window.clearTimeout(timer)+ // materialize reads the current render's form state; re-arming on the+ // identity inputs is what matters.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [ready, slug, draft])+}++/** New Bot's live Capabilities tab: a hint until the name is usable, a spinner+ * until its draft profile exists, then the real surface pinned to that draft. */+function CapabilitiesTab({ connection, draft, hint }: { connection?: string; draft: null | string; hint: null | string }) {+ const b = useBots()+ const note = 'px-2 py-3 text-center text-xs text-(--ui-text-tertiary)'++ if (hint) {+ return <div className={note}>{hint}</div>+ }++ if (!draft) {+ return (+ <div className="flex justify-center py-4">+ <GlyphSpinner className="text-(--ui-text-tertiary)" spinner="breathe" />+ </div>+ )+ }++ // The tab list is gated on the same export, so this is only reachable via+ // persisted tab state on a build that lacks it — a message rather than+ // rendering `undefined` as a component, which throws.+ if (!CapabilitiesView) {+ return <div className={note}>{b.editor.newerDesktop}</div>+ }++ return (+ <ResizableFrame>+ <CapabilitiesView embedded fixedProfile={draft} {...(connection ? { fixedConnection: connection } : {})} />+ </ResizableFrame>+ )+}+export function CreateAgentDialog({ open, onClose, onConfigureModel, roster }: CreateAgentDialogProps) {const { t } = useI18n()const b = useBots()@@ -306,6 +358,13 @@ export function CreateAgentDialog({ open, onClose, onConfigureModel, roster }: C// switched must not key the preview (or the describe call) either.const capSource = cloneFrom === '__none__' || remoteTarget ? 'default' : cloneFrom+ const materializeForCaps = () =>+ void ensureAgentCreated()+ .then(created => created && setCreatedForCaps(created))+ .catch(err => host.notifyError(err, b.bot.createFailed))++ useCapabilitiesDraft(advTab === 'capabilities' && valid && !taken, slug, createdForCaps, materializeForCaps)+const ensureCaps = () => {if ((caps && caps.source === capSource) || capsFailed) {return@@ -370,8 +429,7 @@ export function CreateAgentDialog({ open, onClose, onConfigureModel, roster }: C// (its consumers — the taken check, draft discard on cancel, the MCP setup// button's profile param — all read a string); flightRef shares the// in-flight creation promise so simultaneous MCP setup / Create clicks fire- // ONE profiles.create. A settled flight clears its slot: failures retry,- // and a null result (form invalid at flight time) isn't sticky.+ // ONE profiles.create. A failed flight clears its slot so a retry can run.const ensureAgentCreated = (): Promise<null | string> => {// Renamed since the draft materialized? The old draft is orphaned —// discard it and create fresh under the new slug.@@ -384,11 +442,14 @@ export function CreateAgentDialog({ open, onClose, onConfigureModel, roster }: Creturn Promise.resolve(createdRef.current)}- const flight = singleFlight(flightRef, async () => {- if (!valid || taken) {- return null- }+ // Never start a flight for an unusable name: singleFlight only clears its+ // slot on failure, so a null result would be returned to every later+ // caller and the draft could never be created once a name is typed.+ if (!valid || taken) {+ return Promise.resolve(null)+ }+ const flight = singleFlight(flightRef, async () => {await requestForTarget('profiles.create', {name: slug,description: descriptionText,@@ -735,12 +796,9 @@ export function CreateAgentDialog({ open, onClose, onConfigureModel, roster }: CsetCapFilter('')if (id === 'capabilities') {- // The live surface needs a real profile —- // materialize it now (same lazy-create door- // the MCP setup buttons use).- void ensureAgentCreated()- .then(created => created && setCreatedForCaps(created))- .catch(err => host.notifyError(err, b.bot.createFailed))+ // The live surface needs a real profile; a name typed later+ // is picked up by useCapabilitiesDraft.+ materializeForCaps()} else if (id !== 'general') {ensureCaps()}@@ -826,33 +884,11 @@ export function CreateAgentDialog({ open, onClose, onConfigureModel, roster }: C</label></div>) : advTab === 'capabilities' ? (- !valid || taken ? (- <div className="px-2 py-3 text-center text-xs text-(--ui-text-tertiary)">- {taken ? b.editor.nameTakenHint : b.editor.nameFirstHint}- </div>- ) : !createdForCaps ? (- <div className="flex justify-center py-4">- <GlyphSpinner className="text-(--ui-text-tertiary)" spinner="breathe" />- </div>- ) : CapabilitiesView ? (- <ResizableFrame height={440} minHeight={280}>- <CapabilitiesView- embedded- fixedProfile={createdForCaps}- {...(remoteTarget- ? {- fixedConnection: targetConnection- }- : {})}- />- </ResizableFrame>- ) : (- // The tab list is gated on the same export, so this is only- // reachable via persisted tab state on a build that lacks it- // — a message rather than rendering `undefined` as a- // component, which throws.- <div className="px-2 py-3 text-center text-xs text-(--ui-text-tertiary)">{b.editor.newerDesktop}</div>- )+ <CapabilitiesTab+ connection={remoteTarget ? targetConnection : undefined}+ draft={createdForCaps === slug ? createdForCaps : null}+ hint={!valid ? b.editor.nameFirstHint : taken ? b.editor.nameTakenHint : null}+ />) : capsFailed ? (<div className="px-2 py-3 text-center text-xs text-(--ui-text-tertiary)">{b.editor.newerGateway}</div>) : !caps ? (diff --git a/apps/desktop/src/plugins/hermes-bots/dialog-parts.tsx b/apps/desktop/src/plugins/hermes-bots/dialog-parts.tsxindex 5c0655bdd2c..05bd1586895 100644--- a/apps/desktop/src/plugins/hermes-bots/dialog-parts.tsx+++ b/apps/desktop/src/plugins/hermes-bots/dialog-parts.tsx@@ -19,22 +19,21 @@ export function labeled(label: ReactNode, control: ReactNode) {)}-interface ResizableFrameProps {- children: ReactNode- /** CSS `resize` has nothing to drag from without a concrete height, and the- * two surfaces that embed Capabilities budget it different room. */- height: number- minHeight: number-}+// Module-level so the ref callback is stable and fires on mount only.+const revealOnMount = (el: HTMLDivElement | null) => el?.scrollIntoView?.({ block: 'nearest' })-/** A fixed-height viewport with the native vertical resize handle. */-export function ResizableFrame({ children, height, minHeight }: ResizableFrameProps) {+/** The embedded Capabilities viewport: tall enough for the installed list AND+ * the Skills Hub picker stacked under it (a fixed few hundred pixels left the+ * list a sliver), with the native vertical resize handle. Scrolled into view+ * on mount, since it opens below the dialog's identity fields. */+export function ResizableFrame({ children }: { children: ReactNode }) {return (<divclassName="resize-y overflow-auto rounded-md border border-(--ui-stroke-secondary)"+ ref={revealOnMount}style={{- height,- minHeight+ height: 'min(85vh, 960px)',+ minHeight: 360}}>{children}diff --git a/apps/desktop/src/plugins/hermes-bots/profile-config.tsx b/apps/desktop/src/plugins/hermes-bots/profile-config.tsxindex da265f89219..e302d20c0f0 100644--- a/apps/desktop/src/plugins/hermes-bots/profile-config.tsx+++ b/apps/desktop/src/plugins/hermes-bots/profile-config.tsx@@ -270,7 +270,7 @@ export function AdvancedProfileConfig({ bot, state, setState }: AdvancedProfileC/>{labeled(b.editor.liveCapabilities,- <ResizableFrame height={460} minHeight={300}>+ <ResizableFrame><CapabilitiesViewembeddedfixedProfile={backendProfile}