fix: Open Original File Button in Image Details Panel (#536)fix: Open Original File Button in Image Details Panel (#536)#542
Conversation
WalkthroughReplaces browser-based window.open with Tauri shell open for the “Open Original File” action in MediaInfoPanel, adds an import for the Tauri shell, updates the button styling to include a pointer cursor, and changes the click handler to async with try/catch error handling. No public API changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as MediaInfoPanel (React)
participant Shell as Tauri Shell
participant OS as OS File Handler
User->>UI: Click "Open Original File"
UI-->>UI: async handler, try { await open(path) } catch (err)
UI->>Shell: open(currentImage.path)
Note right of Shell: Invoke native shell to open file path
Shell->>OS: Launch associated app with file
OS-->>User: File opens in default application
alt error
Shell-->>UI: error
UI-->>User: (handle/report error)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
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
🧹 Nitpick comments (1)
frontend/src/components/Media/MediaInfoPanel.tsx (1)
134-136: Consider adding path validation for security.Per security best practices for the Tauri shell plugin, validate that
currentImage.pathis a legitimate file path before passing it toopen(). While the path comes from application data rather than direct user input, adding validation provides defense in depth.Based on learnings.
Consider adding validation like:
if (currentImage?.path) { const isValidPath = /^[a-zA-Z]:[\\\/]|^\//.test(currentImage.path); // Basic absolute path check if (!isValidPath) { console.error('Invalid file path format'); return; } try { await open(currentImage.path); } catch (error) { console.error('Failed to open file:', error); } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/components/Media/MediaInfoPanel.tsx(2 hunks)
🔇 Additional comments (2)
frontend/src/components/Media/MediaInfoPanel.tsx (2)
132-132: LGTM: Good UX improvement.Adding
cursor-pointerprovides better visual feedback for the clickable button.
2-2: Tauri shell plugin registration verified Import ofopenand backend plugin initialization are correct.
rahulharpal1603
left a comment
There was a problem hiding this comment.
LGTM!
Thanks @ShivaGupta-14
Solves Issue #536
There was an issue in MediaInfoPanel.tsx under Image Details where the Open Original File Button did not open the file. This PR fixes the problem by using the correct Tauri API.
css
Path -> frontend\src\components\Media\MediaInfoPanel.tsx
Approach
Problem:
may not work as expected.”
Solution:
Testing Done
Summary by CodeRabbit
Bug Fixes
Style