Skip to content

Commit e7fbd0c

Browse files
authored
Automatically add unknown catalog servers (#9482)
previously, when clicking a rerun dataplatform url to a catalog you're not connected with, the recording would load fine but not show up on the left hand panel since that depended on the catalog being known. Alternatives considered: Show the recording under "disconnected". In some ways this is nicer since nobody asked to connect to the catalog as a whole. But as long as this is light weight in both perf and ux this is probably fine 🤷
1 parent bc9281d commit e7fbd0c

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

crates/viewer/re_redap_browser/src/servers.rs

+5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ impl RedapServers {
144144
self.servers.is_empty() && self.pending_servers.is_empty()
145145
}
146146

147+
/// Whether we already know about a given server (or have it queued to be added).
148+
pub fn has_server(&self, origin: &re_uri::Origin) -> bool {
149+
self.servers.contains_key(origin) || self.pending_servers.contains(origin)
150+
}
151+
147152
/// Add a server to the hub.
148153
pub fn add_server(&self, origin: re_uri::Origin) {
149154
let _ = self.command_sender.send(Command::AddServer(origin));

crates/viewer/re_viewer/src/app_state.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ impl AppState {
688688
}
689689

690690
// This must run after any ui code, or other code that tells egui to open an url:
691-
check_for_clicked_hyperlinks(&ctx);
691+
check_for_clicked_hyperlinks(&ctx, redap_servers);
692692

693693
// Deselect on ESC. Must happen after all other UI code to let them capture ESC if needed.
694694
if ui.input(|i| i.key_pressed(egui::Key::Escape)) && !is_any_popup_open {
@@ -875,7 +875,7 @@ pub(crate) fn recording_config_entry<'cfgs>(
875875
/// Must run after any ui code, or other code that tells egui to open an url.
876876
///
877877
/// See [`re_ui::UiExt::re_hyperlink`] for displaying hyperlinks in the UI.
878-
fn check_for_clicked_hyperlinks(ctx: &ViewerContext<'_>) {
878+
fn check_for_clicked_hyperlinks(ctx: &ViewerContext<'_>, redap_servers: &RedapServers) {
879879
let recording_scheme = "recording://";
880880

881881
let mut recording_path = None;
@@ -884,9 +884,9 @@ fn check_for_clicked_hyperlinks(ctx: &ViewerContext<'_>) {
884884
ctx.egui_ctx().output_mut(|o| {
885885
o.commands.retain_mut(|command| {
886886
if let egui::OutputCommand::OpenUrl(open_url) = command {
887-
let is_rerun_url = open_url.url.parse::<re_uri::RedapUri>().is_ok();
887+
let redap_uri = open_url.url.parse::<re_uri::RedapUri>();
888888

889-
if is_rerun_url {
889+
if let Ok(redap_uri) = redap_uri {
890890
let data_source = re_data_source::DataSource::from_uri(
891891
re_log_types::FileSource::Uri,
892892
open_url.url.clone(),
@@ -909,6 +909,18 @@ fn check_for_clicked_hyperlinks(ctx: &ViewerContext<'_>) {
909909
}),
910910
});
911911

912+
// If this is a dataset url, we add the server if we don't know about it already.
913+
// Otherwise we end up in a situation where we have a data from an unknown server,
914+
// which is unnecessary and can get us into a strange ui state.
915+
if let re_uri::RedapUri::DatasetData(dataset_endpoint) = redap_uri {
916+
if !redap_servers.has_server(&dataset_endpoint.origin) {
917+
ctx.command_sender()
918+
.send_system(SystemCommand::AddRedapServer {
919+
endpoint: re_uri::CatalogEndpoint::new(dataset_endpoint.origin),
920+
});
921+
}
922+
}
923+
912924
match data_source.stream(on_cmd, None) {
913925
Ok(re_data_source::StreamSource::LogMessages(rx)) => {
914926
ctx.command_sender()

0 commit comments

Comments
 (0)