Skip to content

The agent that grows with you

fix(bot-mode): a bot row whose connection was deleted renders instead of throwing

teknium19d5d202c4de1
diff --git a/apps/desktop/src/plugins/hermes-bots/data.identity.test.ts b/apps/desktop/src/plugins/hermes-bots/data.identity.test.ts
index e398be9fcb4..f7f7e946409 100644
--- a/apps/desktop/src/plugins/hermes-bots/data.identity.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/data.identity.test.ts
@@ -23,6 +23,7 @@ import {
botSelectionKey,
clearBotAttention,
filterBots,
+ isDefaultBot,
mentionNameForms,
noteBotAttention,
preferReachableSameNameRows,
@@ -194,6 +195,16 @@ describe('source-qualified keys', () => {
expect(botSelectionKey(row({ name: 'ops' }))).toBe('ops')
expect(botMetaKey(row({ name: 'ops' }))).toBe('ops')
})
+
+ it('reads a row whose connection was deleted as a settled state, not an exception', () => {
+ // A persisted group roster keeps an orphaned member (connection removed) with no route
+ // (group-membership.ts::durableGroupChatMembers); rendering it must not throw (#110002).
+ const orphan = row({ name: 'ops', remoteSource: true, sourceScoped: true })
+
+ expect(botMetaKey(orphan)).toBe(botSelectionKey(orphan))
+ expect(isDefaultBot(orphan)).toBe(false)
+ expect(isDefaultBot(row({ name: 'default', remoteSource: true, sourceScoped: true }))).toBe(true)
+ })
})
describe('which session speaks for a bot', () => {
diff --git a/apps/desktop/src/plugins/hermes-bots/data.ts b/apps/desktop/src/plugins/hermes-bots/data.ts
index 72cb6c6e9a7..60ee12472ec 100644
--- a/apps/desktop/src/plugins/hermes-bots/data.ts
+++ b/apps/desktop/src/plugins/hermes-bots/data.ts
@@ -18,6 +18,7 @@ import {
botWorkspaceOwnerKey,
indexAliasRoutes,
requestForBot,
+ resolveBotConnectionRoute,
setBotsWorkspaceOwner
} from './routing'
import { getPluginCtx, ID } from './shared'
@@ -1080,10 +1081,12 @@ export function botSelectionKey(bot: Partial<RosterRow> | null | undefined): str
/* eslint-enable no-redeclare */
export function isDefaultBot(bot: Partial<RosterRow> | null | undefined): boolean {
- const route = botConnectionRoute(bot)
+ // Render-path read (bot-row context menu, hidden-bots selection over the whole roster):
+ // an orphaned row (connection deleted) resolves by its own name instead of throwing.
+ const resolved = resolveBotConnectionRoute(bot)
return (
- String(route?.profile || bot?.name || '')
+ String(resolved.route?.profile || bot?.name || '')
.trim()
.toLowerCase() === 'default'
)
@@ -1223,9 +1226,15 @@ export function botMetaKey(bot: RosterRow): string
export function botMetaKey(bot: Partial<RosterRow> | null | undefined): string | undefined
export function botMetaKey(bot: Partial<RosterRow> | null | undefined): string | undefined {
- const route = botConnectionRoute(bot)
+ // Passive meta lookup, read while painting: branch on the typed status like botRosterMeta does.
+ // An orphaned row (connection deleted) keys by its degraded roster key rather than throwing.
+ const resolved = resolveBotConnectionRoute(bot)
+
+ if (resolved.status === 'owner_removed') {
+ return botRosterKey(bot)
+ }
- return route ? botRouteKey(route) : bot?.name
+ return resolved.route ? botRouteKey(resolved.route) : bot?.name
}
/* eslint-enable no-redeclare */