From 20064d9681c6828d482e91de59add4e8e00ecdcf Mon Sep 17 00:00:00 2001 From: Trey Moen <50057480+greatgitsby@users.noreply.github.com> Date: Sat, 12 Sep 2026 20:46:51 -0700 Subject: [PATCH] cabana: show placeholder for unresolved timestamps (#38870) --- openpilot/tools/cabana/ui/widgets/videowidget.cc | 15 ++++++++++----- openpilot/tools/cabana/ui/widgets/videowidget.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/openpilot/tools/cabana/ui/widgets/videowidget.cc b/openpilot/tools/cabana/ui/widgets/videowidget.cc index 0896951bab..7860a95138 100644 --- a/openpilot/tools/cabana/ui/widgets/videowidget.cc +++ b/openpilot/tools/cabana/ui/widgets/videowidget.cc @@ -147,8 +147,13 @@ void VideoWidget::drawPlaybackController() { const char *play_icon = can->isPaused() ? icon::PLAY : icon::PAUSE; const char *play_tooltip = can->isPaused() ? "Play" : "Pause"; const char *loop_icon = getReplay() && getReplay()->loop() ? icon::REPEAT : icon::REPEAT_1; - const std::string time_text = slider_ ? formatTime(can->currentSec(), true) + " / " + formatTime(slider_->maximum() / slider_->factor) - : formatTime(can->currentSec(), true); + const bool timestamps_resolved = can->liveStreaming() + ? msgs_received_ + : can->beginDateTime() != std::chrono::system_clock::time_point{}; + const std::string time_text = timestamps_resolved + ? (slider_ ? formatTime(can->currentSec(), true) + " / " + formatTime(slider_->maximum() / slider_->factor) + : formatTime(can->currentSec(), true)) + : "--:--.-- / --:--.--"; const char *time_tooltip = settings.absolute_time ? "Elapsed time" : "Absolute time"; std::vector items; @@ -161,14 +166,14 @@ void VideoWidget::drawPlaybackController() { } else { items.push_back(toolbarAction("fast-forward", icon::FAST_FORWARD, "Seek forward", []() { can->seekTo(can->currentSec() + 1); })); } - if (slider_ || msgs_received_) { + if (slider_ || timestamps_resolved) { // a mono font: with proportional digits the time changed width as it ticked and the items after it moved - pushMonoFont(ImGui::GetFontSize()); + pushMonoFont(ImGui::GetStyle().FontSizeBase); const float time_width = ImGui::CalcTextSize(time_text.c_str()).x; popMonoFont(); items.push_back({time_width, [&]() { - pushMonoFont(ImGui::GetFontSize()); + pushMonoFont(ImGui::GetStyle().FontSizeBase); ImGui::AlignTextToFramePadding(); ImGui::TextUnformatted(time_text.c_str()); popMonoFont(); diff --git a/openpilot/tools/cabana/ui/widgets/videowidget.h b/openpilot/tools/cabana/ui/widgets/videowidget.h index 1abdbdbe71..94b50dbf3f 100644 --- a/openpilot/tools/cabana/ui/widgets/videowidget.h +++ b/openpilot/tools/cabana/ui/widgets/videowidget.h @@ -112,7 +112,7 @@ private: std::string speed_text_; int speed_index_ = -1; // checked entry of the speed menu bool skip_to_end_enabled_ = true; - bool msgs_received_ = false; // the time is blank until the live stream delivers its first messages + bool msgs_received_ = false; // live-stream timestamps resolve when the first messages arrive double thumbnail_display_time_ = -1; std::unique_ptr slider_; std::unique_ptr camera_tab_;