Skip to content

feat(chat): copy and download images from the image itself - #1951

Open
zszz3 wants to merge 1 commit into
vastsa:mainfrom
zszz3:feat/copy-chat-images
Open

zszz3 wants to merge 1 commit into
vastsa:mainfrom
zszz3:feat/copy-chat-images

Conversation

@zszz3

@zszz3 zszz3 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Refs #1917. 接替 #1918:维护者在 #1918 中判定这是新增能力,应以 feat 提交,因此改为 feat 重新提交。代码与 #1918 最终版本相同(含 review 修复:image/jpg 兼容、URL 下载名去掉 ?/#),已合并到最新 main 后整理为单个提交。

右键菜单

功能

  • 对话里的 Markdown 本地图片和生成图片,右键菜单新增「复制图片」「下载图片」,原有的「复制完整地址 / 复制相对地址」保留。
  • 生成图片查看器新增复制按钮,支持 Cmd/Ctrl+C;查看器是 modal <dialog>,菜单 portal 到 dialog 内,复制结果用内联状态提示(toast 会被顶层遮挡)。
  • 复制统一写入 PNG(JPEG/JPG/WebP 经 canvas 转码);下载名取 URL path 的最后一段并解码,本地路径原样保留。
  • 不新增 IPC,不改主进程权限。

验证

  • pnpm build:js、desktop typecheck、pnpm lint、architecture check、git diff --check 通过。
  • desktop 测试 4568 tests / 0 fail;i18n 31/31。
  • 新增测试:image-clipboard、image-download-name、generated-image-context-menu,并更新 chat-file-open-with-menu 的契约断言。
  • 剪贴板相关 Electron E2E 没有跑。

Images in a reply could only be opened or have their path copied, so
getting the picture itself into another app meant a detour through the
file manager. Generated images and Markdown images now offer Copy image
and Download image on right-click; the generated-image viewer also has a
copy button and Cmd/Ctrl+C.

Copy writes PNG to the clipboard (JPEG, JPG and WebP are re-encoded).
Download names come from the URL path without its query or fragment;
local paths keep their file name verbatim.

Refs vastsa#1917, supersedes vastsa#1918.

@muzimu217 muzimu217 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same change I reviewed as #1918, resubmitted as feat per the maintainer's call, and the two points from that review are both in: SUPPORTED_IMAGE_DATA_URL now accepts jpe?g with a comment explaining that sources emit image/jpg often enough to matter, and downloadMarkdownImage strips [?#] before taking the last path segment, with a test for the alias.

Single commit, rebased onto current main, and the permission story is unchanged from #1918: navigator.clipboard.write works because installLiveMicrophonePermissionHandlers grants every non-media permission on session.defaultSession (microphone-permissions.ts:50-58), which is why no IPC change is needed. Nothing new to object to.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants