feat(chat): render images in agent turns, paste-to-send from the input - #160
Merged
Merged
Conversation
Closes #158. The ACP wire already supports image ContentBlocks; the gap was the bridge (only forwarded text chunks) and the console (no image render, no paste handling). Bridge: acp-tunnel classifies session/update content by type (text/image), remote.rs forwards image chunks as their own agent-update and threads PromptImage attachments through agent_prompt/session.prompt. Console: chat.ts renders images behind a mime allow-list + base64-shape check (agent content is less trusted than markdown text), chatPanel.ts adds a paste handler with a 5MB/image, 4-images/turn cap and a removable preview strip above the input. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ContentBlocks (crates/openab-gateway/src/adapters/acp_schema.rs:5311inopenabdev/openab) — the gap was the bridge and the console, not the protocol.crates/acp-tunnel,src-tauri/src/remote.rs):parse_inboundnow classifiessession/updatecontent by itstype(text→Inbound::AgentChunk,image→ newInbound::AgentImage), forwarded to the panel as its ownagent-update(kind: "image").Session::prompttakes a newimages: &[PromptImage]param and appends image blocks after the text block;agent_prompt/OutMsg::Promptthread it through.console/src/chat.ts):ChatTurngains an optionalimagesfield;appendImagemirrorsappendChunk's open-turn rule. Images render asdata:URI<img>s behind a mime allow-list (png/jpeg/gif/webp) + a base64-shape check, since agent-sourced content is less trusted than markdown text (same concern the issue flagged for a DOMPurify-safety pass).console/src/chatPanel.ts): apastehandler on the textarea picks up clipboard image items, base64-encodes them client-side, and shows a removable preview strip above the input;submit()bundles pending images into the nextagent_promptcall and allows an image-only send (empty text).Test plan
cargo test -p acp-tunnel— 38/38 pass (12 new: prompt image-block building,session/updateimage classification)cargo check --workspace— clean (workspace excludessrc-tauri, which needs GTK/webkit system libs this Linux container doesn't have — same reasondesktop.yml's Linux compile-validation stage is disabled;src-tauri's edits are small/mechanical and covered by the macOSdesktop.ymljob on this PR)npm run typecheck(console) — cleannpm test(console) — 117/117 pass (10 new:appendImage,isRenderableImage,turnHtmlimage rendering)/acpgateway (paste an image in, confirm an agent-sent image renders) — not done in this session, no live gateway available here🤖 Generated with Claude Code