Skip to content

The agent that grows with you

fix(desktop): annotate canonical relay targets for remote @mentions

liuhao10242e542c92e671
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts b/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
index 1844349c38e..5ec79763918 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
@@ -253,11 +253,15 @@ describe('the mention middleware', () => {
expect(hostMock.requestProfile).not.toHaveBeenCalled()
})
- it('hands the agent the connection-qualified message_agent target', async () => {
+ it('hands the agent a relay-resolvable canonical target', async () => {
const { handler } = await contributions()
const result = await handler({ text: 'ping @default-vera' })
- expect(result.text).toMatch(/message_agent target: "default-vera@vera"/)
+ // The UI alias ('default-vera') is not a relay identity: resolve_remote_target()
+ // accepts only a roster row's handle/profile, optionally @connection-qualified.
+ // The annotation must carry the canonical profile@connection form (#97678).
+ expect(result.text).toMatch(/message_agent target: "default@vera"/)
+ expect(result.text).not.toMatch(/message_agent target: "default-vera/)
expect(result.text).toMatch(/on Vera/)
})
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.tsx b/apps/desktop/src/plugins/hermes-bots/plugin.tsx
index 02f52826a8d..2b599d5b542 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.tsx
@@ -734,7 +734,13 @@ export default {
botRosterMeta(bot, $botMeta.get())?.title || bot.ui_meta?.['hermes-bots']?.title || bot.title || ''
).trim()
- const target = bot.remoteSource && bot.connectionId ? `${handle}@${bot.connectionId}` : handle
+ // message_agent only resolves canonical identities: the relay
+ // matches a roster row's handle/profile (± @connection-id), the
+ // local path a bare profile name or 'hermes'. botHandle() prefers
+ // the row's source-qualified UI alias ('default-vera'), which
+ // neither resolver accepts — annotate the canonical form instead.
+ const target =
+ bot.remoteSource && bot.connectionId ? `${bot.name}@${bot.connectionId}` : botHandle(bot.name)
const where = bot.remoteSource
? ` — on ${bot.connectionLabel || bot.connectionId} (message_agent target: "${target}")`
diff --git a/tests/tools/test_bot_relay.py b/tests/tools/test_bot_relay.py
index 7b9fb528f1b..5ec13225783 100644
--- a/tests/tools/test_bot_relay.py
+++ b/tests/tools/test_bot_relay.py
@@ -84,6 +84,9 @@ def test_resolve_remote_target_forms(root):
assert bot_relay.resolve_remote_target("default", roster)["connection_id"] == "cloud-1"
# exact connection-qualified form
assert bot_relay.resolve_remote_target("hermes@cloud-1", roster)["profile"] == "default"
+ # profile@connection — the form Desktop's mention middleware annotates
+ # for remote bots (#97678); the UI alias form must not be required
+ assert bot_relay.resolve_remote_target("default@cloud-1", roster)["profile"] == "default"
assert bot_relay.resolve_remote_target("hermes@nope", roster) is None
assert bot_relay.resolve_remote_target("ghost", roster) is None