From 77bd62051e237d2359bb1b104f9f93ebbfff413a Mon Sep 17 00:00:00 2001 From: Paddy <89168564+patrickballard@users.noreply.github.com> Date: Mon, 26 Oct 2026 01:13:35 +0000 Subject: [PATCH 1/2] fix(desktop-gpui): show hours in the editor's clock, ruler and timing cards The transport clock, timeline ruler and timing cards printed minutes and seconds only, so a point 1 h 5 m 5 s into a recording read 65:05. Print H:MM:SS (H:MM:SS.s on the timing cards) from an hour on; shorter times print as before. --- apps/desktop-gpui/src/editor_panels.rs | 14 +++++++++-- apps/desktop-gpui/src/editor_timeline.rs | 31 ++++++++++++++++++------ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/apps/desktop-gpui/src/editor_panels.rs b/apps/desktop-gpui/src/editor_panels.rs index cdedff72c85..1c773856704 100644 --- a/apps/desktop-gpui/src/editor_panels.rs +++ b/apps/desktop-gpui/src/editor_panels.rs @@ -6230,12 +6230,19 @@ impl EditorWindow { } } -/// `formatTime` -- the `M:SS` clock the timing cards print. +/// `formatTime` -- the `M:SS` clock the timing cards print, as `H:MM:SS` from +/// an hour on. fn format_time(seconds: f64) -> String { let seconds = seconds.max(0.); + let hours = (seconds / 3600.).floor() as u32; + let seconds = seconds - f64::from(hours) * 3600.; let minutes = (seconds / 60.).floor() as u32; let rest = seconds - f64::from(minutes) * 60.; - format!("{minutes}:{rest:04.1}") + if hours > 0 { + format!("{hours}:{minutes:02}:{rest:04.1}") + } else { + format!("{minutes}:{rest:04.1}") + } } impl EditorWindow { @@ -8420,6 +8427,9 @@ mod tests { assert_eq!(format_time(0.), "0:00.0"); assert_eq!(format_time(9.25), "0:09.2"); assert_eq!(format_time(75.5), "1:15.5"); + assert_eq!(format_time(3599.5), "59:59.5"); + assert_eq!(format_time(3600.), "1:00:00.0"); + assert_eq!(format_time(3905.5), "1:05:05.5"); } // -- Text presets ------------------------------------------------------ diff --git a/apps/desktop-gpui/src/editor_timeline.rs b/apps/desktop-gpui/src/editor_timeline.rs index 16773fb1a3e..ad0f22557c5 100644 --- a/apps/desktop-gpui/src/editor_timeline.rs +++ b/apps/desktop-gpui/src/editor_timeline.rs @@ -472,12 +472,17 @@ pub fn marking_resolution(zoom: f64) -> f64 { } /// `formatTime` (`routes/editor/utils.ts:1-13`) -- `M:SS`, which is both the -/// transport clock and the **ruler's** label (`TL/index.tsx:48, 1597`). +/// transport clock and the **ruler's** label (`TL/index.tsx:48, 1597`). One +/// deliberate deviation: from an hour on it prints `H:MM:SS`, where the source +/// prints a minute count such as `65:05`. pub fn format_time(seconds: f64) -> String { - let seconds = seconds.max(0.0); - let minutes = (seconds / 60.0).floor() as u64; - let secs = (seconds % 60.0).floor() as u64; - format!("{minutes}:{secs:02}") + let total = seconds.max(0.0).floor() as u64; + let (hours, minutes, secs) = (total / 3600, total / 60 % 60, total % 60); + if hours > 0 { + format!("{hours}:{minutes:02}:{secs:02}") + } else { + format!("{minutes}:{secs:02}") + } } /// The *other* `formatTime`, the clip track's own (`TL/ClipTrack.tsx:129-141`): @@ -1947,8 +1952,8 @@ pub fn render_ruler(theme: &Theme, view: TimelineView, viewport_width: f32) -> A // overhang into the icon gutter // (`TL/index.tsx:1591-1594`). gpui has no // transform, so the label sits in a fixed box wide - // enough for `M:SS` at any minute count and is - // centred inside it. + // enough for `M:SS`, or `H:MM:SS` below ten hours, + // and is centred inside it. .when(second != 0., |this| this.left(px(-22.))) .w(px(44.)) .flex() @@ -3792,6 +3797,18 @@ mod tests { // -- The ruler ---------------------------------------------------------- + #[test] + fn the_clock_and_ruler_show_hours_from_an_hour_on() { + assert_eq!(format_time(0.), "0:00"); + assert_eq!(format_time(95.7), "1:35"); + assert_eq!(format_time(3599.9), "59:59"); + assert_eq!(format_time(3600.), "1:00:00"); + assert_eq!(format_time(3905.), "1:05:05"); + assert_eq!(format_time(5400.), "1:30:00"); + assert_eq!(format_time(36000.), "10:00:00"); + assert_eq!(format_time(-3.), "0:00"); + } + #[test] fn clip_markings_stop_at_the_clip_edge() { // A 30s clip 10 minutes into a fully zoomed-out 30-minute timeline: From 387644bbd500f6a322c6a695b284e0fba07dd434 Mon Sep 17 00:00:00 2001 From: Paddy <89168564+patrickballard@users.noreply.github.com> Date: Mon, 26 Oct 2026 02:13:57 +0000 Subject: [PATCH 2/2] fix(desktop-gpui): show hours in the recording timer and clip durations The recording controls' timer and the clips sidebar's clip durations also counted minutes past 59, so a recording 1 h 5 m 5 s in read 65:05. Format both with the editor clock's format_time; under an hour they print as before. --- apps/desktop-gpui/src/controls_window.rs | 16 +++++++++++++--- apps/desktop-gpui/src/editor_clips.rs | 15 +++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/apps/desktop-gpui/src/controls_window.rs b/apps/desktop-gpui/src/controls_window.rs index 4aca069a69d..37a723cd7a4 100644 --- a/apps/desktop-gpui/src/controls_window.rs +++ b/apps/desktop-gpui/src/controls_window.rs @@ -130,10 +130,10 @@ impl ControlsWindow { }) } - /// `formatTime`: `M:SS`, hours folded into minutes the same way. + /// `formatTime`, through the editor clock's formatter, so a recording past + /// an hour reads `H:MM:SS` where the source folds the hours into minutes. fn format_elapsed(elapsed: Duration) -> String { - let total = elapsed.as_secs(); - format!("{}:{:02}", total / 60, total % 60) + crate::editor_timeline::format_time(elapsed.as_secs_f64()) } fn action_button( @@ -609,6 +609,16 @@ mod repaint_tests { assert_eq!(until_next_second(Duration::ZERO), Duration::from_secs(1)); } + #[test] + fn the_timer_shows_hours_from_an_hour_on() { + let label = |seconds| ControlsWindow::format_elapsed(Duration::from_secs_f64(seconds)); + assert_eq!(label(0.), "0:00"); + assert_eq!(label(95.7), "1:35"); + assert_eq!(label(3_599.9), "59:59"); + assert_eq!(label(3_600.), "1:00:00"); + assert_eq!(label(3_905.), "1:05:05"); + } + #[test] fn a_resumed_timer_wakes_at_the_next_second_and_a_paused_one_idles() { assert_eq!( diff --git a/apps/desktop-gpui/src/editor_clips.rs b/apps/desktop-gpui/src/editor_clips.rs index 865968054f6..51ea12b7551 100644 --- a/apps/desktop-gpui/src/editor_clips.rs +++ b/apps/desktop-gpui/src/editor_clips.rs @@ -42,7 +42,7 @@ use gpui::{ use crate::{ app_windows, editor_edits::{self as edits, TrackSegmentOps}, - editor_timeline::clip_timeline_offsets, + editor_timeline::{clip_timeline_offsets, format_time}, editor_window::EditorWindow, session::{Phase, RecordingSession}, theme::Theme, @@ -53,13 +53,13 @@ use crate::{ // Naming (`ClipsSidebar.tsx:558-609`) // --------------------------------------------------------------------------- -/// `formatClipDuration` (`ClipsSidebar.tsx:79-85`). +/// `formatClipDuration` (`ClipsSidebar.tsx:79-85`), with hours from an hour on +/// like the editor's clock, where the source counts minutes past 59. pub(crate) fn format_clip_duration(seconds: f64) -> String { if !seconds.is_finite() || seconds <= 0.0 { return "0:00".to_string(); } - let total = seconds.round() as i64; - format!("{}:{:02}", total / 60, total % 60) + format_time(seconds.round()) } /// `clipLabel` (`:563`). @@ -119,8 +119,8 @@ fn display_name_at(segments: &[TimelineSegment], index: usize) -> String { } } -/// `segmentDescription` (`:598-609`): `m:ss`, prefixed with the parent clip's -/// label for a split. +/// `segmentDescription` (`:598-609`): `m:ss` (`h:mm:ss` from an hour on), +/// prefixed with the parent clip's label for a split. pub(crate) fn segment_description(segments: &[TimelineSegment], index: usize) -> String { let formatted = format_clip_duration(segments[index].duration()); if segment_split_number(segments, index) > 1 { @@ -3878,6 +3878,9 @@ mod tests { assert_eq!(format_clip_duration(0.6), "0:01"); assert_eq!(format_clip_duration(59.6), "1:00"); assert_eq!(format_clip_duration(75.0), "1:15"); + assert_eq!(format_clip_duration(3_599.4), "59:59"); + assert_eq!(format_clip_duration(3_599.6), "1:00:00"); + assert_eq!(format_clip_duration(3_905.0), "1:05:05"); assert_eq!(format_clip_duration(600.0), "10:00"); }