Repository navigation
fix(desktop-gpui): movable manual captions, area aspect ratio lock, playhead clamp after shortening edits - #3230
Conversation
…layhead back to the end after a shortening edit
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@greptileai review |
| "top-left" => (0.05, 0.08), | ||
| "top-center" | "top" => (0.5, 0.08), | ||
| "top-right" => (0.95, 0.08), | ||
| "bottom-left" => (0.05, 0.85), | ||
| "bottom-right" => (0.95, 0.85), |
There was a problem hiding this comment.
Switching a left- or right-aligned caption to Manual still moves it. caption_position_center treats 5% and 95% as the caption’s centre, but the renderer uses those values for its outer edge. A 400-pixel caption on a 1920-pixel frame moves from a 96-pixel left margin to the frame’s edge. Seed Manual from the rendered box centre rather than its edge.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/editor_tabs.rs
Line: 468-472
Comment:
**Captions jump when switching**
Switching a left- or right-aligned caption to Manual still moves it. `caption_position_center` treats 5% and 95% as the caption’s centre, but the renderer uses those values for its outer edge. A 400-pixel caption on a 1920-pixel frame moves from a 96-pixel left margin to the frame’s edge. Seed Manual from the rendered box centre rather than its edge.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Kept as is, with the comment corrected. The renderer draws left and right presets from a 5% margin, and the box width needed to centre them exactly only exists inside the renderer's text layout, which the editor does not run. The seed matches the previous editor's captionPositionCenter, centred presets keep their spot exactly, and the new sliders move it from there.
There was a problem hiding this comment.
Fixed properly now: the captions layer records the centre of the box it last drew, as fractions of the frame, with the position it was drawn for (cap_rendering::last_caption_center). Switching to Manual starts from that drawn centre, so a left or right preset keeps its margin; the preset table is only the fallback when nothing has been drawn yet.
| let mut width = (pointer.0 - anchor).abs(); | ||
| let room_x = if handle.west() { | ||
| anchor | ||
| } else { | ||
| display.0 - anchor | ||
| }; |
There was a problem hiding this comment.
Dragging an edge past its opposite edge makes the selection grow away from the pointer. area_edge_resize_with_ratio takes the absolute distance but keeps the original direction. With a square starting at x = 400, dragging its east edge to x = 300 puts that edge at x = 500. Choose the direction and available space from the pointer’s side of the anchor, as the corner resize already does. The vertical branch has the same problem.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/target_overlay.rs
Line: 600-605
Comment:
**Selection grows the wrong way**
Dragging an edge past its opposite edge makes the selection grow away from the pointer. `area_edge_resize_with_ratio` takes the absolute distance but keeps the original direction. With a square starting at `x = 400`, dragging its east edge to `x = 300` puts that edge at `x = 500`. Choose the direction and available space from the pointer’s side of the anchor, as the corner resize already does. The vertical branch has the same problem.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| } | ||
| } | ||
|
|
||
| /// The manual caption centre: the stored one, else the preset's. |
There was a problem hiding this comment.
Comments repeat straightforward code
The comment above caption_manual_center repeats its name and short implementation. AGENTS.md explicitly forbids comments that narrate code or paraphrase parameter names. The comments above set_caption_manual_center and on ManualX and ManualY repeat this pattern. Remove this narration before merging to satisfy the repository requirement. Keep comments that explain a non-obvious bug or constraint.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/editor_tabs.rs
Line: 477
Comment:
**Comments repeat straightforward code**
The comment above `caption_manual_center` repeats its name and short implementation. `AGENTS.md` explicitly forbids comments that narrate code or paraphrase parameter names. The comments above `set_caption_manual_center` and on `ManualX` and `ManualY` repeat this pattern. Remove this narration before merging to satisfy the repository requirement. Keep comments that explain a non-obvious bug or constraint.
**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!
…cross the opposite edge
|
@greptileai review |
|
@greptileai review |
| static LAST_CAPTION_CENTER: std::sync::Mutex<Option<(CaptionPosition, [f32; 2])>> = | ||
| std::sync::Mutex::new(None); |
There was a problem hiding this comment.
Editors share caption positions
LAST_CAPTION_CENTER is shared by every editor, and last_caption_center checks only the preset. With two projects open, a caption drawn in one window can overwrite the centre used when the other window switches to Manual. That saves a position based on the wrong caption box. Keep the measured centre with its editor or renderer instead of in a process-wide value.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/rendering/src/layers/captions.rs
Line: 109-110
Comment:
**Editors share caption positions**
`LAST_CAPTION_CENTER` is shared by every editor, and `last_caption_center` checks only the preset. With two projects open, a caption drawn in one window can overwrite the centre used when the other window switches to Manual. That saves a position based on the wrong caption box. Keep the measured centre with its editor or renderer instead of in a process-wide value.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| ]; | ||
|
|
||
| self.active_layout = Some(CaptionOverlayLayout { rect, position }); | ||
| record_caption_center(position, rect, (width, height)); |
There was a problem hiding this comment.
record_caption_center saves the box centre after bounce_offset has been added. If the user pauses during a Bounce animation and chooses Manual, that temporary offset becomes part of manual_position. The next render adds the bounce again, so the caption jumps and keeps an unwanted vertical offset afterward. Save the centre before the animation offset is added.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/rendering/src/layers/captions.rs
Line: 1017
Comment:
**Bounce moves captions twice**
`record_caption_center` saves the box centre after `bounce_offset` has been added. If the user pauses during a Bounce animation and chooses Manual, that temporary offset becomes part of `manual_position`. The next render adds the bounce again, so the caption jumps and keeps an unwanted vertical offset afterward. Save the centre before the animation offset is added.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| static LAST_CAPTION_CENTER: std::sync::Mutex<Option<(CaptionPosition, [f32; 2])>> = | ||
| std::sync::Mutex::new(None); |
There was a problem hiding this comment.
Caption positions leak between editor instances
Medium Severity
Open two projects with bottom-left captions of different widths, leave the first paused, and render captions in the second. Switching the first project's position to Manual reads the second project's center: AppWindows allows multiple editors, but this process-wide cache checks only CaptionPosition. The first caption consequently jumps and saves coordinates measured for another project. Keep the measured center with its editor/render instance and retrieve that instance's layout when switching to Manual.
| ]; | ||
|
|
||
| self.active_layout = Some(CaptionOverlayLayout { rect, position }); | ||
| record_caption_center(position, rect, (width, height)); |
There was a problem hiding this comment.
Switching to Manual applies the Bounce offset twice
Medium Severity
Pause a preset-positioned caption during its Bounce entrance or exit, then select Manual. The recorded rect already includes bounce_offset, so set_caption_position_from persists that animated center as manual_position. The next CaptionsLayer::prepare adds the same offset again, causing an immediate jump and leaving a permanent vertical displacement after the animation finishes. Record the unanimated placement center rather than the animated draw rectangle.
Three GPUI editor and picker problems from 0.6.1 support threads and logs.
Manual captions could not be moved (Discord support, macOS). Picking "Manual" only set
position = "manual". Nothing in GPUI ever wrotemanual_position, so the renderer fell back to bottom-centre and there was no control to change it.set_caption_position, matchingcaptionPositionCenterin the TauriCaptionsTab.tsx), so the captions don't jump.set_caption_manual_center).manual_position(crates/rendering/src/layers/captions.rs).No aspect ratio for area selection (Discord support: "in an earlier release there was an option to set a specific aspect ratio when selecting an area"). The area toolbar now has a ratio button beside the size readout. It cycles Free, 16:9, 4:3, 1:1, 9:16, 16:10, 21:9, 3:2 and 2:1, and the choice is remembered.
area_from_anchor_with_ratio).area_edge_resize_with_ratio).area_with_ratio).Playhead left past the end after deleting a clip (Windows 0.6.1 log: 223
Preview renderer: no segment foundafter a delete). The engine-side flood was fixed by #2750. GPUI still left its own playhead and clock past the new end.rebuild_timelinenow seeks back to the end when an edit shortens the timeline past the playhead, assetPlayheaddoes in the Tauri editor.flowchart LR E[edit_project] --> R[rebuild_timeline] R -->|"playhead > total"| S["apply_seek(total)"]Tests:
manual_caption_position_starts_at_the_preset_and_moves(editor_tabs.rs)a_drawn_area_keeps_the_chosen_aspect_ratio,resizing_an_area_keeps_the_chosen_aspect_ratio(every handle, pointers on all sides and past the display),choosing_a_ratio_reshapes_the_area_around_its_centre(target_overlay.rs)a_shortened_timeline_brings_the_playhead_back_to_its_end(editor_window.rs)

Confidence Score: 5/5
The PR appears safe to merge, with two non-blocking caption-placement issues remaining from earlier findings.Findings
Fix with agent prompt
Summary
The PR adds manual caption sliders, remembered area ratios, and a playhead clamp after shortening edits.
Reviews (4) · Last reviewed commit: "fix(desktop-gpui): start Manual captions..." · Reviewed by Greptile