Skip to content

fix(desktop-gpui): movable manual captions, area aspect ratio lock, playhead clamp after shortening edits - #3230

Merged
richiemcilroy merged 4 commits into
mainfrom
fix/gpui-editor-0-6-1-reports
Oct 25, 2026
Merged

richiemcilroy merged 4 commits into
mainfrom
fix/gpui-editor-0-6-1-reports

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

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 wrote manual_position, so the renderer fell back to bottom-centre and there was no control to change it.

  • Switching to Manual now starts from the preset's spot (set_caption_position, matching captionPositionCenter in the Tauri CaptionsTab.tsx), so the captions don't jump.
  • When Manual is selected, the panel shows "Horizontal Position" and "Vertical Position" sliders (0 to 100 % of the frame). Moving either one on a preset switches it to Manual from the preset's spot (set_caption_manual_center).
  • The renderer already places and clamps 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.

  • Drawing keeps the ratio from the anchor in any direction, and the longest span wins (area_from_anchor_with_ratio).
  • Corner resizes keep the opposite corner. Edge resizes keep the opposite edge and the centre line (area_edge_resize_with_ratio).
  • Choosing a ratio reshapes the current area around its centre (area_with_ratio).
  • The area always stays on the display; it shrinks rather than leaving it.

Playhead left past the end after deleting a clip (Windows 0.6.1 log: 223 Preview renderer: no segment found after a delete). The engine-side flood was fixed by #2750. GPUI still left its own playhead and clock past the new end. rebuild_timeline now seeks back to the end when an edit shortens the timeline past the playhead, as setPlayhead does in the Tauri editor.

flowchart LR
    E[edit_project] --> R[rebuild_timeline]
    R -->|"playhead > total"| S["apply_seek(total)"]
Loading

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)

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with two non-blocking caption-placement issues remaining from earlier findings.

Findings

  1. P2 Editors share caption positions ▶
  2. P2 Bounce moves captions twice ▶
Fix with agent prompt
### Issue 1
crates/rendering/src/layers/captions.rs:109-110
`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.

### Issue 2
crates/rendering/src/layers/captions.rs:undefined-1017
`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.

Summary

The PR adds manual caption sliders, remembered area ratios, and a playhead clamp after shortening edits.

  • Manual captions start at the preset's spot and can be moved.
  • The area picker keeps selections at a chosen screen ratio.
  • The playhead returns to the new timeline end after shortening edits.

Reviews (4) · Last reviewed commit: "fix(desktop-gpui): start Manual captions..." · Reviewed by Greptile

…layhead back to the end after a shortening edit
@vercel

vercel Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cap-status Ready Ready Preview Oct 25, 2026 12:09pm UTC

@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

Comment on lines +468 to +472
"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),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/desktop-gpui/src/target_overlay.rs Outdated
Comment on lines +600 to +605
let mut width = (pointer.0 - anchor).abs();
let room_x = if handle.west() {
anchor
} else {
display.0 - anchor
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

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.

Comment thread apps/desktop-gpui/src/editor_tabs.rs Outdated
}
}

/// The manual caption centre: the stored one, else the preset's.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

Comment on lines +109 to +110
static LAST_CAPTION_CENTER: std::sync::Mutex<Option<(CaptionPosition, [f32; 2])>> =
std::sync::Mutex::new(None);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

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.

@richiemcilroy
richiemcilroy marked this pull request as ready for review October 25, 2026 18:27
@richiemcilroy
richiemcilroy merged commit a8e23af into main Oct 25, 2026
55 checks passed

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found 2 potential issues (2 medium).

View 2 other findings in Capy.

Open in Capy

Comment on lines +109 to +110
static LAST_CAPTION_CENTER: std::sync::Mutex<Option<(CaptionPosition, [f32; 2])>> =
std::sync::Mutex::new(None);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Capy

];

self.active_layout = Some(CaptionOverlayLayout { rect, position });
record_caption_center(position, rect, (width, height));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Capy

This branch was successfully deployed

2 active deployments
Preview – cap-web — 0deb2368 Deployed Oct 25, 2026 by vercel[bot]
Preview – cap-status — 0deb2368 Deployed Oct 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant