The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep shared group files visible and downloadable after Send
David Dudok de Wite518b42421f5
diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-attachment-download.ts b/apps/desktop/src/plugins/hermes-bots/canonical-attachment-download.tsnew file mode 100644index 00000000000..d0ba7dd4e31--- /dev/null+++ b/apps/desktop/src/plugins/hermes-bots/canonical-attachment-download.ts@@ -0,0 +1,20 @@+/** Use the existing browser-download -> Electron Save File workflow, not composer staging.+ * Mirrors downloadTextFile and #104199's attachment delivery without a new native IPC. */+export function downloadCanonicalAttachment(bytes: Uint8Array<ArrayBuffer>, name: string, mime: string, signal?: AbortSignal) {+ if (signal?.aborted) {return}+ const url = URL.createObjectURL(new Blob([bytes], { type: mime }))+ const link = document.createElement('a')+ link.href = url+ link.download = name+ link.rel = 'noopener noreferrer'+ link.style.display = 'none'+ document.body.appendChild(link)++ try {+ if (!signal?.aborted) {link.click()}+ } finally {+ link.remove()+ // Keep the object URL alive while Chromium hands the bytes to its download manager.+ window.setTimeout(() => URL.revokeObjectURL(url), 30_000)+ }+}diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-download-test-utils.ts b/apps/desktop/src/plugins/hermes-bots/canonical-download-test-utils.tsnew file mode 100644index 00000000000..f6bde6dc7be--- /dev/null+++ b/apps/desktop/src/plugins/hermes-bots/canonical-download-test-utils.ts@@ -0,0 +1,47 @@+import { expect, vi } from 'vitest'++/** Observe a user-facing browser download, not a private cache-writing IPC. */+export function observeDownloads() {+ const blobs = new Map<string, Blob>()+ const downloads: Array<{ blob: Blob; name: string; connected: boolean }> = []++ const create = vi.fn((blob: Blob) => {+ const url = `blob:http://localhost/file-${blobs.size}`+ blobs.set(url, blob)++ return url+ })++ const revoke = vi.fn()+ vi.stubGlobal('URL', class extends URL {+ static createObjectURL = create+ static revokeObjectURL = revoke+ })++ const click = vi.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(function (this: HTMLAnchorElement) {+ const blob = blobs.get(this.href)++ if (!blob) {throw new Error('Download did not use the provided bytes')}+ downloads.push({ blob, name: this.download, connected: this.isConnected })+ })++ return { downloads, create, revoke, click }+}++export async function expectDownloaded(+ observed: ReturnType<typeof observeDownloads>, bytes: Uint8Array, name: string, mime: string, index = 0+) {+ const entry = observed.downloads[index]+ expect(entry.name).toBe(name)+ expect(entry.connected).toBe(true)+ expect(entry.blob.type).toBe(mime)++ const buffer = await new Promise<ArrayBuffer>((resolve, reject) => {+ const reader = new FileReader()+ reader.onload = () => resolve(reader.result as ArrayBuffer)+ reader.onerror = () => reject(reader.error)+ reader.readAsArrayBuffer(entry.blob)+ })++ expect(new Uint8Array(buffer)).toEqual(bytes)+}diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.test.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.test.tsxindex 1ec9abb1565..93824b078d4 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.test.tsx@@ -2,6 +2,8 @@ import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/reimport type { ComponentProps } from 'react'import { afterEach, expect, it, vi } from 'vitest'+import { expectDownloaded, observeDownloads } from './canonical-download-test-utils'+const request = vi.hoisted(() => vi.fn())vi.mock('@hermes/plugin-sdk', () => ({host: { requestProfile: request },@@ -16,7 +18,7 @@ import { CanonicalGroupAttachments } from './canonical-group-attachments'const binding = { connectionId: 'remote-owner', profile: 'reviewer', roomId: 'room' }const originalDesktop = window.hermesDesktop-afterEach(() => { cleanup(); request.mockReset(); window.hermesDesktop = originalDesktop })+afterEach(() => { cleanup(); request.mockReset(); vi.restoreAllMocks(); vi.unstubAllGlobals(); window.hermesDesktop = originalDesktop })it.each([32, 1_048_576])('uploads all %i bytes using the canonical owner method', async size => {const bytes = Uint8Array.from({ length: size }, (_, index) => index % 256)@@ -26,6 +28,7 @@ it.each([32, 1_048_576])('uploads all %i bytes using the canonical owner method'const uploaded = { attachment_id: 'file-one', kind: 'file', name: file.name, mime: file.type, size }request.mockImplementation(async (route, method, params) => {expect(route).toMatchObject({ connectionId: binding.connectionId, targetProfile: binding.profile })+if (method !== 'groups.attachment.upload') {throw new Error('Unknown gateway method')}expect(params).toMatchObject({ profile: binding.profile, room_id: binding.roomId, name: file.name })const decoded = Uint8Array.from(atob(params.data_base64), value => value.charCodeAt(0))@@ -47,9 +50,11 @@ it.each([32, 1_048_576])('uploads all %i bytes using the canonical owner method'it('downloads only the selected committed attachment from its captured owner', async () => {const attachment = { attachment_id: 'file-one', event_id: 'event-one', kind: 'file', name: 'report.bin', mime: 'application/octet-stream' }const save = vi.fn().mockResolvedValue(undefined)+ const observed = observeDownloads()window.hermesDesktop = { saveImageBuffer: save } as unknown as typeof window.hermesDesktoprequest.mockImplementation(async (route, method, params) => {expect(route).toMatchObject({ connectionId: binding.connectionId, targetProfile: binding.profile })+if (method !== 'groups.attachment.download') {throw new Error('Unknown gateway method')}expect(params).toEqual({ profile: binding.profile, room_id: binding.roomId,event_id: attachment.event_id, attachment_id: attachment.attachment_id })@@ -60,7 +65,9 @@ it('downloads only the selected committed attachment from its captured owner', aconst changed = vi.fn()render(<form onSubmit={submit}><CanonicalGroupAttachments attachments={[attachment]} binding={binding} disabled={false} onChange={changed} /></form>)fireEvent.click(screen.getByRole('button', { name: 'Download' }))- await waitFor(() => expect(save).toHaveBeenCalledWith(new Uint8Array([0, 1, 2, 255]), '.bin', attachment.name))+ await waitFor(() => expect(observed.downloads).toHaveLength(1))+ await expectDownloaded(observed, new Uint8Array([0, 1, 2, 255]), attachment.name, attachment.mime)+ expect(save).not.toHaveBeenCalled()expect(request).toHaveBeenCalledTimes(1)await waitFor(() => expect((screen.getByRole('button', { name: 'Remove' }) as HTMLButtonElement).disabled).toBe(false))fireEvent.click(screen.getByRole('button', { name: 'Remove' }))diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.tsxindex 08165156d38..ee131c93150 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-attachments.tsx@@ -1,10 +1,12 @@import { Button } from '@hermes/plugin-sdk'-import { useRef, useState } from 'react'+import { useLayoutEffect, useRef, useState } from 'react'+import { downloadCanonicalAttachment } from './canonical-attachment-download'import { useCanonicalGroupLabels } from './canonical-group-labels'import { type CanonicalGroupBinding, canonicalGroupRequest } from './canonical-groups'-interface Attachment { attachment_id?: string; event_id?: string; kind: string; name: string; mime: string; size?: number }+export 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 }function kindFor(file: File): string {@@ -15,26 +17,29 @@ function kindFor(file: File): string {return 'file'}-function extension(mime: string, name: string): string {- const dot = name.lastIndexOf('.')-- if (dot > 0) {return name.slice(dot)}-- return mime === 'application/pdf' ? '.pdf' : mime.split('/')[1] ? `.${mime.split('/')[1]}` : '.bin'-}--export function CanonicalGroupAttachments({ binding, attachments, onChange, disabled }: {+export function CanonicalGroupAttachments({ binding, attachments, onChange, disabled, readOnly = false }: {binding: CanonicalGroupBindingattachments: Attachment[]- onChange: (attachments: Attachment[]) => voiddisabled: boolean-}) {+} & ({ readOnly: true; onChange?: never } | { readOnly?: false; onChange: (attachments: Attachment[]) => void })) {const labels = useCanonicalGroupLabels()const input = useRef<HTMLInputElement>(null)const [error, setError] = useState('')const [busy, setBusy] = useState(false)+ const lifetime = useRef<AbortController | null>(null)++ useLayoutEffect(() => {+ const controller = new AbortController()+ lifetime.current = controller++ if (disabled) {controller.abort()}+ setBusy(false)++ return () => controller.abort()+ }, [binding.connectionId, binding.profile, binding.roomId, disabled, readOnly])async function upload(file: File) {+ if (readOnly) {return}setBusy(true); setError('')try {@@ -52,13 +57,15 @@ export function CanonicalGroupAttachments({ binding, attachments, onChange, disa// 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 }])+ onChange?.([...attachments, { attachment_id, kind, name, mime, size }])} catch (e) { setError(e instanceof Error ? e.message : String(e)) }finally { setBusy(false) }}async function download(attachment: Attachment) {- if (!attachment.attachment_id || !attachment.event_id || !window.hermesDesktop?.saveImageBuffer) {return}+ const signal = lifetime.current?.signal++ if (!signal || signal.aborted || !attachment.attachment_id || !attachment.event_id) {return}setBusy(true); setError('')try {@@ -66,20 +73,21 @@ export function CanonicalGroupAttachments({ binding, attachments, onChange, disaroom_id: binding.roomId, event_id: attachment.event_id, attachment_id: attachment.attachment_id})+ if (signal.aborted) {return}const bytes = Uint8Array.from(atob(result.data_base64), char => char.charCodeAt(0))- await window.hermesDesktop.saveImageBuffer(bytes, extension(result.mime, result.name), result.name)- } catch (e) { setError(e instanceof Error ? e.message : String(e)) }- finally { setBusy(false) }+ downloadCanonicalAttachment(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)} }}return <div className="flex flex-wrap items-center gap-2">- <input hidden onChange={e => { const file = e.target.files?.[0];+ {!readOnly && <><input hidden onChange={e => { const file = e.target.files?.[0];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>+ <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>- <Button disabled={disabled || busy} onClick={() => onChange(attachments.filter(item => item !== a))} type="button">{labels.removeAttachment}</Button>+ {!readOnly && <Button disabled={disabled || busy} onClick={() => onChange?.(attachments.filter(item => item !== a))} type="button">{labels.removeAttachment}</Button>}</span>)}{error && <span role="alert">{labels.uploadFailed}: {error}</span>}</div>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.tsxnew file mode 100644index 00000000000..b09aa7e4987--- /dev/null+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-download-lifetime.test.tsx@@ -0,0 +1,78 @@+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'+import type { ComponentProps, ReactNode } from 'react'+import { afterEach, expect, it, vi } from 'vitest'++import { expectDownloaded, observeDownloads } from './canonical-download-test-utils'++const request = vi.hoisted(() => vi.fn())+vi.mock('@hermes/plugin-sdk', async () => {+ const { en } = await import('@/i18n/en')++ return { host: { requestProfile: request }, useI18n: () => ({ locale: 'en', t: en }),+ Button: (props: ComponentProps<'button'>) => <button {...props} />,+ Codicon: () => <span />, Tip: ({ children }: { children: ReactNode }) => <>{children}</> }+})+vi.mock('./canonical-group-labels', async () => {+ const { CANONICAL_GROUP_LOCALES } = await import('./canonical-group-locales')++ return { useCanonicalGroupLabels: () => ({ ...CANONICAL_GROUP_LOCALES.en, refresh: 'Refresh', retry: 'Retry',+ send: 'Send', stop: 'Stop', download: 'Download', discard: 'Discard', cancel: 'Cancel' }) }+})+import { CanonicalGroupWorkspace } from './canonical-group-workspace'++const binding = { connectionId: 'owner-a', profile: 'reviewer', roomId: 'room-one' }+const attachment = { attachment_id: 'att_00000000000000000000000000000001', kind: 'file', name: 'retained.txt', mime: 'text/plain', size: 1 }+const originalDesktop = window.hermesDesktop+afterEach(() => { cleanup(); request.mockReset(); vi.restoreAllMocks(); vi.unstubAllGlobals(); localStorage.clear(); window.hermesDesktop = originalDesktop })++function setup() {+ const observed = observeDownloads()+ const cache = vi.fn().mockResolvedValue('/private/composer-images/not-a-user-download')+ window.hermesDesktop = { saveImageBuffer: cache } as unknown as typeof window.hermesDesktop+ let release!: (value: unknown) => void+ const held = new Promise(resolve => { release = resolve })+ request.mockImplementation(async (_route, method) => {+ if (method === 'groups.state') {return { room: { name: 'Room' } }}++ if (method === 'groups.log') {return { events: [{ seq: 1, room_id: binding.roomId, event_id: 'committed',+ kind: 'message.member', payload: { attachments: [attachment] } }] }}++ if (method === 'groups.attachment.download') {return held}+ throw new Error(`Unexpected method ${method}`)+ })++ return { observed, cache, release: () => release({ ...attachment, event_id: 'committed', data_base64: 'QQ==' }) }+}++it('initiates the real user-facing download with exact bytes/name, never the composer cache', async () => {+ const { observed, cache, release } = setup()+ render(<CanonicalGroupWorkspace binding={binding} />)+ const history = within(screen.getByRole('log'))+ fireEvent.click(await history.findByRole('button', { name: 'Download' }))+ await act(async () => release())+ await waitFor(() => expect(observed.downloads).toHaveLength(1), { timeout: 2000 })+ await expectDownloaded(observed, new Uint8Array([65]), attachment.name, attachment.mime)+ expect(cache).not.toHaveBeenCalled()+ expect(request.mock.calls.find(call => call[1] === 'groups.attachment.download')?.[2]).toEqual({+ profile: binding.profile, room_id: binding.roomId, event_id: 'committed', attachment_id: attachment.attachment_id+ })+})++it.each(['unmount', 'hidden', 'profile', 'connection', 'room'])('does not initiate a late download or cache write after %s', async change => {+ const { observed, cache, release } = setup()+ const view = render(<CanonicalGroupWorkspace binding={binding} />)+ fireEvent.click(await within(screen.getByRole('log')).findByRole('button', { name: 'Download' }))+ await waitFor(() => expect(request.mock.calls.some(call => call[1] === 'groups.attachment.download')).toBe(true))++ if (change === 'unmount') {view.unmount()}+ else if (change === 'hidden') {view.rerender(<CanonicalGroupWorkspace binding={binding} visible={false} />)}+ else {+ const key = change === 'connection' ? 'connectionId' : change === 'room' ? 'roomId' : 'profile'+ view.rerender(<CanonicalGroupWorkspace binding={{ ...binding, [key]: 'other' }} />)+ }++ await act(async () => release())+ expect(observed.create).not.toHaveBeenCalled()+ expect(observed.downloads).toHaveLength(0)+ expect(cache).not.toHaveBeenCalled()+})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.tsxnew file mode 100644index 00000000000..7fabb26b8cf--- /dev/null+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-history.test.tsx@@ -0,0 +1,106 @@+import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'+import type { ComponentProps, ReactNode } from 'react'+import { afterEach, expect, it, vi } from 'vitest'++import { expectDownloaded, observeDownloads } from './canonical-download-test-utils'++const request = vi.hoisted(() => vi.fn())+vi.mock('@hermes/plugin-sdk', async () => {+ const { en } = await import('@/i18n/en')++ return { host: { requestProfile: request }, useI18n: () => ({ locale: 'en', t: en }),+ Button: (props: ComponentProps<'button'>) => <button {...props} />,+ Codicon: () => <span />, Tip: ({ children }: { children: ReactNode }) => <>{children}</> }+})+vi.mock('./canonical-group-labels', async () => {+ const { CANONICAL_GROUP_LOCALES } = await import('./canonical-group-locales')++ return { useCanonicalGroupLabels: () => ({ ...CANONICAL_GROUP_LOCALES.en, back: 'Back', refresh: 'Refresh', retry: 'Retry',+ send: 'Send', stop: 'Stop', download: 'Download', discard: 'Discard', cancel: 'Cancel' }) }+})++import { CanonicalGroupWorkspace } from './canonical-group-workspace'++const binding = { connectionId: 'original-owner', profile: 'reviewer', roomId: 'room-one' }+const manifest = { attachment_id: 'att_00000000000000000000000000000001', kind: 'file', name: 'notes.txt', mime: 'text/plain', size: 1 }+const originalDesktop = window.hermesDesktop+afterEach(() => { cleanup(); request.mockReset(); vi.restoreAllMocks(); vi.unstubAllGlobals(); localStorage.clear(); window.hermesDesktop = originalDesktop })++it('keeps a committed file downloadable in history after Send clears the composer (F31)', async () => {+ const observed = observeDownloads()+ const save = vi.fn().mockResolvedValue(undefined)+ window.hermesDesktop = { saveImageBuffer: save } as unknown as typeof window.hermesDesktop+ let sent = false+ request.mockImplementation(async (_route, method, params) => {+ if (method === 'groups.state') {return { room: { name: 'Room' }, driver_status: {} }}++ if (method === 'groups.log') {return { events: sent ? [{ seq: 1, room_id: binding.roomId, event_id: 'committed-user-event',+ kind: 'message.user', payload: { text: 'Review these notes', attachments: [manifest] } }] : [] }}++ if (method === 'groups.attachment.upload') {return { ...manifest, sha256: 'receipt-only' }}++ if (method === 'groups.send') {expect(params.payload.attachments).toEqual([manifest]); sent = true;++ return { accepted: true }}++ if (method === 'groups.attachment.download') {return { ...manifest, event_id: params.event_id, data_base64: 'QQ==' }}+ throw new Error(`Unexpected method ${method}`)+ })+ const view = render(<CanonicalGroupWorkspace binding={binding} />)+ await waitFor(() => expect((screen.getByRole('textbox') as HTMLTextAreaElement).disabled).toBe(false))+ fireEvent.change(view.container.querySelector('input[type=file]')!, { target: { files: [new File(['A'], manifest.name, { type: manifest.mime })] } })+ await waitFor(() => expect(screen.getByText(manifest.name)).toBeTruthy())+ fireEvent.change(screen.getByRole('textbox'), { target: { value: 'Review these notes' } })+ fireEvent.click(screen.getByRole('button', { name: 'Send' }))+ await waitFor(() => expect((screen.getByRole('textbox') as HTMLTextAreaElement).value).toBe(''))+ const history = within(screen.getByRole('log'))+ await waitFor(() => expect(history.getByText(manifest.name)).toBeTruthy(), { timeout: 2000 })+ expect(history.queryByRole('button', { name: 'Attach files' })).toBeNull()+ expect(history.queryByRole('button', { name: 'Remove attachment' })).toBeNull()+ expect(view.container.querySelector('form')?.textContent).not.toContain(manifest.name)+ fireEvent.click(history.getByRole('button', { name: 'Download' }))+ await waitFor(() => expect(observed.downloads).toHaveLength(1))+ await expectDownloaded(observed, new Uint8Array([65]), manifest.name, manifest.mime)+ expect(save).not.toHaveBeenCalled()+ const call = request.mock.calls.find(call => call[1] === 'groups.attachment.download')!+ expect(call[0]).toMatchObject({ connectionId: binding.connectionId, targetProfile: binding.profile })+ expect(call[2]).toEqual({ profile: binding.profile, room_id: binding.roomId,+ event_id: 'committed-user-event', attachment_id: manifest.attachment_id })+ expect(request.mock.calls.some(call => call[1] === 'groups.attachment.list')).toBe(false)+})++it('binds user/member history downloads to their real event and refuses missing or foreign room identity', async () => {+ const observed = observeDownloads()+ const save = vi.fn().mockResolvedValue(undefined)+ window.hermesDesktop = { saveImageBuffer: save } as unknown as typeof window.hermesDesktop++ const events = [+ { seq: 1, room_id: binding.roomId, event_id: 'user-event', kind: 'message.user' },+ { seq: 2, room_id: binding.roomId, event_id: 'member-event', kind: 'message.member', actor: { member_id: 'helper' } },+ { seq: 3, room_id: binding.roomId, kind: 'message.user' },+ { seq: 4, room_id: 'other-room', event_id: 'foreign-event', kind: 'message.member' }+ ].map(event => ({ ...event, payload: { attachments: [{ ...manifest, event_id: 'not-the-event' }] } }))++ request.mockImplementation(async (_route, method, params) => {+ if (method === 'groups.state') {return { room: { name: 'Room' } }}++ if (method === 'groups.log') {return { events }}++ if (method === 'groups.attachment.download') {return { ...manifest, event_id: params.event_id, data_base64: 'QQ==' }}+ throw new Error(`Unexpected method ${method}`)+ })+ render(<CanonicalGroupWorkspace binding={binding} />)+ const history = within(screen.getByRole('log'))+ await waitFor(() => expect(history.getAllByRole('button', { name: 'Download' })).toHaveLength(4))+ const buttons = history.getAllByRole('button', { name: 'Download' }) as HTMLButtonElement[]+ expect(buttons.map(button => button.disabled)).toEqual([false, false, true, true])+ fireEvent.click(buttons[0])+ await waitFor(() => expect(observed.downloads).toHaveLength(1))+ fireEvent.click(buttons[1])+ await waitFor(() => expect(observed.downloads).toHaveLength(2))+ expect(save).not.toHaveBeenCalled()+ const reads = request.mock.calls.filter(call => call[1] === 'groups.attachment.download')+ expect(reads.map(call => call[2].event_id)).toEqual(['user-event', 'member-event'])+ expect(reads.every(call => call[2].room_id === binding.roomId && call[2].profile === binding.profile)).toBe(true)+ expect(history.queryByRole('button', { name: 'Remove attachment' })).toBeNull()+})diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-history.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-history.tsxnew file mode 100644index 00000000000..ea997278171--- /dev/null+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-history.tsx@@ -0,0 +1,21 @@+import { type CanonicalGroupAttachment, CanonicalGroupAttachments } from './canonical-group-attachments'+import type { CanonicalGroupBinding } from './canonical-groups'++export interface CanonicalGroupEvent {+ seq: number+ event_id?: string+ room_id?: string+ kind: string+ payload: { text?: string; content?: string; attachments?: CanonicalGroupAttachment[] }+ actor?: { member_id?: string }+}++export function CanonicalGroupHistory({ binding, events, disabled = false }: { binding: CanonicalGroupBinding; events: CanonicalGroupEvent[]; disabled?: boolean }) {+ return <>{events.map(event => <div className="whitespace-pre-wrap py-2" key={event.seq}>+ {event.actor?.member_id && <strong>{event.actor.member_id}: </strong>}+ {event.payload.text || event.payload.content || event.kind}+ {!!event.payload.attachments?.length && <CanonicalGroupAttachments+ attachments={event.payload.attachments.map(attachment => ({ ...attachment, event_id: event.event_id }))}+ binding={binding} disabled={disabled || !event.event_id || event.room_id !== binding.roomId} readOnly />}+ </div>)}</>+}diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.tsxindex 01decf3d208..05d3cfe3850 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-workspace.tsx@@ -2,13 +2,14 @@ import { Button } from '@hermes/plugin-sdk'import { useEffect, useRef, useState } from 'react'import { CanonicalGroupAttachments } from './canonical-group-attachments'+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 } from './canonical-groups'-interface RoomEvent { seq: number; kind: string; payload: { text?: string; content?: string }; actor?: { member_id?: string } }+type RoomEvent = CanonicalGroupEventinterface Attachment { attachment_id?: string; event_id?: string; kind: string; name: string; mime: string; size?: number }interface RoomState { room: { name: string }; driver_status?: { pending_actions?: CanonicalPendingAction[] } }@@ -145,7 +146,7 @@ function CanonicalRoomView({ binding: initialBinding, visible, onBack }: {{error && <div role="alert">{error}</div>}{state && !state.driver_status && <p>{labels.driverUnavailable}</p>}<div className="min-h-0 flex-1 overflow-auto" role="log">- {events.map(event => <div className="whitespace-pre-wrap py-2" key={event.seq}>{event.actor?.member_id && <strong>{event.actor.member_id}: </strong>}{event.payload.text || event.payload.content || event.kind}</div>)}+ <CanonicalGroupHistory binding={binding} disabled={!visible} events={events} /></div>{(state?.driver_status?.pending_actions || []).map(action => <div className="flex items-center gap-2" key={`${action.kind}:${action.task_id}:${action.execution_generation}`}><span>{action.member_id}</span>