Skip to content

The agent that grows with you

fix(desktop): keep a contributed @-mention row that claims its own text

kokhlo7113504f472a
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-at-completions-contrib.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-at-completions-contrib.test.tsx
index 7586a81e9b8..e931dd78050 100644
--- a/apps/desktop/src/app/chat/composer/hooks/use-at-completions-contrib.test.tsx
+++ b/apps/desktop/src/app/chat/composer/hooks/use-at-completions-contrib.test.tsx
@@ -131,6 +131,31 @@ describe('contributed @ completion sources', () => {
expect(rows.some(label => label.toLowerCase() === '@default')).toBe(true)
})
+ it('keeps a contributed row that declares its own text as a handle', async () => {
+ vi.useFakeTimers()
+ // A bot whose mention tag IS its profile name claims that same name. The
+ // claim is meant to retire the gateway's twin row, not the declaring row:
+ // filtering both deleted the bot from the picker entirely while it stayed
+ // listed in the Bots pane, and only a profile whose friendly name differed
+ // from its raw name (`default` tagged `hermes`) survived — which is why
+ // this read as "only the default bot is mentionable".
+ addSource('bots', q =>
+ 'cur'.startsWith(q) ? [{ insert: '@curio', meta: 'Bot · Curio', handles: ['@curio'] }] : []
+ )
+
+ const gateway = gatewayStub([
+ { text: '@curio', display: '@curio', meta: 'agent profile' },
+ { text: '@file:src/curio.md', display: 'curio.md', meta: 'file' }
+ ])
+
+ const { result } = renderHook(() => useAtCompletions({ gateway: gateway as never, sessionId: 's1', cwd: '/repo' }))
+
+ const rows = await searchAndRead(result, 'cur')
+
+ expect(rows.filter(label => label.toLowerCase() === '@curio')).toEqual(['@curio'])
+ expect(rows.some(label => label.includes('curio.md'))).toBe(true)
+ })
+
it('drops rows when the query does not match the source filter', async () => {
vi.useFakeTimers()
addSource('bots', q => ('researcher'.startsWith(q) ? [{ insert: '@researcher', meta: 'Bot' }] : []))
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-at-completions.ts b/apps/desktop/src/app/chat/composer/hooks/use-at-completions.ts
index 65fe2557acc..505e0e646ef 100644
--- a/apps/desktop/src/app/chat/composer/hooks/use-at-completions.ts
+++ b/apps/desktop/src/app/chat/composer/hooks/use-at-completions.ts
@@ -158,10 +158,20 @@ export function useAtCompletions(options: {
// identity it owns: the gateway lists the same target under one
// of them (the raw profile name), and that twin gets dropped in
// the merge below.
+ //
+ // A handle that is the row's own text names no alias and claims
+ // nothing. Taken at face value it deleted the row that declared
+ // it, so a bot whose mention tag equals its profile name never
+ // reached the popover — it was listed in the Bots pane and absent
+ // from the one picker that could insert it. The roster emits such
+ // a handle for every local profile, and which rows hit it depends
+ // on the user's naming, so it read as "only the default bot works".
+ const own = normalize(item.insert)
+
for (const handle of item.handles || []) {
const claimed = normalize(handle)
- if (claimed) {
+ if (claimed && claimed !== own) {
claimedHandles.add(claimed)
}
}
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 b6cc0b91205..89cb62d4ffd 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
@@ -388,6 +388,21 @@ describe('@-mention completions', () => {
expect(eva?.handles).toEqual(['@eva-2'])
})
+ it('claims its own text when a bot tags as its raw profile name', async () => {
+ // No title on the profile, so the mention tag IS the profile name. The
+ // picker still needs the claim (it retires the gateway's twin row for
+ // that name), and the merge treats a handle matching the row's own text
+ // as naming no alias — so this shape must keep offering the bot.
+ const { provide } = await contributions({
+ focused: 'default',
+ profiles: [{ name: 'curio' }, { name: 'default' }]
+ })
+
+ const curio = provide('cur').find(item => item.insert === '@curio')
+
+ expect(curio?.handles).toEqual(['@curio'])
+ })
+
it("never claims a remote row's name — the local gateway's twin is a different bot", async () => {
const { provide } = await contributions({ profiles: [{ name: 'default' }, REMOTE_DEFAULTS[0]] })