Fix/open original file 688#782
Conversation
WalkthroughThis PR fixes the "Open Original File" button in the Image Details panel by migrating from the deprecated Tauri shell API to the tauri-plugin-opener. It updates dependencies, adds necessary Tauri capabilities, modifies the frontend component logic, and adjusts OpenAPI schema definitions. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
docs/backend/backend_python/openapi.json(1 hunks)frontend/src-tauri/2(1 hunks)frontend/src-tauri/Cargo.toml(1 hunks)frontend/src-tauri/capabilities/migrated.json(1 hunks)frontend/src/components/Media/MediaInfoPanel.tsx(3 hunks)
🔇 Additional comments (6)
docs/backend/backend_python/openapi.json (1)
1-2927: Clarify the scope and relationship between backend schema changes and frontend file-opening fix.This file is the auto-generated OpenAPI documentation for the Python FastAPI backend. The PR description focuses exclusively on frontend changes (MediaInfoPanel.tsx, MediaView.tsx) and Tauri capability updates for opening local files. The inclusion of backend API schema documentation appears unrelated to the stated PR objective.
The specific schema change at lines 1114–1130 (wrapping the
input_typeparameter in anallOfstructure with additional metadata) is valid OpenAPI 3.1.0 syntax, but its presence in this PR requires clarification:
- Was the backend code modified, triggering automatic schema regeneration?
- Are all schema changes intentional and aligned with backend implementation updates?
- Why are backend API documentation updates included in a frontend feature fix?
Confirm these details before approval.
frontend/src/components/Media/MediaInfoPanel.tsx (3)
2-2: LGTM! Correct migration to opener plugin.The import correctly migrates from the deprecated shell plugin to the Tauri v2-compatible opener plugin, using the appropriate
openPathandopenUrlfunctions.
29-39: LGTM! Well-implemented location handler.The function properly validates metadata presence, constructs a valid Google Maps URL, and includes appropriate error handling for the async operation.
163-174: LGTM! Correctly fixes the "Open Original File" functionality.The migration from
opentoopenPathis correct and directly addresses issue #688. The implementation includes proper null checks and error handling.frontend/src-tauri/capabilities/migrated.json (1)
139-161: Verify the security implications of wildcard permissions.The opener permissions now allow opening ANY file path (
"**") and ANY HTTP/HTTPS URL ("https://*","http://*"). While this enables the required functionality, it's quite permissive.For an image management application where users legitimately need to open arbitrary image files and external links, these permissions are likely appropriate. However, please confirm this aligns with your application's security model and consider whether more restrictive patterns could be used.
If you want to restrict the scope, consider:
- Limiting paths to specific directories (e.g., user's Pictures, Documents)
- Restricting URLs to specific domains (e.g., only maps.google.com for location links)
Example of more restrictive URL permissions:
{ "identifier": "opener:allow-open-url", "allow": [ { "url": "https://maps.google.com/*" }, { "url": "https://www.google.com/maps/*" } ] }frontend/src-tauri/Cargo.toml (1)
37-37: The version constraint change is safe; version 2.5.2 does not exist.The loosened version from a non-existent "2.5.2" to "2" (any 2.x) is actually a correction rather than a risk. The latest published version of tauri-plugin-opener is v2.4.0, and the Tauri plugin ecosystem follows semantic versioning—no breaking changes occur within the 2.x line for minor or patch releases. The change allows for the current stable version and future compatible releases without introducing compatibility issues.
|
|
||
| removed 1 package, and audited 901 packages in 7s | ||
|
|
||
| 165 packages are looking for funding | ||
| run `npm fund` for details | ||
|
|
||
| 1 moderate severity vulnerability | ||
|
|
||
| To address all issues, run: | ||
| npm audit fix | ||
|
|
||
| Run `npm audit` for details. |
There was a problem hiding this comment.
Remove accidentally committed npm audit output.
This file appears to be npm audit command output that was unintentionally committed. Build artifacts and command output should not be tracked in version control.
Apply this fix:
#!/bin/bash
# Remove the accidentally committed file
git rm frontend/src-tauri/2Additionally, consider addressing the reported moderate severity vulnerability by running:
cd frontend/src-tauri && npm audit fix🤖 Prompt for AI Agents
In frontend/src-tauri/2 around lines 1-12 the file contains npm audit CLI output
that was accidentally committed; remove the file from the repo (use git rm and
commit the deletion), add a rule to .gitignore to prevent committing CLI/build
output in the future, and if you want to address the reported vulnerability run
npm audit fix in frontend/src-tauri, review and commit any updated lockfile
changes.
Fixes #688
Problem
The “Open Original File” button in the Image Details panel was not working. Clicking the button resulted in no action due to:
Use of @tauri-apps/plugin-shell, which supports URLs only and cannot open local file paths
Absence of a proper file-opening mechanism compatible with Tauri v2
Removal of the legacy tauri::api::shell::open API in Tauri v2
Solution
Migrated file and URL handling to @tauri-apps/plugin-opener, which provides native OS support for opening local files, revealing files in the system explorer, and opening external URLs in Tauri v2.
What this PR does
Introduces @tauri-apps/plugin-opener for native file and URL handling
Opens local images using the system’s default viewer
Reveals image files directly in the system file explorer
Opens location links (Google Maps) in the default browser
Adds required Tauri capability permissions
Files Updated
MediaInfoPanel.tsx
MediaView.tsx
frontend/src-tauri/capabilities/migrated.json
Verification
Open Original File opens the image correctly
Open Folder reveals the file in the OS file manager
External location links open in the browser
Verified on Windows, macOS, and Linux
Impact
Restores expected functionality
Aligns file handling with current Tauri standards
Improves overall reliability and user experience
Closes #688
Summary by CodeRabbit
New Features
Improvements
Chores
✏️ Tip: You can customize this high-level summary in your review settings.