Repository navigation
feat(chat): inline previews for agent-written images, with copy to the user's clipboard - #1993
Open
aarontrowbridge wants to merge 2 commits into
Open
aarontrowbridge wants to merge 2 commits into
aarontrowbridge wants to merge 2 commits into
Conversation
…e user's clipboard Markdown images with an absolute server path load through /file/content and render framed in chat; click opens a full-size preview, and the hover/preview Copy action writes a PNG to the OS clipboard via a new clipboard-image-write bridge kind handled by the extension host (osascript / xclip / wl-copy) — on the machine the user is at, not the server.
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Chat image frames and the full-size preview gain a Download button next to Copy. Inside the chat iframe the PNG rides the existing save-file bridge kind, so the extension host opens a native Save dialog (default ~/Downloads) on the machine the user is at; unframed, an anchor download stands. The file keeps the authored basename (or the alt text), saved as .png since both save and copy rasterize to PNG. Adds the outline-download v2 icon and the ui.message.download string.
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.
Important
Problem: Images the agent writes to the server's disk (slide equations, plots) can't be seen in the chat panel, and an image can't be copied out of chat. The chat iframe can't reach the server's disk, a bare
<img>can't send the server credential,file://is stripped by the sanitizer and blocked by the page's security policy, andvscode.env.clipboardonly handles text.Approach:
images load through the existing/file/contentroute, using a loader the app registers (the same pattern as the file-ref resolver).clipboard-image-writemessage over the bridge. The extension host writes the PNG natively, so the paste lands on the machine the user is sitting at, which can differ from the server that produced the image.Changes
markdown-local-images: path detection, loader registry and cache, and the image-framing and loading passes.markdown.tsxwires those passes in and adds click-to-preview.image-lightbox.tsx: a full-size preview with Copy and Close buttons.copyImageToClipboardinutil/clipboard: uses the bridge inside the frame,ClipboardItemoutside it, and converts non-PNG images to PNG first.AmicodeFileRefBridgealso registers the local-image loader. It turns the base64 from/file/contentinto adata:URL, and handles SVG returned as text.clipboard-image-writehandler inchat_bridge.ts. It accepts PNG only, is capped at 24 MB, requires the panel to be visible, and replies with aclipboard-image-writtenack.osascript(the file path is passed as an argument, never inserted into the script), Linuxxclip, orwl-copyunder Wayland. Windows is served through WSL.chat_panel.tsallowlists.manifest.jsonrefreshed; the drift gate passes.Testing
session-ui: newmarkdown-local-images.test.tscovers path classification, loader cache and dedupe, retrying failed loads, stale-unregister safety, one frame per image, that a local path never fires a network request, and that a cached image is set synchronously when a block is rebuilt. The full suite gives 457 passes and 1 failure, in the CodeMirror selection-highlight test, which this PR doesn't touch.extension: three new bridge tests (ack shape; rejected payloads; per-platform command selection with no path in the script). Full vitest gives 5600 passes.tscis clean.appandsession-uitypechecks (tsgo) are clean on the materialized tree.Notes