The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): group chat rename, disband, mentions and attachment paste
unsupportedpastels2b75150de5a4
diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.tsxindex 0d0f6afbbaf..bd5cc32e4c8 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.tsx@@ -1,5 +1,5 @@import { Button } from '@hermes/plugin-sdk'-import { useLayoutEffect, useRef, useState } from 'react'+import { type Ref, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react'import { downloadCanonicalAttachment } from './canonical-attachment-download'import { useCanonicalGroupLabels } from './canonical-group-labels'@@ -8,6 +8,15 @@ import { type CanonicalGroupBinding, canonicalGroupRequest } from './canonical-gexport interface CanonicalGroupAttachment { attachment_id?: string; event_id?: string; kind: string; name: string; mime: string; size?: number }type Attachment = CanonicalGroupAttachmentinterface DownloadedAttachment extends Attachment { data_base64: string }+export interface CanonicalGroupUploader { upload: (files: File[]) => void }++export async function fetchCanonicalGroupAttachment(binding: CanonicalGroupBinding, eventId: string, attachmentId: string) {+ const result = await canonicalGroupRequest<DownloadedAttachment>(binding, 'groups.attachment.download', {+ room_id: binding.roomId, event_id: eventId, attachment_id: attachmentId+ })++ return { name: result.name, mime: result.mime, bytes: Uint8Array.from(atob(result.data_base64), char => char.charCodeAt(0)) }+}function kindFor(file: File): string {if (file.type.startsWith('image/')) {return 'image'}@@ -17,12 +26,14 @@ function kindFor(file: File): string {return 'file'}-export function CanonicalGroupAttachments({ binding, attachments, onChange, onUploadingChange, disabled, readOnly = false }: {+export function CanonicalGroupAttachments({ binding, attachments, onChange, onUploadingChange, disabled, readOnly = false, ref }: {binding: CanonicalGroupBindingattachments: Attachment[]disabled: boolean// C21: the form holds Send while a selected file's manifest is not committed yet.onUploadingChange?: (uploading: boolean) => void+ // Paste and drop in the composer reuse this upload path.+ ref?: Ref<CanonicalGroupUploader>} & ({ readOnly: true; onChange?: never } | { readOnly?: false; onChange: (attachments: Attachment[]) => void })) {const labels = useCanonicalGroupLabels()const input = useRef<HTMLInputElement>(null)@@ -40,11 +51,14 @@ export function CanonicalGroupAttachments({ binding, attachments, onChange, onUpreturn () => controller.abort()}, [binding.connectionId, binding.profile, binding.roomId, disabled, readOnly])- async function upload(file: File) {- if (readOnly) {return}+ useImperativeHandle(ref, () => ({ upload: files => void upload(files) }))++ async function upload(files: File[]) {+ if (readOnly || busy) {return}setBusy(true); setError(''); onUploadingChange?.(true)+ let next = attachments- try {+ try { for (const file of files) {const data = await new Promise<string>((resolve, reject) => {const reader = new FileReader()reader.onload = () => resolve(String(reader.result).split(',', 2)[1])@@ -59,8 +73,9 @@ export function CanonicalGroupAttachments({ binding, attachments, onChange, onUp// Upload receipts include storage metadata; Send accepts only the manifest.const { attachment_id, kind, name, mime, size } = result- onChange?.([...attachments, { attachment_id, kind, name, mime, size }])- } catch (e) { setError(e instanceof Error ? e.message : String(e)) }+ next = [...next, { attachment_id, kind, name, mime, size }]+ onChange?.(next)+ } } catch (e) { setError(e instanceof Error ? e.message : String(e)) }finally { setBusy(false); onUploadingChange?.(false) }}@@ -71,13 +86,10 @@ export function CanonicalGroupAttachments({ binding, attachments, onChange, onUpsetBusy(true); setError('')try {- const result = await canonicalGroupRequest<DownloadedAttachment>(binding, 'groups.attachment.download', {- room_id: binding.roomId, event_id: attachment.event_id, attachment_id: attachment.attachment_id- })+ const result = await fetchCanonicalGroupAttachment(binding, attachment.event_id, attachment.attachment_id)if (signal.aborted) {return}- const bytes = Uint8Array.from(atob(result.data_base64), char => char.charCodeAt(0))- downloadCanonicalAttachment(bytes, result.name, result.mime, signal)+ downloadCanonicalAttachment(result.bytes, result.name, result.mime, signal)} catch (e) { if (!signal.aborted) {setError(e instanceof Error ? e.message : String(e))} }finally { if (!signal.aborted) {setBusy(false)} }}@@ -85,7 +97,7 @@ export function CanonicalGroupAttachments({ binding, attachments, onChange, onUpreturn <div className="flex flex-wrap items-center gap-2">{!readOnly && <><input hidden onChange={e => { const file = e.target.files?.[0];- if (file) {void upload(file);} e.currentTarget.value = '' }} ref={input} type="file" />+ if (file) {void upload([file]);} e.currentTarget.value = '' }} ref={input} type="file" /><Button disabled={disabled || busy} onClick={() => input.current?.click()} type="button">{labels.attachFiles}</Button></>}{attachments.map(a => <span className="flex items-center gap-1" key={a.attachment_id ?? a.name}><span>{a.name}</span><Button disabled={disabled || busy} onClick={() => void download(a)} type="button">{labels.download}</Button>diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-download-lifetime.test.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-download-lifetime.test.tsxindex 1b473e18bd6..fed7cfd2fee 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-download-lifetime.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-download-lifetime.test.tsx@@ -13,6 +13,7 @@ vi.mock('@hermes/plugin-sdk', async () => {Button: (props: ComponentProps<'button'>) => <button {...props} />,Codicon: () => <span />, Tip: ({ children }: { children: ReactNode }) => <>{children}</> }})+vi.mock('./group-chat-parts', () => ({ GroupMentionInput: () => null }))vi.mock('./canonical-group-labels', async () => {const { CANONICAL_GROUP_LOCALES } = await import('./canonical-group-locales')diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-header.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-header.tsxnew file mode 100644index 00000000000..6eec7ab495e--- /dev/null+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-header.tsx@@ -0,0 +1,57 @@+import { Button, Input } from '@hermes/plugin-sdk'+import { useState } from 'react'++import { CanonicalGroupRoster, type CanonicalMemberPhase } from './canonical-group-activity'+import { useCanonicalGroupLabels } from './canonical-group-labels'+import type { CanonicalRoom } from './canonical-groups'++interface CanonicalGroupHeaderProps {+ busy: boolean+ canStop: boolean+ onBack?: () => void+ onDisband: () => void+ onRename: (name: string) => void+ onStop: () => void+ phases: Map<string, CanonicalMemberPhase>+ room?: CanonicalRoom+}++export function CanonicalGroupHeader({ busy, canStop, onBack, onDisband, onRename, onStop, phases, room }: CanonicalGroupHeaderProps) {+ const labels = useCanonicalGroupLabels()+ const [renaming, setRenaming] = useState<string | null>(null)+ const [ending, setEnding] = useState(false)++ const rename = (name: string) => {+ setRenaming(null)++ if (name) {onRename(name)}+ }++ const end = () => {+ setEnding(false)+ onDisband()+ }++ return <>+ <header className="flex items-center gap-2">+ {onBack && <Button onClick={onBack}>{labels.back}</Button>}+ <div className="min-w-0">+ <h2 className="text-sm font-medium">{room?.name || labels.loadingGroup}</h2>+ <CanonicalGroupRoster label={labels.members} labels={labels} members={room?.members} phases={phases} />+ </div>+ <Button disabled={busy || !canStop} onClick={onStop}>{labels.stop}</Button>+ <Button disabled={busy || !room} onClick={() => setRenaming(room?.name ?? '')}>{labels.rename}</Button>+ <Button disabled={busy || !room} onClick={() => setEnding(true)}>{labels.disband}</Button>+ </header>+ {renaming !== null && <form className="flex items-center gap-2" onSubmit={event => { event.preventDefault(); rename(renaming.trim()) }}>+ <Input aria-label={labels.renameLabel} autoFocus onChange={event => setRenaming(event.target.value)} value={renaming} />+ <Button disabled={busy || !renaming.trim()} type="submit">{labels.save}</Button>+ <Button onClick={() => setRenaming(null)} type="button">{labels.cancel}</Button>+ </form>}+ {ending && <div aria-label={labels.disbandTitle} role="alertdialog">+ <p>{labels.disbandTitle}</p>+ <Button disabled={busy} onClick={end}>{labels.disband}</Button>+ <Button onClick={() => setEnding(false)}>{labels.cancel}</Button>+ </div>}+ </>+}diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-history.test.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-history.test.tsxindex 612a304404b..3da18d2cfa6 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-history.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-history.test.tsx@@ -15,6 +15,11 @@ vi.mock('@hermes/plugin-sdk', async () => {Streamdown: ({ children }: { children: ReactNode }) => <div data-testid="markdown">{children}</div>,Codicon: () => <span />, Tip: ({ children }: { children: ReactNode }) => <>{children}</> }})+// The @ picker reads Bot Mode stores this hosted-room fixture does not mock.+vi.mock('./group-chat-parts', () => ({+ GroupMentionInput: ({ onChange, ...props }: Omit<ComponentProps<'textarea'>, 'onChange'> & { onChange: (value: string) => void }) =>+ <textarea aria-label={props['aria-label']} disabled={props.disabled} onChange={event => onChange(event.target.value)} value={props.value} />+}))vi.mock('./canonical-group-labels', async () => {const { CANONICAL_GROUP_LOCALES } = await import('./canonical-group-locales')diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-history.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-history.tsxindex cf59c58943d..d4b8a5b352b 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-history.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-history.tsx@@ -1,6 +1,7 @@import * as sdk from '@hermes/plugin-sdk'+import { useEffect, useState } from 'react'-import { type CanonicalGroupAttachment, CanonicalGroupAttachments } from './canonical-group-attachments'+import { type CanonicalGroupAttachment, CanonicalGroupAttachments, fetchCanonicalGroupAttachment } from './canonical-group-attachments'import { useCanonicalGroupLabels } from './canonical-group-labels'import type { CanonicalGroupBinding, CanonicalRoomMember } from './canonical-groups'@@ -65,6 +66,34 @@ function EventBody({ event, notice }: { event: CanonicalGroupEvent; notice?: str</div>}+// Previews download the whole file over RPC; larger or unsized images keep only Download.+const IMAGE_PREVIEW_MAX_BYTES = 5 * 1024 * 1024++function ImagePreview({ binding, eventId, attachment, disabled }: {+ binding: CanonicalGroupBinding; eventId: string; attachment: CanonicalGroupAttachment; disabled: boolean+}) {+ const [src, setSrc] = useState('')+ const { attachment_id: attachmentId, size } = attachment+ const { connectionId, profile, roomId } = binding+ const previewable = size !== undefined && size <= IMAGE_PREVIEW_MAX_BYTES++ useEffect(() => {+ if (disabled || !attachmentId || !previewable) {return}+ let cancelled = false+ let url = ''+ // A failed preview leaves the Download button as the way to the file.+ void fetchCanonicalGroupAttachment({ connectionId, profile, roomId }, eventId, attachmentId).then(({ bytes, mime }) => {+ if (cancelled) {return}+ url = URL.createObjectURL(new Blob([bytes], { type: mime }))+ setSrc(url)+ }, () => undefined)++ return () => { cancelled = true; URL.revokeObjectURL(url); setSrc('') }+ }, [connectionId, profile, roomId, eventId, attachmentId, disabled, previewable])++ return src ? <img alt={attachment.name} className="max-h-64 max-w-full rounded object-contain" src={src} /> : null+}+export function CanonicalGroupHistory({ binding, events, members = [], disabled = false }: CanonicalGroupHistoryProps) {const labels = useCanonicalGroupLabels()const roster = new Map(members.map(member => [member.member_id, member]))@@ -87,6 +116,7 @@ export function CanonicalGroupHistory({ binding, events, members = [], disabledif (!notice && !isMessage) {return null}const author = eventAuthor(event, roster, isMessage)+ const previewEventId = event.room_id === binding.roomId ? event.event_id : undefinedreturn <div className="grid grid-cols-[minmax(0,1fr)] gap-1 px-2 py-1.5" key={event.seq}><div className="flex items-center gap-2">@@ -94,6 +124,8 @@ export function CanonicalGroupHistory({ binding, events, members = [], disabled<EventTime timestamp={event.created_at} /></div><EventBody event={event} notice={notice} />+ {previewEventId && event.payload.attachments?.filter(a => a.kind === 'image').map(a =>+ <ImagePreview attachment={a} binding={binding} disabled={disabled} eventId={previewEventId} key={a.attachment_id ?? a.name} />)}{!!event.payload.attachments?.length && <CanonicalGroupAttachmentsattachments={event.payload.attachments.map(attachment => ({ ...attachment, event_id: event.event_id }))}binding={binding} disabled={disabled || !event.event_id || event.room_id !== binding.roomId} readOnly />}diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-labels.ts b/apps/desktop/src/plugins/hermes-bots/canonical-group-labels.tsindex 5ad29e8ffb9..57ae8392ad8 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-labels.ts+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-labels.ts@@ -5,7 +5,7 @@ import { useBots } from './i18n'/** Hosted group copy stays plugin-owned; generic controls reuse the core catalog. */export function useCanonicalGroupLabels() {const { t } = useI18n()- const { canonical } = useBots()+ const { canonical, group } = useBots()return {...canonical,@@ -16,6 +16,11 @@ export function useCanonicalGroupLabels() {send: t.common.send,stop: t.composer.stop,discard: t.composer.queueLostDiscard,- download: t.fileMenu.download+ download: t.fileMenu.download,+ rename: t.fileMenu.renameTitle,+ renameLabel: t.fileMenu.renameLabel,+ save: t.common.save,+ disband: group.disbandAction,+ disbandTitle: group.disbandTitle}}diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.test.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.test.tsxindex e5d0c24c2d8..8cd12a1dd06 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.test.tsx@@ -1,5 +1,5 @@import { useStore } from '@nanostores/react'-import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'import { atom } from 'nanostores'import type { ComponentProps } from 'react'import { afterEach, beforeEach, expect, it, vi } from 'vitest'@@ -15,6 +15,8 @@ vi.mock('@hermes/plugin-sdk', async () => {useI18n: () => ({ t: en }),usePluginI18n: () => (key: string) => CANONICAL_GROUP_LOCALES.en[key.replace('canonical.', '') as keyof typeof CANONICAL_GROUP_LOCALES.en] ?? key,Button: (p: ComponentProps<'button'>) => <button {...p} />,+ Input: (p: ComponentProps<'input'>) => <input {...p} />,+ RowButton: (p: ComponentProps<'button'>) => <button type="button" {...p} />,host: { ...gateway.host, requestProfile: request } }})import { registerCanonicalGroup } from './canonical-group-registry'@@ -199,3 +201,77 @@ it('shows which bots are working, and still says the group is working on a gatewrender(<CanonicalGroupWorkspace binding={{ connectionId: 'local', profile: 'team', roomId: 'older' }} />)await waitFor(() => expect(screen.getByRole('status').textContent).toBe('The group is working…'))})+++const roomReads = (members: unknown[] = [], events: unknown[] = []) => (method: string) => method === 'groups.state'+ ? { room: { name: 'Room', members }, driver_status: {} } : method === 'groups.log' ? { events } : undefined++it('describes only a send restored from the journal as restored, never an ordinary in-flight send', async () => {+ let ack!: () => void+ request.mockImplementation(async (_route, method) => roomReads()(method)+ ?? (method === 'groups.send' ? new Promise(resolve => { ack = () => resolve({}) }) : {}))+ const view = render(<CanonicalGroupWorkspace binding={{ connectionId: 'remote', profile: 'team', roomId: 'ordinary' }} />)+ await waitFor(() => expect((screen.getByRole('textbox') as HTMLTextAreaElement).disabled).toBe(false))+ fireEvent.change(screen.getByRole('textbox'), { target: { value: 'Hello' } })+ fireEvent.click(screen.getByRole('button', { name: 'Send' }))+ await waitFor(() => expect(request.mock.calls.some(c => c[1] === 'groups.send')).toBe(true))+ expect(screen.queryByText(/unconfirmed send was restored/)).toBeNull()+ await act(async () => ack())+ view.unmount()++ const binding = { connectionId: 'remote', profile: 'team', roomId: 'restored' }+ await prepareCanonicalGroupSend(binding, { text: 'Left over', attachments: [] })+ render(<CanonicalGroupWorkspace binding={binding} />)+ await screen.findByText(/unconfirmed send was restored/)+})++it('renames the room and disbands it only after confirmation, through the gateway handlers', async () => {+ const onBack = vi.fn()+ request.mockImplementation(async (_route, method) => roomReads()(method) ?? {})+ render(<CanonicalGroupWorkspace binding={{ connectionId: 'remote', profile: 'team', roomId: 'controls' }} onBack={onBack} />)+ fireEvent.click(await screen.findByRole('button', { name: 'Rename' }))+ fireEvent.change(screen.getByRole('textbox', { name: 'New name' }), { target: { value: ' Renamed ' } })+ fireEvent.click(screen.getByRole('button', { name: 'Save' }))+ await waitFor(() => expect(request.mock.calls.find(c => c[1] === 'groups.rename')?.[2]).toMatchObject({ room_id: 'controls', name: 'Renamed' }))+ const disband = screen.getByRole('button', { name: /disband/i }) as HTMLButtonElement+ await waitFor(() => expect(disband.disabled).toBe(false))+ fireEvent.click(disband)+ expect(request.mock.calls.some(c => c[1] === 'groups.disband')).toBe(false)+ fireEvent.click(within(screen.getByRole('alertdialog')).getByRole('button', { name: /disband/i }))+ await waitFor(() => expect(onBack).toHaveBeenCalledOnce())+ expect(request.mock.calls.find(c => c[1] === 'groups.disband')?.[2]).toMatchObject({ room_id: 'controls', cancel_id: expect.any(String) })+})++it('@-completes room members with the exact handle the gateway resolves', async () => {+ request.mockImplementation(async (_route, method) => roomReads([{ member_id: 'm1', profile: 'ops', handle: 'ops-2', display_name: 'Ops Bot' }])(method) ?? {})+ render(<CanonicalGroupWorkspace binding={{ connectionId: 'local', profile: 'team', roomId: 'mentions' }} />)+ await screen.findByText('Ops Bot')+ await waitFor(() => expect((screen.getByRole('textbox') as HTMLTextAreaElement).disabled).toBe(false))+ fireEvent.change(screen.getByRole('textbox'), { target: { value: '@' } })+ expect(screen.getByText('@everyone')).toBeTruthy()+ fireEvent.change(screen.getByRole('textbox'), { target: { value: '@op' } })+ fireEvent.mouseDown(screen.getByText('@ops-2'))+ expect((screen.getByRole('textbox') as HTMLTextAreaElement).value).toBe('@ops-2 ')+})++it('uploads pasted and dropped files through the room upload and previews committed images inline', async () => {+ Object.defineProperty(URL, 'createObjectURL', { configurable: true, value: vi.fn(() => 'blob:preview') })+ Object.defineProperty(URL, 'revokeObjectURL', { configurable: true, value: vi.fn() })+ const image = { attachment_id: 'img', kind: 'image', name: 'shot.png', mime: 'image/png', size: 1 }+ const large = { ...image, attachment_id: 'large', name: 'large.png', size: 6 * 1024 * 1024 }+ const events = [{ seq: 1, room_id: 'paste', event_id: 'e1', kind: 'message.member', payload: { attachments: [image, large] } }]+ request.mockImplementation(async (_route, method, params) => roomReads([], events)(method)+ ?? (method === 'groups.attachment.upload' ? { attachment_id: `att-${params.name}`, kind: params.kind, name: params.name, mime: params.mime, size: 1 }+ : method === 'groups.attachment.download' ? { ...image, data_base64: 'QQ==' } : {}))+ render(<CanonicalGroupWorkspace binding={{ connectionId: 'local', profile: 'team', roomId: 'paste' }} />)+ await waitFor(() => expect(screen.getByRole('img', { name: 'shot.png' }).getAttribute('src')).toBe('blob:preview'))+ expect(request.mock.calls.filter(c => c[1] === 'groups.attachment.download').map(c => c[2].attachment_id)).toEqual(['img'])+ const box = screen.getByRole('textbox')+ await waitFor(() => expect((box as HTMLTextAreaElement).disabled).toBe(false))+ fireEvent.paste(box, { clipboardData: { files: [], types: ['text/plain'] } })+ fireEvent.paste(box, { clipboardData: { files: [new File(['a'], 'a.png', { type: 'image/png' })], types: ['Files'] } })+ await screen.findByText('a.png')+ fireEvent.drop(box, { dataTransfer: { files: [new File(['b'], 'b.txt', { type: 'text/plain' })], types: ['Files'] } })+ await screen.findByText('b.txt')+ expect(request.mock.calls.filter(c => c[1] === 'groups.attachment.upload').map(c => [c[2].name, c[2].kind])).toEqual([['a.png', 'image'], ['b.txt', 'file']])+})diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.tsxindex ebd59872eac..ecb9767e52d 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.tsx@@ -1,14 +1,16 @@-import { Button, Textarea } from '@hermes/plugin-sdk'-import { useEffect, useRef, useState } from 'react'+import { Button } from '@hermes/plugin-sdk'+import { type ClipboardEvent, type DragEvent, useEffect, useRef, useState } from 'react'-import { type CanonicalDriverActivity, CanonicalGroupRoster, CanonicalGroupWorkingLine, canonicalMemberPhases } from './canonical-group-activity'-import { CanonicalGroupAttachments } from './canonical-group-attachments'+import { type CanonicalDriverActivity, CanonicalGroupWorkingLine, canonicalMemberPhases } from './canonical-group-activity'+import { CanonicalGroupAttachments, type CanonicalGroupUploader } from './canonical-group-attachments'+import { CanonicalGroupHeader } from './canonical-group-header'import { type CanonicalGroupEvent, CanonicalGroupHistory } from './canonical-group-history'import { useCanonicalGroupLabels } from './canonical-group-labels'import { prepareCanonicalGroupSend, readCanonicalGroupSend, retireCanonicalGroupSend } from './canonical-group-send'import type { PreparedCanonicalGroupSend } from './canonical-group-send'import { actCanonicalGroup, canonicalGroupRequest } from './canonical-groups'import type { CanonicalGroupBinding, CanonicalPendingAction, CanonicalRoom } from './canonical-groups'+import { GroupMentionInput } from './group-chat-parts'type RoomEvent = CanonicalGroupEventinterface Attachment { attachment_id?: string; event_id?: string; kind: string; name: string; mime: string; size?: number }@@ -38,6 +40,9 @@ function CanonicalRoomView({ binding: initialBinding, visible, onBack }: {const [uploading, setUploading] = useState(false)const [restored, setRestored] = useState(false)const [pending, setPending] = useState<PreparedCanonicalGroupSend | null>(null)+ // Only a journal entry found on mount is "restored"; this window's own in-flight send also sets `pending`.+ const [restoredPending, setRestoredPending] = useState(false)+ const uploader = useRef<CanonicalGroupUploader>(null)const [busy, setBusy] = useState(false)const busyRef = useRef(false)const alive = useRef(true)@@ -55,6 +60,7 @@ function CanonicalRoomView({ binding: initialBinding, visible, onBack }: {if (entry) {setPending(entry)+ setRestoredPending(true)setDraft(String(entry.params.payload.text ?? ''))setAttachments((entry.params.payload.attachments as Attachment[] | undefined) ?? [])}@@ -107,7 +113,7 @@ function CanonicalRoomView({ binding: initialBinding, visible, onBack }: {// eslint-disable-next-line react-hooks/exhaustive-deps}, [visible])- const mutate = async (operation: () => Promise<unknown>) => {+ const mutate = async (operation: () => Promise<unknown>, settle: () => unknown = refresh) => {if (busyRef.current) {return}busyRef.current = truesetBusy(true)@@ -115,7 +121,7 @@ function CanonicalRoomView({ binding: initialBinding, visible, onBack }: {try { await operation();- if (alive.current) {await refresh()} }+ if (alive.current) {await settle()} }catch (e) { if (alive.current) {setError(e instanceof Error ? e.message : String(e))} }finally {busyRef.current = false@@ -146,6 +152,7 @@ function CanonicalRoomView({ binding: initialBinding, visible, onBack }: {const held = heldDraft.currentheldDraft.current = nullsetPending(null)+ setRestoredPending(false)setDraft(held?.text ?? '')setAttachments(held?.attachments ?? [])}@@ -155,18 +162,30 @@ function CanonicalRoomView({ binding: initialBinding, visible, onBack }: {const act = (action: CanonicalPendingAction, choice?: 'once' | 'deny') =>mutate(() => actCanonicalGroup(binding, action, choice))+ const rename = (name: string) =>+ void mutate(() => canonicalGroupRequest(binding, 'groups.rename', { room_id: binding.roomId, event_id: crypto.randomUUID(), name }))++ // A disbanded room no longer reads back, so leave it instead of refreshing.+ const end = () =>+ void mutate(() => canonicalGroupRequest(binding, 'groups.disband', { room_id: binding.roomId, cancel_id: crypto.randomUUID() }), () => onBack?.())+const composerLocked = !restored || busy || !!pendingconst phases = canonicalMemberPhases(state?.driver_status)+ const mentionMembers = (state?.room.members ?? []).map(member => ({ name: member.handle, handle: member.handle, display_name: member.display_name }))++ // Text pastes stay in the composer; only files go through the picker's upload.+ const attachTransfer = (event: ClipboardEvent | DragEvent, data: DataTransfer | null) => {+ const files = [...(data?.files ?? [])]++ if (!files.length) {return}+ event.preventDefault()++ if (!composerLocked && !uploading) {uploader.current?.upload(files)}+ }return <section className="flex h-full min-h-0 flex-col gap-3 p-3">- <header className="flex items-center gap-2">- {onBack && <Button onClick={onBack}>{labels.back}</Button>}- <div className="min-w-0">- <h2 className="text-sm font-medium">{state?.room.name || labels.loadingGroup}</h2>- <CanonicalGroupRoster label={labels.members} labels={labels} members={state?.room.members} phases={phases} />- </div>- <Button disabled={busy || !state?.driver_status} onClick={() => void mutate(() => canonicalGroupRequest(binding, 'groups.stop', { room_id: binding.roomId, cancel_id: crypto.randomUUID() }))}>{labels.stop}</Button>- </header>+ <CanonicalGroupHeader busy={busy} canStop={!!state?.driver_status} onBack={onBack} onDisband={end} onRename={rename}+ onStop={() => void mutate(() => canonicalGroupRequest(binding, 'groups.stop', { room_id: binding.roomId, cancel_id: crypto.randomUUID() }))} phases={phases} room={state?.room} />{readError && <div role="alert">{readError}<Button onClick={() => void refresh().catch(e => setReadError(String(e)))}>{labels.refresh}</Button></div>}{error && <div role="alert">{error}</div>}{state && !state.driver_status && <p>{labels.driverUnavailable}</p>}@@ -185,10 +204,12 @@ function CanonicalRoomView({ binding: initialBinding, visible, onBack }: {<Button disabled={busy} onClick={() => { const exact = discard; setDiscard(null); void act(exact) }}>{labels.confirmDiscard}</Button><Button onClick={() => setDiscard(null)}>{labels.cancel}</Button></div>}- {pending && <p role="status">{labels.restoredPendingSend}</p>}- <form className="flex gap-2" onSubmit={event => { event.preventDefault(); send() }}>- <CanonicalGroupAttachments attachments={attachments} binding={binding} disabled={composerLocked} onChange={setAttachments} onUploadingChange={setUploading} />- <Textarea aria-label={labels.groupMessage} className="min-w-0 flex-1" disabled={composerLocked} onChange={e => setDraft(e.target.value)} value={draft} />+ {restoredPending && <p role="status">{labels.restoredPendingSend}</p>}+ <form className="flex gap-2" onDragOver={event => { if (event.dataTransfer.types.includes('Files')) {event.preventDefault()} }}+ onDrop={event => attachTransfer(event, event.dataTransfer)} onPaste={event => attachTransfer(event, event.clipboardData)} onSubmit={event => { event.preventDefault(); send() }}>+ <CanonicalGroupAttachments attachments={attachments} binding={binding} disabled={composerLocked} onChange={setAttachments} onUploadingChange={setUploading} ref={uploader} />+ <GroupMentionInput aria-label={labels.groupMessage} className="min-w-0 flex-1" disabled={composerLocked} handleFor={member => member.handle}+ members={mentionMembers} onChange={setDraft} onSubmitDraft={send} value={draft} /><Button disabled={!restored || busy || uploading || (!pending && !draft.trim() && !attachments.length) || !state?.driver_status} type="submit">{pending ? labels.retry : labels.send}</Button></form></section>diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsx b/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsxindex 733529b5eb7..83cef561219 100644--- a/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsx+++ b/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsx@@ -159,6 +159,9 @@ interface GroupMentionInputProps {'aria-label'?: stringautoFocus?: booleanclassName?: string+ disabled?: boolean+ /** The exact token a member's mention inserts, for rooms that resolve only frozen handles. */+ handleFor?: (member: GroupMember) => string | undefinedmembers: GroupMember[]onChange: (value: string) => voidonPaste?: (event: ClipboardEvent<HTMLTextAreaElement>) => void@@ -174,7 +177,7 @@ interface GroupMentionInputProps {* the strings parseGroupChatMentions resolves. Keyboard: Up/Down navigate,* Enter/Tab insert (Enter falls through to submit when the popover is* closed), Escape dismisses. */-export function GroupMentionInput({ members, onChange, onSubmitDraft, value, ...inputProps }: GroupMentionInputProps) {+export function GroupMentionInput({ handleFor, members, onChange, onSubmitDraft, value, ...inputProps }: GroupMentionInputProps) {const b = useBots()const allMeta: Record<string, BotMeta> = useValue($botMeta)const inputRef = useRef<HTMLTextAreaElement | null>(null)@@ -196,7 +199,7 @@ export function GroupMentionInput({ members, onChange, onSubmitDraft, value, ...const handle = String(botHandle(member.name, member) || '').trim()const display = displayName(member, botRosterMeta(member, allMeta))// Renamed members complete on their friendly tag; parser resolves both.- const tag = String(botMentionTag(member) || handle).trim()+ const tag = String(handleFor?.(member) ?? (botMentionTag(member) || handle)).trim()if (!tag) {continuediff --git a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts b/apps/desktop/src/plugins/hermes-bots/group-test-utils.tsindex e0e45413f7f..29666d6aa20 100644--- a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts@@ -456,9 +456,11 @@ export function createGroupGateway(options: GatewayOptions = {}): ScriptedGatewaexport async function pluginSdkMock(host: Record<string, unknown>) {const nanostores = await import('nanostores')const { Textarea } = await import('@/components/ui/textarea')+ const { cn } = await import('@/lib/utils')return {Textarea,+ cn,// Real value: approval.respond forwards it as its client deadline (#60654).APPROVAL_RESPOND_TIMEOUT_MS: 300_000,atom: nanostores.atom,