Skip to content

The agent that grows with you

fix(desktop): refresh Bot Chat transcript when a roster click fronts an already-open tab

cmyyy3ea71a47b3f8
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.ts
index ca87583ff59..a50c8802803 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,6 +71,24 @@ 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 () => {
+ // 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
+ // turn). Fronting must force a registry open so forceResume re-pulls the
+ // latest rows instead of leaving a stale snapshot until the next turn
+ // (#99393 class; #95600 only covered the not-yet-open path).
+ host.focusOpenWorkspaceSession = vi.fn((_key: string, _probe: unknown, only?: readonly string[]) =>
+ only?.includes('bot-chat-tip') ? 'bot-chat-tip' : null
+ ) as never
+ $selectedStoredSessionId.set('bot-chat-tip')
+
+ await expect(openRosterBot(canonicalBot)).resolves.toBe(true)
+
+ expect(openBotCanonicalChat).toHaveBeenCalledWith(canonicalBot, expect.any(Function))
+ $selectedStoredSessionId.set(null)
+ })
+
it('resolves the registry when only a side thread is open', async () => {
// The shell would happily front 'side-thread' — the allowlist excludes it.
host.focusOpenWorkspaceSession = vi.fn((_key: string, _probe: unknown, only?: readonly string[]) =>
diff --git a/apps/desktop/src/plugins/hermes-bots/roster-actions.ts b/apps/desktop/src/plugins/hermes-bots/roster-actions.ts
index 29f2ce81d2f..fb7cce2397b 100644
--- a/apps/desktop/src/plugins/hermes-bots/roster-actions.ts
+++ b/apps/desktop/src/plugins/hermes-bots/roster-actions.ts
@@ -246,6 +246,14 @@ export async function openRosterBot(bot: RosterRow): Promise<boolean> {
// the roster-activity refresh treat it exactly like a registry open.
$openBotChat.set({ key, openedRegistryId: fronted.registryId, openedSessionId: fronted.storedSessionId })
+ // Fronting is presentation-only: the pane keeps whatever transcript it
+ // last painted, which can predate rows the bot wrote while the user was
+ // elsewhere (another bot's turn, a cron delivery, a teammate's
+ // 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)
+
return true
}