Add use clipboard text when saving option#1590
Conversation
LiliaDoe
commented
Mar 23, 2025
- Resolves [Feature]: Save image as [content of clipboard] #1588
- Very niche option, but figured it was simple enough to add
- Only making a PR in case someone else might want it
- If it doesn't fit HZ+ in general, I'd understand and will close it
There was a problem hiding this comment.
Hello @LiliaDoe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request adds a new option to Hover Zoom+ that copies the filename of an image to the clipboard when the image is saved. The author notes this is a niche feature but simple to add. The changes include adding a new checkbox in the options menu, updating the options storage to include the new setting, and modifying the save function to copy the filename to the clipboard if the option is enabled.
Highlights
- New Feature: Copy Filename on Save: Adds a new option to copy the filename to the clipboard when saving an image.
- Options Menu Update: Adds a checkbox to the options menu to enable/disable the 'copy filename on save' feature.
- Code Modification: Modifies the save function to copy the filename to the clipboard if the new option is enabled.
Changelog
Click here to see the changelog
- _locales/en/messages.json
- Added new message keys for the 'copy filename when saving' option and its tooltip (lines 710-716).
- html/options.html
- Added a new checkbox and label to the options page for the 'copy filename when saving' feature (lines 625-631).
- js/common.js
- Added a new
copyFileNameWhenSavingoption to thefactorySettingsobject, defaulting tofalse(line 56).
- Added a new
- js/hoverzoom.js
- Modified the
saveFilefunction to copy the filename to the clipboard usingnavigator.clipboard.writeText(filename)if thecopyFileNameWhenSavingoption is enabled (lines 3444-3445).
- Modified the
- js/options.js (1)
- Modified the
saveOptionsfunction to save the state of thechkCopyFileNameWhenSavingcheckbox to theoptionsobject (line 141).
- Modified the
- js/options.js (2)
- Modified the
restoreOptionsfunction to restore the state of thechkCopyFileNameWhenSavingcheckbox from theoptionsobject (line 313).
- Modified the
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A simple tweak, a helpful hand,
To copy names across the land.
With clipboard's grace, the filename flies,
A niche request that now complies.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
The pull request introduces a new feature to copy the filename to the clipboard when saving an image. The changes seem straightforward and well-implemented. However, there are a few points that could be improved for better user experience and code clarity.
Summary of Findings
- User feedback on filename copy: Consider providing visual feedback to the user when the filename is copied to the clipboard, such as a brief notification. This would improve the user experience by confirming that the action was successful.
- Error handling for clipboard access: The code currently doesn't handle potential errors when writing to the clipboard. Implement error handling to gracefully manage scenarios where clipboard access is denied or fails.
Merge Readiness
The pull request is almost ready for merging. Addressing the error handling for clipboard access is crucial. Adding user feedback would be a nice enhancement, but not necessarily required for merging. I am unable to approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.
| if (options.copyFileNameWhenSaving) | ||
| navigator.clipboard.writeText(filename); // Copy the filename to clipboard |
There was a problem hiding this comment.
Consider adding a try...catch block to handle potential errors when writing to the clipboard. For example, the user might not have granted the extension clipboard permissions, or the clipboard might be temporarily unavailable. Without error handling, the extension might fail silently. Also, consider providing user feedback to let them know if the copy was successful.
if (options.copyFileNameWhenSaving) {
try {
navigator.clipboard.writeText(filename);
// Optionally, provide user feedback here (e.g., a notification)
} catch (err) {
console.error('Failed to copy filename: ', err);
// Optionally, provide user feedback about the failure
}
}|
As far as I understand #1588, the request was for the opposite - use clipboard to determine a file name to save. |
|
Oh, that was the request. I misread completely |
…Doe/hoverzoom into Use-clipboard-text-when-saving
|
I suppose that's what they actually wanted |
|


