Repository navigation
fix(editor): refresh project snapshot on watch receiver updates to invalidate legacy zoom after split (#2230) - #3925
Conversation
…validate legacy zoom after split (CapSoftware#2230)
|
@cocvn157 is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
| let mut initial_config = ProjectConfiguration::default(); | ||
| initial_config.timeline = Some(TimelineConfiguration { | ||
| zoom_segments: vec![initial_zoom], | ||
| ..Default::default() |
There was a problem hiding this comment.
The new test uses ..Default::default(), but TimelineConfiguration does not implement Default. This prevents the editor's tests from compiling. Fill in the remaining fields explicitly or build the fixture with the existing JSON approach.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/editor/src/editor_instance.rs
Line: 2511
Comment:
**Editor tests cannot compile**
The new test uses `..Default::default()`, but `TimelineConfiguration` does not implement `Default`. This prevents the editor's tests from compiling. Fill in the remaining fields explicitly or build the fixture with the existing JSON approach.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| let mut snapshot = Arc::new(project_rx.borrow_and_update().clone()); | ||
| let initial = Arc::clone(&snapshot); | ||
|
|
||
| // User splits zoom into two, then adjusts the new split zoom to a new area (x: 0.75, y: 0.75) |
There was a problem hiding this comment.
Comment repeats the test setup
The added comment narrates the split and coordinate values already shown by the test. AGENTS.md explicitly bans comments that narrate code or describe the current change. Remove it before merging to satisfy that requirement; the test name and fixture already explain the case.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/editor/src/editor_instance.rs
Line: 2518
Comment:
**Comment repeats the test setup**
The added comment narrates the split and coordinate values already shown by the test. `AGENTS.md` explicitly bans comments that narrate code or describe the current change. Remove it before merging to satisfy that requirement; the test name and fixture already explain the case.
**Context Used:** AGENTS.md ([source](https://github.com/capsoftware/cap/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Thanks @cocvn157, this looks like a useful change. Before we can merge it:
Once those are sorted, request a re-review from Greptile. |
|
Thanks @richiemcilroy! Updated in 0433190 to construct |
|
Thanks so much for this, @cocvn157! On |
Fixes #2230
/claim #2230
Context and Problem
When a user splits a zoom segment into two and then adjusts the new split zoom segment to a new area (manual coordinates, mode, or zoom amount), the editor preview continued zooming into the old area from before the split.
Root Cause
In
crates/editor/src/editor_instance.rs,refresh_project_snapshotupdates the preview renderer's cached project snapshot when project configuration changes arrive over theproject_rx: watch::Receiver<ProjectConfiguration>watch channel.Previously,
refresh_project_snapshotcalledlet project = project_rx.borrow_and_update()and then checkedif !project.has_changed() { return None; }. Becauseprojectwas thewatch::Refnewly returned byborrow_and_update(), callinghas_changed()on the reference checked whether another write had arrived after that exact borrow, which evaluates to false in sequential execution. As a result:refresh_project_snapshotconsistently returnedNoneinstead of yielding the previous and updated project snapshot.EditorInstance::spawn_preview_renderernever triggeredzoom_timelines.clear()or updatedproject.ZoomTransformTimelinestate computed prior to the split, rendering frames with the legacy zoom target instead of the newly adjusted zoom area.Changes
refresh_project_snapshotincrates/editor/src/editor_instance.rsto checkif !project_rx.has_changed().unwrap_or(false) { return None; }before callingborrow_and_update(), matching the receiver check pattern used across playback and preview tasks.refresh_project_snapshotnow correctly advances the receiver, replaces the snapshot with the updated config, and returns the previous snapshot.spawn_preview_renderer,!ZoomTransformTimeline::project_inputs_match(&previous, &project, screen_size)correctly evaluates to true on zoom splits and adjustments, clearing cached zoom timelines and precomputing with the new target parameters.preview_project_snapshot_detects_zoom_split_and_area_adjustmentverifying that splitting a zoom and modifying coordinates triggers snapshot updates and signals project input changes.

Confidence Score: 5/5
The PR appears safe to merge, with both previous findings fixed and no new actionable issues found.Summary
Updates the preview's saved project settings so zoom edits clear the old zoom timelines.
Tests were not run.
Reviews (3) · Last reviewed commit: "test(editor): construct TimelineConfigur..." · Reviewed by Greptile