The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-mode): group-chat replies render through the chat's message renderer
teknium19073bfb77c69
diff --git a/apps/desktop/e2e/group-chat-code-block-and-media.spec.ts b/apps/desktop/e2e/group-chat-code-block-and-media.spec.tsnew file mode 100644index 00000000000..634d016cdb1--- /dev/null+++ b/apps/desktop/e2e/group-chat-code-block-and-media.spec.ts@@ -0,0 +1,145 @@+import fs from 'node:fs'+import path from 'node:path'++import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'+import { expect, test } from './test'++// A bot's group-chat reply was rendered through raw Streamdown, whose stock+// code block lays its header and body out as inline siblings: the code body+// sat shifted right by the header's width and the wrapper's overflow-hidden+// clipped the tail with no scrollbar (#91878). The same raw path never ran the+// Desktop's `MEDIA:` transform, so a bot's `MEDIA:/path/file.png` showed as+// a plain path instead of an inline image/player (#93728). Group replies now+// go through the same message renderer as the 1:1 chat.++const SHOT_DIR = '/tmp/batchbots/panes-layout-cron-tile/shots'+const LONG_LINE = 'const veryLongIdentifierNameForTheGroupChatCodeBlockRepro = computeSomethingWith(argumentNumberOne, argumentNumberTwo, argumentNumberThree)'+// 1x1 PNG.+const PNG_BASE64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=='++let fixture: MockBackendFixture | null = null+let mediaPath = ''++function codeReply(): string {+ return ['Here is the draft:', '', '```ts', LONG_LINE, 'export {}', '```', '', `MEDIA:${mediaPath}`].join('\n')+}++async function openBots(page: MockBackendFixture['page']): Promise<void> {+ const tab = page+ .getByRole('button', { name: 'Bots', exact: true })+ .or(page.getByRole('tab', { name: 'Bots', exact: true }))+ .first()++ await tab.click()+ await expect(page.getByRole('button', { name: 'New bot or group chat' })).toBeVisible()+}++async function createAgent(page: MockBackendFixture['page'], name: string, title: string): Promise<void> {+ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New Bot' }).click()++ const dialog = page.getByRole('dialog', { name: 'New Bot' })+ await dialog.getByPlaceholder('inbox-triage').fill(name)+ await dialog.getByPlaceholder('Inbox Triage').fill(title)+ await dialog.getByRole('button', { name: 'Create Bot' }).click()+ await expect(dialog).toBeHidden({ timeout: 30_000 })+ await expect(page.getByRole('button', { name: new RegExp(`^${title}\\b`) }).first()).toBeVisible({ timeout: 30_000 })+}++async function createRoom(page: MockBackendFixture['page']) {+ await openBots(page)+ await createAgent(page, 'writer', 'Writer')+ await createAgent(page, 'editor', 'Editor')++ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New Group Chat' }).click()++ const dialog = page.getByRole('dialog', { name: 'New Group Chat' })++ for (const title of ['Writer', 'Editor']) {+ await dialog.getByText(title, { exact: true }).locator('xpath=ancestor::label').getByRole('checkbox').click()+ }++ await dialog.getByRole('textbox', { name: 'Group name' }).fill('Writer, Editor')+ await dialog.getByRole('button', { name: 'Create Group (2)' }).click()++ const composer = page.getByRole('textbox', { name: 'Message Writer, Editor' }).filter({ visible: true })+ await expect(composer).toBeVisible({ timeout: 20_000 })++ return composer+}++test.beforeEach(async () => {+ fixture = await setupMockBackend({+ mockServer: {+ replyForPrompt: prompt => (prompt.includes('CODE_BLOCK_REPRO') ? codeReply() : 'ok')+ }+ })+ mediaPath = path.join(fixture.sandbox.hermesHome, 'group-media.png')+ fs.writeFileSync(mediaPath, Buffer.from(PNG_BASE64, 'base64'))+ fs.mkdirSync(SHOT_DIR, { recursive: true })+ await waitForAppReady(fixture, 120_000)+})++test.afterEach(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('a group reply renders its code block inside the message and its MEDIA: line as inline media', async () => {+ test.setTimeout(300_000)+ const page = fixture!.page+ const composer = await createRoom(page)++ await composer.fill('@writer CODE_BLOCK_REPRO')+ await composer.press('Enter')++ const code = page.getByText(/veryLongIdentifierNameForTheGroupChatCodeBlockRepro/).filter({ visible: true }).first()+ await expect(code).toBeVisible({ timeout: 90_000 })+ await expect(page.getByRole('button', { name: 'Stop', exact: true })).toHaveCount(0, { timeout: 60_000 })+ await page.screenshot({ path: path.join(SHOT_DIR, 'group-chat-code-media.png') })++ const geometry = await code.evaluate(el => {+ const body = el.closest<HTMLElement>('[data-selectable-text="true"]')!+ const bodyRect = body.getBoundingClientRect()+ const pre = el.closest('pre') ?? el+ const preRect = pre.getBoundingClientRect()+ // Every box between the code text and the message body: a box whose+ // content is wider than itself must scroll, never clip — that is the+ // "cut off with no horizontal scrollbar" the report describes.+ const chain: Array<{ tag: string; overflowX: string; scrollWidth: number; clientWidth: number }> = []+ let node: HTMLElement | null = el as HTMLElement++ while (node && node !== body.parentElement) {+ chain.push({+ tag: node.tagName.toLowerCase(),+ overflowX: getComputedStyle(node).overflowX,+ scrollWidth: node.scrollWidth,+ clientWidth: node.clientWidth+ })+ node = node.parentElement+ }++ const clippedWithoutScroll = chain.filter(+ box => box.scrollWidth > box.clientWidth + 1 && !['auto', 'scroll'].includes(box.overflowX)+ )++ return {+ body: { left: bodyRect.left, right: bodyRect.right },+ pre: { left: preRect.left, right: preRect.right, width: preRect.width },+ chain,+ clippedWithoutScroll,+ rawMedia: body.textContent?.includes('MEDIA:') ?? false,+ inlineMedia: Boolean(body.querySelector('img, audio, video'))+ }+ })++ console.log('GROUP CODE BLOCK GEOMETRY', JSON.stringify(geometry))+ // The code block stays inside the message column...+ expect.soft(geometry.pre.right).toBeLessThanOrEqual(geometry.body.right + 1)+ // ...and no box between the code and the message clips text it cannot scroll.+ expect.soft(geometry.clippedWithoutScroll).toEqual([])+ // MEDIA: renders as media, never as the raw directive.+ expect.soft(geometry.rawMedia).toBe(false)+ expect.soft(geometry.inlineMedia).toBe(true)+})diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsx b/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsxindex 79fb4b6671d..9a67f3034f6 100644--- a/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsx+++ b/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsx@@ -102,6 +102,13 @@ import { bumpBotOpenGeneration, getPluginCtx, ID } from './shared'import type { Attachment, BotMeta, GroupChat, GroupMember, GroupMessage, RosterRow } from './types'const Streamdown = typeof sdk === 'undefined' ? undefined : sdk.Streamdown+// The 1:1 chat's message renderer: `MEDIA:` lines become inline players and+// images instead of a raw path (#93728), and a fenced block gets the app's own+// code card — stock Streamdown lays a code block's header and body out as+// inline siblings, so the body sat shifted right and its tail was clipped with+// no scrollbar (#91878). Feature-detected: an older shell without the export+// keeps the raw Streamdown path.+const MessageTextContent = typeof sdk === 'undefined' ? undefined : sdk.MessageTextContent/** Soft-disband a group chat: remove only this group from every local member's* membership list (the metadata syncs cross-machine via ui_meta), drop the@@ -1054,11 +1061,17 @@ export function GroupChatWorkspace({ group, members, onBack, visible = true }: G) : null}</div><div- className="text-xs text-(--ui-text-secondary) [&_p]:mb-1 [&_p:last-child]:mb-0 [&_ul]:mb-1 [&_ul]:list-disc [&_ul]:pl-4 [&_ol]:mb-1 [&_ol]:list-decimal [&_ol]:pl-4 [&_pre]:overflow-x-auto" // The app shell sets user-select: none globally; message bodies opt+ className="min-w-0 text-xs text-(--ui-text-secondary) [&_p]:mb-1 [&_p:last-child]:mb-0 [&_ul]:mb-1 [&_ul]:list-disc [&_ul]:pl-4 [&_ol]:mb-1 [&_ol]:list-decimal [&_ol]:pl-4 [&_pre]:overflow-x-auto" // The app shell sets user-select: none globally; message bodies opt// back in so drag-select and ⌘C work in group chat logs.data-selectable-text="true">- {Streamdown ? <Streamdown>{entry.text}</Streamdown> : entry.text}+ {MessageTextContent ? (+ <MessageTextContent text={entry.text} />+ ) : Streamdown ? (+ <Streamdown>{entry.text}</Streamdown>+ ) : (+ entry.text+ )}</div>{/* User attachments: what every responding bot was *//* shown — image previews, or a named chip for */diff --git a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts b/apps/desktop/src/plugins/hermes-bots/group-test-utils.tsindex 64f532228a7..100c216db83 100644--- a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts@@ -434,6 +434,7 @@ export async function pluginSdkMock(host: Record<string, unknown>) {createBudgetedLoop: undefined,host,SkillsView: undefined,+ MessageTextContent: undefined,Streamdown: undefined,queryClient: { invalidateQueries: () => undefined },useQuery: () => ({ data: [], isLoading: false }),diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex e247ccc0f23..e0e3fdfad36 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -1574,10 +1574,6 @@ export {} from '@/app/overlays/panel'export { type RouteContribution, ROUTES_AREA, SIDEBAR_NAV_AREA, type SidebarNavContribution } from '@/app/routes'-/** Canonical raw message renderer: applies Desktop message transforms (including- * `MEDIA:` delivery directives) and the same rich Markdown/media components as- * core chat. Prefer this over raw Streamdown for transcript-style messages. */-export { MessageTextContent } from '@/components/assistant-ui/markdown-text'/** THE full per-toolset config panel core Settings renders — provider picker,* env vars / API keys, model catalog picker, and post-setup runners. Route-* decoupled (the "manage keys" deep link is a no-op outside the router); pass@@ -1612,6 +1608,10 @@ export { SkillsView } from '@/app/skills'* renders anywhere (a plugin dialog); pass a live `gateway` (see* `host.getGateway()`) and an optional `profile` to scope it to one bot. */export { McpTab } from '@/app/skills/mcp-tab'+/** Canonical raw message renderer: applies Desktop message transforms (including+ * `MEDIA:` delivery directives) and the same rich Markdown/media components as+ * core chat. Prefer this over raw Streamdown for transcript-style messages. */+export { MessageTextContent } from '@/components/assistant-ui/markdown-text'/** The oversized Collapse lettering an empty chat is titled with — core writes* "HERMES AGENT" with it, a `chat.empty` contribution writes its own name. */export { Wordmark } from '@/components/chat/wordmark'