Skip to content

The agent that grows with you

fix(desktop): group chats no longer crash when a member's connection is deleted

chelsealong09529afdd2ac
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.js
index 02185300a9e..28ceef638b2 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.js
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js
@@ -5215,7 +5215,19 @@ function aliasIdentityFor(bot) {
// aliasRouteIndex above — which is connection-exact, never name-based.
function botRosterMeta(bot, metaByName) {
if (bot?.sourceScoped || bot?.remoteSource) {
- const route = botConnectionRoute(bot)
+ // A row orphaned by a deleted connection (connectionId gone, e.g. from a
+ // stale persisted group roster) has no route to resolve. botConnectionRoute
+ // fails closed there for routing dispatch — correct for a network call,
+ // but this is a passive meta lookup, and the whole component tree above
+ // display-only code must not crash rendering an unroutable member.
+ let route = null
+
+ try {
+ route = botConnectionRoute(bot)
+ } catch {
+ route = null
+ }
+
const direct = route ? metaByName?.[botRouteKey(route)] : null
if (direct) {
diff --git a/apps/desktop/src/plugins/hermes-bots/tests/multi-source-roster.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/multi-source-roster.test.mjs
index 815e21585e4..ead2641cd30 100644
--- a/apps/desktop/src/plugins/hermes-bots/tests/multi-source-roster.test.mjs
+++ b/apps/desktop/src/plugins/hermes-bots/tests/multi-source-roster.test.mjs
@@ -254,6 +254,18 @@ test('default rows use source identity without borrowing another source title',
assert.equal(name(active, undefined), 'Hermes')
})
+test('botRosterMeta: a group roster row orphaned by a deleted connection does not throw', () => {
+ const { __botRosterMeta: metaFor } = runtime()
+ // Mirrors the persisted `group-chats` descriptor left behind once its
+ // connection is removed: remoteSource is still true, but connectionId is
+ // gone, so botConnectionRoute has nothing to resolve. This must not crash
+ // rendering the group (#93492) just because one member is unroutable.
+ const orphaned = { name: 'halakukhan', handle: 'halakukhan', connectionId: null, remoteSource: true }
+
+ assert.doesNotThrow(() => metaFor(orphaned, {}))
+ assert.equal(metaFor(orphaned, {}), null)
+})
+
test('botHandle: precomputed multi-source handle wins; default stays hermes', () => {
const { __botHandle: botHandle } = runtime()