feat: add process plugin integration and update app updater logic#27
Conversation
WalkthroughAdds 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ 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)
🔇 Additional comments (1)
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)
src/pages/main/MainPage.tsx (1)
17-23: Addupdater.checkForUpdatesto the dependency array.The
useEffectusesupdater.checkForUpdatesbut 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
⛔ Files ignored due to path filters (2)
package-lock.jsonis excluded by!**/package-lock.jsonsrc-tauri/Cargo.lockis 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
silentparameter 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: 0ensures 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
Summary by CodeRabbit