Skip to content

Add use clipboard text when saving option#1590

Merged
extesy merged 7 commits intoextesy:masterfrom
LiliaDoe:Copy-file-name-when-saving
Mar 24, 2025
Merged

Add use clipboard text when saving option#1590
extesy merged 7 commits intoextesy:masterfrom
LiliaDoe:Copy-file-name-when-saving

Conversation

@LiliaDoe
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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 copyFileNameWhenSaving option to the factorySettings object, defaulting to false (line 56).
  • js/hoverzoom.js
    • Modified the saveFile function to copy the filename to the clipboard using navigator.clipboard.writeText(filename) if the copyFileNameWhenSaving option is enabled (lines 3444-3445).
  • js/options.js (1)
    • Modified the saveOptions function to save the state of the chkCopyFileNameWhenSaving checkbox to the options object (line 141).
  • js/options.js (2)
    • Modified the restoreOptions function to restore the state of the chkCopyFileNameWhenSaving checkbox from the options object (line 313).
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

  1. 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread js/hoverzoom.js Outdated
Comment on lines +3444 to +3445
if (options.copyFileNameWhenSaving)
navigator.clipboard.writeText(filename); // Copy the filename to clipboard
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.

high

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
                }
            }

@extesy
Copy link
Copy Markdown
Owner

extesy commented Mar 24, 2025

As far as I understand #1588, the request was for the opposite - use clipboard to determine a file name to save.

@LiliaDoe LiliaDoe changed the title Copy file name when saving Add copy file name when saving image option Mar 24, 2025
@LiliaDoe
Copy link
Copy Markdown
Contributor Author

Oh, that was the request. I misread completely

@LiliaDoe LiliaDoe changed the title Add copy file name when saving image option Add use clipboard text when saving option Mar 24, 2025
@LiliaDoe LiliaDoe closed this Mar 24, 2025
@LiliaDoe LiliaDoe deleted the Copy-file-name-when-saving branch March 24, 2025 00:20
@LiliaDoe LiliaDoe restored the Copy-file-name-when-saving branch March 24, 2025 00:21
@LiliaDoe LiliaDoe deleted the Copy-file-name-when-saving branch March 24, 2025 00:21
@LiliaDoe LiliaDoe restored the Copy-file-name-when-saving branch March 24, 2025 00:22
@LiliaDoe LiliaDoe reopened this Mar 24, 2025
@LiliaDoe
Copy link
Copy Markdown
Contributor Author

LiliaDoe commented Mar 24, 2025

I suppose that's what they actually wanted

@sonarqubecloud
Copy link
Copy Markdown

@extesy extesy merged commit 8a09532 into extesy:master Mar 24, 2025
3 checks passed
@LiliaDoe LiliaDoe deleted the Copy-file-name-when-saving branch March 24, 2025 16:34
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.

[Feature]: Save image as [content of clipboard]

2 participants