Skip to content

Open Files - #2

Merged
rafaelfaustini merged 5 commits into
mainfrom
dev
Apr 4, 2026
Merged

rafaelfaustini merged 5 commits into
mainfrom
dev

Conversation

@rafaelfaustini

Copy link
Copy Markdown
Owner
  • Open files
  • Unit tests (Path assemble logic from FileExplorer was decoupled from UI allowing us to have unit tests)
  • Feature integration test

We want to be able to open a file, the test will fail since we didn't implement the feature yet
Simple implementation until test passes
By mistake I was putting .extension in the extension mocks, when I should've put just the extension
There were non UI logic in the FileExplorer component, related to path assembly used for the navigation. Therefore, in the refactor process the logic was separated into functions in a new util. With this logic decoupled of the UI, unit tests were made to cover edge cases with less cost of integration tests

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an “open file” capability to the File Explorer by wiring a new Tauri command and decoupling path construction into a reusable utility, with accompanying unit and integration tests.

Changes:

  • Introduces pathUtils helpers for assembling folder/file paths and adds unit tests for the path assembly logic.
  • Updates FileExplorer to open files on double-click via a new Tauri open_file command.
  • Extends the Tauri backend with a file command module and adjusts directory listing behavior; updates dependency range/lockfiles.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
yarn.lock Updates lock entry for @tauri-apps/plugin-opener.
package.json Switches @tauri-apps/plugin-opener version range to ~2.
src/utils/pathUtils.ts Adds shared path assembly utilities for folders/files.
src/utils/pathUtils.test.ts Adds unit tests for pathUtils.
src/setupTests.ts Minor test setup cleanup.
src/components/FileExplorer/FileExplorer.tsx Uses pathUtils and invokes open_file on file double-click.
src/components/FileExplorer/FileExplorer.test.tsx Updates extension fixtures and adds a file-open double-click test.
src-tauri/src/lib.rs Registers the new open_file command (removes unused greet).
src-tauri/src/commands/mod.rs Exposes the new file module.
src-tauri/src/commands/file.rs Implements open_file using tauri-plugin-opener.
src-tauri/src/commands/directory.rs Changes name extraction to file_stem() in directory listings.
Comments suppressed due to low confidence (1)

src-tauri/src/commands/directory.rs:37

  • path.file_stem() is used for all entries, including directories. For folder names containing dots (e.g., my.folder), file_stem will truncate the name to my and treat folder as an extension, which will make the UI show an incorrect folder name. Consider using file_name() when metadata.is_dir() is true (or always use file_name() and only compute extension for files).
        let name = path.file_stem()
            .map(|n| n.to_string_lossy().into_owned())
            .unwrap_or_else(|| "Unknown".to_string());

        let extension = path.extension()
            .map(|e| e.to_string_lossy().into_owned())
            .unwrap_or_default();

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/pathUtils.test.ts Outdated
Comment thread package.json
1. Removed unused imports in pathUtils tests
2. package-log.json was regenerated via npm install to avoid inconsistency with package.json
3. When double clicking a folder/file, the name was being selected giving a non button behaviour, the user-select needed some fallbacks in css

This comment was marked as resolved.

@rafaelfaustini rafaelfaustini self-assigned this Apr 4, 2026
@rafaelfaustini
rafaelfaustini merged commit 9fda107 into main Apr 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants