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

Automatically select user timeline if no timeline was explicitly selected yet #2986

Merged
merged 3 commits into from
Aug 16, 2023

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Aug 15, 2023

Slight deviation from the desired behavior from the ticket: We'll always select the user timeline which is alphabetically first. I deem this good enough though and an improvement in any case!

Going back the the "auto select" state is not possible explicitely, but will happen if for whatever reason no user timeline is available anymore.

Tested as seen in the video and then confirmed separately the described alphabetic behavior

Screen.Recording.2023-08-15.at.16.17.20.mov

Checklist

@Wumpf Wumpf added enhancement New feature or request 📺 re_viewer affects re_viewer itself labels Aug 15, 2023
@Wumpf Wumpf added this to the 0.8.1 milestone Aug 15, 2023
.or_insert_with(|| TimeState::new(view.min))
.view = Some(view);
}

/// The range of time we are currently zoomed in on.
pub fn reset_time_view(&mut self) {
if let Some(state) = self.states.get_mut(&self.timeline) {
if let Some(state) = self.states.get_mut(self.timeline.get()) {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of changing all &foo to foo.get(), just implement Deref for EditableAutoValue!

Copy link
Member Author

Choose a reason for hiding this comment

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

🤯

Copy link
Member Author

Choose a reason for hiding this comment

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

for those cases I still need get() due to the way Deref works in rust: *self.timeline gives the underlying Timeline by value. But with Deref in place *self.timeline.get() becomes *self.timeline and self.timeline.get().typ() becomes self.timeline.typ()

Copy link
Member Author

Choose a reason for hiding this comment

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

could ofc also do &*self.timeline.get() if that's preferred

Copy link
Member

Choose a reason for hiding this comment

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

I mean do &*self.timeline

// If the timeline is auto refresh it every frame, otherwise only pick a new one if invalid.
if self.timeline.is_auto() || !is_timeline_valid(self.timeline(), times_per_timeline) {
self.timeline = EditableAutoValue::Auto(
default_timeline(times_per_timeline.timelines()).map_or(Default::default(), |t| *t),
Copy link
Member

Choose a reason for hiding this comment

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

The alphabetical order behavior is a bit unexpected (though I agree still a net improvement).

Since times_per_timeline persists with the EntityDb, internally tracking insertion order as part of TimesPerTimeline::insert() wouldn't be all that painful though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm I think you're right. I'll try to go the extra step tomorrow

Copy link
Member Author

Choose a reason for hiding this comment

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

poked it a bit, but changing this BTreeMap of timelines right now is a bit too annoying for the moment and then it gets less viable for a patch release

Copy link
Member

@jleibs jleibs left a comment

Choose a reason for hiding this comment

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

Nice improvement. Seems to work for me.

@Wumpf Wumpf merged commit d0de66c into main Aug 16, 2023
@Wumpf Wumpf deleted the andreas/fix-timeline-auto-select branch August 16, 2023 07:45
emilk pushed a commit that referenced this pull request Aug 17, 2023
…cted yet (#2986)

* Fixes #2186

Slight deviation from the desired behavior from the ticket: We'll always
select the user timeline which is _alphabetically first_. I deem this
good enough though and an improvement in any case!

Going back the the "auto select" state is not possible explicitely, but
will happen if for whatever reason no user timeline is available
anymore.

Tested as seen in the video and then confirmed separately the described
alphabetic behavior



https://github.com/rerun-io/rerun/assets/1220815/0d3303d7-7b19-4854-993d-0523b3e35cbb



### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2986) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2986)
- [Docs
preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-timeline-auto-select/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-timeline-auto-select/examples)
@emilk emilk mentioned this pull request Aug 17, 2023
3 tasks
emilk pushed a commit that referenced this pull request Aug 17, 2023
…cted yet (#2986)

* Fixes #2186

Slight deviation from the desired behavior from the ticket: We'll always
select the user timeline which is _alphabetically first_. I deem this
good enough though and an improvement in any case!

Going back the the "auto select" state is not possible explicitely, but
will happen if for whatever reason no user timeline is available
anymore.

Tested as seen in the video and then confirmed separately the described
alphabetic behavior



https://github.com/rerun-io/rerun/assets/1220815/0d3303d7-7b19-4854-993d-0523b3e35cbb



### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2986) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2986)
- [Docs
preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-timeline-auto-select/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-timeline-auto-select/examples)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 📺 re_viewer affects re_viewer itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Selected timeline heuristic is unstable
3 participants