The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): follow focused bot for mentions
Gille76952ba54f5d
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.jsindex 9cbcf975ec3..51bdcb39697 100644--- a/apps/desktop/src/plugins/hermes-bots/plugin.js+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js@@ -195,6 +195,13 @@ const $selectedBot = atom('default')* the socket happened to be homed on. */const $focusedBotProfile = host.state.focusedSessionProfile || host.state.profile+/** Profile that owns the chat currently on screen. Bot Mode opens another+ * profile's session without moving the gateway socket, so mention filtering+ * and sender identity must follow focus rather than host.state.profile. */+function focusedMentionProfile() {+ return String($focusedBotProfile.get?.() || '').trim() || 'default'+}+/** Optional secondary navigation inside the Bots pane (group-chat rooms). *//** Group-chat rooms: { [group]: { log: [{from:{kind,name},text,at}], watermarks:{[member]:idx}, epoch, running } }.@@ -10786,7 +10793,7 @@ export default {return []}- const active = (host.state.profile.get() || 'default').trim() || 'default'+ const active = focusedMentionProfile()const q = (query || '').toLowerCase()const items = []const live = {@@ -11087,7 +11094,7 @@ export default {}const live = {- name: (host.state.profile.get() || 'default').trim() || 'default',+ name: focusedMentionProfile(),connectionId: String(host.state.connectionId?.get?.() || host.activeConnectionId?.() || 'local')}const cached = cachedUnionRoster()diff --git a/apps/desktop/src/plugins/hermes-bots/tests/mention-completions.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/mention-completions.test.mjsindex 8d89609052c..71120fd77da 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/mention-completions.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/mention-completions.test.mjs@@ -9,7 +9,7 @@ import vm from 'node:vm'const source = readFileSync(new URL('../plugin.js', import.meta.url), 'utf8')-function loadProvide({ roster, active = 'default', meta = {} } = {}) {+function loadProvide({ roster, active = 'default', focused = active, meta = {} } = {}) {const registrations = []const atom = value => {let current = value@@ -51,7 +51,12 @@ function loadProvide({ roster, active = 'default', meta = {} } = {}) {setQueryData: () => undefined},host: {- state: { profile: { get: () => active, listen: () => () => undefined }, gateway: { get: () => null, listen: () => () => undefined }, connectionId: { get: () => 'local', listen: () => () => undefined } },+ state: {+ profile: { get: () => active, listen: () => () => undefined },+ focusedSessionProfile: { get: () => focused, listen: () => () => undefined },+ gateway: { get: () => null, listen: () => () => undefined },+ connectionId: { get: () => 'local', listen: () => () => undefined }+ },request: async () => ({}),onEvent: () => () => undefined},@@ -111,6 +116,29 @@ test('prefix-filters against the handle', () => {assert.strictEqual(provide('zzz').length, 0)})+test('filters self by the focused Bot Chat owner, not the gateway socket profile', () => {+ const provide = loadProvide({+ active: 'default',+ focused: 'renametest',+ roster: {+ profiles: [+ { name: 'default', display_name: 'Lucy' },+ { name: 'renametest' }+ ]+ }+ })++ const inserts = provide('').map(item => item.insert)+ assert.ok(+ inserts.includes('@lucy'),+ 'renamed default profile remains mentionable from the focused bot chat'+ )+ assert.ok(+ !inserts.includes('@renametest'),+ 'focused bot excludes itself even when the socket stays on default'+ )+})+test('empty roster cache yields no rows (never throws)', () => {const provide = loadProvide({ roster: undefined })diff --git a/apps/desktop/src/plugins/hermes-bots/tests/mention-handoff-quoting.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/mention-handoff-quoting.test.mjsindex 330c03fa3cb..aef58e4f4d0 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/mention-handoff-quoting.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/mention-handoff-quoting.test.mjs@@ -15,7 +15,12 @@ import vm from 'node:vm'const pluginSource = readFileSync(new URL('../plugin.js', import.meta.url), 'utf8')-function load({ activeProfile = 'research', profiles = ['research', 'ops'], title = null } = {}) {+function load({+ activeProfile = 'research',+ focusedProfile = activeProfile,+ profiles = ['research', 'ops'],+ title = null+} = {}) {const values = new Map()const atom = initial => {const slot = { get: () => values.get(slot), set: value => values.set(slot, value) }@@ -30,11 +35,19 @@ function load({ activeProfile = 'research', profiles = ['research', 'ops'], titlhost: {request: async method => {if (method === 'profiles.list') {- return { profiles: profiles.map(name => ({ name })) }+ return {+ profiles: profiles.map(profile =>+ typeof profile === 'string' ? { name: profile } : profile+ )+ }}return {}},- state: { profile: { get: () => activeProfile, listen: () => undefined }, gateway: { listen: () => undefined } }+ state: {+ profile: { get: () => activeProfile, listen: () => undefined },+ focusedSessionProfile: { get: () => focusedProfile, listen: () => undefined },+ gateway: { listen: () => undefined }+ }}}const source = pluginSource@@ -111,6 +124,22 @@ test('regression: the handoff command quotes the recipient argument', async () =assert.match(result.text, /`hermes -p 'ops' chat --in ~/)})+test('behavior: a renamed default profile routes from another focused Bot Chat', async () => {+ const { handler } = load({+ activeProfile: 'default',+ focusedProfile: 'renametest',+ profiles: [+ { name: 'default', display_name: 'Lucy' },+ { name: 'renametest' }+ ]+ })++ const result = await handler({ text: 'ask @lucy for a status update' })++ assert.match(result.text, /`hermes -p 'default' chat --in ~/)+ assert.match(result.text, /Message from 🤖 Renametest \(@renametest\)/)+})+test('behavior: @dixie on a Connections bot stays in this chat and does not hermes -p', async () => {const values = new Map()const atom = initial => {