From 8ee3077f7ef735ed7659ecb77225547105202a0a Mon Sep 17 00:00:00 2001 From: Yoav Levavi Date: Wed, 21 Oct 2026 18:36:03 +0300 Subject: [PATCH 1/7] gpui: rename timeline lanes by double-clicking their label Names are stored per lane in ProjectConfiguration::track_names, keyed ":"; an empty name restores the track's own label. Co-Authored-By: Claude Opus 5.5 --- apps/desktop-gpui/src/editor_timeline.rs | 74 ++++++++++- apps/desktop-gpui/src/editor_window.rs | 162 ++++++++++++++++++++++- crates/project/src/configuration.rs | 5 + 3 files changed, 237 insertions(+), 4 deletions(-) diff --git a/apps/desktop-gpui/src/editor_timeline.rs b/apps/desktop-gpui/src/editor_timeline.rs index 7b11b9c17f4..31f54b442ba 100644 --- a/apps/desktop-gpui/src/editor_timeline.rs +++ b/apps/desktop-gpui/src/editor_timeline.rs @@ -983,6 +983,24 @@ pub enum TrackKind { } impl TrackKind { + /// The track's part of a `ProjectConfiguration::track_names` key. + pub fn name_key(self) -> &'static str { + match self { + Self::Clip => "clip", + Self::Style => "style", + Self::Image => "image", + Self::Caption => "caption", + Self::Keyboard => "keyboard", + Self::Text => "text", + Self::Shape => "shape", + Self::Mask => "mask", + Self::Audio => "audio", + Self::Zoom => "zoom", + Self::ThreeD => "3d", + Self::Scene => "scene", + } + } + /// `trackDefinitions` (`TL/index.tsx:89-144`) and `trackIcons` (`:70-80`). pub fn label(self) -> &'static str { match self { @@ -1348,6 +1366,8 @@ impl TrackRow { /// Everything the timeline draws, derived once per project-config change. #[derive(Debug, Clone, Default)] pub struct TimelineModel { + /// Lane names the user gave, by `":"`. + pub track_names: std::collections::BTreeMap, pub style: Vec, pub image: Vec, pub rows: Vec, @@ -1609,6 +1629,7 @@ impl TimelineModel { }) .collect(); let mut model = Self { + track_names: Default::default(), style, image, rows: Vec::new(), @@ -1649,6 +1670,12 @@ impl TimelineModel { ) -> Self { let mut model = Self::build(config, has_camera, multiple_clips); model.rows = build_rows(config, &model, has_camera, lanes); + model.track_names = config + .track_names + .iter() + .filter(|(_, name)| !name.trim().is_empty()) + .map(|(key, name)| (key.clone(), SharedString::from(name.clone()))) + .collect(); model } } @@ -1973,7 +2000,11 @@ impl SegmentUi<'_> { /// The gutter cell: a tinted 22px tile carrying the track's glyph, then the /// track's name. The saturated pill the source draws /// (`TL/TrackManager.tsx:264-281`) is gone. -pub fn track_chip(theme: &Theme, kind: TrackKind) -> impl IntoElement { +pub fn track_name_key(row: TrackRow) -> String { + format!("{}:{}", row.kind.name_key(), row.lane) +} + +pub fn track_chip(theme: &Theme, kind: TrackKind, name: Option) -> impl IntoElement { let color = kind.color(); div() .w_full() @@ -2008,7 +2039,7 @@ pub fn track_chip(theme: &Theme, kind: TrackKind) -> impl IntoElement { .text_size(px(11.)) .line_height(px(14.)) .font_weight(FontWeight::MEDIUM) - .child(kind.label()), + .child(name.unwrap_or_else(|| SharedString::new_static(kind.label()))), ) } @@ -2305,7 +2336,11 @@ pub fn render_row( .w(px(TRACK_GUTTER)) .flex_none() .relative() - .child(track_chip(theme, row.kind)), + .child(track_chip( + theme, + row.kind, + model.track_names.get(&track_name_key(row)).cloned(), + )), ) .child( div() @@ -4127,6 +4162,39 @@ mod tests { const AUDIO_SAMPLE_RATE: usize = 48_000; + #[test] + fn lane_names_come_from_the_project_by_track_and_lane() { + let mut config = ProjectConfiguration::default(); + config.track_names.insert("audio:1".into(), "Music".into()); + config.track_names.insert("text:0".into(), " ".into()); + let lanes = TrackLanes { + style: 0, + image: 0, + caption: false, + keyboard: false, + scene: false, + three_d: false, + text: 1, + shape: 0, + mask: 0, + audio: 2, + }; + let model = TimelineModel::build_with_lanes(&config, false, false, &lanes); + let audio = TrackRow { + kind: TrackKind::Audio, + lane: 1, + }; + assert_eq!(track_name_key(audio), "audio:1"); + assert_eq!( + model.track_names.get("audio:1").map(|n| n.as_ref()), + Some("Music") + ); + assert!( + !model.track_names.contains_key("text:0"), + "blank names are ignored" + ); + } + // -- The ruler ---------------------------------------------------------- #[test] diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rs index d19371448c6..8f27cc43519 100644 --- a/apps/desktop-gpui/src/editor_window.rs +++ b/apps/desktop-gpui/src/editor_window.rs @@ -1658,6 +1658,9 @@ pub struct EditorWindow { presets_menu: Option, preset_dialog: Option, style_presets: style_preset_ui::StylePresetsState, + /// The lane being renamed (double-click on its label), and the input. + track_rename: Option, + track_name_input: Entity, caption_sync_signature: Option, pub(crate) export: Option, pub(crate) sharing: Option, @@ -2140,6 +2143,23 @@ impl EditorWindow { }, )); let markers_state = markers::MarkersState::new(window, cx, &mut text_events); + let track_name_input = cx.new(|cx| { + let mut input = ui::TextInputState::single_line(window, cx); + input.set_placeholder("Track name"); + input + }); + text_events.push(cx.subscribe_in( + &track_name_input, + window, + |this: &mut Self, _input, event: &ui::TextInputEvent, window, cx| match event { + ui::TextInputEvent::Confirmed => this.commit_track_rename(window, cx), + ui::TextInputEvent::Cancelled => { + this.track_rename = None; + cx.notify(); + } + _ => {} + }, + )); let player_frame_rect = crate::editor_canvas::canvas_rect_cell(); let preview = cx.new(|_| PreviewFrameView::new(player_frame_rect.clone())); let editor = cx.entity(); @@ -2263,6 +2283,8 @@ impl EditorWindow { hex_inputs, picker_hex, preset_name_input, + track_rename: None, + track_name_input, fields: HashMap::new(), field_editing: None, _text_events: text_events, @@ -8067,6 +8089,141 @@ impl EditorWindow { cx.notify(); } + /// Double-click on a lane's label: rename it. An empty name restores the + /// track's own label. + fn open_track_rename(&mut self, row: TrackRow, window: &mut Window, cx: &mut Context) { + if !self.project_ready() { + return; + } + let current = self + .project + .track_names + .get(&timeline::track_name_key(row)) + .cloned() + .unwrap_or_else(|| row.kind.label().to_string()); + self.track_rename = Some(row); + self.track_name_input.update(cx, |input, cx| { + input.set_text(current, cx); + input.focus_and_select_all(window, cx); + }); + cx.notify(); + } + + fn commit_track_rename(&mut self, window: &mut Window, cx: &mut Context) { + let Some(row) = self.track_rename.take() else { + return; + }; + let name = self.track_name_input.read(cx).text().trim().to_string(); + let key = timeline::track_name_key(row); + let default = name.is_empty() || name == row.kind.label(); + self.edit_project("track-rename", window, cx, move |project| { + if default { + project.track_names.remove(&key).is_some() + } else if project.track_names.get(&key) == Some(&name) { + false + } else { + project.track_names.insert(key, name); + true + } + }); + let focus = self.focus.clone(); + window.focus(&focus, cx); + cx.notify(); + } + + fn render_track_rename(&self, cx: &mut Context) -> Option { + self.track_rename?; + let theme = self.theme; + Some( + div() + .absolute() + .top_0() + .left_0() + .size_full() + .flex() + .items_center() + .justify_center() + .child( + div() + .id("track-rename-backdrop") + .absolute() + .top_0() + .left_0() + .size_full() + .bg(gpui::hsla(0., 0., 0., 0.5)) + .on_click(cx.listener(|this, _, _window, cx| { + this.track_rename = None; + cx.notify(); + })), + ) + .child( + div() + .w(px(360.)) + .flex() + .flex_col() + .gap(px(12.)) + .p(px(16.)) + .rounded(px(12.)) + .border_1() + .border_color(Hsla::from(theme.editor.line)) + .bg(Hsla::from(theme.editor.card)) + .shadow(theme.editor.pop_shadow()) + .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation()) + .child( + div() + .text_size(px(14.)) + .font_weight(FontWeight::SEMIBOLD) + .text_color(Hsla::from(theme.editor.text_1)) + .child("Rename track"), + ) + .child( + ui::TextInput::plain(&theme, "track-name", &self.track_name_input) + .padding_x(px(12.)) + .height(px(36.)) + .radius(px(8.)) + .text_size(px(14.)), + ) + .child( + div() + .flex() + .flex_row() + .justify_end() + .gap(px(8.)) + .child( + ui::Button::plain( + &theme, + "track-rename-cancel", + ui::ButtonVariant::Gray, + ui::ButtonSize::Md, + ) + .label("Cancel") + .on_click(cx.listener( + |this, _, _window, cx| { + this.track_rename = None; + cx.notify(); + }, + )), + ) + .child( + ui::Button::plain( + &theme, + "track-rename-confirm", + ui::ButtonVariant::Blue, + ui::ButtonSize::Md, + ) + .label("Rename") + .on_click(cx.listener( + |this, _, window, cx| { + this.commit_track_rename(window, cx); + }, + )), + ), + ), + ) + .into_any_element(), + ) + } + fn scene_available(&self) -> bool { timeline::scene_available(&self.project, self.has_camera) } @@ -12113,7 +12270,9 @@ impl EditorWindow { MouseButton::Left, cx.listener(move |this, event: &MouseDownEvent, window, cx| { if f32::from(event.position.x) < timeline::content_left() { - if can_reorder { + if event.click_count == 2 { + this.open_track_rename(track_row, window, cx); + } else if can_reorder { this.begin_lane_reorder(track_row, event.position, window, cx); } else { this.select_lane_header(kind, lane, cx); @@ -13253,6 +13412,7 @@ impl Render for EditorWindow { .children(self.render_style_presets_menu(cx)) .children(self.render_preset_dialog(cx)) .children(self.render_marker_overlays(window, cx)) + .children(self.render_track_rename(cx)) // The clips overlays: import menu, record modal, and the card // drag's window-wide layer with its floating ghost. .children(self.render_clips_overlays(cx)) diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rs index be8638b50e0..31f41de9d51 100644 --- a/crates/project/src/configuration.rs +++ b/crates/project/src/configuration.rs @@ -3094,6 +3094,10 @@ pub struct ProjectConfiguration { skip_serializing_if = "Vec::is_empty" )] pub markers: Vec, + /// Names the user gave timeline lanes, keyed `":"` (for + /// example `"audio:1"`). Lanes without one show the track's own label. + #[serde(default)] + pub track_names: std::collections::BTreeMap, } pub const TEXT_SIZE_VERSION: u32 = 1; @@ -3147,6 +3151,7 @@ impl Default for ProjectConfiguration { text_size_version: TEXT_SIZE_VERSION, text_anim_version: TEXT_ANIM_VERSION, markers: Vec::new(), + track_names: Default::default(), } } } From ba69f02a302c7360ca9398ae1328764f4b2ab38e Mon Sep 17 00:00:00 2001 From: Yoav Levavi Date: Sun, 25 Oct 2026 17:27:14 +0200 Subject: [PATCH 2/7] Track names: follow lanes through reorders; skip empty; merge main - reorder_track_names moves a track's lane names with the same shift as reorder_track_lane, in the same edit, so a renamed lane keeps its name after being dragged (overlay reorders only change overlay_order, so their names already stay put). Test included. - track_names is skipped when empty, so projects without names save unchanged; bindings regenerated. track_name_key sits above track_chip's doc comment again. - Merges origin/main; audio_project_key lists track_names as not affecting playback audio. Co-Authored-By: Claude Opus 5.5 --- apps/desktop-gpui/src/editor_edits.rs | 69 ++++++++++++++++++++---- apps/desktop-gpui/src/editor_timeline.rs | 6 +-- apps/desktop-gpui/src/editor_window.rs | 13 ++++- crates/editor/src/audio.rs | 1 + crates/project/src/configuration.rs | 2 +- 5 files changed, 76 insertions(+), 15 deletions(-) diff --git a/apps/desktop-gpui/src/editor_edits.rs b/apps/desktop-gpui/src/editor_edits.rs index 079eab3403a..818af549802 100644 --- a/apps/desktop-gpui/src/editor_edits.rs +++ b/apps/desktop-gpui/src/editor_edits.rs @@ -1207,6 +1207,42 @@ pub fn reorder_overlay_track( true } +/// Where `lane` ends up when lane `from` is dragged to `to`: the moved lane +/// takes `to`, and the lanes it passed shift by one toward `from`. +fn reordered_lane(lane: u32, from: u32, to: u32) -> u32 { + if lane == from { + to + } else if from < to && lane > from && lane <= to { + lane - 1 + } else if from > to && lane >= to && lane < from { + lane + 1 + } else { + lane + } +} + +/// Moves `kind`'s lane names along with a [`reorder_track_lane`], so a name +/// stays on the lane it was given to. +pub fn reorder_track_names( + names: &mut std::collections::BTreeMap, + kind: TrackKind, + from: u32, + to: u32, +) { + let prefix = format!("{}:", kind.name_key()); + let moved: Vec<(u32, String)> = names + .iter() + .filter_map(|(key, name)| { + let lane = key.strip_prefix(&prefix)?.parse::().ok()?; + Some((lane, name.clone())) + }) + .collect(); + names.retain(|key, _| !key.starts_with(&prefix)); + for (lane, name) in moved { + names.insert(format!("{prefix}{}", reordered_lane(lane, from, to)), name); + } +} + pub fn reorder_track_lane( timeline: &mut TimelineConfiguration, kind: TrackKind, @@ -1226,15 +1262,7 @@ pub fn reorder_track_lane( let mut changed = false; for segment in segments { let lane = segment.lane(); - let next = if lane == from { - to - } else if from < to && lane > from && lane <= to { - lane - 1 - } else if from > to && lane >= to && lane < from { - lane + 1 - } else { - lane - }; + let next = reordered_lane(lane, from, to); if next != lane { set(segment, next); changed = true; @@ -3163,6 +3191,29 @@ mod tests { // -- Selection ---------------------------------------------------------- + #[test] + fn lane_names_follow_their_lane_when_lanes_are_reordered() { + let mut names = std::collections::BTreeMap::from([ + ("audio:0".to_string(), "Voice".to_string()), + ("audio:1".to_string(), "Music".to_string()), + ("style:0".to_string(), "Intro".to_string()), + ]); + reorder_track_names(&mut names, TrackKind::Audio, 1, 0); + assert_eq!(names.get("audio:0").map(String::as_str), Some("Music")); + assert_eq!(names.get("audio:1").map(String::as_str), Some("Voice")); + assert_eq!(names.get("style:0").map(String::as_str), Some("Intro")); + + // Dragging lane 0 to the bottom of three shifts the others up. + let mut names = std::collections::BTreeMap::from([ + ("audio:0".to_string(), "A".to_string()), + ("audio:2".to_string(), "C".to_string()), + ]); + reorder_track_names(&mut names, TrackKind::Audio, 0, 2); + assert_eq!(names.get("audio:2").map(String::as_str), Some("A")); + assert_eq!(names.get("audio:1").map(String::as_str), Some("C")); + assert!(!names.contains_key("audio:0")); + } + #[test] fn a_plain_click_selects_one_segment() { let selection = click_selection(None, TrackKind::Zoom, 3, false, false); diff --git a/apps/desktop-gpui/src/editor_timeline.rs b/apps/desktop-gpui/src/editor_timeline.rs index 31f54b442ba..89137d0ac64 100644 --- a/apps/desktop-gpui/src/editor_timeline.rs +++ b/apps/desktop-gpui/src/editor_timeline.rs @@ -1997,13 +1997,13 @@ impl SegmentUi<'_> { // Rendering // --------------------------------------------------------------------------- -/// The gutter cell: a tinted 22px tile carrying the track's glyph, then the -/// track's name. The saturated pill the source draws -/// (`TL/TrackManager.tsx:264-281`) is gone. pub fn track_name_key(row: TrackRow) -> String { format!("{}:{}", row.kind.name_key(), row.lane) } +/// The gutter cell: a tinted 22px tile carrying the track's glyph, then the +/// track's name. The saturated pill the source draws +/// (`TL/TrackManager.tsx:264-281`) is gone. pub fn track_chip(theme: &Theme, kind: TrackKind, name: Option) -> impl IntoElement { let color = kind.color(); div() diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rs index 8f27cc43519..f172ee8d514 100644 --- a/apps/desktop-gpui/src/editor_window.rs +++ b/apps/desktop-gpui/src/editor_window.rs @@ -5299,14 +5299,23 @@ impl EditorWindow { edits::reorder_overlay_track(&mut self.project, &available, from, reorder.target_index) } else { rows.get(reorder.target_index).is_some_and(|target| { - self.project.timeline.as_mut().is_some_and(|timeline| { + let moved = self.project.timeline.as_mut().is_some_and(|timeline| { edits::reorder_track_lane( timeline, reorder.source.kind, reorder.source.lane, target.lane, ) - }) + }); + if moved { + edits::reorder_track_names( + &mut self.project.track_names, + reorder.source.kind, + reorder.source.lane, + target.lane, + ); + } + moved }) }; if changed { diff --git a/crates/editor/src/audio.rs b/crates/editor/src/audio.rs index db1004fef56..69bf085033b 100644 --- a/crates/editor/src/audio.rs +++ b/crates/editor/src/audio.rs @@ -2113,6 +2113,7 @@ fn audio_project_key(project: &ProjectConfiguration) -> Option> { text_size_version: _, text_anim_version: _, markers: _, + track_names: _, } = project; let timeline = timeline.as_ref().map(|timeline| { let TimelineConfiguration { diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rs index 31f41de9d51..fa4f757b114 100644 --- a/crates/project/src/configuration.rs +++ b/crates/project/src/configuration.rs @@ -3096,7 +3096,7 @@ pub struct ProjectConfiguration { pub markers: Vec, /// Names the user gave timeline lanes, keyed `":"` (for /// example `"audio:1"`). Lanes without one show the track's own label. - #[serde(default)] + #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")] pub track_names: std::collections::BTreeMap, } From 3a431d3d671bae82a11cbfe003f85b663b946a67 Mon Sep 17 00:00:00 2001 From: Yoav Levavi Date: Tue, 27 Oct 2026 21:27:40 +0200 Subject: [PATCH 3/7] Save lane renames past an open style group Co-Authored-By: Claude Opus 5.5 --- apps/desktop-gpui/src/editor_window.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rs index f172ee8d514..6507355a10c 100644 --- a/apps/desktop-gpui/src/editor_window.rs +++ b/apps/desktop-gpui/src/editor_window.rs @@ -8125,16 +8125,21 @@ impl EditorWindow { let name = self.track_name_input.read(cx).text().trim().to_string(); let key = timeline::track_name_key(row); let default = name.is_empty() || name == row.kind.label(); - self.edit_project("track-rename", window, cx, move |project| { - if default { - project.track_names.remove(&key).is_some() - } else if project.track_names.get(&key) == Some(&name) { - false - } else { - project.track_names.insert(key, name); - true - } - }); + // Written straight to the project: `edit_project` goes through an + // open style group's apply path, which keeps only style settings. + let track_names = &mut self.project.track_names; + let changed = if default { + track_names.remove(&key).is_some() + } else if track_names.get(&key) == Some(&name) { + false + } else { + track_names.insert(key, name); + true + }; + if changed && self.project_ready() { + self.project_changed(window, cx); + self.note_project_edit("track-rename"); + } let focus = self.focus.clone(); window.focus(&focus, cx); cx.notify(); From 160820700cd720163c459e2fbcbad939a8ea36cb Mon Sep 17 00:00:00 2001 From: Yoav Levavi Date: Tue, 3 Nov 2026 05:36:35 +0200 Subject: [PATCH 4/7] Track names: shift lane names when a lane is deleted Deleting a lane renumbered its segments but left the track_names keys alone, so the lane that moved down showed the deleted lane's name. The lane delete now drops the deleted lane's name and moves the names above it down in the same edit, also when the deleted lane was empty. Drops the comments that restated the rename state and handler. Co-Authored-By: Claude Opus 5.5 --- apps/desktop-gpui/src/editor_edits.rs | 86 +++++++++++++++++++++++++- apps/desktop-gpui/src/editor_window.rs | 3 - 2 files changed, 85 insertions(+), 4 deletions(-) diff --git a/apps/desktop-gpui/src/editor_edits.rs b/apps/desktop-gpui/src/editor_edits.rs index 818af549802..2c22657e8c6 100644 --- a/apps/desktop-gpui/src/editor_edits.rs +++ b/apps/desktop-gpui/src/editor_edits.rs @@ -1184,7 +1184,38 @@ pub fn delete_track_lane_and_order( true } }); - timeline_changed || order_changed + let names_changed = matches!( + kind, + TrackKind::Style | TrackKind::Image | TrackKind::Text | TrackKind::Mask | TrackKind::Audio + ) && delete_track_name(&mut project.track_names, kind, lane); + timeline_changed || order_changed || names_changed +} + +fn delete_track_name( + names: &mut std::collections::BTreeMap, + kind: TrackKind, + deleted: u32, +) -> bool { + let prefix = format!("{}:", kind.name_key()); + let lanes: Vec<(u32, String)> = names + .iter() + .filter_map(|(key, name)| { + let lane = key.strip_prefix(&prefix)?.parse::().ok()?; + (lane >= deleted).then(|| (lane, name.clone())) + }) + .collect(); + if lanes.is_empty() { + return false; + } + for (lane, _) in &lanes { + names.remove(&format!("{prefix}{lane}")); + } + for (lane, name) in lanes { + if lane > deleted { + names.insert(format!("{prefix}{}", lane - 1), name); + } + } + true } pub fn reorder_overlay_track( @@ -3191,6 +3222,59 @@ mod tests { // -- Selection ---------------------------------------------------------- + #[test] + fn deleting_a_lane_drops_its_name_and_shifts_the_names_above() { + let mut project = config(serde_json::json!({ + "timeline": { + "segments": [{ "recordingSegment": 0, "timescale": 1.0, "start": 0.0, "end": 30.0 }], + "zoomSegments": [], + "audioSegments": [ + { "start": 0.0, "end": 5.0, "track": 0, "path": "voice.mp3", "name": "Voice", "duration": 5.0 }, + { "start": 0.0, "end": 5.0, "track": 1, "path": "music.mp3", "name": "Music", "duration": 5.0 } + ] + }, + "trackNames": { "audio:0": "Voice", "audio:1": "Music", "text:0": "Titles" } + })); + assert!(delete_track_lane_and_order( + &mut project, + &[], + TrackKind::Audio, + 0 + )); + let names = |project: &ProjectConfiguration| { + project + .track_names + .iter() + .map(|(key, name)| (key.clone(), name.clone())) + .collect::>() + }; + assert_eq!( + names(&project), + [ + ("audio:0".to_string(), "Music".to_string()), + ("text:0".to_string(), "Titles".to_string()) + ] + ); + + let mut empty_lane = config(serde_json::json!({ + "timeline": { + "segments": [{ "recordingSegment": 0, "timescale": 1.0, "start": 0.0, "end": 30.0 }], + "zoomSegments": [] + }, + "trackNames": { "text:0": "Empty", "text:1": "Above" } + })); + assert!(delete_track_lane_and_order( + &mut empty_lane, + &[], + TrackKind::Text, + 0 + )); + assert_eq!( + names(&empty_lane), + [("text:0".to_string(), "Above".to_string())] + ); + } + #[test] fn lane_names_follow_their_lane_when_lanes_are_reordered() { let mut names = std::collections::BTreeMap::from([ diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rs index 6507355a10c..42de3a85186 100644 --- a/apps/desktop-gpui/src/editor_window.rs +++ b/apps/desktop-gpui/src/editor_window.rs @@ -1658,7 +1658,6 @@ pub struct EditorWindow { presets_menu: Option, preset_dialog: Option, style_presets: style_preset_ui::StylePresetsState, - /// The lane being renamed (double-click on its label), and the input. track_rename: Option, track_name_input: Entity, caption_sync_signature: Option, @@ -8098,8 +8097,6 @@ impl EditorWindow { cx.notify(); } - /// Double-click on a lane's label: rename it. An empty name restores the - /// track's own label. fn open_track_rename(&mut self, row: TrackRow, window: &mut Window, cx: &mut Context) { if !self.project_ready() { return; From 4345bb314693bed0f9d019187fc07fb7e4b49417 Mon Sep 17 00:00:00 2001 From: Yoav Levavi Date: Tue, 3 Nov 2026 06:23:23 +0200 Subject: [PATCH 5/7] Track names: follow lane renumbering on delete; move empty lanes' names - Deleting segments from a style or audio lane renumbers the lanes that still hold segments; the names now move with them, and a named lane left empty keeps its name below them. - Reordering lanes moves their names even when no segment moves (empty lanes), and saves the edit when only names changed. - Drops the remaining comments that restated the code. Co-Authored-By: Claude Opus 5.5 --- apps/desktop-gpui/src/editor_edits.rs | 121 +++++++++++++++++++++-- apps/desktop-gpui/src/editor_timeline.rs | 2 - apps/desktop-gpui/src/editor_window.rs | 22 ++--- crates/project/src/configuration.rs | 2 - 4 files changed, 126 insertions(+), 21 deletions(-) diff --git a/apps/desktop-gpui/src/editor_edits.rs b/apps/desktop-gpui/src/editor_edits.rs index 2c22657e8c6..ee37303a797 100644 --- a/apps/desktop-gpui/src/editor_edits.rs +++ b/apps/desktop-gpui/src/editor_edits.rs @@ -1238,8 +1238,6 @@ pub fn reorder_overlay_track( true } -/// Where `lane` ends up when lane `from` is dragged to `to`: the moved lane -/// takes `to`, and the lanes it passed shift by one toward `from`. fn reordered_lane(lane: u32, from: u32, to: u32) -> u32 { if lane == from { to @@ -1252,14 +1250,13 @@ fn reordered_lane(lane: u32, from: u32, to: u32) -> u32 { } } -/// Moves `kind`'s lane names along with a [`reorder_track_lane`], so a name -/// stays on the lane it was given to. pub fn reorder_track_names( names: &mut std::collections::BTreeMap, kind: TrackKind, from: u32, to: u32, -) { +) -> bool { + let before = names.clone(); let prefix = format!("{}:", kind.name_key()); let moved: Vec<(u32, String)> = names .iter() @@ -1272,6 +1269,70 @@ pub fn reorder_track_names( for (lane, name) in moved { names.insert(format!("{prefix}{}", reordered_lane(lane, from, to)), name); } + *names != before +} + +/// Style and audio deletes renumber the lanes that still hold segments +/// densely from zero, so names follow those lanes; a named lane left empty +/// keeps its name below them. +pub fn delete_segments_with_names( + project: &mut ProjectConfiguration, + kind: TrackKind, + indices: &[usize], +) -> bool { + fn surviving_lanes(segments: &[T], deleted: &[usize]) -> Vec { + let mut lanes: Vec = segments + .iter() + .enumerate() + .filter(|(index, _)| !deleted.contains(index)) + .map(|(_, segment)| segment.lane()) + .collect(); + lanes.sort_unstable(); + lanes.dedup(); + lanes + } + let Some(timeline) = project.timeline.as_mut() else { + return false; + }; + let lanes = match kind { + TrackKind::Style => Some(surviving_lanes(&timeline.style_segments, indices)), + TrackKind::Audio => Some(surviving_lanes(&timeline.audio_segments, indices)), + _ => None, + }; + if !delete_segments(timeline, kind, indices) { + return false; + } + if let Some(lanes) = lanes { + renumber_track_names(&mut project.track_names, kind, &lanes); + } + true +} + +fn renumber_track_names( + names: &mut std::collections::BTreeMap, + kind: TrackKind, + kept_lanes: &[u32], +) { + let prefix = format!("{}:", kind.name_key()); + let named: Vec<(u32, String)> = names + .iter() + .filter_map(|(key, name)| { + let lane = key.strip_prefix(&prefix)?.parse::().ok()?; + Some((lane, name.clone())) + }) + .collect(); + names.retain(|key, _| !key.starts_with(&prefix)); + let mut next_empty = kept_lanes.len() as u32; + for (lane, name) in named { + let new_lane = match kept_lanes.iter().position(|kept| *kept == lane) { + Some(position) => position as u32, + None => { + next_empty += 1; + next_empty - 1 + } + }; + names.insert(format!("{prefix}{new_lane}"), name); + } } pub fn reorder_track_lane( @@ -3275,6 +3336,55 @@ mod tests { ); } + #[test] + fn deleting_a_lanes_last_segment_moves_the_names_with_the_lanes() { + let mut project = config(serde_json::json!({ + "timeline": { + "segments": [{ "recordingSegment": 0, "timescale": 1.0, "start": 0.0, "end": 30.0 }], + "zoomSegments": [], + "audioSegments": [ + { "start": 0.0, "end": 5.0, "track": 0, "path": "voice.mp3", "name": "Voice", "duration": 5.0 }, + { "start": 0.0, "end": 5.0, "track": 1, "path": "music.mp3", "name": "Music", "duration": 5.0 } + ] + }, + "trackNames": { "audio:0": "Voice", "audio:1": "Music", "style:0": "Intro" } + })); + assert!(delete_segments_with_names( + &mut project, + TrackKind::Audio, + &[0] + )); + assert_eq!( + project.timeline.as_ref().unwrap().audio_segments[0].track, + 0 + ); + assert_eq!( + project + .track_names + .iter() + .map(|(key, name)| (key.as_str(), name.as_str())) + .collect::>(), + [ + ("audio:0", "Music"), + ("audio:1", "Voice"), + ("style:0", "Intro") + ] + ); + } + + #[test] + fn reordering_empty_named_lanes_still_moves_their_names() { + let mut names = std::collections::BTreeMap::from([ + ("audio:0".to_string(), "A".to_string()), + ("audio:1".to_string(), "B".to_string()), + ]); + assert!(reorder_track_names(&mut names, TrackKind::Audio, 0, 1)); + assert_eq!(names.get("audio:0").map(String::as_str), Some("B")); + assert_eq!(names.get("audio:1").map(String::as_str), Some("A")); + let mut unnamed = std::collections::BTreeMap::new(); + assert!(!reorder_track_names(&mut unnamed, TrackKind::Audio, 0, 1)); + } + #[test] fn lane_names_follow_their_lane_when_lanes_are_reordered() { let mut names = std::collections::BTreeMap::from([ @@ -3287,7 +3397,6 @@ mod tests { assert_eq!(names.get("audio:1").map(String::as_str), Some("Voice")); assert_eq!(names.get("style:0").map(String::as_str), Some("Intro")); - // Dragging lane 0 to the bottom of three shifts the others up. let mut names = std::collections::BTreeMap::from([ ("audio:0".to_string(), "A".to_string()), ("audio:2".to_string(), "C".to_string()), diff --git a/apps/desktop-gpui/src/editor_timeline.rs b/apps/desktop-gpui/src/editor_timeline.rs index 89137d0ac64..835bd1c6f22 100644 --- a/apps/desktop-gpui/src/editor_timeline.rs +++ b/apps/desktop-gpui/src/editor_timeline.rs @@ -983,7 +983,6 @@ pub enum TrackKind { } impl TrackKind { - /// The track's part of a `ProjectConfiguration::track_names` key. pub fn name_key(self) -> &'static str { match self { Self::Clip => "clip", @@ -1366,7 +1365,6 @@ impl TrackRow { /// Everything the timeline draws, derived once per project-config change. #[derive(Debug, Clone, Default)] pub struct TimelineModel { - /// Lane names the user gave, by `":"`. pub track_names: std::collections::BTreeMap, pub style: Vec, pub image: Vec, diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rs index 42de3a85186..52240a9151b 100644 --- a/apps/desktop-gpui/src/editor_window.rs +++ b/apps/desktop-gpui/src/editor_window.rs @@ -5306,15 +5306,13 @@ impl EditorWindow { target.lane, ) }); - if moved { - edits::reorder_track_names( - &mut self.project.track_names, - reorder.source.kind, - reorder.source.lane, - target.lane, - ); - } - moved + let renamed = edits::reorder_track_names( + &mut self.project.track_names, + reorder.source.kind, + reorder.source.lane, + target.lane, + ); + moved || renamed }) }; if changed { @@ -6843,8 +6841,10 @@ impl EditorWindow { cx, ) } else { - self.edit( - |timeline| edits::delete_segments(timeline, selection.track, &selection.indices), + self.edit_timeline_project( + |project| { + edits::delete_segments_with_names(project, selection.track, &selection.indices) + }, window, cx, ) diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rs index fa4f757b114..33cf923085d 100644 --- a/crates/project/src/configuration.rs +++ b/crates/project/src/configuration.rs @@ -3094,8 +3094,6 @@ pub struct ProjectConfiguration { skip_serializing_if = "Vec::is_empty" )] pub markers: Vec, - /// Names the user gave timeline lanes, keyed `":"` (for - /// example `"audio:1"`). Lanes without one show the track's own label. #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")] pub track_names: std::collections::BTreeMap, } From c87f8bfa6344bba2af71e0f2167969e59904bad3 Mon Sep 17 00:00:00 2001 From: Yoav Levavi Date: Sun, 15 Nov 2026 13:57:43 +0200 Subject: [PATCH 6/7] Track names: translate the rename dialog The dialog's title, placeholder and buttons were English literals. They now come from editor.window.track_rename (Cancel from common.cancel) in every catalog, and the placeholder is set when the dialog opens so it follows a language change. Co-Authored-By: Claude Opus 5.5 --- apps/desktop-gpui/locales/de.toml | 5 +++++ apps/desktop-gpui/locales/en.toml | 5 +++++ apps/desktop-gpui/locales/es.toml | 5 +++++ apps/desktop-gpui/locales/fr.toml | 5 +++++ apps/desktop-gpui/locales/hi.toml | 5 +++++ apps/desktop-gpui/locales/ja.toml | 5 +++++ apps/desktop-gpui/locales/zh-CN.toml | 5 +++++ apps/desktop-gpui/src/editor_window.rs | 13 +++++-------- .../src/i18n/editor_shell_surface_tests.rs | 6 ++++++ 9 files changed, 46 insertions(+), 8 deletions(-) diff --git a/apps/desktop-gpui/locales/de.toml b/apps/desktop-gpui/locales/de.toml index c96d36f22a2..e6984d1a7d9 100644 --- a/apps/desktop-gpui/locales/de.toml +++ b/apps/desktop-gpui/locales/de.toml @@ -3124,6 +3124,11 @@ save_failed = "Der Aufnahmetitel für {path} konnte nicht gespeichert werden: {e clear_all = "Alle entfernen" delete = "Löschen" +[editor.window.track_rename] +title = "Spur umbenennen" +placeholder = "Spurname" +confirm = "Umbenennen" + [editor.window.transition] title = "Übergang" add = "Übergang hinzufügen" diff --git a/apps/desktop-gpui/locales/en.toml b/apps/desktop-gpui/locales/en.toml index 29f268aa5c6..078d44d7ed5 100644 --- a/apps/desktop-gpui/locales/en.toml +++ b/apps/desktop-gpui/locales/en.toml @@ -3126,6 +3126,11 @@ save_failed = "Could not save the recording title for {path}: {error}" clear_all = "Clear all" delete = "Delete" +[editor.window.track_rename] +title = { text = "Rename track", context = "Title of the dialog opened by double-clicking a timeline lane label." } +placeholder = "Track name" +confirm = "Rename" + [editor.window.transition] title = { text = "Transition", context = "Title of the popover that edits the transition between two clips." } add = { text = "Add transition", context = "Tooltip on the + button at a cut between two clips on the timeline." } diff --git a/apps/desktop-gpui/locales/es.toml b/apps/desktop-gpui/locales/es.toml index 27fbf306d17..6f159b6c8ab 100644 --- a/apps/desktop-gpui/locales/es.toml +++ b/apps/desktop-gpui/locales/es.toml @@ -3124,6 +3124,11 @@ save_failed = "No se pudo guardar el título de la grabación de {path}: {error} clear_all = "Borrar todo" delete = "Eliminar" +[editor.window.track_rename] +title = "Renombrar pista" +placeholder = "Nombre de la pista" +confirm = "Renombrar" + [editor.window.transition] title = "Transición" add = "Añadir transición" diff --git a/apps/desktop-gpui/locales/fr.toml b/apps/desktop-gpui/locales/fr.toml index 87b46c59460..5ef5aa579da 100644 --- a/apps/desktop-gpui/locales/fr.toml +++ b/apps/desktop-gpui/locales/fr.toml @@ -3124,6 +3124,11 @@ save_failed = "Impossible d'enregistrer le titre de l'enregistrement pour {path} clear_all = "Tout effacer" delete = "Supprimer" +[editor.window.track_rename] +title = "Renommer la piste" +placeholder = "Nom de la piste" +confirm = "Renommer" + [editor.window.transition] title = "Transition" add = "Ajouter une transition" diff --git a/apps/desktop-gpui/locales/hi.toml b/apps/desktop-gpui/locales/hi.toml index 319ed6675bb..32bf37d76ae 100644 --- a/apps/desktop-gpui/locales/hi.toml +++ b/apps/desktop-gpui/locales/hi.toml @@ -3124,6 +3124,11 @@ save_failed = "{path} का रिकॉर्डिंग टाइटल स clear_all = "सब साफ़ करें" delete = "हटाएँ" +[editor.window.track_rename] +title = "ट्रैक का नाम बदलें" +placeholder = "ट्रैक का नाम" +confirm = "नाम बदलें" + [editor.window.transition] title = "ट्रांज़िशन" add = "ट्रांज़िशन जोड़ें" diff --git a/apps/desktop-gpui/locales/ja.toml b/apps/desktop-gpui/locales/ja.toml index d007debfd05..a30f066620d 100644 --- a/apps/desktop-gpui/locales/ja.toml +++ b/apps/desktop-gpui/locales/ja.toml @@ -3124,6 +3124,11 @@ save_failed = "{path}の録画タイトルを保存できませんでした:{e clear_all = "すべて消去" delete = "削除" +[editor.window.track_rename] +title = "トラック名を変更" +placeholder = "トラック名" +confirm = "名前を変更" + [editor.window.transition] title = "トランジション" add = "トランジションを追加" diff --git a/apps/desktop-gpui/locales/zh-CN.toml b/apps/desktop-gpui/locales/zh-CN.toml index 922d4ee4a5d..5fa1b796b47 100644 --- a/apps/desktop-gpui/locales/zh-CN.toml +++ b/apps/desktop-gpui/locales/zh-CN.toml @@ -3124,6 +3124,11 @@ save_failed = "无法保存 {path} 的录制标题:{error}" clear_all = "全部清除" delete = "删除" +[editor.window.track_rename] +title = "重命名轨道" +placeholder = "轨道名称" +confirm = "重命名" + [editor.window.transition] title = "转场" add = "添加转场" diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rs index 52240a9151b..46666798d34 100644 --- a/apps/desktop-gpui/src/editor_window.rs +++ b/apps/desktop-gpui/src/editor_window.rs @@ -2142,11 +2142,7 @@ impl EditorWindow { }, )); let markers_state = markers::MarkersState::new(window, cx, &mut text_events); - let track_name_input = cx.new(|cx| { - let mut input = ui::TextInputState::single_line(window, cx); - input.set_placeholder("Track name"); - input - }); + let track_name_input = cx.new(|cx| ui::TextInputState::single_line(window, cx)); text_events.push(cx.subscribe_in( &track_name_input, window, @@ -8109,6 +8105,7 @@ impl EditorWindow { .unwrap_or_else(|| row.kind.label().to_string()); self.track_rename = Some(row); self.track_name_input.update(cx, |input, cx| { + input.set_placeholder(tr::editor::window::track_rename::placeholder()); input.set_text(current, cx); input.focus_and_select_all(window, cx); }); @@ -8185,7 +8182,7 @@ impl EditorWindow { .text_size(px(14.)) .font_weight(FontWeight::SEMIBOLD) .text_color(Hsla::from(theme.editor.text_1)) - .child("Rename track"), + .child(tr::editor::window::track_rename::title()), ) .child( ui::TextInput::plain(&theme, "track-name", &self.track_name_input) @@ -8207,7 +8204,7 @@ impl EditorWindow { ui::ButtonVariant::Gray, ui::ButtonSize::Md, ) - .label("Cancel") + .label(tr::common::cancel()) .on_click(cx.listener( |this, _, _window, cx| { this.track_rename = None; @@ -8222,7 +8219,7 @@ impl EditorWindow { ui::ButtonVariant::Blue, ui::ButtonSize::Md, ) - .label("Rename") + .label(tr::editor::window::track_rename::confirm()) .on_click(cx.listener( |this, _, window, cx| { this.commit_track_rename(window, cx); diff --git a/apps/desktop-gpui/src/i18n/editor_shell_surface_tests.rs b/apps/desktop-gpui/src/i18n/editor_shell_surface_tests.rs index 05e50b7b5a8..c5836eed7c7 100644 --- a/apps/desktop-gpui/src/i18n/editor_shell_surface_tests.rs +++ b/apps/desktop-gpui/src/i18n/editor_shell_surface_tests.rs @@ -1441,6 +1441,12 @@ fn editor_shell_surfaces_match_the_literals_they_replaced() { tr::editor::timeline::picker::shape(), "Draw arrows, boxes, circles and highlights over your recording.", ), + (tr::editor::window::track_rename::title(), "Rename track"), + ( + tr::editor::window::track_rename::placeholder(), + "Track name", + ), + (tr::editor::window::track_rename::confirm(), "Rename"), ]; for (translated, literal) in pairs { assert_eq!(translated, literal); From 701058d2798d212f77c0ca98d4ff559f52b82585 Mon Sep 17 00:00:00 2001 From: Yoav Levavi Date: Sun, 15 Nov 2026 14:00:48 +0200 Subject: [PATCH 7/7] Track names: keep empty lanes' names in place when a segment is deleted Renumbering after a delete packed every named empty lane straight below the lanes that still hold segments, so a name on an empty lane with an unnamed empty lane beneath it slid down a row. Lanes that end up empty now keep their order and the gaps between them. Co-Authored-By: Claude Opus 5.5 --- apps/desktop-gpui/src/editor_edits.rs | 35 ++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/apps/desktop-gpui/src/editor_edits.rs b/apps/desktop-gpui/src/editor_edits.rs index ee37303a797..29d5e2887c9 100644 --- a/apps/desktop-gpui/src/editor_edits.rs +++ b/apps/desktop-gpui/src/editor_edits.rs @@ -1322,13 +1322,12 @@ fn renumber_track_names( }) .collect(); names.retain(|key, _| !key.starts_with(&prefix)); - let mut next_empty = kept_lanes.len() as u32; for (lane, name) in named { let new_lane = match kept_lanes.iter().position(|kept| *kept == lane) { - Some(position) => position as u32, + Some(position) => position, None => { - next_empty += 1; - next_empty - 1 + let kept_below = kept_lanes.iter().filter(|kept| **kept < lane).count(); + kept_lanes.len() + lane as usize - kept_below } }; names.insert(format!("{prefix}{new_lane}"), name); @@ -3372,6 +3371,34 @@ mod tests { ); } + #[test] + fn deleting_a_segment_keeps_the_gaps_between_empty_named_lanes() { + let mut project = config(serde_json::json!({ + "timeline": { + "segments": [{ "recordingSegment": 0, "timescale": 1.0, "start": 0.0, "end": 30.0 }], + "zoomSegments": [], + "audioSegments": [ + { "start": 0.0, "end": 5.0, "track": 0, "path": "voice.mp3", "name": "Voice", "duration": 5.0 }, + { "start": 6.0, "end": 9.0, "track": 0, "path": "voice.mp3", "name": "Voice", "duration": 3.0 } + ] + }, + "trackNames": { "audio:2": "Music" } + })); + assert!(delete_segments_with_names( + &mut project, + TrackKind::Audio, + &[1] + )); + assert_eq!( + project + .track_names + .iter() + .map(|(key, name)| (key.as_str(), name.as_str())) + .collect::>(), + [("audio:2", "Music")] + ); + } + #[test] fn reordering_empty_named_lanes_still_moves_their_names() { let mut names = std::collections::BTreeMap::from([