Skip to content

Linux button fix#599

Merged
jhweir merged 9 commits intodevfrom
linux-button-fix
Apr 24, 2025
Merged

Linux button fix#599
jhweir merged 9 commits intodevfrom
linux-button-fix

Conversation

@lucksus
Copy link
Copy Markdown
Member

@lucksus lucksus commented Apr 23, 2025

Uses Tauri's opener plugin instead of the old shell plugin to fix opening of URLs and files not working on some distros.

Summary by CodeRabbit

  • New Features

    • Added the ability to reveal the log file directly from the menu and settings, making it easier to locate log files on your system.
    • Introduced a new command to retrieve the application's data path.
  • Improvements

    • Updated menu and settings labels to "Reveal Log File" for clarity.
    • Enhanced the mechanism for opening external URLs and revealing files using an improved system integration.
  • Bug Fixes

    • Fixed open button functionality on Linux by integrating Tauri's opener plugin.
  • Chores

    • Updated dependencies to support new file and URL opening features.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 23, 2025

Warning

Rate limit exceeded

@lucksus has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 52 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f905d1c and dea8e90.

📒 Files selected for processing (4)
  • ui/src-tauri/src/commands/app.rs (1 hunks)
  • ui/src-tauri/src/lib.rs (4 hunks)
  • ui/src-tauri/src/menu.rs (4 hunks)
  • ui/src/components/Settings.tsx (4 hunks)

Walkthrough

This update integrates the Tauri Opener plugin into both the backend (Rust) and frontend (TypeScript/React) of the application. It adds the necessary dependencies and permissions, introduces a new Tauri command for retrieving the data path, and updates logic for revealing log files and opening URLs. Event names and menu labels related to log file access are revised, and the mechanism for opening URLs and revealing files now uses the Opener plugin instead of the Shell plugin. The changes affect configuration files, command definitions, menu handling, and UI components.

Changes

File(s) Change Summary
ui/package.json, ui/src-tauri/Cargo.toml Added @tauri-apps/plugin-opener (frontend) and tauri-plugin-opener (backend) as dependencies.
ui/src-tauri/capabilities/desktop.json Appended new permissions for opener capabilities: "opener:allow-reveal-item-in-dir", "opener:allow-default-urls", "opener:default".
ui/src-tauri/src/commands/app.rs Added new Tauri command get_data_path to return the application's data path as a string.
ui/src-tauri/src/lib.rs Integrated the opener plugin, registered the new get_data_path command, updated event handling for revealing log files, and adjusted imports accordingly.
ui/src-tauri/src/menu.rs Renamed menu item and handler from "Open Logs"/open_logs_folder to "Reveal Log File"/reveal_log_file, changed logic to reveal a specific log file using the opener plugin; removed old function.
ui/src-tauri/src/util.rs Updated event listener and handler for tray window, switching from "copyLogs"/open_logs_folder to "revealLogFile"/reveal_log_file.
ui/src/components/Apps.tsx Switched URL opening implementation from @tauri-apps/plugin-shell to @tauri-apps/plugin-opener; updated function call accordingly.
ui/src/components/Settings.tsx Updated log revealing and URL opening to use the opener plugin; changed button label and logic to reveal a specific log file; replaced event emission with direct plugin calls.
ui/src/components/Splashscreen.tsx Renamed function from copyFile to revealLogFile; changed event emission from "copyLogs" to "revealLogFile"; updated button handler accordingly.
CHANGELOG Added a fix entry noting that open buttons now work on Linux by integrating Tauri's opener plugin.

Sequence Diagram(s)

sequenceDiagram
    participant UI as React UI
    participant Tauri as Tauri Backend
    participant Opener as Opener Plugin

    UI->>Tauri: Invoke get_data_path command
    Tauri-->>UI: Return data path string
    UI->>Opener: revealItemInDir(data_path/ad4m.log)
    Opener-->>UI: Reveals log file in directory

    UI->>Opener: openUrl("https://fluxsocial-dev.netlify.app/")
    Opener-->>UI: Opens URL in default browser
Loading

Poem

🐇
With a hop and a jump, new plugins appear,
The Opener’s magic now brings us cheer!
Revealing log files with just one click,
URLs open fast, smooth, and slick.
Permissions aligned, menus refined—
In this fresh update, new pathways we find!
—Your friendly code rabbit 🥕✨


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
ui/src-tauri/src/menu.rs (2)

47-51: Error message in reveal_log_file should be updated

The function now reveals a specific log file rather than opening a folder, but the error message still refers to "opening logs folder".

pub fn reveal_log_file(app: &AppHandle) {
    if let Err(err) = app.opener().reveal_item_in_dir(data_path().join("ad4m.log")) {
-        log::error!("Error opening logs folder: {}", err);
+        log::error!("Error revealing log file: {}", err);
    }
}

47-51: Consider checking if the log file exists before revealing

The code assumes the log file exists at the expected path. Consider adding a check to ensure the file exists before attempting to reveal it.

pub fn reveal_log_file(app: &AppHandle) {
-    if let Err(err) = app.opener().reveal_item_in_dir(data_path().join("ad4m.log")) {
-        log::error!("Error opening logs folder: {}", err);
+    let log_file_path = data_path().join("ad4m.log");
+    if !log_file_path.exists() {
+        log::error!("Log file does not exist at path: {:?}", log_file_path);
+        return;
+    }
+    
+    if let Err(err) = app.opener().reveal_item_in_dir(log_file_path) {
+        log::error!("Error revealing log file: {}", err);
    }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33c6ab2 and cf1ea3c.

⛔ Files ignored due to path filters (5)
  • Cargo.lock is excluded by !**/*.lock
  • ui/src-tauri/gen/schemas/acl-manifests.json is excluded by !**/gen/**
  • ui/src-tauri/gen/schemas/capabilities.json is excluded by !**/gen/**
  • ui/src-tauri/gen/schemas/desktop-schema.json is excluded by !**/gen/**
  • ui/src-tauri/gen/schemas/linux-schema.json is excluded by !**/gen/**
📒 Files selected for processing (9)
  • ui/package.json (1 hunks)
  • ui/src-tauri/Cargo.toml (1 hunks)
  • ui/src-tauri/capabilities/desktop.json (1 hunks)
  • ui/src-tauri/src/commands/app.rs (1 hunks)
  • ui/src-tauri/src/lib.rs (4 hunks)
  • ui/src-tauri/src/menu.rs (4 hunks)
  • ui/src-tauri/src/util.rs (2 hunks)
  • ui/src/components/Apps.tsx (2 hunks)
  • ui/src/components/Settings.tsx (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
ui/src-tauri/src/commands/app.rs (1)
ui/src-tauri/src/config.rs (1)
  • data_path (5-7)
ui/src-tauri/src/menu.rs (1)
ui/src-tauri/src/config.rs (1)
  • data_path (5-7)
🔇 Additional comments (19)
ui/package.json (1)

17-17: Appropriate plugin addition for cross-platform compatibility.

Adding the Tauri opener plugin is a good approach to fix the URL and file opening issues on Linux distributions. The version ~2.2.6 is compatible with the other Tauri 2.x plugins being used in the project.

ui/src-tauri/Cargo.toml (1)

56-56: Rust dependency added to match frontend changes.

The addition of tauri-plugin-opener on the Rust side complements the frontend dependency change. The version 2.2.6 matches the expected version for Tauri 2.x plugins and maintains consistency with the frontend dependency version.

ui/src/components/Apps.tsx (2)

1-1: Import updated to use the opener plugin.

Switching from the shell plugin to the more specialized opener plugin is appropriate. This change should help resolve the Linux-specific URL opening issues.


75-75: Implementation updated to use the opener plugin.

The function call has been properly updated to use openUrl from the opener plugin instead of open from the shell plugin, maintaining the same functionality while potentially fixing the Linux compatibility issues.

ui/src-tauri/src/util.rs (3)

4-4: Import correctly updated to match function rename

The import was correctly updated to reference the new reveal_log_file function instead of open_logs_folder, aligning with the changes in menu.rs.


50-52: Event name appropriately updated for consistency

The event name was properly updated from "copyLogs" to "revealLogFile" to match the new functionality. The app handle is correctly cloned to avoid lifetime issues.


58-58: Function call updated to use the new reveal_log_file function

The function call was correctly updated to pass the app handle to the new function.

ui/src-tauri/src/lib.rs (6)

45-45: Added get_data_path to imported functions

The get_data_path function is now correctly imported from the app commands module.


51-51: Updated import to use reveal_log_file

The import was properly updated to use the renamed function.


217-217: Tauri opener plugin properly initialized

The tauri_plugin_opener is now correctly initialized in the Tauri builder chain, enabling the functionality needed for opening URLs and files on Linux.


241-243: Added get_data_path to invoke handler list

The get_data_path function is correctly registered with the invoke handler, making it accessible from the frontend.


251-253: Event listener updated for the splashscreen window

The event listener has been properly updated to listen for "revealLogFile" instead of "copyLogs", maintaining consistency with the changes in other files.


259-259: Updated function call to use reveal_log_file

The call to reveal_log_file now correctly passes the app handle, aligning with the function's new signature.

ui/src-tauri/src/menu.rs (3)

4-4: Added import for OpenerExt trait

The OpenerExt trait is correctly imported from the tauri_plugin_opener crate, enabling access to the reveal_item_in_dir method.


16-16: Menu item label updated to reflect new functionality

The menu item label has been properly updated from "Open Logs" to "Reveal Log File" to match the new functionality.


26-30: Menu event handler updated to use reveal_log_file

The menu event handler now correctly clones the app handle and passes it to the reveal_log_file function.

ui/src/components/Settings.tsx (3)

5-5: Import updated to use Tauri opener plugin

This change replaces the shell plugin with the opener plugin as mentioned in the PR objectives, aligning with the goal of addressing URL and file opening issues on some Linux distributions.


359-359: Implementation correctly uses the new opener plugin API

This line successfully updates the URL opening mechanism to use the Tauri opener plugin instead of the shell plugin, maintaining the same functionality while addressing the Linux compatibility issues.


370-370: Button label updated to match new functionality

The label now accurately reflects that the action reveals a specific log file rather than generally showing logs, improving clarity for users.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
ui/src/components/Splashscreen.tsx (1)

12-19: Consider renaming the state variable for better semantic accuracy.

The function has been updated to reveal the log file rather than copy it, but the state variable is still called copied. Consider renaming it to better reflect the updated functionality.

- const [copied, setCopied] = useState(false);
+ const [fileRevealed, setFileRevealed] = useState(false);

  function revealLogFile() {
    appWindow.emit("revealLogFile");

    setTimeout(() => {
-     setCopied(true);
-     setTimeout(() => setCopied(false), 2000);
+     setFileRevealed(true);
+     setTimeout(() => setFileRevealed(false), 2000);
    }, 500);
  }

Also update the button text in line 48 to match:

- {copied ? "Opened" : "Open Logs"}
+ {fileRevealed ? "Opened" : "Show Log File"}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1d503d and f905d1c.

📒 Files selected for processing (1)
  • ui/src/components/Splashscreen.tsx (2 hunks)
🔇 Additional comments (2)
ui/src/components/Splashscreen.tsx (2)

12-13: Function name and event updated to better represent actual behavior.

The function rename from copyFile to revealLogFile and event change from "copyLogs" to "revealLogFile" better represents what the functionality actually does - revealing the log file in the file explorer rather than copying it. This aligns with the PR objective of replacing the shell plugin with Tauri's opener plugin.


45-45: Updated onClick handler to use the renamed function.

Correctly updated the button's onClick handler to call the renamed function.

@jhweir jhweir merged commit c8d3640 into dev Apr 24, 2025
3 checks passed
@lucksus lucksus deleted the linux-button-fix branch August 22, 2025 12:19
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.

2 participants