Skip to content

Commit

Permalink
Introduce RecordingUri component (rerun-io#8210)
Browse files Browse the repository at this point in the history
### What

This PR introduces a new `RecordingUri` component (which contains just a
string) and assorted UI, which present the URI as a link that opens said
component. Also introduce a new `FileSource::Uri` to account for this
new way of opening recordings.

Note: displaying links is disabled in wasm build, because
`DataSource::from_uri()` is not available there. I'm actually not quite
sure what the story is to load remote recordings from the web viewer 🤷🏻

<img width="1783" alt="image"
src="https://github.com/user-attachments/assets/c5816ad2-36f6-41f5-87a5-38d13a2d5328">
  • Loading branch information
abey79 authored Nov 26, 2024
1 parent fb034b0 commit 10c1f5c
Show file tree
Hide file tree
Showing 25 changed files with 349 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5390,8 +5390,11 @@ dependencies = [
"egui",
"egui_extras",
"egui_plot",
"re_data_source",
"re_data_ui",
"re_format",
"re_log",
"re_log_types",
"re_tracing",
"re_types",
"re_types_blueprint",
Expand Down
10 changes: 7 additions & 3 deletions crates/store/re_log_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ impl std::fmt::Display for PythonVersion {
pub enum FileSource {
Cli,

/// The user clicked on a recording URI in the viewer.
Uri,

DragAndDrop {
/// The [`ApplicationId`] that the viewer heuristically recommends should be used when loading
/// this data source, based on the surrounding context.
Expand Down Expand Up @@ -463,7 +466,7 @@ impl FileSource {
recommended_application_id,
..
} => recommended_application_id.as_ref(),
Self::Cli | Self::Sdk => None,
Self::Cli | Self::Uri | Self::Sdk => None,
}
}

Expand All @@ -478,7 +481,7 @@ impl FileSource {
recommended_recording_id,
..
} => recommended_recording_id.as_ref(),
Self::Cli | Self::Sdk => None,
Self::Cli | Self::Uri | Self::Sdk => None,
}
}

Expand All @@ -491,7 +494,7 @@ impl FileSource {
| Self::DragAndDrop {
force_store_info, ..
} => *force_store_info,
Self::Cli | Self::Sdk => false,
Self::Cli | Self::Uri | Self::Sdk => false,
}
}
}
Expand Down Expand Up @@ -538,6 +541,7 @@ impl std::fmt::Display for StoreSource {
Self::RustSdk { rustc_version, .. } => write!(f, "Rust SDK (rustc {rustc_version})"),
Self::File { file_source, .. } => match file_source {
FileSource::Cli => write!(f, "File via CLI"),
FileSource::Uri => write!(f, "File via URI"),
FileSource::DragAndDrop { .. } => write!(f, "File via drag-and-drop"),
FileSource::FileDialog { .. } => write!(f, "File via file dialog"),
FileSource::Sdk => write!(f, "File via SDK"),
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/components.fbs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace rerun.components;

// ---

/// A recording URI (Uniform Resource Identifier).
table RecordingUri (
"attr.rust.derive": "PartialEq, Eq, PartialOrd, Ord, Hash",
"attr.docs.unreleased"
) {
recording_uri: rerun.datatypes.Utf8 (order: 100);
}
1 change: 1 addition & 0 deletions crates/store/re_types/src/components/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/store/re_types/src/components/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 104 additions & 0 deletions crates/store/re_types/src/components/recording_uri.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions crates/store/re_types/src/components/recording_uri_ext.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use super::RecordingUri;

impl RecordingUri {
/// Return the Recording URI contained in this component.
pub fn uri(&self) -> &str {
self.0.as_str()
}
}
3 changes: 3 additions & 0 deletions crates/viewer/re_component_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ all-features = true

[dependencies]
re_data_ui.workspace = true # Needed for `item_ui`.
re_data_source.workspace = true
re_format.workspace = true
re_log.workspace = true
re_log_types.workspace = true
re_tracing.workspace = true
re_types = { workspace = true, features = [
"egui_plot", # Needed to draw marker shapes.
Expand Down
3 changes: 3 additions & 0 deletions crates/viewer/re_component_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod map_provider;
mod marker_shape;
mod pinhole;
mod radius;
mod recording_uri;
mod resolution;
mod response_utils;
mod timeline;
Expand Down Expand Up @@ -158,6 +159,8 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry
registry.add_singleline_edit_or_view(pinhole::singleline_view_pinhole);
registry.add_multiline_edit_or_view(pinhole::multiline_view_pinhole);

registry.add_singleline_edit_or_view(recording_uri::singleline_view_recording_uri);

line_strip::register_linestrip_component_ui(&mut registry);
geo_line_string::register_geo_line_string_component_ui(&mut registry);

Expand Down
50 changes: 50 additions & 0 deletions crates/viewer/re_component_ui/src/recording_uri.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use re_types::components::RecordingUri;
use re_viewer_context::{MaybeMutRef, ViewerContext};

pub fn singleline_view_recording_uri(
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
value: &mut MaybeMutRef<'_, RecordingUri>,
) -> egui::Response {
let value = value.as_ref();

#[cfg(not(target_arch = "wasm32"))]
{
use re_viewer_context::{SystemCommand, SystemCommandSender};

let response = ui
.scope(|ui| {
if ui.style().wrap_mode.is_none() {
ui.style_mut().wrap_mode = Some(if ui.is_sizing_pass() {
egui::TextWrapMode::Extend
} else {
egui::TextWrapMode::Truncate
});
}

ui.link(value.uri())
})
.inner;

if response.clicked() {
let data_source = re_data_source::DataSource::from_uri(
re_log_types::FileSource::Uri,
value.uri().to_owned(),
);

match data_source.stream(None) {
Ok(rx) => _ctx
.command_sender
.send_system(SystemCommand::AddReceiver(rx)),
Err(err) => re_log::warn!("Could not open recording URI: {err}"),
}
}

response
}

#[cfg(target_arch = "wasm32")]
{
re_viewer_context::UiLayout::List.label(ui, value.uri())
}
}
8 changes: 8 additions & 0 deletions crates/viewer/re_viewer/src/reflection/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/viewer/re_viewer/src/viewer_analytics/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub fn open_recording(
S::RustSdk { .. } => "rust_sdk".to_owned(),
S::File { file_source } => match file_source {
re_log_types::FileSource::Cli => "file_cli".to_owned(),
re_log_types::FileSource::Uri => "file_uri".to_owned(),
re_log_types::FileSource::DragAndDrop { .. } => "file_drag_and_drop".to_owned(),
re_log_types::FileSource::FileDialog { .. } => "file_dialog".to_owned(),
re_log_types::FileSource::Sdk => "file_sdk".to_owned(),
Expand Down
1 change: 1 addition & 0 deletions docs/content/reference/types/components.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/content/reference/types/components/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions docs/content/reference/types/components/recording_uri.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/content/reference/types/datatypes/utf8.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lychee.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ exclude = [
'https://static.rerun.io/my_screenshot/',
'https://your-hosted-asset-url.com/widget.js',
'file:///path/to/file',
'rerun://localhost:51234/recording/some-recording-id',

# Link fragments and data links in examples.
'https://raw.githubusercontent.com/googlefonts/noto-emoji/', # URL fragment.
Expand Down
1 change: 1 addition & 0 deletions rerun_cpp/src/rerun/components.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rerun_cpp/src/rerun/components/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 10c1f5c

Please sign in to comment.