Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to copy direct link to fully qualified URL #4165

Merged
merged 8 commits into from
Nov 7, 2023

Conversation

jprochazk
Copy link
Member

@jprochazk jprochazk commented Nov 7, 2023

What

When on web, the command pallete now lists a command to copy a direct link to the "fully qualified" URL, which is location.origin + query["url"].

Fixes #4122

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested demo.rerun.io (if applicable)
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

@jprochazk jprochazk added 🕸️ web regarding running the viewer in a browser 📺 re_viewer affects re_viewer itself include in changelog labels Nov 7, 2023
@emilk emilk self-requested a review November 7, 2023 09:57
Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice solution! But we should be able to remove the hard-coded app.rerun.io fallback

Comment on lines 575 to 580
self.toasts.add(toasts::Toast {
kind: toasts::ToastKind::Warning,
text: format!("Could not copy direct link, no recording is open"),
options: toasts::ToastOptions::with_ttl_in_seconds(4.0),
});
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this really be an error? I would expect to just get a copy to the viewer in this case (https://app.rerun.io)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, anything logged with re_log::warn! will also show up as a warning toast

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, changed it to default to location.origin by itself

});
return;
};
let direct_link = match &self.startup_options.location {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is StartupOptions::location None? Looking at the code it seems to always be set on wasm, so maybe it doesn't need to be an Option? In any case, you could also call eframe::web::web_location() here if you prefer. That way we don't need the hard-coded fallback to app.rerun.io

Copy link
Member Author

@jprochazk jprochazk Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's an Option because of this Default impl:

location: None,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like that impl Default for StartupOptions could have a #[cfg(not(target_arch = "wasm32"))] around it though, so I don't think it needs to be an Option.

@jprochazk
Copy link
Member Author

jprochazk commented Nov 7, 2023

Changed one more thing, the command now checks if we're on app.rerun.io and if so will turn the link into a permanent link by adding the /commit/... or /version/... path based on the available build info

crates/re_viewer/src/app.rs Outdated Show resolved Hide resolved
crates/re_viewer/src/app.rs Outdated Show resolved Hide resolved
Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice to get a perma-link for free!

@jprochazk jprochazk merged commit 8a96b54 into main Nov 7, 2023
37 checks passed
@jprochazk jprochazk deleted the jan/direct-link-to-rrd branch November 7, 2023 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog 📺 re_viewer affects re_viewer itself 🕸️ web regarding running the viewer in a browser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Direct links for examples on app.rerun.io
2 participants