Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
refactor(desktop): move update checking to Rust and run it on a schedule (#4494)
Elijah Potter8ae0f8714cf2
diff --git a/harper-desktop/package.json b/harper-desktop/package.jsonindex b8f7d74db..d7223ca54 100644--- a/harper-desktop/package.json+++ b/harper-desktop/package.json@@ -16,7 +16,6 @@"@tauri-apps/api": "^2","@tauri-apps/plugin-autostart": "^2.5.1","@tauri-apps/plugin-opener": "^2",- "@tauri-apps/plugin-updater": "^2.10.1","components": "workspace:*","harper-editor": "workspace:*","harper.js": "workspace:*"diff --git a/harper-desktop/src-tauri/Cargo.lock b/harper-desktop/src-tauri/Cargo.lockindex 7c0d7b07a..90cc1d866 100644--- a/harper-desktop/src-tauri/Cargo.lock+++ b/harper-desktop/src-tauri/Cargo.lock@@ -3829,6 +3829,7 @@ dependencies = ["objc2-app-kit 0.3.2","objc2-foundation 0.3.2","pollster",+ "reqwest 0.12.28","send_wrapper","serde","serde_json",diff --git a/harper-desktop/src-tauri/Cargo.toml b/harper-desktop/src-tauri/Cargo.tomlindex 7e35645f2..7b1fbcc78 100644--- a/harper-desktop/src-tauri/Cargo.toml+++ b/harper-desktop/src-tauri/Cargo.toml@@ -22,6 +22,7 @@ tauri = { version = "2.11.1", features = ["image-png", "tray-icon"] }tauri-plugin-opener = "2.5.4"serde = { version = "1", features = ["derive"] }serde_json = "1"+reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }base64 = "0.23.1"winit = "0.30.13"thiserror = "2.0.18"diff --git a/harper-desktop/src-tauri/capabilities/default.json b/harper-desktop/src-tauri/capabilities/default.jsonindex ea71ba1b7..ceeb17826 100644--- a/harper-desktop/src-tauri/capabilities/default.json+++ b/harper-desktop/src-tauri/capabilities/default.json@@ -6,7 +6,6 @@"permissions": ["core:default","opener:default",- "updater:default","autostart:allow-enable","autostart:allow-disable","autostart:allow-is-enabled"diff --git a/harper-desktop/src-tauri/src/commands.rs b/harper-desktop/src-tauri/src/commands.rsindex fe6dfcb38..54738c397 100644--- a/harper-desktop/src-tauri/src/commands.rs+++ b/harper-desktop/src-tauri/src/commands.rs@@ -2,6 +2,7 @@//! environment. Use [`application_message_handler`] to load them into the Tauri runtime.use crate::config::Config;+use crate::desktop_updater::{DesktopUpdater, UpdateResult};use crate::highlighter_service::HighlighterService;use crate::os_broker::{AccessibilityPermissionStatus, AppSearchResult, OsBroker};use crate::{IntegrationView, PlatformBroker};@@ -24,8 +25,9 @@ pub fn application_message_handler<R: Runtime>() -> impl Fn(Invoke<R>) -> bool {set_debounce_ms,get_auto_update,set_auto_update,- get_last_update_check,- set_last_update_check,+ get_current_version,+ get_latest_version,+ update_to_latest,get_onboarding_completed,set_onboarding_completed,set_dialect,@@ -104,25 +106,24 @@ async fn set_auto_update(}#[tauri::command]-async fn get_last_update_check(- config: State<'_, Arc<Mutex<Config>>>,-) -> Result<Option<u64>, String> {- Ok(config.lock().await.last_update_check)+fn get_current_version<R: Runtime>(app: tauri::AppHandle<R>) -> String {+ DesktopUpdater::current_version(&app)}#[tauri::command]-async fn set_last_update_check(- last_update_check: Option<u64>,- config: State<'_, Arc<Mutex<Config>>>,-) -> Result<(), String> {- let mut config = config.lock().await;- config.last_update_check = last_update_check;- config- .save_to_system()- .await- .map_err(|error| error.to_string())?;+async fn get_latest_version() -> Result<String, String> {+ DesktopUpdater::latest_version().await+}- Ok(())+#[tauri::command]+async fn update_to_latest<R: Runtime>(+ app: tauri::AppHandle<R>,+ updater: State<'_, DesktopUpdater>,+) -> Result<UpdateResult, String> {+ updater+ .update_to_latest(&app, false)+ .await+ .ok_or_else(|| "Manual update check was unexpectedly skipped.".into())}#[tauri::command]diff --git a/harper-desktop/src-tauri/src/config/mod.rs b/harper-desktop/src-tauri/src/config/mod.rsindex 37fbae32c..059f7c9de 100644--- a/harper-desktop/src-tauri/src/config/mod.rs+++ b/harper-desktop/src-tauri/src/config/mod.rs@@ -23,7 +23,10 @@ pub struct Config {pub auto_enable_new_apps: bool,pub onboarding_completed: bool,pub debounce_ms: u64,+ /// Whether the main process may check for and install updates automatically.pub auto_update: bool,+ /// Unix milliseconds at the start of the last manual or automatic update attempt.+ /// Failed attempts also count toward the automatic 24-hour interval.pub last_update_check: Option<u64>,pub highlighter_service_enabled: bool,}diff --git a/harper-desktop/src-tauri/src/desktop_updater.rs b/harper-desktop/src-tauri/src/desktop_updater.rsnew file mode 100644index 000000000..85df0a99e--- /dev/null+++ b/harper-desktop/src-tauri/src/desktop_updater.rs@@ -0,0 +1,415 @@+//! Desktop updates belong to the main process, not to any particular WebView.++use crate::config::Config;+use serde::Serialize;+use std::{+ future::Future,+ sync::Arc,+ time::{Duration, SystemTime, UNIX_EPOCH},+};+use tauri::{AppHandle, Manager, Runtime};+use tauri_plugin_updater::UpdaterExt;+use tokio::sync::Mutex;++const LATEST_VERSION_URL: &str = "https://writewithharper.com/latestversion";+const DAY_MS: u64 = 24 * 60 * 60 * 1000;+const POLL_INTERVAL: Duration = Duration::from_secs(60);+const REQUEST_TIMEOUT: Duration = Duration::from_secs(30);++/// Outcome of an attempted update, using the settings UI's existing status names.+#[derive(Clone, Debug, PartialEq, Serialize)]+#[serde(rename_all = "kebab-case")]+pub enum UpdateStatus {+ UpToDate,+ Updated,+ Error,+}++/// IPC-safe update outcome. An installed update may still require an app restart.+#[derive(Clone, Debug, PartialEq, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct UpdateResult {+ pub status: UpdateStatus,+ pub current_version: Option<String>,+ pub latest_version: Option<String>,+ pub message: String,+ pub error: Option<String>,+}++impl UpdateResult {+ /// Report a fresh check without forgetting the update already installed on disk.+ fn with_latest_version(mut self, latest_version: Option<String>) -> Self {+ if let Some(latest_version) = latest_version {+ if self.latest_version.as_ref() != Some(&latest_version) {+ self.message = format!(+ "Update installed. Restart Harper to finish before installing version {latest_version}."+ );+ }+ self.latest_version = Some(latest_version);+ }+ self+ }++ fn error(error: String) -> Self {+ Self {+ status: UpdateStatus::Error,+ current_version: None,+ latest_version: None,+ message: format!("Unable to check for updates: {error}"),+ error: Some(error),+ }+ }+}++/// Serializes manual and automatic updates and remembers an installation until restart.+/// The mutex covers the entire attempt, but the separate config lock never covers network I/O.+#[derive(Default)]+pub struct DesktopUpdater {+ installed_update: Mutex<Option<UpdateResult>>,+}++impl DesktopUpdater {+ /// Read the running version from packaged metadata, even after installing an update.+ pub fn current_version<R: Runtime>(app: &AppHandle<R>) -> String {+ normalize_version(&app.package_info().version.to_string())+ }++ /// Fetch display-only release information without invoking the signed updater flow.+ pub async fn latest_version() -> Result<String, String> {+ let response = reqwest::Client::builder()+ .timeout(REQUEST_TIMEOUT)+ .build()+ .map_err(|error| error.to_string())?+ .get(LATEST_VERSION_URL)+ .header(reqwest::header::ACCEPT, "text/plain")+ .send()+ .await+ .and_then(reqwest::Response::error_for_status)+ .map_err(|error| format!("Unable to get latest version: {error}"))?;+ let text = response+ .text()+ .await+ .map_err(|error| format!("Unable to get latest version: {error}"))?;+ Ok(normalize_version(&text))+ }++ /// Check and install an update. Only automatic requests can be skipped (returning `None`).+ /// Record attempts before network I/O so failed checks also respect the daily interval.+ /// Manual requests bypass both the preference and interval, but share installation state.+ /// Checks continue after an installation; further installations wait until restart.+ pub async fn update_to_latest<R: Runtime>(+ &self,+ app: &AppHandle<R>,+ automatic: bool,+ ) -> Option<UpdateResult> {+ self.run_update(|installed_update| async move {+ let now = SystemTime::now()+ .duration_since(UNIX_EPOCH)+ .map_err(|error| error.to_string())?+ .as_millis() as u64;++ {+ let config = app.state::<Arc<Mutex<Config>>>();+ let mut config = config.lock().await;+ if automatic+ && !should_check_for_update(config.auto_update, config.last_update_check, now)+ {+ return Ok(None);+ }++ let previous = config.last_update_check;+ config.last_update_check = Some(now);+ if let Err(error) = config.save_to_system().await {+ config.last_update_check = previous;+ return Err(format!("Unable to save update-check timestamp: {error}"));+ }+ }++ check_and_install(app, installed_update).await.map(Some)+ })+ .await+ }++ /// If an update is already prepared and downloaded, it will be provided to the operation.+ async fn run_update<F, Fut>(&self, operation: F) -> Option<UpdateResult>+ where+ F: FnOnce(Option<UpdateResult>) -> Fut,+ Fut: Future<Output = Result<Option<UpdateResult>, String>>,+ {+ let mut installed = self.installed_update.lock().await;+ let result = match operation(installed.clone()).await {+ Ok(result) => result?,+ Err(error) => UpdateResult::error(error),+ };+ if installed.is_none() && result.status == UpdateStatus::Updated {+ *installed = Some(result.clone());+ }+ Some(result)+ }+}++/// Start once after plugin initialization. The first tick is immediate; subsequent ticks only+/// check eligibility, not the network. Skip missed ticks after sleep rather than catching up.+/// This task lives with the main process, including when all windows are closed.+pub fn start_auto_updates(app: AppHandle) {+ tauri::async_runtime::spawn(async move {+ let mut interval = tokio::time::interval(POLL_INTERVAL);+ interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);+ loop {+ interval.tick().await;+ if let Some(result) = app+ .state::<DesktopUpdater>()+ .update_to_latest(&app, true)+ .await+ && let Some(error) = result.error+ {+ tracing::warn!("Unable to automatically update Harper Desktop: {error}");+ }+ }+ });+}++/// Perform the signed plugin workflow, without changing the plugin's platform restart behavior.+async fn check_and_install<R: Runtime>(+ app: &AppHandle<R>,+ installed_update: Option<UpdateResult>,+) -> Result<UpdateResult, String> {+ let current_version = DesktopUpdater::current_version(app);+ let update = app+ .updater_builder()+ .timeout(REQUEST_TIMEOUT)+ .build()+ .map_err(|error| error.to_string())?+ .check()+ .await+ .map_err(|error| error.to_string())?;++ // Still check the signed-release endpoint, but never replace a pending installation.+ if let Some(installed) = installed_update {+ return Ok(+ installed.with_latest_version(update.map(|update| normalize_version(&update.version)))+ );+ }++ let Some(mut update) = update else {+ return Ok(UpdateResult {+ status: UpdateStatus::UpToDate,+ current_version: Some(current_version),+ latest_version: None,+ message: "Harper is up to date.".into(),+ error: None,+ });+ };+ update.timeout = Some(Duration::from_secs(10 * 60));+ update+ .download_and_install(|_, _| {}, || {})+ .await+ .map_err(|error| error.to_string())?;++ Ok(UpdateResult {+ status: UpdateStatus::Updated,+ current_version: Some(current_version),+ latest_version: Some(normalize_version(&update.version)),+ message: "Update installed. Restart Harper to finish.".into(),+ error: None,+ })+}++fn normalize_version(version: &str) -> String {+ let version = version.trim();+ version+ .strip_prefix(['v', 'V'])+ .unwrap_or(version)+ .to_owned()+}++/// A future timestamp is treated as due so a backwards clock adjustment cannot stall updates.+fn should_check_for_update(auto_update: bool, last_check: Option<u64>, now: u64) -> bool {+ auto_update && last_check.is_none_or(|last| now < last || now.saturating_sub(last) >= DAY_MS)+}++#[cfg(test)]+mod tests {+ use super::*;++ fn installed_result() -> UpdateResult {+ UpdateResult {+ status: UpdateStatus::Updated,+ current_version: Some("2.11.0".into()),+ latest_version: Some("2.12.0".into()),+ message: "Update installed. Restart Harper to finish.".into(),+ error: None,+ }+ }++ async fn install(updater: &DesktopUpdater) {+ let result = updater+ .run_update(|installed| async move {+ assert!(installed.is_none());+ Ok(Some(installed_result()))+ })+ .await;+ assert_eq!(result, Some(installed_result()));+ }++ #[test]+ fn automatic_checks_respect_preference_and_daily_interval() {+ let now = DAY_MS * 2;+ for (enabled, last_check, expected) in [+ (false, None, false),+ (false, Some(0), false),+ (false, Some(now + 1), false),+ (true, None, true),+ (true, Some(now), false),+ (true, Some(now - DAY_MS + 1), false),+ (true, Some(now - DAY_MS), true),+ (true, Some(0), true),+ (true, Some(now + 1), true),+ ] {+ assert_eq!(should_check_for_update(enabled, last_check, now), expected);+ }+ }++ #[test]+ fn versions_are_normalized() {+ for version in ["2.12.0", "v2.12.0", " V2.12.0\n"] {+ assert_eq!(normalize_version(version), "2.12.0");+ }+ }++ #[test]+ fn same_release_keeps_restart_reminder() {+ assert_eq!(+ installed_result().with_latest_version(Some("2.12.0".into())),+ installed_result()+ );+ }++ #[test]+ fn no_release_keeps_restart_reminder() {+ assert_eq!(+ installed_result().with_latest_version(None),+ installed_result()+ );+ }++ #[test]+ fn newer_release_is_reported_without_claiming_it_was_installed() {+ let result = installed_result().with_latest_version(Some("2.13.0".into()));+ assert_eq!(result.status, UpdateStatus::Updated);+ assert_eq!(result.current_version.as_deref(), Some("2.11.0"));+ assert_eq!(result.latest_version.as_deref(), Some("2.13.0"));+ assert!(result.message.contains("before installing version 2.13.0"));+ }++ #[tokio::test]+ async fn checks_continue_after_installation_and_keep_original_installation() {+ let updater = DesktopUpdater::default();+ install(&updater).await;++ let result = updater+ .run_update(|installed| async move {+ assert_eq!(installed, Some(installed_result()));+ Ok(Some(+ installed+ .unwrap()+ .with_latest_version(Some("2.13.0".into())),+ ))+ })+ .await;+ assert_eq!(result.unwrap().latest_version.as_deref(), Some("2.13.0"));++ // The latest check's version must not become the remembered installed version.+ let result = updater+ .run_update(|installed| async move {+ assert_eq!(installed, Some(installed_result()));+ Ok(installed)+ })+ .await;+ assert_eq!(result, Some(installed_result()));+ }++ #[tokio::test]+ async fn ineligible_checks_are_still_skipped_after_installation() {+ let updater = DesktopUpdater::default();+ install(&updater).await;++ let result = updater+ .run_update(|installed| async move {+ assert_eq!(installed, Some(installed_result()));+ Ok(None)+ })+ .await;+ assert_eq!(result, None);+ assert_eq!(+ *updater.installed_update.lock().await,+ Some(installed_result())+ );+ }++ #[tokio::test]+ async fn failed_checks_do_not_prevent_installation() {+ let updater = DesktopUpdater::default();+ let result = updater+ .run_update(|installed| async move {+ assert!(installed.is_none());+ Err("Network unavailable".into())+ })+ .await;+ assert_eq!(result.unwrap().status, UpdateStatus::Error);+ install(&updater).await;+ }++ #[tokio::test]+ async fn failed_checks_preserve_pending_installation() {+ let updater = DesktopUpdater::default();+ install(&updater).await;+ let result = updater+ .run_update(|installed| async move {+ assert_eq!(installed, Some(installed_result()));+ Err("Network unavailable".into())+ })+ .await;+ assert_eq!(result.unwrap().status, UpdateStatus::Error);+ assert_eq!(+ *updater.installed_update.lock().await,+ Some(installed_result())+ );+ }++ #[tokio::test]+ async fn up_to_date_checks_do_not_prevent_later_installation() {+ let updater = DesktopUpdater::default();+ let result = updater+ .run_update(|installed| async move {+ assert!(installed.is_none());+ Ok(Some(UpdateResult {+ status: UpdateStatus::UpToDate,+ current_version: Some("2.11.0".into()),+ latest_version: None,+ message: "Harper is up to date.".into(),+ error: None,+ }))+ })+ .await;+ assert_eq!(result.unwrap().status, UpdateStatus::UpToDate);+ install(&updater).await;+ }++ #[tokio::test]+ async fn concurrent_checks_observe_the_first_installation() {+ let updater = DesktopUpdater::default();+ let first = updater.run_update(|installed| async move {+ assert!(installed.is_none());+ tokio::task::yield_now().await;+ Ok(Some(installed_result()))+ });+ let second = updater.run_update(|installed| async move {+ assert_eq!(installed, Some(installed_result()));+ Ok(installed)+ });+ let (first, second) = tokio::join!(first, second);+ assert_eq!(first, Some(installed_result()));+ assert_eq!(second, Some(installed_result()));+ }+}diff --git a/harper-desktop/src-tauri/src/lib.rs b/harper-desktop/src-tauri/src/lib.rsindex d7371e4d6..60b6a0ee5 100644--- a/harper-desktop/src-tauri/src/lib.rs+++ b/harper-desktop/src-tauri/src/lib.rs@@ -36,6 +36,7 @@ mod commands;pub mod communication;pub mod config;mod debounce;+mod desktop_updater;pub mod highlighter;pub mod highlighter_service;pub mod lint_kind_color;@@ -179,6 +180,7 @@ pub fn run_tauri() {tauri::Builder::default().manage(config)+ .manage(desktop_updater::DesktopUpdater::default()).manage(highlighter_service).manage(StdMutex::new(broker)).manage(async_runtime)@@ -195,6 +197,7 @@ pub fn run_tauri() {set_up_tray_menu(app.handle())?;warm_app_search_cache(app.handle().clone());+ desktop_updater::start_auto_updates(app.handle().clone());if is_first_launch {windows::show_settings_window(app.handle())?;diff --git a/harper-desktop/src/lib/DesktopUpdater.ts b/harper-desktop/src/lib/DesktopUpdater.tsdeleted file mode 100644index 324c9afaa..000000000--- a/harper-desktop/src/lib/DesktopUpdater.ts+++ /dev/null@@ -1,122 +0,0 @@-import { getVersion } from '@tauri-apps/api/app';-import { check, type DownloadEvent } from '@tauri-apps/plugin-updater';-import { Client } from '$lib/client';--const LATEST_VERSION_URL = 'https://writewithharper.com/latestversion';-const DAY_MS = 24 * 60 * 60 * 1000;--export type UpdateStatus = 'up-to-date' | 'updated' | 'error';--export interface UpdateResult {- status: UpdateStatus;- currentVersion?: string;- latestVersion?: string;- message: string;- error?: unknown;-}--export interface UpdateOptions {- silent?: boolean;- onDownloadEvent?: (event: DownloadEvent) => void;-}--const normalizeVersion = (version: string) => version.trim().replace(/^v/i, '');--const shouldCheckForUpdate = (lastUpdateCheck: number | null, now = Date.now()) =>- lastUpdateCheck == null || now - lastUpdateCheck >= DAY_MS;--export class DesktopUpdater {- /**- * Fetch the latest published Harper Desktop version from the public web endpoint.- *- * This exists so settings UI can show the newest available version without invoking- * the full Tauri updater check/download flow.- */- static async getLatestVersion(): Promise<string> {- const resp = await fetch(LATEST_VERSION_URL, {- headers: {- Accept: 'text/plain',- },- });-- if (!resp.ok) {- throw new Error(`Unable to get latest version: ${resp.status} ${resp.statusText}`);- }-- return normalizeVersion(await resp.text());- }-- /**- * Read the current Harper Desktop version from Tauri's bundled app metadata.- *- * This exists to keep displayed version numbers tied to the packaged app instead- * of hardcoded settings-page text.- */- static async getCurrentVersion(): Promise<string> {- return normalizeVersion(await getVersion());- }-- /**- * Check for an available Tauri update and install it when one exists.- *- * This centralizes the updater plugin workflow so manual checks and automatic- * daily checks use the same behavior and return shape.- */- static async updateToLatest(options: UpdateOptions = {}): Promise<UpdateResult> {- try {- const currentVersion = await DesktopUpdater.getCurrentVersion();- const update = await check();-- if (update == null) {- return {- status: 'up-to-date',- currentVersion,- message: 'Harper is up to date.',- };- }-- await update.downloadAndInstall(options.onDownloadEvent);-- return {- status: 'updated',- currentVersion,- latestVersion: normalizeVersion(update.version),- message: 'Update installed. Restart Harper to finish.',- };- } catch (error) {- if (!options.silent) {- console.error('Unable to update Harper Desktop.', error);- }-- return {- status: 'error',- message: `Unable to check for updates: ${error}`,- error,- };- }- }-- /**- * Run the silent daily auto-update check when the user has enabled it.- *- * This exists to keep scheduling and persisted update-check timestamps out of- * Svelte components while avoiding network/update checks on every app launch.- */- static async maybeAutoUpdate(): Promise<UpdateResult | null> {- const autoUpdate = await Client.getAutoUpdate();-- if (!autoUpdate) {- return null;- }-- const lastUpdateCheck = await Client.getLastUpdateCheck();-- if (!shouldCheckForUpdate(lastUpdateCheck)) {- return null;- }-- await Client.setLastUpdateCheck(Date.now());-- return await DesktopUpdater.updateToLatest({ silent: true });- }-}diff --git a/harper-desktop/src/lib/client.ts b/harper-desktop/src/lib/client.tsindex 1613a6ad5..cb7c430d9 100644--- a/harper-desktop/src/lib/client.ts+++ b/harper-desktop/src/lib/client.ts@@ -47,6 +47,15 @@ export interface AppSearchResult {export type AccessibilityPermissionStatus = 'Granted' | 'NotGranted' | 'Unsupported';+/** Serializable Rust updater outcome; an installed update may still require a restart. */+export interface UpdateResult {+ status: 'up-to-date' | 'updated' | 'error';+ currentVersion: string | null;+ latestVersion: string | null;+ message: string;+ error: string | null;+}+/** Provides an easy-to-use interface for interacting with the main Rust Tauri process.* Relevant because that is where the canonical state is stored. */export class Client {@@ -84,20 +93,26 @@ export class Client {await invoke('set_debounce_ms', { debounceMs });}+ /** Check if the app is configured to auto update. */static async getAutoUpdate(): Promise<boolean> {return await invoke<boolean>('get_auto_update');}+ /** Configure the app to auto update. */static async setAutoUpdate(autoUpdate: boolean): Promise<void> {await invoke('set_auto_update', { autoUpdate });}- static async getLastUpdateCheck(): Promise<number | null> {- return await invoke<number | null>('get_last_update_check');+ static async getCurrentVersion(): Promise<string> {+ return await invoke<string>('get_current_version');+ }++ static async getLatestVersion(): Promise<string> {+ return await invoke<string>('get_latest_version');}- static async setLastUpdateCheck(lastUpdateCheck: number | null): Promise<void> {- await invoke('set_last_update_check', { lastUpdateCheck });+ static async updateToLatest(): Promise<UpdateResult> {+ return await invoke<UpdateResult>('update_to_latest');}static async getOnboardingCompleted(): Promise<boolean> {diff --git a/harper-desktop/src/lib/settings/pages/AboutPage.svelte b/harper-desktop/src/lib/settings/pages/AboutPage.svelteindex 6b2a70774..a00b5a367 100644--- a/harper-desktop/src/lib/settings/pages/AboutPage.svelte+++ b/harper-desktop/src/lib/settings/pages/AboutPage.svelte@@ -2,7 +2,7 @@import { openUrl } from '@tauri-apps/plugin-opener';import { Button } from 'components';import { onMount } from 'svelte';-import { DesktopUpdater } from '$lib/DesktopUpdater';+import { Client } from '$lib/client';const SOURCE_URL = 'https://github.com/Automattic/harper';const ISSUE_URL = 'https://github.com/Automattic/harper/issues/new/choose';@@ -15,7 +15,7 @@ onMount(() => {async function loadCurrentVersion() {try {- currentVersion = await DesktopUpdater.getCurrentVersion();+ currentVersion = await Client.getCurrentVersion();} catch (error) {console.error('Unable to load Harper Desktop version.', error);}diff --git a/harper-desktop/src/lib/settings/pages/GeneralPage.svelte b/harper-desktop/src/lib/settings/pages/GeneralPage.svelteindex 9ec46e00c..9d00941ca 100644--- a/harper-desktop/src/lib/settings/pages/GeneralPage.svelte+++ b/harper-desktop/src/lib/settings/pages/GeneralPage.svelte@@ -3,7 +3,6 @@ import { Button, Checkbox, CheckIcon, Input, Select, SettingRow } from 'componenimport type { Dialect } from 'harper.js';import { onMount } from 'svelte';import { Client } from '$lib/client';-import { DesktopUpdater } from '$lib/DesktopUpdater';import { DIALECT_OPTIONS } from '../settings-data';const DialectValue = {@@ -167,8 +166,8 @@ async function setAutoUpdate(enabled: boolean) {async function loadUpdateVersions() {try {const [current, latest] = await Promise.all([- DesktopUpdater.getCurrentVersion(),- DesktopUpdater.getLatestVersion(),+ Client.getCurrentVersion(),+ Client.getLatestVersion(),]);currentVersion = current;latestVersion = latest;@@ -183,15 +182,14 @@ async function checkForUpdates() {updateStatus = 'Checking for updates...';try {- await Client.setLastUpdateCheck(Date.now());- const result = await DesktopUpdater.updateToLatest();+ const result = await Client.updateToLatest();updateStatus = result.message;if (result.latestVersion != null) {latestVersion = result.latestVersion;}- currentVersion = result.currentVersion ?? (await DesktopUpdater.getCurrentVersion());+ currentVersion = result.currentVersion ?? (await Client.getCurrentVersion());} catch (error) {autoUpdateError = `Unable to check for updates: ${error}`;updateStatus = '';diff --git a/harper-desktop/src/routes/+page.svelte b/harper-desktop/src/routes/+page.svelteindex e6eb1b786..86d979421 100644--- a/harper-desktop/src/routes/+page.svelte+++ b/harper-desktop/src/routes/+page.svelte@@ -2,7 +2,6 @@import '../app.css';import { getCurrentWindow } from '@tauri-apps/api/window';import { onMount } from 'svelte';-import { DesktopUpdater } from '$lib/DesktopUpdater';let isSettings = false;let isViewResolved = false;@@ -15,8 +14,6 @@ function hasSettingsRoute() {}onMount(() => {- void DesktopUpdater.maybeAutoUpdate();-let currentWindowLabel = '';try {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 91b23cbb0..71e7073b0 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -47,9 +47,6 @@ importers:'@tauri-apps/plugin-opener':specifier: ^2version: 2.5.4- '@tauri-apps/plugin-updater':- specifier: ^2.10.1- version: 2.10.1components:specifier: workspace:*version: link:../packages/components@@ -4112,9 +4109,6 @@ packages:'@tauri-apps/[email protected]':resolution: {integrity: sha512-1HnPkb+AmgO29HBazm4uPLKB+r7zzcTBW1d0fyYp1uP+jwtpoiNDGKMMzz58SFp49nOIrxdE3aUJtT57lfO9CQ==}- '@tauri-apps/[email protected]':- resolution: {integrity: sha512-NFYMg+tWOZPJdzE/PpFj2qfqwAWwNS3kXrb1tm1gnBJ9mYzZ4WDRrwy8udzWoAnfGCHLuePNLY1WVCNHnh3eRA==}-'@tootallnate/[email protected]':resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==}engines: {node: '>= 10'}@@ -16916,10 +16910,6 @@ snapshots:dependencies:'@tauri-apps/api': 2.11.0- '@tauri-apps/[email protected]':- dependencies:- '@tauri-apps/api': 2.11.0-'@tootallnate/[email protected]': {}'@tootallnate/[email protected]': {}