Skip to content

fix: improve sprite viewer mouse controls#215

Merged
devonjones merged 6 commits intotestfrom
fix/sprite-viewer-mouse-controls
Jan 1, 2026
Merged

fix: improve sprite viewer mouse controls#215
devonjones merged 6 commits intotestfrom
fix/sprite-viewer-mouse-controls

Conversation

@devonjones
Copy link
Collaborator

@devonjones devonjones commented Jan 1, 2026

Summary

  • Fixed right-click drag conflict with context menu
  • Added vertical drag support for top/bottom views
  • Fixed rotation math when transitioning between vertical and horizontal views
  • Added sprite sheet download functionality via backend proxy

Mouse Control Changes

  • Only left mouse button triggers dragging (right-click now shows context menu properly)
  • Drag up switches to top view
  • Drag down switches to bottom view
  • Horizontal drag from vertical views correctly goes to front view first
  • Atomic drag gestures (either horizontal OR vertical, not mixed)

Download Functionality

  • Added download button in bottom-right corner of sprite viewer
  • Added right-click context menu with "Download sprite sheet" option
  • Created backend proxy endpoint /api/images/proxy to bypass CORS restrictions
  • Downloads full sprite sheet (extracting single tiles blocked by CORS)

Technical Details

  • CORS prevents canvas manipulation and download of cross-origin images
  • Backend proxy fetches images server-side and adds Content-Disposition header
  • Proxy validates URLs are from FILE_DOMAIN for security

Testing

  • All existing tests pass
  • Keyboard controls unchanged and working
  • Mouse drag rotation works correctly from all angles

🤖 Generated with Claude Code

- Disable right-click drag to fix context menu conflicts
- Add vertical drag support (up = top view, down = bottom view)
- Fix rotation logic when dragging from vertical views
- Maintain atomic drag gestures (either horizontal OR vertical)

Each drag now properly handles transitions between horizontal and
vertical views without breaking the rotation math.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @devonjones, 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!

This pull request refines the user experience of the sprite viewer by making its mouse controls more robust and intuitive. It addresses several issues related to drag interactions, ensuring that users can seamlessly navigate between different sprite perspectives, including horizontal rotations and dedicated top/bottom views, without unexpected behavior or conflicts.

Highlights

  • Improved Mouse Drag Controls: The sprite viewer's mouse drag functionality has been enhanced to support both horizontal and vertical rotation, allowing users to switch between different sprite angles and top/bottom views more intuitively.
  • Right-Click Conflict Resolution: Dragging is now exclusively triggered by the left mouse button, resolving a conflict where right-click drag interfered with the context menu.
  • Enhanced Vertical View Transitions: Dragging up or down now correctly switches to the top or bottom view, respectively. Additionally, horizontal dragging initiated from a vertical view will now correctly transition to the front view (angle 0) before rotating horizontally.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

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

This pull request effectively improves the sprite viewer's mouse controls by adding vertical drag functionality and resolving a conflict with the right-click context menu. The implementation is logical, particularly the handling of rotation when transitioning from vertical to horizontal views. My main feedback is the lack of tests for this new functionality, which is critical for ensuring its correctness and preventing regressions. I've also provided a suggestion to improve the consistency of the drag detection logic. Overall, these are great enhancements that will improve the user experience once testing is added.

devonjones and others added 2 commits January 1, 2026 13:10
Added download functionality for sprite sheets to address the loss
of right-click "save image" capability. Since sprite tiles are rendered
as CSS background-images, browser context menus don't work normally.

Implementation:
- Added download button positioned in bottom-right of sprite viewer
- Added custom right-click context menu with "Download sprite sheet" option
- Created backend proxy endpoint `/api/images/proxy` to bypass CORS
- Proxy validates URLs are from FILE_DOMAIN for security
- Downloads full sprite sheet (extracting single tiles blocked by CORS)

Technical details:
- CORS prevents canvas manipulation of cross-origin images
- CORS prevents download attribute from working on cross-origin links
- Backend proxy fetches image server-side and adds Content-Disposition header
- Uses existing `requests` library already in requirements.txt

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…comprehensive tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@devonjones
Copy link
Collaborator Author

/gemini review

Copy link
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

This pull request significantly improves the sprite viewer's mouse controls and adds a much-needed sprite sheet download feature. The backend changes introduce a new proxy endpoint to handle downloads, but I've identified a critical security vulnerability (SSRF) in its implementation that needs to be addressed. On the frontend, the new drag logic is well-implemented, but the custom context menu uses direct DOM manipulation, which is not idiomatic for React and could lead to bugs and maintenance issues. I've provided detailed feedback and suggestions to resolve these issues.

- CRITICAL: Fixed SSRF vulnerability in proxy_image by validating FILE_DOMAIN is configured
- Added query parameter stripping for clean filenames
- Fixed download button title to match actual functionality
- Added context menu cleanup on component unmount to prevent memory leak

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@devonjones
Copy link
Collaborator Author

/gemini review

Copy link
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

This pull request enhances the sprite viewer's mouse controls and adds a valuable sprite sheet download feature. The backend implementation includes a new proxy endpoint to handle downloads, which is a good approach to bypass CORS issues. However, I've identified a significant security vulnerability (SSRF) in the proxy's URL validation logic, as well as a less severe path traversal risk. On the frontend, the new mouse controls and associated tests are well-implemented. The custom context menu for downloading is functional, but its implementation relies on direct DOM manipulation, which is an anti-pattern in React; I've suggested refactoring it to a more idiomatic, state-driven approach for better maintainability. My review includes specific suggestions to address these points.

- Use urlparse to compare netloc instead of startswith check
- Prevents SSRF bypass via subdomain attacks
- Add secure_filename sanitization to prevent path traversal
- Import urllib.parse for robust URL validation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@devonjones
Copy link
Collaborator Author

/gemini review

Copy link
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

This pull request introduces significant improvements to the sprite viewer's mouse controls and adds a new download functionality. The backend proxy for downloads is well-implemented, though I've suggested a minor improvement for filename extraction to make it more robust. The new mouse control logic and corresponding tests are comprehensive. However, on the frontend, I've identified a couple of areas for improvement. The new context menu is implemented using direct DOM manipulation, which is a React anti-pattern; I've recommended refactoring this into a declarative React component for better maintainability. Additionally, the logic for differentiating vertical and horizontal views relies on an implicit array ordering, which I've suggested making more explicit and robust. Overall, great work on enhancing the user experience of the sprite viewer.

- Add fallback for URLs without filenames (empty path case)
- Use explicit topIndex/bottomIndex comparison instead of >= check
- Makes angle detection independent of array ordering

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@devonjones devonjones merged commit c7279af into test Jan 1, 2026
4 checks passed
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.

1 participant