fix: enable Open Original File using plugin-opener (closes #688)#783
fix: enable Open Original File using plugin-opener (closes #688)#783Akash1xe wants to merge 1 commit into
Conversation
WalkthroughThis PR fixes the non-functional "Open Original File" button by updating the frontend MediaInfoPanel component to use Tauri's opener plugin instead of the deprecated shell API. It also includes OpenAPI schema refinements, Tauri dependency version adjustment, and expanded opener capability permissions to support opening both files and URLs. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (4 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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
frontend/src/components/Media/MediaInfoPanel.tsx (2)
2-40: Fix lat/lon falsy checks (0.0 is valid) and encode the maps URL.
BothhandleLocationClickand the render branch use truthiness checks, which will incorrectly hide/open failure for coordinates like0(equator/prime meridian). Use!= nullchecks and encode the query.import React from 'react'; import { openPath, openUrl } from '@tauri-apps/plugin-opener'; @@ const handleLocationClick = async () => { - if (currentImage?.metadata?.latitude && currentImage?.metadata?.longitude) { + const lat = currentImage?.metadata?.latitude; + const lon = currentImage?.metadata?.longitude; + if (lat != null && lon != null) { - const { latitude, longitude } = currentImage.metadata; - const url = `https://maps.google.com/?q=${latitude},${longitude}`; + const url = `https://maps.google.com/?q=${encodeURIComponent(`${lat},${lon}`)}`; try { await openUrl(url); } catch (error) { console.error('Failed to open map URL:', error); } } };
108-121: Match the UI condition with the fixed null-check logic.
Same falsy issue in the JSX conditional.- {currentImage?.metadata?.latitude && - currentImage?.metadata?.longitude ? ( + {currentImage?.metadata?.latitude != null && + currentImage?.metadata?.longitude != null ? (
🧹 Nitpick comments (1)
frontend/src/components/Media/MediaInfoPanel.tsx (1)
163-176: Opener migration for “Open Original File” looks correct—consider surfacing errors to users.
openPath(currentImage.path)is the right direction for Tauri v2; currently failures only go to console (might be OK, but UX could be improved with a toast/snackbar).
📜 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 (2)
docs/backend/backend_python/openapi.json (1)
1119-1128: OpenAPI 3.1-friendly $ref decoration viaallOflooks good—verify client generators.
This pattern is typically used to attachtitle/default/descriptionaround a$ref; just ensure any downstream tooling (client generation, validators) used by the project accepts it.frontend/src-tauri/Cargo.toml (1)
31-38: No action needed—Rust and JS opener plugin versions already match. Thetauri-plugin-opener = "2"in Cargo.toml pairs with@tauri-apps/plugin-opener@^2.5.2in package.json, both at major version 2 and compatible.
|
|
||
| up to date, audited 901 packages in 3s | ||
|
|
||
| 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/relocate this accidental audit artifact file.
A file named frontend/src-tauri/2 with plain npm-audit output looks unintentional and doesn’t belong in src-tauri. Consider deleting it or moving it to a clearly named docs location if you want to track audit status.
🤖 Prompt for AI Agents
In frontend/src-tauri/2 (lines 1-12): this file contains accidental npm-audit
output and should not live in src-tauri; remove the file from the repository
(git rm) or move it to a proper docs or assets location with a clear name (e.g.,
docs/audit-output/npm-audit-YYYYMMDD.txt), update any references, and commit the
change; if you want to preserve audit logs going forward, add a process or
.gitignore entry so transient audit outputs aren’t accidentally committed.
| "opener:allow-reveal-item-in-dir", | ||
| "opener:allow-open-path", | ||
| "opener:allow-open-url", | ||
| "opener:allow-default-urls", | ||
| { | ||
| "identifier": "opener:allow-open-path", | ||
| "allow": [ | ||
| { | ||
| "path": "**" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "identifier": "opener:allow-open-url", | ||
| "allow": [ | ||
| { | ||
| "url": "https://*" | ||
| }, | ||
| { | ||
| "url": "http://*" | ||
| } | ||
| ] | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check the migrated.json file structure
echo "=== Migrated.json opener permissions ==="
rg -n "opener:" frontend/src-tauri/capabilities/migrated.json -A1 -B1
echo ""
echo "=== Search for opener plugin imports ==="
rg -r '@tauri-apps/plugin-opener' frontend/src --type ts --type tsx --type js
echo ""
echo "=== Search for openUrl calls ==="
rg -n 'openUrl\s*\(' frontend/src --type ts --type tsx --type js -A2 -B2 || echo "No openUrl calls found"
echo ""
echo "=== Search for openPath calls ==="
rg -n 'openPath\s*\(' frontend/src --type ts --type tsx --type js -A2 -B2 || echo "No openPath calls found"
echo ""
echo "=== Search for http:// URL patterns in frontend ==="
rg 'http://' frontend/src --type ts --type tsx --type js | head -20
echo ""
echo "=== Search for getVersion or URL scheme patterns ==="
rg 'allow-default-urls' frontend/src-tauri/capabilities/ -B5 -A5 || echo "No default-urls context"Repository: AOSSIE-Org/PictoPy
Length of output: 1614
🏁 Script executed:
#!/bin/bash
echo "=== Search src-tauri Rust files for opener usage ==="
find frontend/src-tauri -name "*.rs" -type f | head -20
echo ""
echo "=== Search for opener in Rust code ==="
rg -n 'opener' frontend/src-tauri --type rust -i -A3 -B3 2>/dev/null || echo "No opener matches in Rust"
echo ""
echo "=== Search for openPath or openUrl in Rust ==="
rg -n 'open_path|openPath|open_url|openUrl' frontend/src-tauri -i -A3 -B3 2>/dev/null || echo "No openPath/openUrl matches"
echo ""
echo "=== Check file structure in src-tauri ==="
ls -la frontend/src-tauri/ | head -30
echo ""
echo "=== Check for any references to http in config ==="
rg 'http://' frontend/src-tauri/capabilities/ -B2 -A2Repository: AOSSIE-Org/PictoPy
Length of output: 2282
🏁 Script executed:
#!/bin/bash
echo "=== Search for Tauri command handlers or invoke patterns ==="
rg -n '#\[command\]|#\[tauri::command\]' frontend/src-tauri/src -A5 2>/dev/null | head -40
echo ""
echo "=== Search for any async invoke or command patterns ==="
rg -n 'invoke\s*\(|Command|command' frontend/src-tauri/src --type rust -i -A2 | head -40
echo ""
echo "=== Check what lib.rs exports ==="
cat -n frontend/src-tauri/src/lib.rs
echo ""
echo "=== Check README or docs for opener context ==="
find . -name "README*" -o -name "*.md" | xargs grep -l 'opener\|open.*file\|open.*url' 2>/dev/null | head -5
echo ""
echo "=== Look at git history for migrated.json changes ==="
git log --oneline frontend/src-tauri/capabilities/migrated.json 2>/dev/null | head -10
echo ""
echo "=== Check app purpose - look at tauri.conf ==="
cat frontend/src-tauri/tauri.conf.jsonRepository: AOSSIE-Org/PictoPy
Length of output: 3068
🏁 Script executed:
#!/bin/bash
echo "=== Search for invocations through Tauri API calls ==="
rg -n 'invoke.*opener|window\.__TAURI__' frontend/src --type js -A3 -B1 2>/dev/null | head -50
echo ""
echo "=== Search for references to issue 688 ==="
rg -rn '688|Open Original File|reveal.*item' frontend/src-tauri frontend/src --type js --type rust 2>/dev/null | head -20
echo ""
echo "=== Check frontend structure ==="
find frontend -name "*.ts" -o -name "*.tsx" | grep -v node_modules | head -20
echo ""
echo "=== Search main frontend files for any opener/url/path opens ==="
find frontend/src -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" \) ! -path "*/node_modules/*" | head -10 | xargs cat 2>/dev/null | grep -i 'open\|url\|path' | head -30Repository: AOSSIE-Org/PictoPy
Length of output: 1351
Tighten opener permissions: open-path with "**" and http://* are overly permissive for a photo management app.
The feature enables "Open Original File" (#688) but the allowlists are unnecessarily broad:
path: "**"allows opening any file on the system; restrict to user home directory, Pictures folder, or user-selected library roots.http://*creates a MITM risk and is likely unnecessary (photo apps need only local file access or HTTPS for remote images).allow-default-urlsshould be removed unless explicitly required.
If the webview is exposed to XSS (the app's CSP asset scope is already broad with scope: ["**"]), these permissions increase impact. Tighten to minimum viable access.
|
Please resolve the merge conflicts before review. Your PR will only be reviewed by a maintainer after all conflicts have been resolved. 📺 Watch this video to understand why conflicts occur and how to resolve them: |
Fixes #688
❌ Problem
The Open Original File button was non-functional because:
@tauri-apps/plugin-shell only supports URLs, not local file paths
No backend-compatible mechanism existed for opening local files
Legacy tauri::api::shell::open API is removed in Tauri v2
✅ Solution
Migrated file and URL handling to @tauri-apps/plugin-opener, which provides native OS support 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 in the default browser
Adds required Tauri capability permissions
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
Related Issue
Closes #688
Summary by CodeRabbit
New Features
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.