The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): refresh busy bot chat on explicit open
Gille9a017b969123
diff --git a/apps/desktop/src/plugins/hermes-bots/bot-row-opens-canonical-chat.test.ts b/apps/desktop/src/plugins/hermes-bots/bot-row-opens-canonical-chat.test.tsindex a50c8802803..67d05b95849 100644--- a/apps/desktop/src/plugins/hermes-bots/bot-row-opens-canonical-chat.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/bot-row-opens-canonical-chat.test.ts@@ -71,7 +71,7 @@ describe('a row click lands on the canonical chat, never a remembered side tab',})})- it('fronting an already-open Bot Chat refreshes its transcript in place', async () => {+ it('fronting a busy, already-open Bot Chat refreshes its transcript in place', async () => {// The front is presentation-only: the pane keeps whatever transcript it// last painted, which can predate rows the bot wrote while the user was// elsewhere (a cron delivery, a teammate's message_agent, another bot's@@ -82,11 +82,16 @@ describe('a row click lands on the canonical chat, never a remembered side tab',only?.includes('bot-chat-tip') ? 'bot-chat-tip' : null) as never$selectedStoredSessionId.set('bot-chat-tip')+ const busy = vi.spyOn(host.state.busy, 'get').mockReturnValue(true)- await expect(openRosterBot(canonicalBot)).resolves.toBe(true)+ try {+ await expect(openRosterBot(canonicalBot)).resolves.toBe(true)- expect(openBotCanonicalChat).toHaveBeenCalledWith(canonicalBot, expect.any(Function))- $selectedStoredSessionId.set(null)+ expect(openBotCanonicalChat).toHaveBeenCalledWith(canonicalBot, expect.any(Function))+ } finally {+ busy.mockRestore()+ $selectedStoredSessionId.set(null)+ }})it('resolves the registry when only a side thread is open', async () => {@@ -143,4 +148,20 @@ describe('the open Bot Chat follows its session on the gateway', () => {expect(openBotCanonicalChat).not.toHaveBeenCalled()$selectedStoredSessionId.set(null)})++ it('does not re-open a focused Bot Chat from roster activity while its turn is busy', () => {+ $selectedBot.set('alpha')+ $selectedStoredSessionId.set('bot-chat-tip')+ const busy = vi.spyOn(host.state.busy, 'get').mockReturnValue(true)++ try {+ trackInboundActivity([activeBot(500)])+ trackInboundActivity([activeBot(600)])++ expect(openBotCanonicalChat).not.toHaveBeenCalled()+ } finally {+ busy.mockRestore()+ $selectedStoredSessionId.set(null)+ }+ })})diff --git a/apps/desktop/src/plugins/hermes-bots/roster-actions.ts b/apps/desktop/src/plugins/hermes-bots/roster-actions.tsindex fb7cce2397b..e6e699c0f57 100644--- a/apps/desktop/src/plugins/hermes-bots/roster-actions.ts+++ b/apps/desktop/src/plugins/hermes-bots/roster-actions.ts@@ -116,11 +116,11 @@ export function trackInboundActivity(roster: RosterRow[]) {* session — a group room or another tab owning the center must not be* yanked away by background activity — and never mid-turn, when the* activity is the turn itself, already streaming. */-function refreshOpenBotChat(bot: RosterRow) {+function refreshOpenBotChat(bot: RosterRow, { allowWhileBusy = false }: { allowWhileBusy?: boolean } = {}) {const canonicalIds = [bot.canonical_session?.id, bot.canonical_session?.resolved_id].filter(Boolean).map(String)const focused = String(host.state.focusedStoredSessionId?.get?.() || '')- if (!focused || !canonicalIds.includes(focused) || host.state.busy.get()) {+ if (!focused || !canonicalIds.includes(focused) || (!allowWhileBusy && host.state.busy.get())) {return}@@ -252,7 +252,7 @@ export async function openRosterBot(bot: RosterRow): Promise<boolean> {// message_agent). Force a registry open so forceResume re-pulls the// latest transcript instead of leaving a stale snapshot until the next// user turn (#99393 class; #95600 only covered the not-yet-open path).- refreshOpenBotChat(bot)+ refreshOpenBotChat(bot, { allowWhileBusy: true })return true}