From 1396a30cd7d540d0a5661f769c2e5998f324c8d4 Mon Sep 17 00:00:00 2001 From: "Hermes (Lift-Off agent)" Date: Mon, 24 Aug 2026 12:08:17 +0000 Subject: [PATCH] test(desktop): cover canonical activity stale-runtime split --- .../tests/remote-routing-races.test.mjs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/apps/desktop/src/plugins/hermes-bots/tests/remote-routing-races.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/remote-routing-races.test.mjs index 88972c60c2..dae14aa079 100644 --- a/apps/desktop/src/plugins/hermes-bots/tests/remote-routing-races.test.mjs +++ b/apps/desktop/src/plugins/hermes-bots/tests/remote-routing-races.test.mjs @@ -80,6 +80,7 @@ function load({ requestProfile, agents, profileRoutes } = {}) { .concat(` globalThis.__race = { $botMeta, + botActivitySession, botConnectionRoute, botRosterKey, botSelectionKey, @@ -282,6 +283,41 @@ test('non-identity alias resolves the canonical chat by NAME on the backend prof assert.equal(opened[1], 'worker-chat-tip', 'the lineage tip opens; the registry row stays the identity') }) +test('canonical sidebar activity and an explicit bot switch converge on a forced-resume open', async () => { + const bot = { + ...remoteBot, + canonical_session: { id: 'bot-chat', last_active: 20, preview: 'new canonical activity' }, + last_session: { id: 'old-visible-chat', last_active: 10, preview: 'stale visible activity' } + } + const runtime = load({ + requestProfile: async (_route, method) => { + if (method === 'session.list') { + return { + sessions: [{ id: 'bot-chat', resolved_id: 'bot-chat-tip', title: 'Bot Chat', message_count: 4 }] + } + } + + return {} + } + }) + + assert.equal( + runtime.context.__race.botActivitySession(bot).id, + 'bot-chat', + 'the sidebar activity tile follows the hidden canonical chat' + ) + + const result = await runtime.context.__race.openBotCanonicalChat(bot) + const opened = runtime.calls.find(call => call[0] === 'openSession') + + assert.deepEqual(JSON.parse(JSON.stringify(result)), { registryId: 'bot-chat', openedId: 'bot-chat-tip' }) + assert.equal(opened[1], 'bot-chat-tip', 'the explicit switch opens the canonical lineage tip') + assert.equal(opened[2].awaitHydration, true) + assert.equal(opened[2].expectHistory, true) + assert.equal(opened[2].forceResume, true, 'a cached stale runtime must never suppress session.resume') + assert.equal(opened[2].route.connectionId, 'remote-a', 'resume stays on the canonical chat owner') +}) + test('remote canonical lookup failure rejects instead of minting on the remote source', async () => { const runtime = load({ requestProfile: async (_route, method) => {