Skip to content

feat: add process plugin integration and update app updater logic#27

Merged
AbianS merged 2 commits into
mainfrom
feat/automatic-updater
Nov 5, 2025
Merged

feat: add process plugin integration and update app updater logic#27
AbianS merged 2 commits into
mainfrom
feat/automatic-updater

Conversation

@AbianS

@AbianS AbianS commented Nov 5, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added in-app process support enabling controlled relaunch/restart flows.
    • Seamless restart after update with explicit "Restart Now" action; update messaging clarified.
    • Update checking integrated into main page with visible status badges and contextual button states.
  • Bug Fixes / UX
    • Silent update checks option to suppress toasts when desired.
  • Chores
    • App capabilities updated to permit restart/process actions.

@coderabbitai

coderabbitai Bot commented Nov 5, 2025

Copy link
Copy Markdown

Walkthrough

Adds the Tauri process plugin, grants process permissions, initializes the plugin, and refactors the app update flow to support silent checks, user-initiated restart, and lifted update state from DatabaseManager to MainPage.

Changes

Cohort / File(s) Summary
JS & Cargo dependencies
package.json, src-tauri/Cargo.toml
Added the Tauri process plugin: @tauri-apps/plugin-process (v2.3.1) in package.json and tauri-plugin-process = "2.3.1" in src-tauri/Cargo.toml for non-mobile targets.
Tauri capabilities & init
src-tauri/capabilities/default.json, src-tauri/src/lib.rs
Added "process:default" and "process:allow-restart" to capabilities and initialized the process plugin via .plugin(tauri_plugin_process::init()) in the Tauri app builder.
Update hook behavior
src/features/app/hooks/use-app-updater.ts
Introduced relaunch import and handleRelaunch, added optional silent parameter to checkForUpdates to suppress toasts, changed install flow to present a "Restart Now" action that calls relaunch, and added error handling/logging for relaunch failures.
Page wiring & props
src/pages/main/MainPage.tsx
Calls updater on mount (silent), holds update state, and passes update flags and onCheckForUpdates handler down to DatabaseManager.
DatabaseManager UI & props
src/pages/main/components/DatabaseManager.tsx
Removed internal updater usage; added props updateAvailable, checkingUpdate, downloadingUpdate, onCheckForUpdates; updated button UI/state, added update-available badge and dynamic labels/actions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MainPage
    participant DatabaseManager
    participant useAppUpdater
    participant TauriAPI
    participant ProcessPlugin

    User->>MainPage: Mount
    MainPage->>useAppUpdater: checkForUpdates(silent=true)
    useAppUpdater->>TauriAPI: check for update
    TauriAPI-->>useAppUpdater: response (available / up-to-date)
    useAppUpdater-->>MainPage: update state
    MainPage->>DatabaseManager: pass state + onCheckForUpdates

    alt User clicks "Check for Updates"
        User->>DatabaseManager: click
        DatabaseManager->>MainPage: onCheckForUpdates()
        MainPage->>useAppUpdater: checkForUpdates(silent=false)
        useAppUpdater->>TauriAPI: check for update
        TauriAPI-->>useAppUpdater: update available
        useAppUpdater-->>User: show toast with Install action
    end

    alt User clicks Install
        User->>useAppUpdater: Install
        useAppUpdater->>TauriAPI: download & install
        TauriAPI-->>useAppUpdater: install complete
        useAppUpdater-->>User: toast with "Restart Now"
    end

    alt User clicks "Restart Now"
        User->>useAppUpdater: Restart Now
        useAppUpdater->>ProcessPlugin: relaunch()
        ProcessPlugin->>TauriAPI: restart app
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to:
    • correct plugin version and initialization in src-tauri/src/lib.rs and Cargo.toml
    • capability entries formatting in src-tauri/capabilities/default.json
    • new silent behavior in use-app-updater.ts and toast suppression across branches
    • relaunch error handling and user-facing messaging
    • prop changes to DatabaseManager and all usages to ensure no missing props or type mismatches

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: adding process plugin integration and updating the app updater logic with restart capabilities.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/automatic-updater

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 439a68f and 2813d1f.

📒 Files selected for processing (1)
  • src-tauri/Cargo.toml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Backend (Tests + Build)
🔇 Additional comments (1)
src-tauri/Cargo.toml (1)

50-50: Dependency addition looks good.

The tauri-plugin-process v2.3.1 is correctly added to the platform-specific dependencies section (non-Android/iOS targets), which is appropriate since process management may not be available or needed on mobile platforms. The version is consistent with other Tauri plugins in the manifest.

Please confirm that the plugin initialization in src-tauri/src/lib.rs and permission grants in src-tauri/capabilities/default.json are properly in place for the process plugin to function as intended.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/pages/main/MainPage.tsx (1)

17-23: Add updater.checkForUpdates to the dependency array.

The useEffect uses updater.checkForUpdates but doesn't include it in the dependency array. While the function is unlikely to change, React's exhaustive-deps rule expects all used values to be declared.

Apply this diff to fix the dependency:

   useEffect(() => {
     updater.checkForUpdates(true);
-  }, []);
+  }, [updater.checkForUpdates]);

Alternatively, if you want it to run only once on mount regardless of function identity changes, you can add an ESLint disable comment:

   useEffect(() => {
     updater.checkForUpdates(true);
+    // eslint-disable-next-line react-hooks/exhaustive-deps
   }, []);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7069d9 and 439a68f.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • src-tauri/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • package.json (1 hunks)
  • src-tauri/Cargo.toml (1 hunks)
  • src-tauri/capabilities/default.json (1 hunks)
  • src-tauri/src/lib.rs (1 hunks)
  • src/features/app/hooks/use-app-updater.ts (4 hunks)
  • src/pages/main/MainPage.tsx (3 hunks)
  • src/pages/main/components/DatabaseManager.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/pages/main/MainPage.tsx (1)
src/features/app/hooks/use-app-updater.ts (1)
  • useAppUpdater (9-134)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Backend (Tests + Build)
🔇 Additional comments (9)
src-tauri/Cargo.toml (1)

50-50: LGTM!

The process plugin is correctly added under the conditional target configuration, consistent with the updater plugin pattern. This ensures the plugin is only included for desktop platforms.

src-tauri/src/lib.rs (1)

12-12: LGTM!

The process plugin is correctly initialized in the Tauri builder chain, following the same pattern as other plugins. The placement after the updater plugin is appropriate given their related functionality.

src-tauri/capabilities/default.json (1)

35-36: LGTM!

The process permissions are correctly declared and follow the principle of least privilege by only allowing restart operations. This aligns with the relaunch functionality implemented in the updater hook.

src/pages/main/MainPage.tsx (1)

39-42: LGTM!

The updater state and handler are correctly passed to the DatabaseManager component, enabling update status visibility and user-initiated update checks in the UI.

src/features/app/hooks/use-app-updater.ts (3)

18-27: LGTM!

The relaunch error handling is well-implemented with appropriate user feedback. The try-catch ensures graceful degradation if the restart fails, prompting users to restart manually.


33-68: LGTM!

The silent parameter elegantly supports both auto-check-on-startup (silent) and user-initiated update checks (non-silent), providing appropriate feedback only when needed. The conditional toast logic is correct.


104-112: LGTM!

The post-install flow correctly defers the restart to user action rather than auto-restarting. Setting duration: 0 ensures the restart prompt persists until the user acts, which is the appropriate UX for this critical action.

src/pages/main/components/DatabaseManager.tsx (2)

34-37: LGTM!

The new props extend the component's interface cleanly to support external update state management. This follows good separation of concerns by keeping the update logic in the parent component.


149-174: LGTM!

The update button implementation provides excellent UX:

  • Clear visual feedback during checking/downloading states
  • Disabled state prevents multiple concurrent operations
  • The animated badge effectively draws attention when an update is available
  • The relative positioning container is necessary for the absolute-positioned badge

Comment thread package.json
@AbianS
AbianS merged commit cad7a75 into main Nov 5, 2025
3 checks passed
@AbianS
AbianS deleted the feat/automatic-updater branch November 5, 2025 09:55
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.

1 participant