Skip to content

The agent that grows with you

feat(desktop): auto-grow the Bot group composer for long prompts

addelh755781341e7f
diff --git a/apps/desktop/e2e/group-composer-auto-grow.spec.ts b/apps/desktop/e2e/group-composer-auto-grow.spec.ts
new file mode 100644
index 00000000000..009ab7bb579
--- /dev/null
+++ b/apps/desktop/e2e/group-composer-auto-grow.spec.ts
@@ -0,0 +1,151 @@
+import fs from 'node:fs'
+import path from 'node:path'
+
+import { startMockServer } from '../../../tests-js/scripts/mock-server'
+
+import {
+ buildAppEnv,
+ createSandbox,
+ launchDesktop,
+ type MockBackendFixture,
+ waitForAppReady,
+ writeEnvFile,
+ writeMockProviderConfig
+} from './fixtures'
+import { RealSessionBuilder } from './real-session-builder'
+import { expect, test } from './test'
+
+// The group-room composer starts as one compact row, grows with wrapped text
+// and newlines so a long brief can be read back while drafting, and stops at
+// min(50vh, 24rem) — past that the textarea scrolls internally so the room
+// transcript keeps its space (hermes-agent#95300).
+
+type Page = MockBackendFixture['page']
+
+let fixture: MockBackendFixture | null = null
+
+// GROUP_COMPOSER_SCREENSHOT_DIR=<dir> saves full-window captures at the key
+// states — PR evidence; never part of the assertions.
+async function capture(page: Page, name: string): Promise<void> {
+ const dir = process.env.GROUP_COMPOSER_SCREENSHOT_DIR
+
+ if (!dir) {
+ return
+ }
+
+ fs.mkdirSync(dir, { recursive: true })
+ await page.screenshot({ path: path.join(dir, `${name}.png`) })
+}
+
+async function seedBot(hermesHome: string, mockUrl: string, name: string): Promise<void> {
+ const dir = path.join(hermesHome, 'profiles', name)
+ fs.mkdirSync(dir, { recursive: true })
+ writeMockProviderConfig(dir, mockUrl)
+ writeEnvFile(dir)
+
+ const builder = await RealSessionBuilder.start(dir)
+
+ try {
+ await builder.createSession({ title: 'Bot Chat', turns: [`Hello ${name}`] })
+ } finally {
+ await builder.close()
+ }
+}
+
+const ROOM = 'Standup'
+
+test.beforeAll(async () => {
+ const mock = await startMockServer()
+ const sandbox = createSandbox('bots-group-composer')
+ writeMockProviderConfig(sandbox.hermesHome, mock.url)
+ writeEnvFile(sandbox.hermesHome)
+
+ for (const name of ['alpha', 'beta']) {
+ await seedBot(sandbox.hermesHome, mock.url, name)
+ }
+
+ const { app, page } = await launchDesktop(buildAppEnv(sandbox))
+
+ fixture = {
+ app,
+ page,
+ mock,
+ mockUrl: mock.url,
+ sandbox,
+ cleanup: async () => {
+ await app.close().catch(() => undefined)
+ await mock.close()
+ sandbox.cleanup()
+ }
+ }
+ await waitForAppReady(fixture, 120_000)
+})
+
+test.afterAll(async () => {
+ await fixture?.cleanup()
+ fixture = null
+})
+
+test('the group composer grows with a long prompt and stops at the viewport cap', async () => {
+ test.setTimeout(300_000)
+ const page = fixture!.page
+
+ 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()
+ await expect(page.locator('[data-roster-key="local::alpha"]')).toBeVisible({ timeout: 30_000 })
+
+ 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 name of ['Alpha @alpha', 'Beta @beta']) {
+ await dialog.getByRole('checkbox', { name }).click()
+ }
+
+ await dialog.getByRole('textbox', { name: 'Group name' }).fill(ROOM)
+ await dialog.getByRole('button', { name: 'Create Group (2)' }).click()
+ await expect(dialog).toBeHidden({ timeout: 30_000 })
+
+ const composer = page.getByRole('textbox', { name: `Message ${ROOM}` }).filter({ visible: true })
+ await expect(composer).toBeVisible({ timeout: 30_000 })
+
+ const metrics = () =>
+ composer.evaluate(el => {
+ const box = el.getBoundingClientRect()
+
+ return { height: Math.round(box.height), scrollHeight: el.scrollHeight, clientHeight: el.clientHeight }
+ })
+
+ const empty = await metrics()
+ await capture(page, '1-composer-empty')
+
+ // Eight explicit lines: the box must grow well past the single row.
+ const brief = Array.from({ length: 8 }, (_, i) => `Brief line ${i + 1}: agree on the release checklist item`).join('\n')
+ await composer.fill(brief)
+ const grown = await metrics()
+ await capture(page, '2-composer-eight-lines')
+ expect(grown.height).toBeGreaterThan(empty.height * 3)
+ // Content fits: nothing to scroll yet.
+ expect(grown.scrollHeight).toBeLessThanOrEqual(grown.clientHeight + 1)
+
+ // Far more than fits: growth stops at min(50vh, 24rem) and the text
+ // scrolls inside the box instead of taking over the room.
+ await composer.fill(Array.from({ length: 80 }, (_, i) => `Line ${i + 1}`).join('\n'))
+ const capped = await metrics()
+ await capture(page, '3-composer-capped-scrolls')
+ const viewport = page.viewportSize() ?? (await page.evaluate(() => ({ height: window.innerHeight, width: 0 })))
+ const cap = Math.min(viewport.height / 2, 24 * 16)
+ expect(capped.height).toBeLessThanOrEqual(cap + 1)
+ expect(capped.height).toBeGreaterThanOrEqual(grown.height)
+ expect(capped.scrollHeight).toBeGreaterThan(capped.clientHeight + 40)
+
+ // Enter still sends (not a newline): the composer empties back to one row.
+ await composer.fill('@alpha hello there')
+ await composer.press('Enter')
+ await expect.poll(async () => (await metrics()).height).toBe(empty.height)
+})
diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat-parts.test.tsx b/apps/desktop/src/plugins/hermes-bots/group-chat-parts.test.tsx
index e9ecd226ded..cca1e0a4648 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-chat-parts.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/group-chat-parts.test.tsx
@@ -175,6 +175,20 @@ describe('insertion', () => {
// #89884: the composer used to be a single-line Input whose form submitted on
// every Enter, so multi-line room prompts were impossible.
+describe('sizing (#95300)', () => {
+ it('sizes from its content up to a viewport-bounded cap and scrolls beyond it, while starting at one row', async () => {
+ const { input } = await mount()
+
+ // Chromium's field-sizing does the growing; the contract the room relies
+ // on is the class set: content-sized, capped, scrolling past the cap,
+ // and a single compact row when empty.
+ expect(input.rows).toBe(1)
+ expect(input.classList.contains('field-sizing-content')).toBe(true)
+ expect(input.classList.contains('max-h-[min(50vh,24rem)]')).toBe(true)
+ expect(input.classList.contains('overflow-y-auto')).toBe(true)
+ })
+})
+
describe('keyboard (#89884)', () => {
it('submits on Enter and leaves Shift+Enter to the textarea', async () => {
const { input, onSubmitDraft } = await mount('a room prompt')
diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsx b/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsx
index 86a33fc52b7..d157be5be84 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsx
@@ -283,7 +283,13 @@ export function GroupMentionInput({ members, onChange, onSubmitDraft, value, ...
// Input whose form submitted on every Enter — newlines were
// impossible. Enter (no Shift) still submits via onSubmitDraft;
// Shift+Enter falls through to the textarea's native newline.
- className={cn('max-h-40 min-h-9 resize-none', inputProps.className)}
+ // Grow with wrapped text/newlines so long briefs stay reviewable
+ // (#95300), then scroll internally before the composer takes over
+ // the room — same field-sizing idiom as the Kanban drawer.
+ className={cn(
+ 'field-sizing-content max-h-[min(50vh,24rem)] min-h-9 resize-none overflow-y-auto',
+ inputProps.className
+ )}
onBlur={() => setToken(null)}
onChange={event => {
onChange(event.target.value)
diff --git a/website/docs/user-guide/bot-mode.md b/website/docs/user-guide/bot-mode.md
index f3a470308a1..707f9da352b 100644
--- a/website/docs/user-guide/bot-mode.md
+++ b/website/docs/user-guide/bot-mode.md
@@ -117,6 +117,8 @@ Groups are standalone rows in the same activity-ordered roster as Bot DMs. A Bot
A room row organizes like a Bot row. Right-click it → **Pin to top** to keep a daily-driver room above the unpinned Bots and rooms (**Unpin** puts it back into recency order); the pin is saved with the room on this Desktop. Right-click → **Move to section** files the room into one of your [sections](#organize-bots-into-sections) — or drag the row onto a section heading — and **Remove from section** returns it to the group-chat bucket. A room's section is stored on its room record (rooms have no profile), so it stays local to this Desktop like the section list itself.
+The room composer (and the reply-in-thread composer) starts as a single row and grows as your prompt wraps or gains **Shift+Enter** newlines, up to half the window (at most 24rem); past that it scrolls inside the box so the transcript keeps its space. **Enter** sends.
+
Use the **Move up** and **Move down** arrows beside a room to choose its position among rooms. Until the first move, the existing pinned-first, recent-activity order is unchanged. After a move, room order is saved on this Desktop and survives reloads; new rooms follow the explicitly ordered rooms within their pinned or unpinned band. Moves cannot cross the pinned boundary, and filtering does not discard hidden rooms from the saved order. These controls reorder actual Group Chat rooms, not user-created Bot folders, and do not change membership or gateway ownership.
**Open chat** on any group row (2–6 Bots) opens a shared room where the whole group coordinates: