Skip to content

The agent that grows with you

fix(desktop): an empty relay route list does not spend the one roster clear

teknium1c02a269351ad
diff --git a/apps/desktop/src/plugins/hermes-bots/relay.test.ts b/apps/desktop/src/plugins/hermes-bots/relay.test.ts
index 8f19c429977..ae14216422e 100644
--- a/apps/desktop/src/plugins/hermes-bots/relay.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/relay.test.ts
@@ -467,13 +467,35 @@ describe('the roster loop pushes the OTHER connections’ agents', () => {
startBotRelay()
await vi.advanceTimersByTimeAsync(0)
- expect(calls).toEqual([expect.objectContaining({ connectionId: 'a', method: 'bot_relay.roster.sync', params: { agents: [] } })])
+ expect(calls).toEqual([
+ expect.objectContaining({ connectionId: 'a', method: 'bot_relay.roster.sync', params: { agents: [] } })
+ ])
await vi.advanceTimersByTimeAsync(60_000)
expect(calls).toHaveLength(1)
stopBotRelay()
})
+
+ it('an empty route list before the registry loads does not spend the one roster clear', async () => {
+ hostMock.profileRoutes = vi.fn(async () => [])
+
+ const calls = respondWith(() => ({}))
+ const { startBotRelay, stopBotRelay } = await loadRelay()
+
+ startBotRelay()
+ await vi.advanceTimersByTimeAsync(0)
+ expect(calls).toHaveLength(0)
+
+ // The registry arrives with a single connection: it still gets its clear.
+ hostMock.profileRoutes = vi.fn(async () => [route('a')])
+ await vi.advanceTimersByTimeAsync(60_000)
+ expect(calls).toEqual([
+ expect.objectContaining({ connectionId: 'a', method: 'bot_relay.roster.sync', params: { agents: [] } })
+ ])
+
+ stopBotRelay()
+ })
})
describe('the drain loop wires drain → deliver → reply', () => {
@@ -711,7 +733,10 @@ describe('the roster loop forgets a machine that left', () => {
// A returning peer starts the union pushes again.
hostMock.profileRoutes = vi.fn(async () => [route('a'), route('b')])
await vi.advanceTimersByTimeAsync(60_000)
- expect(calls.filter(call => call.method === 'bot_relay.roster.sync').map(call => call.connectionId)).toEqual(['a', 'b'])
+ expect(calls.filter(call => call.method === 'bot_relay.roster.sync').map(call => call.connectionId)).toEqual([
+ 'a',
+ 'b'
+ ])
stopBotRelay()
})
diff --git a/apps/desktop/src/plugins/hermes-bots/relay.ts b/apps/desktop/src/plugins/hermes-bots/relay.ts
index 95a68835524..046d450b475 100644
--- a/apps/desktop/src/plugins/hermes-bots/relay.ts
+++ b/apps/desktop/src/plugins/hermes-bots/relay.ts
@@ -264,8 +264,9 @@ async function syncRelayRosters() {
// Nothing to relay — but the gateways that remain still hold the last
// pushed roster, so a departed machine's agents would stay in every
// bot's prompt (and as message_agent targets) until a second connection
- // reappears. Push the now-empty roster once so they forget it.
- if (!relay.rosterCleared) {
+ // reappears. Push the now-empty roster once so they forget it. An empty
+ // route list (registry not loaded yet) must not spend the one clear.
+ if (connections.length === 1 && !relay.rosterCleared) {
relay.rosterCleared = true
await Promise.all(
connections.map(async connection => {