From 74aaa6ef14b59e36770806d5989c387aafda43a0 Mon Sep 17 00:00:00 2001 From: hlatimer266 Date: Tue, 21 Jul 2026 13:13:09 +0200 Subject: [PATCH] Use configured explorer and seed for links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit explorerUrl() hardcoded both the seed ("iris.radicle.network") and the explorer base ("https://radicle.network"), so every "Copy Link" and "Open in …" action ignored the user's config and could point at a host that does not replicate the repo. Expose publicExplorer and preferredSeeds on the Config type (both already carried by radicle::profile::Config) and thread config through to every explorerUrl() call site. URLs are now built from the publicExplorer template, filling $host from the first preferred seed (falling back to rosa only when none are configured), and link labels show the configured explorer's host. Co-authored-by: Rūdolfs Ošiņš --- .../radicle-types/bindings/config/Config.ts | 9 +++++ crates/radicle-types/src/config.rs | 10 ++++- crates/radicle-types/src/traits.rs | 4 ++ src/components/AppSidebar.svelte | 1 + src/components/IdentityButton.svelte | 14 +++++-- src/components/RepoHeader.svelte | 8 ++-- src/components/SidebarRepoList.svelte | 15 +++++-- src/lib/utils.ts | 40 ++++++++++++++++--- src/views/repo/Issue.svelte | 5 ++- src/views/repo/Patch.svelte | 5 ++- src/views/repo/RepoCommit.svelte | 12 ++++-- src/views/repo/RepoCommits.svelte | 7 +++- src/views/repo/RepoHome.svelte | 7 +++- 13 files changed, 109 insertions(+), 28 deletions(-) diff --git a/crates/radicle-types/bindings/config/Config.ts b/crates/radicle-types/bindings/config/Config.ts index 729ed1107..2312e350a 100644 --- a/crates/radicle-types/bindings/config/Config.ts +++ b/crates/radicle-types/bindings/config/Config.ts @@ -18,4 +18,13 @@ export type Config = { seedingPolicy: { default: "allow"; scope: "followed" | "all" } | { default: "block"; }; + /** + * Public explorer URL template, e.g. `https://radicle.network/nodes/$host/$rid$path`. + */ + publicExplorer: string; + /** + * Preferred seed addresses, in priority order. Used to pick a host for + * explorer links. + */ + preferredSeeds: Array; }; diff --git a/crates/radicle-types/src/config.rs b/crates/radicle-types/src/config.rs index a0376e659..0acb7c9c5 100644 --- a/crates/radicle-types/src/config.rs +++ b/crates/radicle-types/src/config.rs @@ -1,9 +1,10 @@ use radicle::crypto::PublicKey; +use radicle::explorer::Explorer; use serde::Serialize; use ts_rs::TS; use radicle::node::Alias; -use radicle::node::config::DefaultSeedingPolicy; +use radicle::node::config::{ConnectAddress, DefaultSeedingPolicy}; /// Service configuration. #[derive(Debug, TS, Serialize, PartialEq)] @@ -21,6 +22,13 @@ pub struct Config { #[serde(default)] #[ts(type = "{ default: 'allow', scope: 'followed' | 'all' } | { default: 'block' }")] pub seeding_policy: DefaultSeedingPolicy, + /// Public explorer URL template, e.g. `https://radicle.network/nodes/$host/$rid$path`. + #[ts(as = "String")] + pub public_explorer: Explorer, + /// Preferred seed addresses, in priority order. Used to pick a host for + /// explorer links. + #[ts(as = "Vec")] + pub preferred_seeds: Vec, } pub struct Version { diff --git a/crates/radicle-types/src/traits.rs b/crates/radicle-types/src/traits.rs index fb0dd0958..bd614f834 100644 --- a/crates/radicle-types/src/traits.rs +++ b/crates/radicle-types/src/traits.rs @@ -19,6 +19,8 @@ pub trait Profile { public_key: p.public_key, alias: p.config.node.alias.clone(), seeding_policy: p.config.node.seeding_policy, + public_explorer: p.config.public_explorer.clone(), + preferred_seeds: p.config.preferred_seeds.clone(), } } @@ -55,6 +57,8 @@ mod test { public_key: *signer.public_key(), alias: Alias::from_str("seed").unwrap(), seeding_policy: config::DefaultSeedingPolicy::Block, + public_explorer: state.profile.config.public_explorer.clone(), + preferred_seeds: state.profile.config.preferred_seeds.clone(), } ) } diff --git a/src/components/AppSidebar.svelte b/src/components/AppSidebar.svelte index dcbb84248..d20db9526 100644 --- a/src/components/AppSidebar.svelte +++ b/src/components/AppSidebar.svelte @@ -199,6 +199,7 @@ diff --git a/src/components/IdentityButton.svelte b/src/components/IdentityButton.svelte index a7bd0d37f..7746aa283 100644 --- a/src/components/IdentityButton.svelte +++ b/src/components/IdentityButton.svelte @@ -4,7 +4,12 @@ import debounce from "lodash/debounce"; import { writeToClipboard } from "@app/lib/invoke"; - import { didFromPublicKey, explorerUrl, truncateDid } from "@app/lib/utils"; + import { + didFromPublicKey, + explorerHost, + explorerUrl, + truncateDid, + } from "@app/lib/utils"; import Button from "@app/components/Button.svelte"; import DropdownListItem from "@app/components/DropdownListItem.svelte"; @@ -60,11 +65,14 @@ style:text-decoration="none" style:width="100%" onclick={closeFocused} - href={explorerUrl(`users/${didFromPublicKey(config.publicKey)}`)} + href={explorerUrl( + `users/${didFromPublicKey(config.publicKey)}`, + config, + )} target="_blank"> - view on iris.radicle.network + Open in {explorerHost(config)} diff --git a/src/components/RepoHeader.svelte b/src/components/RepoHeader.svelte index de60ad27b..f8b8f0300 100644 --- a/src/components/RepoHeader.svelte +++ b/src/components/RepoHeader.svelte @@ -1,4 +1,5 @@