Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(chat): read clipboard image files before item fallback

Eloi Torrents372912ba094b
diff --git a/app/src/components/chat/ChatComposer.tsx b/app/src/components/chat/ChatComposer.tsx
index 3664c1aed0..c0e6bbb2c3 100644
--- a/app/src/components/chat/ChatComposer.tsx
+++ b/app/src/components/chat/ChatComposer.tsx
@@ -302,11 +302,17 @@ function ChatComposerBody({
// it would route files to a runtime attachment adapter this app does not use.
const handlePaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {
if (attachDisabled) return;
- const items = Array.from(e.clipboardData?.items ?? []);
- const files = items
- .filter(item => item.kind === 'file' && /^(image|video)\//.test(item.type))
- .map(item => item.getAsFile())
- .filter((file): file is File => file !== null);
+ // Prefer FileList: a webview can expose a clipboard image there without
+ // a usable DataTransferItem. Use items only as a fallback, so the same
+ // screenshot represented in both lists is attached once.
+ const isMedia = (file: File) => /^(image|video)\//.test(file.type);
+ let files = Array.from(e.clipboardData?.files ?? []).filter(isMedia);
+ if (files.length === 0) {
+ files = Array.from(e.clipboardData?.items ?? [])
+ .filter(item => item.kind === 'file')
+ .map(item => item.getAsFile())
+ .filter((file): file is File => file !== null && isMedia(file));
+ }
if (files.length === 0) return;
e.preventDefault();
debug('[chat-composer] paste: ingesting %d media file(s)', files.length);
diff --git a/app/src/components/chat/__tests__/ChatComposer.test.tsx b/app/src/components/chat/__tests__/ChatComposer.test.tsx
index b0b0b29bda..566163c7be 100644
--- a/app/src/components/chat/__tests__/ChatComposer.test.tsx
+++ b/app/src/components/chat/__tests__/ChatComposer.test.tsx
@@ -417,6 +417,69 @@ describe('ChatComposer', () => {
expect(onAttachFiles).toHaveBeenCalledWith([file]);
});
+ it('attaches a screenshot exposed only through clipboard files', () => {
+ const onAttachFiles = vi.fn().mockResolvedValue(undefined);
+ renderComposer({ onAttachFiles });
+ const file = new File([new Uint8Array(4)], 'screenshot.png', { type: 'image/png' });
+ const notPrevented = fireEvent.paste(screen.getByRole('textbox'), {
+ clipboardData: { files: [file], items: [] },
+ });
+ expect(onAttachFiles).toHaveBeenCalledWith([file]);
+ expect(notPrevented).toBe(false);
+ });
+
+ it('uses the image file type when its clipboard item type is empty', () => {
+ const onAttachFiles = vi.fn().mockResolvedValue(undefined);
+ renderComposer({ onAttachFiles });
+ const file = new File([new Uint8Array(4)], 'screenshot.png', { type: 'image/png' });
+ fireEvent.paste(screen.getByRole('textbox'), {
+ clipboardData: { items: [{ kind: 'file', type: '', getAsFile: () => file }] },
+ });
+ expect(onAttachFiles).toHaveBeenCalledWith([file]);
+ });
+
+ it('attaches an image once when both clipboard lists expose it', () => {
+ const onAttachFiles = vi.fn().mockResolvedValue(undefined);
+ renderComposer({ onAttachFiles });
+ const file = new File([new Uint8Array(4)], 'screenshot.png', { type: 'image/png' });
+ fireEvent.paste(screen.getByRole('textbox'), {
+ clipboardData: {
+ files: [file],
+ items: [{ kind: 'file', type: 'image/png', getAsFile: () => file }],
+ },
+ });
+ expect(onAttachFiles).toHaveBeenCalledTimes(1);
+ expect(onAttachFiles).toHaveBeenCalledWith([file]);
+ });
+
+ it('does not attach clipboard files when attachments are disabled', () => {
+ const onAttachFiles = vi.fn().mockResolvedValue(undefined);
+ renderComposer({ onAttachFiles, attachmentsEnabled: false });
+ fireEvent.paste(screen.getByRole('textbox'), {
+ clipboardData: {
+ files: [new File([new Uint8Array(4)], 'screenshot.png', { type: 'image/png' })],
+ },
+ });
+ expect(onAttachFiles).not.toHaveBeenCalled();
+ });
+
+ it('ignores unreadable clipboard items and non-media files', () => {
+ const onAttachFiles = vi.fn().mockResolvedValue(undefined);
+ renderComposer({ onAttachFiles });
+ const file = new File(['text'], 'note.txt', { type: 'text/plain' });
+ const notPrevented = fireEvent.paste(screen.getByRole('textbox'), {
+ clipboardData: {
+ files: [file],
+ items: [
+ { kind: 'file', type: 'image/png', getAsFile: () => null },
+ { kind: 'file', type: 'text/plain', getAsFile: () => file },
+ ],
+ },
+ });
+ expect(onAttachFiles).not.toHaveBeenCalled();
+ expect(notPrevented).toBe(true);
+ });
+
it('ignores plain-text paste (no media items)', () => {
const onAttachFiles = vi.fn().mockResolvedValue(undefined);
renderComposer({ onAttachFiles });
diff --git a/docs/RELEASE-MANUAL-SMOKE.md b/docs/RELEASE-MANUAL-SMOKE.md
index 8b23ad1773..7ba405d072 100644
--- a/docs/RELEASE-MANUAL-SMOKE.md
+++ b/docs/RELEASE-MANUAL-SMOKE.md
@@ -34,6 +34,8 @@ Applies to every release, all platforms.
### macOS
+- [ ] **Screenshot paste in normal chat (4.2.8)** — Copy a screenshot to the clipboard, focus the chat message input, and press Cmd+V. Expected: one image preview appears, the draft text is preserved, and no message is sent. Repeat via Edit → Paste, then paste plain text and confirm normal insertion.
+
- [ ] **Gatekeeper accepts the signed `.app` on first launch** — Double-click the `.app` from a fresh download (Quarantine attribute set). Expected: app opens without `"OpenHuman" cannot be opened because the developer cannot be verified` dialog. If it appears, the build is unsigned or the notarization stapler is missing.
- [ ] **`codesign --verify --deep --strict <path-to-OpenHuman.app>` exits 0** — Run from terminal. Expected: no output, exit 0. Any `code object is not signed at all` or `invalid signature` output blocks the release.
- [ ] **DMG drag-to-Applications flow works** — Mount the `.dmg`, drag `OpenHuman.app` to the `Applications` alias. Expected: copy completes; eject succeeds; first launch from `/Applications` does not re-prompt Gatekeeper.
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index 41d0c661c8..08173b6e9e 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -188,7 +188,7 @@ Canonical mapping of every product feature to its test source(s). Drives gap-fil
| 4.2.6 | Background-activity panel (chat-header Background tasks button) | VU+WD | `app/src/features/conversations/hooks/useBackgroundActivity.test.ts`, `app/src/features/conversations/components/__tests__/BackgroundActivityRows.test.tsx`, `app/test/e2e/specs/chat-background-activity-panel.spec.ts` | ✅ | View-only panel surfacing this chat's async sub-agents + global cron jobs and memory syncing; freshness-only "Syncing now" labeling; E2E opens the panel and asserts its sections render and close |
| 4.2.7 | Plan-mode review (Approve / Reject / Send-feedback before execute) | RU+RI+VU | `crates/openhuman-core/src/agent/plan_review/gate.rs`, `crates/openhuman-core/src/agent/plan_review/tool.rs`, `crates/openhuman-core/src/agent/plan_review/schemas.rs`, `tests/json_rpc_e2e.rs`, `app/src/features/conversations/components/PlanReviewCard.test.tsx`, `app/src/pages/__tests__/Conversations.render.test.tsx` | ✅ | Interactive turns call `request_plan_review`, which parks the LIVE turn on the in-memory `PlanReviewGate` (oneshot) until the user decides; `plan_review_request` socket event drives `PlanReviewCard`, which resolves via `openhuman.plan_review_decide` (approve resumes-and-executes / reject resumes-and-stops / revise resumes-with-feedback). RU covers gate park/resolve/timeout + tool auto-approve + parking; RI covers the decide RPC; VU covers the card + provider wiring. WD E2E (agent-driven park flow) tracked as follow-up |
-| 4.2.8 | Composer attachments (image / video / document; drag-drop + paste) | VU | `app/src/lib/attachments.test.ts`, `app/src/components/chat/__tests__/ChatComposer.test.tsx`, `app/src/pages/__tests__/Conversations.attachments.test.tsx` | 🟡 | Attach affordance gated on the resolved vision tier (images/video need vision; documents flow on any model); video is sampled into still frames client-side and forwarded through the existing `[IMAGE:]` vision path; drag-drop + clipboard-paste reuse the picker ingest. VU covers MIME/kind/limits/marker building + drag-drop + paste; real video decode and the frames→vision round-trip are manual-smoke only (jsdom has no video codec). WD E2E is a follow-up |
+| 4.2.8 | Composer attachments (image / video / document; drag-drop + paste) | VU | `app/src/lib/attachments.test.ts`, `app/src/components/chat/__tests__/ChatComposer.test.tsx`, `app/src/pages/__tests__/Conversations.attachments.test.tsx` | 🟡 | Attach affordance gated on the resolved vision tier (images/video need vision; documents flow on any model); video is sampled into still frames client-side and forwarded through the existing `[IMAGE:]` vision path; drag-drop + clipboard-paste reuse the picker ingest. VU covers MIME/kind/limits/marker building + drag-drop + paste (FileList-only clipboard images, missing item MIME, duplicate representations, disabled ingestion and plain text); real video decode and the frames→vision round-trip are manual-smoke only (jsdom has no video codec). WD E2E is a follow-up |
| 4.2.9 | Share cards ("Look what my agent did" post to X / LinkedIn) | VU | `app/src/features/share/shareContent.test.ts`, `app/src/features/share/shareTargets.test.ts`, `app/src/features/share/shareCaption.test.ts`, `app/src/features/share/shareCard.test.ts`, `app/src/features/share/ShareMessageButton.test.tsx`, `app/src/features/share/ShareCardModal.test.tsx` | ✅ | Hover Share button under completed agent messages opens a Canvas 2D branded card; LLM-drafted headline/caption via `inference_agent_chat_simple` with deterministic offline fallback; X/LinkedIn intent URLs + copy/save PNG; secrets/paths/emails redacted before render. MVP wires only the completed-task trigger; workflow-run + Human-tab triggers are follow-ups. WD E2E deferred |
| 4.2.10 | Durable agent reply (core stores it before announcing `chat_done`) | RU+VU | `crates/openhuman-core/src/web_chat/reply_persistence_tests.rs`, `crates/openhuman-core/src/web_chat/presentation_tests.rs`, `app/src/providers/__tests__/ChatRuntimeProvider.test.tsx` | ✅ | `deliver_response` persists an unsegmented reply under `agent:<request_id>` before publishing the terminal event, so a dropped socket, a failed `threads_message_append` or a reloaded webview costs a repaint rather than the answer; the client's append collapses onto that row by id. RU covers the write, its idempotency, the empty-reply and missing-thread paths, and that delivery still announces when the store refuses. VU covers the mirrored id, the segmented exception, the refetch that recovers a failed append, and the reconnect that rejoins orphaned thread rooms. WD E2E (kill the append mid-turn) is a follow-up |