The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): allow explicit canonical Bot Chat tab opens
kvarnelis0679c9112db9
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 168c4468c67..4298fea17f8 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@@ -109,7 +109,10 @@ describe('a row click lands on the canonical chat, never a remembered side tab',await expect(openRosterBot(canonicalBot)).resolves.toBe(true)- expect(openBotCanonicalChat).toHaveBeenCalledWith(canonicalBot, { openingStillCurrent: expect.any(Function) })+ expect(openBotCanonicalChat).toHaveBeenCalledWith(canonicalBot, {+ intent: 'in-place',+ openingStillCurrent: expect.any(Function)+ })expect($openBotChat.get()?.openedSessionId).toBe('bot-chat-tip')})@@ -172,3 +175,21 @@ describe('the open Bot Chat follows its session on the gateway', () => {}})})++describe('opening a Bot Chat as a stacked tab (⌘-click / "Open Bot Chat in new tab")', () => {+ // Two Bot Chats could never be open at once: every row click spent main, so+ // the second bot replaced the first. A `tab` intent reaches the canonical+ // open so the chat stacks beside whatever main holds; a plain click keeps+ // its in-place meaning.+ it('threads a tab intent into the canonical open', async () => {+ await expect(openRosterBot(bot, { intent: 'tab' })).resolves.toBe(true)++ expect(openBotCanonicalChat).toHaveBeenCalledWith(bot, expect.objectContaining({ intent: 'tab' }))+ })++ it('a plain click still opens in place', async () => {+ await expect(openRosterBot(bot)).resolves.toBe(true)++ expect(openBotCanonicalChat).toHaveBeenCalledWith(bot, expect.objectContaining({ intent: 'in-place' }))+ })+})diff --git a/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx b/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsxindex 85531fb5205..f7c7d1e1b75 100644--- a/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx@@ -139,7 +139,15 @@ describe('the row delegates the open and claims no activation authority', () =>fireEvent.click(renderRow(bot))expect(ensureAgent).not.toHaveBeenCalled()- expect(openRosterBot.mock.calls).toEqual([[bot]])+ expect(openRosterBot.mock.calls).toEqual([[bot, { intent: 'in-place' }]])+ })++ it.each([{ metaKey: true }, { ctrlKey: true }])('modifier click %j opens the Bot Chat as a stacked tab', modifiers => {+ const bot = { connectionId: 'local', name: 'research' } as RosterRow++ fireEvent.click(renderRow(bot), modifiers)++ expect(openRosterBot.mock.calls).toEqual([[bot, { intent: 'tab' }]])})it('never resolves a remote default into the same-named local bot', async () => {@@ -168,6 +176,15 @@ describe('the menu opens the same forever-chat a row click does', () => {expect(openRosterBot.mock.calls).toEqual([[bot]])})++ it('"Open Bot Chat in new tab" stacks it beside the current chat', async () => {+ const bot = { name: 'alpha' } as RosterRow++ fireEvent.contextMenu(renderRow(bot))+ fireEvent.click(await screen.findByText('Open Bot Chat in new tab'))++ expect(openRosterBot.mock.calls).toEqual([[bot, { intent: 'tab' }]])+ })})describe('context-menu mutations hydrate the alias first', () => {diff --git a/apps/desktop/src/plugins/hermes-bots/bot-row.tsx b/apps/desktop/src/plugins/hermes-bots/bot-row.tsxindex c5d24667ec2..f0c7a2864ca 100644--- a/apps/desktop/src/plugins/hermes-bots/bot-row.tsx+++ b/apps/desktop/src/plugins/hermes-bots/bot-row.tsx@@ -226,8 +226,11 @@ export function BotRow({ bot, onDelete, onEdit, onGroup, onNewSection, showHandl}// Rows and Active Now share the exact-owner open path; only that path may- // activate a source and resolve the canonical Bot Chat.- const open = () => void openRosterBot(bot)+ // activate a source and resolve the canonical Bot Chat. ⌘/⌃-click opens+ // the Bot Chat as a stacked tab beside the current one (same modifier the+ // Sessions rows honour) instead of replacing whatever main holds.+ const open = (event?: { ctrlKey?: boolean; metaKey?: boolean }) =>+ void openRosterBot(bot, { intent: event?.metaKey || event?.ctrlKey ? 'tab' : 'in-place' })// DRAG lives on the row button itself: it already takes pointer events, so// the click that opens the bot and the drag that files it are one element's@@ -331,6 +334,7 @@ export function BotRow({ bot, onDelete, onEdit, onGroup, onNewSection, showHandl<ContextMenuTrigger asChild>{row}</ContextMenuTrigger><ContextMenuContent><ContextMenuItem onSelect={() => void openRosterBot(bot)}>{b.bot.openBotChat}</ContextMenuItem>+ <ContextMenuItem onSelect={() => void openRosterBot(bot, { intent: 'tab' })}>{b.bot.openBotChatInNewTab}</ContextMenuItem><ContextMenuItem onSelect={() => openBotScreen(bot, meta)}>{b.screen.menu}</ContextMenuItem><ContextMenuCheckboxItemchecked={Boolean(meta?.screenAutoOpen)}diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-chat-registry.test.ts b/apps/desktop/src/plugins/hermes-bots/canonical-chat-registry.test.tsindex d366884a7ca..803245e7c85 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-chat-registry.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/canonical-chat-registry.test.ts@@ -93,6 +93,26 @@ beforeEach(() => {})describe('the registry row wins, always', () => {+ it('passes explicit tab intent to the stored canonical chat without creating another session', async () => {+ const calls = respondWith(method => {+ if (method === 'session.list') {+ return { sessions: [{ id: 'root', resolved_id: 'tip', message_count: 10, title: 'Bot Chat' }] }+ }++ return {}+ })++ const { openBotCanonicalChat } = await loadModule()++ await expect(openBotCanonicalChat('ops', { intent: 'tab' })).resolves.toEqual({+ openedId: 'tip', registryId: 'root'+ })+ expect(hostMock.openSession).toHaveBeenCalledWith('tip', expect.objectContaining({+ intent: 'tab', profile: 'ops', workspaceMode: 'bots', workspaceOwnerKey: 'bot:ops'+ }))+ expect(calls.map(call => call.method)).toEqual(['session.list'])+ })+it('resolves the profile\u2019s "Bot Chat" row by exact title and opens it', async () => {const calls = respondWith(method => {if (method === 'session.list') {diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-chat.ts b/apps/desktop/src/plugins/hermes-bots/canonical-chat.tsindex 33ecf3c1bc5..d57a307fe37 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-chat.ts+++ b/apps/desktop/src/plugins/hermes-bots/canonical-chat.ts@@ -113,13 +113,20 @@ interface OpenStoredBotChatOptions {* only for explicit opens — a background wake resolves once the resume* is requested, never blocking on a cold backend. */background?: boolean+ /** `tab`: open BESIDE the current chat as a stacked tab instead of loading+ * into main. The default `in-place` spends main, so a second Bot Chat+ * always replaced the first; ⌘-click / "Open in new tab" on a bot row+ * pass `tab` so two Bot Chats can stay open side by side. */+ intent?: BotChatOpenIntent}+export type BotChatOpenIntent = 'in-place' | 'tab'+async function openStoredBotChat(owner: RosterRow | string,storedId: string,summary: CanonicalChatRow,- { background = false }: OpenStoredBotChatOptions = {}+ { background = false, intent = 'in-place' }: OpenStoredBotChatOptions = {}): Promise<string> {if (!storedId || typeof host.openSession !== 'function') {throw new Error('This Hermes Desktop version cannot open stored sessions')@@ -170,14 +177,9 @@ async function openStoredBotChat(}: {}),profile: name,- // Same intent a session row click uses. `tab` stacked a fresh tile every- // time focusOpenSession missed, so bot chats piled up beside each other and- // beside the untouched "New session" draft, which then kept focus —- // clicking a bot appeared to do nothing. `in-place` still fronts an- // already-open tile first, so Bot tabs survive owner lifecycles (#a81854a2,- // the reason this stopped being `main`); it just loads into main instead of- // minting a second tab when there is nothing to front.- intent: 'in-place',+ // Default to the same in-place behavior as a session row. Explicit tab+ // opens preserve main; either intent fronts an already-open session first.+ intent,awaitHydration: !background,expectHistory,forceResume: true,@@ -355,6 +357,9 @@ interface OpenCanonicalChatOptions {* open degrades to the old navigating shape. */background?: booleanopeningStillCurrent?: (() => boolean) | null+ /** See OpenStoredBotChatOptions.intent. Only honored for an EXISTING Bot+ * Chat; a freshly minted one always lands in main. */+ intent?: BotChatOpenIntent}/** The self-introduction a brand-new bot is born with (#91827).@@ -609,7 +614,7 @@ export function createCanonicalChat(* bot's chat opens without re-homing Desktop's chrome. */export async function openBotCanonicalChat(owner: RosterRow | string,- { background = false, openingStillCurrent = null }: OpenCanonicalChatOptions = {}+ { background = false, openingStillCurrent = null, intent = 'in-place' }: OpenCanonicalChatOptions = {}): Promise<{ openedId: string; registryId: string } | null> {const existing = await findExistingCanonicalChat(owner)@@ -619,7 +624,7 @@ export async function openBotCanonicalChat(}const openedId = existing.resolved_id || existing.id- await openStoredBotChat(owner, openedId, existing, { background })+ await openStoredBotChat(owner, openedId, existing, { background, intent })// Both identities matter downstream: the durable registry row names the// chat; the resolved lineage tip is what actually takes session focus.diff --git a/apps/desktop/src/plugins/hermes-bots/i18n-messages.ts b/apps/desktop/src/plugins/hermes-bots/i18n-messages.tsindex ba04a09039c..5be72bdd20e 100644--- a/apps/desktop/src/plugins/hermes-bots/i18n-messages.ts+++ b/apps/desktop/src/plugins/hermes-bots/i18n-messages.ts@@ -145,6 +145,7 @@ export type BotsMessages = {/** Re-opens the forever-chat on purpose. A plain row click only returns to* the tabs already open, so a closed Bot Chat needs an explicit ask. */openBotChat: string+ openBotChatInNewTab: string/** Screen-reader label for the row spinner while a cold bot chat opens. */openingChat: string/** Row context menu: pin/hide toggles, their toasts, and the groups entry. */diff --git a/apps/desktop/src/plugins/hermes-bots/i18n.ts b/apps/desktop/src/plugins/hermes-bots/i18n.tsindex 786c53778c9..af1e008414b 100644--- a/apps/desktop/src/plugins/hermes-bots/i18n.ts+++ b/apps/desktop/src/plugins/hermes-bots/i18n.ts@@ -181,6 +181,7 @@ const en: BotsMessages = {descriptionHint: 'Leave blank to generate from the bot’s name and description.',newChatWith: 'New chat with this bot',openBotChat: 'Open Bot Chat',+ openBotChatInNewTab: 'Open Bot Chat in new tab',openingChat: 'Opening chat…',pinToTop: 'Pin to top',unpin: 'Unpin',@@ -622,6 +623,7 @@ const ja: BotsMessages = {descriptionHint: '空欄のままにすると、ボットの名前と説明から生成します。',newChatWith: 'このボットと新しいチャット',openBotChat: 'ボットチャットを開く',+ openBotChatInNewTab: 'ボットチャットを新しいタブで開く',openingChat: 'チャットを開いています…',pinToTop: '先頭にピン留め',unpin: 'ピン留めを解除',@@ -1056,6 +1058,7 @@ const zh: BotsMessages = {descriptionHint: '留空则根据机器人的名称和描述生成。',newChatWith: '与此机器人开新聊天',openBotChat: '打开机器人聊天',+ openBotChatInNewTab: '在新标签页中打开机器人聊天',openingChat: '正在打开聊天…',pinToTop: '置顶',unpin: '取消置顶',@@ -1483,6 +1486,7 @@ const zhHant: BotsMessages = {descriptionHint: '留空則依機器人的名稱和描述產生。',newChatWith: '與此機器人開新聊天',openBotChat: '開啟機器人聊天',+ openBotChatInNewTab: '在新分頁中開啟機器人聊天',openingChat: '正在開啟聊天…',pinToTop: '釘選到頂端',unpin: '取消釘選',diff --git a/apps/desktop/src/plugins/hermes-bots/roster-actions.ts b/apps/desktop/src/plugins/hermes-bots/roster-actions.tsindex ab189ac5d2d..0fb7d1a98a0 100644--- a/apps/desktop/src/plugins/hermes-bots/roster-actions.ts+++ b/apps/desktop/src/plugins/hermes-bots/roster-actions.ts@@ -19,6 +19,7 @@ import {saveSelectedRosterBot} from './bot-state'import { isStaleBotChatTile, notifyBotOpenFailure, openBotCanonicalChat, prepareBotSource } from './canonical-chat'+import type { BotChatOpenIntent } from './canonical-chat'import { $botMeta, botActivitySession, botRosterKey, botSelectionKey, newBotChat } from './data'import { $groupChats, $groupChatWorkspace } from './group-chat'import { openGroupChat } from './group-chat-view'@@ -223,7 +224,14 @@ function focusExistingBotTab(bot: RosterRow): null | { registryId: string; store* conversations ("[Bots] - Sessions is not in sync again"). The workspace* remembers only this transient opened-view observation; it never stores or* resolves a canonical-chat id. */-export async function openRosterBot(bot: RosterRow): Promise<boolean> {+export interface OpenRosterBotOptions {+ /** `tab`: open the Bot Chat as a stacked tab beside the current chat+ * (⌘/⌃-click, "Open in new tab") instead of loading it into main. An+ * already-open Bot Chat is fronted either way. */+ intent?: BotChatOpenIntent+}++export async function openRosterBot(bot: RosterRow, { intent = 'in-place' }: OpenRosterBotOptions = {}): Promise<boolean> {const generation = bumpBotOpenGeneration()const key = botRosterKey(bot)const meta = botRosterMeta(bot, $botMeta.get())@@ -324,7 +332,10 @@ export async function openRosterBot(bot: RosterRow): Promise<boolean> {}try {- const opened = await openBotCanonicalChat(bot, { openingStillCurrent: () => generation === getBotOpenGeneration() })+ const opened = await openBotCanonicalChat(bot, {+ intent,+ openingStillCurrent: () => generation === getBotOpenGeneration()+ })if (generation !== getBotOpenGeneration()) {settlePendingBotOpen(generation)