Repository navigation
feat(native-chat): copy chat images from the right-click menu - #24161
Conversation
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Copy image menu item —
use-native-chat-context-menu.tsxreads the right-clicked image when the menu opens and renders a Copy image item above the text Copy whenever an image is present under the pointer. - Full-size source, not the thumbnail — both preview surfaces stamp
data-native-chat-copy-image-srcwith the on-disk blob URL (never the pasteddata:thumbnail), and withhold it for.svgpaths and the web client. - Preview stays open —
keepPreviewOpenForChatMenuin the newnative-chat-image-copy.tssuppresses the Radix Dialog close that a click on the portaled chat menu triggers, so the full-size preview survives a copy. - Clipboard write path —
copyNativeChatImageconverts to PNG via the shared converter (moved unchanged tolib/image-blob-png.ts), writes throughwriteClipboardImage, and toasts on failure with a distinct too-large description. - i18n —
copyImage/copyImageFailed/copyImageTooLargeadded to all six catalogs. - Tests — new unit coverage for the full-size source, SVG/web-client gating, copying after a blob revoke, the too-large toast, and the preview-stays-open guard.
I read the whole diff, traced the moved-image path, and checked the seams: rg confirms the relocated blobToBase64 / convertImageBlobToPng have no other consumers, the localized keys sit under components.native-chat.composer, and the three touched test files (20 tests), pnpm tc:web, and pnpm run verify:localization-catalogs all pass. A couple of notes worth keeping in mind rather than acting on: the preview-close guard keys off document.activeElement being inside the menu at close time, and while the X-close path is unit-tested, the backdrop-close path the PR body mentions is not; and the PNG-only conversion means animated GIF/WebP frames are flattened and large photos can hit the size limit (both called out in the PR).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughNative chat image previews expose eligible full-size image sources for copying. The context menu adds a Copy image action that converts the image to PNG and writes it to the clipboard. Copy failures and oversized images display translated messages. Shared image conversion and base64 utilities are now used by the web clipboard API. Priority: ➖ Normal Severity of issue fixed: Low Merge Risk: 🔵 Low · up to Copy image is unavailable for sent images that have both a displayable URL and a local file. The PR remains mergeable with this bounded limitation acknowledged or fixed. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Existing clipboard access controls and image limits remain in place. The principal concern is that overlapping copy operations can leave the clipboard holding an earlier selection. Platform-specific failure behavior remains unverified. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 23.81% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 11 files. (6 skipped: 6 unsupported.)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor note on the new e2e coverage.
Reviewed changes
- New Electron e2e —
tests/e2e/native-chat-copy-image.spec.tslaunches the app, pastes an 800×600 PNG, and asserts Copy image from both the composer thumbnail and the full-size preview writes an 800×600 image to the (stubbed) clipboard while the preview stays open, then that X still closes it.
Lint on the new spec is clean and typecheck:e2e reports no errors in it (the pre-existing e2e-project errors elsewhere are unrelated).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
9861eaa to
7b5869a
Compare
|
Follow-up: once this merges I'll open a separate PR that gives chat images their own right-click menu (Copy image, Save image as…, Reveal in Finder) instead of reusing the general chat menu. It will also remove the keep-the-preview-open workaround in this PR. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Discriminating e2e fixture — the Electron spec now pastes a 64×48 PNG while the on-disk fixture stays 800×600, so the
800x600clipboard assertion fails if Copy image ever reads the composer preview instead of the saved file, closing the prior review's gap. - Chat view seeding — the pane agent status is seeded as
doneso the native-chat composer renders for the paste.
The prior size-assertion thread is replied to and resolved; Greptile's preview-interaction thread was already resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Thanks Kelvin. This works well: I checked on a Mac that Copy image puts the full-size file on the clipboard from the thumbnail and from the open preview, and that the preview stays open. I pushed two small follow-up commits on top, plus a merge of the latest
Not covered: Windows/Linux and SSH weren't run live. Images that exist only as a URL still can't be copied; that's a fair follow-up. |
| try { | ||
| const png = await convertImageBlobToPng(await image) | ||
| await window.api.ui.writeClipboardImage(`data:image/png;base64,${await blobToBase64(png)}`) | ||
| toast.success(translate('components.native-chat.composer.imageCopied', 'Image copied')) |
There was a problem hiding this comment.
After a successful Copy image action, this shows an “Image copied” toast. The intended behavior is to copy silently, so users now get an unwanted notification every time the action succeeds.
| toast.success(translate('components.native-chat.composer.imageCopied', 'Image copied')) |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Load the local source when an image reference has both a URL… · NativeChatTranscriptChrome.tsx:97
src/renderer/src/components/native-chat/NativeChatTranscriptChrome.tsx:97
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winLoad the local source when an image reference has both a URL and a path.
NativeChatImageRefBlockcan reach this component with both fields. When the URL is renderable, the current guard passesundefinedtouseLocalImageSrc, socopyableNativeChatImageSrcreceives no source and the Copy image attribute is absent. Keep the URL for display, but resolveblock.pathfor copying.Suggested fix
const localSrc = useLocalImageSrc( - leaseActive && !external && runtimeContext !== undefined ? source : undefined, + leaseActive && runtimeContext !== undefined + ? external + ? block.path + : source + : undefined, filePath, runtimeContext?.connectionId, runtimeContext
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 148c2d09-dbda-4d8c-8fde-393dc93daf4e
📥 Commits
Reviewing files that changed from the base of the PR and between 7b5869abb6216e1b6cfd02fc0bcb7fcdfe84683c and a6b65a0061527a945b942b0be435ae96f94a4226.
📒 Files selected for processing (14)
src/renderer/src/components/native-chat/NativeChatImageAttachmentPreview.test.tsxsrc/renderer/src/components/native-chat/NativeChatImageAttachmentPreview.tsxsrc/renderer/src/components/native-chat/NativeChatTranscriptChrome.tsxsrc/renderer/src/components/native-chat/native-chat-image-copy.tssrc/renderer/src/components/native-chat/use-native-chat-context-menu.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-context-menu.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/image-blob-png.test.tssrc/renderer/src/lib/image-blob-png.ts
🚧 Files skipped from review as they are similar to previous changes (6)
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/zh.json
- src/renderer/src/i18n/locales/fr.json
- src/renderer/src/i18n/locales/es.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the delta since the prior pullfrog review (7b5869a → a6b65a0): two fix commits plus a merge of main.
- Preview keep-open by click target —
keepPreviewOpenForChatMenuis now anonInteractOutsidehandler onDialogContentthat cancels the Radix dismissal when the interaction target sits inside[data-native-chat-context-menu], replacing the earlier predicate that readdocument.activeElementat close time. - PNG passthrough —
convertImageBlobToPngreturns a PNG-signature blob unchanged after the byte-length and decoded-dimension checks, so re-encoding can no longer inflate a PNG past the clipboard limit. - Copy confirmation —
copyNativeChatImagenow toasts "Image copied" on success, with theimageCopiedkey added to all six catalogs. - Tests — new happy-dom coverage for the PNG passthrough, non-PNG conversion, and oversize-PNG rejection, plus a pointer-driven preview keep-open test.
26 tests across the four touched files pass, pnpm tc:web is clean, and the changed-code design-system gate reports 0 findings across 11 changed files.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
…m copies, pass PNGs through The image preview stayed open through a chat-menu click by reading which element had focus, which depends on the menu's exit-animation timing. It now ignores an outside interaction whose target is the chat menu, the same target check other Orca surfaces use for portaled menus. Both previews drop their color and padding overrides on the dialog surface, which the design system reserves to the dialog primitive. A successful Copy image now shows "Image copied"; before, nothing told the user the copy had finished. An image that is already a PNG is copied as-is after the size checks, instead of being decoded and re-encoded, which cost time and could grow a screenshot past the clipboard size limit.
…e PNG Copy image skipped re-encoding any image whose type said PNG, but a chat image's type comes from its file extension. A WebP or GIF saved under a .png name was then sent unconverted, the main process could not decode it, and the user saw "Image copied" with nothing on the clipboard. The pass-through now checks the PNG file signature instead.
a6b65a0 to
3d5ad40
Compare
nwparker
left a comment
There was a problem hiding this comment.
Full-size image copy reuses existing PNG conversion, checks real dimensions/encoded-size, preserves virtualized preview lifetime and releases resources. 47 tests, web typecheck and quality gates pass. Large photos can exceed clipboard cap; SVG/web/URL-only images have no copy action.
Required PR Checks verify passed on this exact commit: 3d5ad40.
Use full-size sent-image sources, read HTTP images when copying is chosen, and rasterize browser-decodable formats through the existing converter. Preserve the current preview surface and prevent a hidden preview from retaining another copy action. Co-authored-by: Kelvin Amoaba <[email protected]>
This reverts commit fa2d91a.
Keep image previews open while their chat menu is used, and inherit the standard dialog padding, background and border. Co-authored-by: Kelvin Amoaba <[email protected]>
Inherit the standard dialog gap together with its padding and surface. Co-authored-by: Kelvin Amoaba <[email protected]>
|
Native chat could preview an attached image but could not copy its original pixels for reuse elsewhere. This PR adds Copy image to composer and sent-message images and their previews, keeps the original resolution, leaves the preview open during copying, and shows Image copied after the write succeeds. Both previews now use the standard dialog padding and spacing. Review fixed these proven issues (P2):
Deferred: F04 (P2, cause: loop). The larger preview framing change remains a separate follow-up: previews still use a filled dialog and visible filename. The approved standard padding/spacing adjustment is included here; it does not complete that broader work. No follow-up ticket was supplied. The existing framing remains in composer preview:184 and sent preview:191. Verified source: The exact pushed head passed 93 targeted tests in seven explicit files, one queued renderer typecheck, formatting, and the unchanged quality gate. The normal main merge preserved every image-copy feature file. A fresh reviewer completed all eight readiness categories without a new proven P0–P3 issue. Current CI: All 36 checks finished: 17 passed, 19 were skipped, and none failed. Static analysis/typecheck, all five unit-test shards, relay integration, Linux and Windows packaging, the changed end-to-end test job, and the final verification check passed. PR Checks, Node checks, test-line check. The selected Linux Electron test passed: it checked original 800×600 dimensions from the composer thumbnail and full preview, preview persistence, and Close. Its clipboard writer is replaced with a dimensions recorder. Not verified: Remote M4Air QA stopped before an app launched: the prescribed driver showed an update prompt, and the next approved driver could not be launched with its model pinned. The first driver terminal was closed and verified gone; the second created no driver or app resources. No matching test on current main or genuine before/after preview screenshots, actual OS clipboard write/read-back or decoded pixels/alpha, real SVG rasterization, HTTP runtime behavior, or Linux SSH-backed image copying ran in this review round. The existing automated Electron test replaces clipboard delivery with an image-dimensions recorder, so it cannot prove those results. Windows/Linux image copying also remains unverified. Source review is complete; manual runtime QA and fresh visual proof remain blocked. This PR remains unmerged. |
|
Will merge once this has a screenshot of the new UI, doing it myself now |

ELI5
Native chat could show an attached image but could not copy its original pixels for reuse elsewhere. You can now right-click a composer or sent-message image, choose Copy image, and paste the full-size image into another app. A successful copy shows Image copied.
What Changed
Copy image is available on composer thumbnails, sent-message images, and their full previews. Copying from a preview keeps it open and uses the original image rather than its thumbnail. Both previews now use the standard dialog padding and spacing; the broader preview framing change remains a separate follow-up.
The action extends the existing chat menu and desktop clipboard path. Readable SVG and other browser-decodable images become PNG at their natural dimensions. Existing PNG bytes pass through after decoding and size checks. Inline and local bytes are captured while their source is available; HTTP images are fetched only when Copy image is selected. Failed reads, decoding, or oversized images show one error. Hiding a chat closes its menu and prevents its preview from starting another image read. The browser client keeps the action hidden because its current image clipboard writer does not write an image.
Why
The existing menu already owns right-click and cleanup, so the image action belongs there. Reusing the original image source, converter, and native clipboard validation preserves resolution and avoids a second image store or retry mechanism.
Linked Issue
Fixes #23904
Visual Proof
Screenshots from a hidden, isolated dev build on macOS: before = main
81a1968bc65, after = this PR at3ec6a5fd4d4. An 800×600 test image was attached through the composer's paperclip.After choosing Copy image: the "Image copied" confirmation appears. Reading the clipboard back in the app's main process returned 800×600, the original image rather than the small thumbnail (from the test driver's log; not visible in the screenshot).
Inside the full-size preview: right-clicking the image offers Copy image, and the preview stays open.
Not shown: sent-message images, SVG or URL images, copying over SSH, Windows and Linux.
Earlier contributor recording — historical evidence, not verification of the final reviewed head.
Testing
Exact pushed head
3ec6a5fd4d4d30e09d2b8312b0706917155a2734passed 93 targeted tests in seven explicit files, one queued renderer typecheck, changed-file formatting, and the unchanged quality gate. A fresh reviewer completed all eight readiness categories without a new proven P0–P3 issue.All 36 CI checks finished: 17 passed, 19 skipped, none failed. Static analysis/typecheck, all five unit-test shards, relay integration, Linux and Windows packaging, the changed end-to-end test job and final verification passed. PR Checks, Node checks, test-line check. The selected Linux Electron test passed: it checked original 800×600 dimensions from the composer thumbnail and full preview, preview persistence, and Close. Its clipboard writer is replaced with a dimensions recorder.
Remote M4Air QA was blocked before app launch: the prescribed driver showed an update prompt, and the next approved driver did not support pinning its model. The first driver terminal was closed and verified gone; the second created no driver or app resources. No same-method current-main control or final-head before/after screenshots, actual OS clipboard write/read-back or decoded pixels/alpha, real SVG conversion, HTTP runtime behavior, Windows/Linux image copying or Linux SSH-backed copy action ran this round. The automated Electron test replaces clipboard delivery with an image-dimensions recorder and does not prove actual OS pixels or SSH copying.
Review
Review fixed menus surviving a hidden chat, missing image actions for displayed inline/URL sources, readable SVG being excluded by its filename, and hidden previews starting another image read. The larger preview framing and visible-title alignment remains deferred as F04, outside this copy change; no follow-up ticket was supplied. The approved standard dialog padding and spacing are included here.
Agent skill upstream boundary
Notes
The image-copy feature makes no main-process, remote protocol, mobile, or platform-specific change. SSH image reads retain existing execution-host routing. The shared converter is also exercised through the browser clipboard consumer. Source validation and real runtime coverage are recorded separately.
Checklist