The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): add host.composer.focus(sessionId) to the plugin composer API
teknium1dcea97b27f62
diff --git a/apps/desktop/src/sdk/index.test.ts b/apps/desktop/src/sdk/index.test.tsindex bbe0cf20129..6e2f0efff1f 100644--- a/apps/desktop/src/sdk/index.test.ts+++ b/apps/desktop/src/sdk/index.test.ts@@ -329,4 +329,20 @@ describe('host.composer draft facade', () => {it('reports a setDraft failure when no surface answers', async () => {await expect(host.composer.setDraft('sess-ghost', 'hello')).resolves.toBe(false)})++ it('routes focus by address on the app focus bus: tile for a session, resolved-active for null', async () => {+ const seen: string[] = []+ const off = (event: Event) => seen.push((event as CustomEvent<{ target: string }>).detail.target)++ window.addEventListener('hermes:composer-focus', off)+ host.composer.focus('sess-1')+ host.composer.focus(null)+ // requestComposerFocus defers a plain focus request one macrotask.+ await new Promise(resolve => window.setTimeout(resolve, 0))+ window.removeEventListener('hermes:composer-focus', off)++ // A session id never resolves to the primary unless the primary shows it —+ // an absent tile drops the request rather than focusing the wrong pane.+ expect(seen).toEqual(['tile:sess-1', 'main'])+ })})diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex 2f4be7be719..7f4d4ed6cb4 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -25,6 +25,7 @@ import { capabilityScoped } from '@/api/client'import {type ComposerInsertMode,type ComposerTarget,+ requestComposerFocus,requestComposerGetDraft,requestComposerInsertAcked,requestComposerSetDraft,@@ -1671,6 +1672,20 @@ export const host = {const { target } = resolveComposerAddress(sessionId === null ? undefined : sessionId)return requestComposerSubmit(text, { target })+ },++ /** Put the caret in a composer — the app's own focus bus, same address+ * resolution as the verbs above. `insertText`/`setDraft` already focus a+ * VISIBLE surface they paint; this is the standalone verb for the other+ * cases (return the caret after a plugin popover/dialog closes, a+ * keybind that "goes to the input") that plugins used to reach with a+ * hand-built `hermes:composer-focus` CustomEvent. Fail-closed like the+ * rest: an absent tile drops the request instead of focusing whatever+ * the primary happens to show. */+ focus: (sessionId: null | string = null): void => {+ const { target } = resolveComposerAddress(sessionId === null ? undefined : sessionId)++ requestComposerFocus(target)}}}