Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(desktop-gpui): skip history entries for reverted drags
Aditya Garudbe0d108dd9a6
diff --git a/apps/desktop-gpui/README.md b/apps/desktop-gpui/README.mdindex e54d9bbb3..e3c2c0853 100644--- a/apps/desktop-gpui/README.md+++ b/apps/desktop-gpui/README.md@@ -1845,7 +1845,7 @@ its baseline values, every drag and delete having been undone.| **Clips cannot be reordered, and their body drag does nothing** | The clip body's 4px drag is a **crossfade-duration** drag, not a move (`TL/ClipTrack.tsx:849-945`) — it grows the incoming transition and selects it. Transitions have no drawn affordance in this rev (E3 renders their effect on the boxes but not the handle or the marker), so the press only ever selects. Reordering exists in the shipping app but **not on the timeline**: it is the Clips layout mode's list (`ClipsSidebar.tsx:650`, behind the header's Clips button), which is its own unit. || **The 3D track's split is not reproduced** | `splitCamera3DSegment` rebuilds both halves' nine pose tracks around the pose the segment held at the cut (`ED/context.ts:640-676`), which needs the keyframe evaluator. Splitting a 3D segment is refused rather than done wrongly; every other track's split is real. || **Only the zoom track creates by click** | The mask, text and audio tracks also add a segment when their empty lane is clicked (`TL/MaskTrack.tsx:120-184` and siblings), each with its own gap-finding placement and default segment. Those are creation flows for objects the sidebar has to configure; the zoom track's is here because its ghost was already drawn. The sidebar now configures all four, so the remaining three are a timeline-side gap rather than a dependency — each needs its own gap-finding placement and default segment, and the mask track's also has to seed a rect on the canvas. |-| **A no-op drag records no undo entry** | The source pushes a history entry on *every* `resume`, because the tracked memo re-runs when `pauseCount` changes — so a click that selected and never moved leaves a duplicate snapshot behind, and the first undo after one appears to do nothing. Here the resume only records when something actually changed during the bracket. |+| **A no-op drag records no undo entry** | The source pushes a history entry on *every* `resume`, because the tracked memo re-runs when `pauseCount` changes — so a click that selected and never moved leaves a duplicate snapshot behind, and the first undo after one appears to do nothing. Here the resume only records when the project ends up different from where the bracket started, so a drag that comes back to its starting value records nothing either. || **No context menus** | Right-clicking a segment opens a real `Menu.popup()` with "Select all" and "Delete" (`TL/ZoomTrack.tsx:544-595`), and the zoom track's own dev-only "Generate zoom segments from clicks". None is reproduced. || **No double-click fill** | Double-clicking a zoom or scene handle expands the segment as far as it can go in that direction (`fillStart`/`fillEnd`, `TL/ZoomTrack.tsx:353-399`). gpui delivers `click_count`, but the behaviour is not wired. || **`normalizeClipTransitions` is a no-op** | `onHandleReleased` re-clamps every transition against its clips after a trim; here `effective_transition` already clamps on every read, so the stored value is left alone. The viewport half of `onHandleReleased` — pulling the transform back when a trim shortens the project out from under it — *is* reproduced. |diff --git a/apps/desktop-gpui/src/editor_edits.rs b/apps/desktop-gpui/src/editor_edits.rsindex 5a81bf8b4..8206e376b 100644--- a/apps/desktop-gpui/src/editor_edits.rs+++ b/apps/desktop-gpui/src/editor_edits.rs@@ -198,6 +198,13 @@ impl ProjectHistory {pub fn resume(&mut self, config: &ProjectConfiguration) {self.paused = self.paused.saturating_sub(1);if self.paused == 0 && std::mem::take(&mut self.dirty) {+ let current = &self.entries[self.entries.len() - self.count - 1];+ if matches!(+ (serde_json::to_value(current), serde_json::to_value(config)),+ (Ok(before), Ok(after)) if before == after+ ) {+ return;+ }self.record(config);}}@@ -2995,6 +3002,34 @@ mod tests {assert!(!clean.can_undo());}+ #[test]+ fn a_drag_returning_to_its_start_keeps_undo_and_redo_unchanged() {+ let initial = ProjectConfiguration::default();+ let mut moved = initial.clone();+ moved.background.padding += 1.0;+ let mut future = initial.clone();+ future.background.padding += 2.0;+ let mut history = ProjectHistory::new(initial.clone());+ history.pause();+ history.record(&moved);+ history.record(&initial);+ history.resume(&initial);+ assert_eq!(history.depth(), 1);+ assert!(!history.can_undo());++ history.record(&future);+ history.undo();+ history.pause();+ history.record(&moved);+ history.record(&initial);+ history.resume(&initial);+ assert!(history.can_redo());+ assert_eq!(+ history.redo().unwrap().background.padding,+ future.background.padding+ );+ }+#[test]fn the_stack_is_capped_at_a_hundred_entries() {let mut history = ProjectHistory::new(with_zoom_count(0));