From 8e683cf7ce35869f6fc556bf8feebbbb5ba7a5ee Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Thu, 5 Jun 2025 13:42:51 +0200 Subject: [PATCH] Provide a full window error if something goes wrong --- crates/radicle-tauri/src/commands/startup.rs | 4 ++ crates/radicle-types/src/error.rs | 4 ++ src/App.svelte | 22 ++++++ src/components/Border.svelte | 3 + src/components/Command.svelte | 5 +- src/components/ExternalLink.svelte | 42 +++++++++++ src/components/FullWindowError.svelte | 76 ++++++++++++++++++++ 7 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 src/components/ExternalLink.svelte create mode 100644 src/components/FullWindowError.svelte diff --git a/crates/radicle-tauri/src/commands/startup.rs b/crates/radicle-tauri/src/commands/startup.rs index 79de2f4ce..4ba895830 100644 --- a/crates/radicle-tauri/src/commands/startup.rs +++ b/crates/radicle-tauri/src/commands/startup.rs @@ -48,9 +48,13 @@ pub(crate) fn check_radicle_cli(ctx: tauri::State) -> Result<(), Error #[tauri::command] pub(crate) fn startup(app: AppHandle) -> Result { let profile = radicle::Profile::load()?; + let home = profile.home(); let repositories = profile.storage.repositories()?; let public_key = profile.public_key; + let cobs_cache = radicle::cob::cache::Store::open(home.cobs().join(COBS_DB_FILE))?; + cobs_cache.check_version()?; + let inbox_db = radicle_types::outbound::sqlite::Sqlite::reader( profile.node().join(NOTIFICATIONS_DB_FILE), )?; diff --git a/crates/radicle-types/src/error.rs b/crates/radicle-types/src/error.rs index df646c88e..7128b8c14 100644 --- a/crates/radicle-types/src/error.rs +++ b/crates/radicle-types/src/error.rs @@ -19,6 +19,10 @@ pub enum Error { #[error("ssh agent not running")] AgentNotRunning, + /// Generic Cob cache error. + #[error(transparent)] + Cache(#[from] radicle::cob::cache::Error), + /// Embeds error. #[error("not able to save embed")] SaveEmbedError, diff --git a/src/App.svelte b/src/App.svelte index 9e7175bab..ca506654b 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -30,6 +30,9 @@ import RepoHome from "@app/views/repo/RepoHome.svelte"; import Repos from "@app/views/home/Repos.svelte"; import Spinner from "./components/Spinner.svelte"; + import FullWindowError from "./components/FullWindowError.svelte"; + import ExternalLink from "./components/ExternalLink.svelte"; + import Command from "./components/Command.svelte"; const activeRouteStore = router.activeRouteStore; @@ -40,6 +43,7 @@ let showSpinner = $state(false); delay(() => (showSpinner = true), 1000); + onMount(async () => { try { profile = await invoke("startup"); @@ -117,6 +121,24 @@ {:else if startup.error?.code === "PassphraseError.InvalidPassphrase" && profile} + {:else if startup.error} + + We were unable to load your Radicle identity, or your Radicle installation + is outdated. +
+ If you have an existing Radicle installation, make sure you have + + the latest version. + +
+
+
+ To migrate your Radicle storage, make sure to restart your radicle-node + or run: + +
+
{:else if showSpinner}
{/if} diff --git a/src/components/Border.svelte b/src/components/Border.svelte index 6966d6b96..62d501db9 100644 --- a/src/components/Border.svelte +++ b/src/components/Border.svelte @@ -10,6 +10,7 @@ stylePadding?: string; styleHeight?: string; styleMaxHeight?: string; + styleMaxWidth?: string; styleMinHeight?: string; styleMinWidth?: string; styleWidth?: string; @@ -33,6 +34,7 @@ stylePadding, styleHeight, styleMaxHeight, + styleMaxWidth, styleMinHeight, stylePosition, styleWidth, @@ -221,6 +223,7 @@
@@ -33,7 +34,7 @@ {styleWidth} variant="ghost"> - $ {command} + {showPrompt ? "$ " : ""}{command} diff --git a/src/components/ExternalLink.svelte b/src/components/ExternalLink.svelte new file mode 100644 index 000000000..e567ca79e --- /dev/null +++ b/src/components/ExternalLink.svelte @@ -0,0 +1,42 @@ + + + + + + {#if children} + {@render children()} + {:else} + {href} + {/if} + + diff --git a/src/components/FullWindowError.svelte b/src/components/FullWindowError.svelte new file mode 100644 index 000000000..a50544ff1 --- /dev/null +++ b/src/components/FullWindowError.svelte @@ -0,0 +1,76 @@ + + + + +
+ +
+ +
+ +

{title}

+ + {#if children} +

+ {@render children()} +

+ {/if} + +

+ If this problem persists, please contact + + support{error ? " with the error details below." : "."} + +

+ + {#if error?.message} + + {/if} +
+