Skip to content

feat(gpui): platform safe zones on the preview - #2782

Open
YoavLevavi wants to merge 7 commits into
CapSoftware:mainfrom
YoavLevavi:feat/gpui-safe-zones
Open

YoavLevavi wants to merge 7 commits into
CapSoftware:mainfrom
YoavLevavi:feat/gpui-safe-zones

Conversation

@YoavLevavi

@YoavLevavi YoavLevavi commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

GPUI port of #2380.

A toolbar button cycles Off / Reels / TikTok / Shorts and shades the parts of a portrait preview that the platform's UI covers (captions, buttons, account row). Only shown for portrait output (width/height ≤ 0.7). Insets are guidance for a 1080x1920 frame.

Testing: new unit tests in editor_window/safe_zones.rs, cargo check in apps/desktop-gpui.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; both previous findings are addressed.

Summary

Adds preview-only safe zones for Reels, TikTok, and Shorts on portrait output.

  • Portrait previews can show where Reels, TikTok, and Shorts cover a video.

Reviews (2) · Last reviewed commit: "Safe zones: lay the guides out from the ..." · Reviewed by Greptile

A toolbar button cycles Off / Reels / TikTok / Shorts and shades the
parts of a portrait preview that the platform's UI covers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

@YoavLevavi is attempting to deploy a commit to the Cap Software Inc Team on Vercel.

A member of the Team first needs to authorize it.

@YoavLevavi

Copy link
Copy Markdown
Contributor Author
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@richiemcilroy

Copy link
Copy Markdown
Member

Thanks for the GPUI port @YoavLevavi, keeping this preview-only and out of the project config is the right call. Two small things: 1) apps/desktop-gpui/src/editor_window/safe_zones.rs:68 the button is always visible, so on a 16:9 project it toggles to a pressed "Reels" state while safe_zone_rect returns None and nothing is drawn. Please hide the button (or disable it with a "Portrait output only" tooltip) when the output isn't portrait, which matches the PR description. 2) safe_zones.rs:102 uses hard-coded hsla values for the shade, border and label. Please pull these from theme.editor so the overlay matches the rest of the editor chrome. Thanks!

The button is hidden when the output isn't portrait, so it can no longer sit
in a pressed state that draws nothing. The overlay's shade, border and label
come from theme.editor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@richiemcilroy

Copy link
Copy Markdown
Member

Thanks @YoavLevavi, both points are addressed: the Safe zones toggle only shows for portrait output and the overlay uses the theme colours now. This looks good to go. One tiny thing before merge: the Some(ui::EditorButton::plain(...)) block around apps/desktop-gpui/src/safe_zones.rs:89 isn't rustfmt-formatted (our CI's cargo fmt --check only covers the root workspace, so it doesn't flag apps/desktop-gpui). Could you run cargo fmt inside apps/desktop-gpui and push? Thanks!

@YoavLevavi

Copy link
Copy Markdown
Contributor Author

Thanks @richiemcilroy, both addressed in 348faa8:

  1. The button only appears when the output is portrait, so it can no longer sit pressed while drawing nothing.
  2. The shade, border and label now come from theme.editor (playhead, accent, card/text_1).
@richiemcilroy

Copy link
Copy Markdown
Member

@greptileai review

Comment on lines +107 to +113
let player = self.player_frame_rect.get()?;
let (fw, fh) = (
f32::from(player.frame.size.width),
f32::from(player.frame.size.height),
);
let origin_x = player.frame.origin.x - player.container.origin.x;
let origin_y = player.frame.origin.y - player.container.origin.y;

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 Guides keep old preview bounds

render_safe_zone_overlay sizes its guides from the previous paint's player_frame_rect. When the preview changes size, these fixed pixel bounds are built before PreviewFrameView paints and updates the rectangle. That update does not request another render, so the guides can stay out of line with the video until another editor update. Calculate the guides from the current layout bounds instead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/editor_window/safe_zones.rs
Line: 107-113

Comment:
**Guides keep old preview bounds**

`render_safe_zone_overlay` sizes its guides from the previous paint's `player_frame_rect`. When the preview changes size, these fixed pixel bounds are built before `PreviewFrameView` paints and updates the rectangle. That update does not request another render, so the guides can stay out of line with the video until another editor update. Calculate the guides from the current layout bounds instead.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Comment on lines +74 to +75
/// The button only exists for portrait output; on any other aspect there
/// is nothing for it to draw.

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 the code

The new comment above render_safe_zone_button only repeats its portrait check. AGENTS.md requires comments to explain non-obvious context, not narrate what the code does. Remove this comment and the similar description above safe_zone_rect before merging to satisfy that requirement. Keep the useful explanation of the platform inset assumptions.

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_window/safe_zones.rs
Line: 74-75

Comment:
**Comments repeat the code**

The new comment above `render_safe_zone_button` only repeats its portrait check. `AGENTS.md` requires comments to explain non-obvious context, not narrate what the code does. Remove this comment and the similar description above `safe_zone_rect` before merging to satisfy that requirement. Keep the useful explanation of the platform inset assumptions.

**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

Thanks @YoavLevavi. After updating the branch with main, Greptile's review came back 4/5 with two points, and both are fair:

  1. In apps/desktop-gpui/src/editor_window/safe_zones.rs (around 107-113), render_safe_zone_overlay sizes the guides from the previous paint's player_frame_rect. When the preview resizes, the guides are built before PreviewFrameView updates that rect, and nothing triggers another render, so they can sit out of line with the video until the next editor update. Please compute the guide bounds from the current layout, for example by letting the overlay size itself relative to the preview element in the same layout pass rather than using cached pixel bounds.
  2. Please remove the comments above render_safe_zone_button and safe_zone_rect that just describe the code (AGENTS.md comment policy). The explanation of the platform inset assumptions is useful, so keep that one.

Once those are pushed, mention @greptileai to re-review. It needs 5/5 with green CI for us to merge. Thanks!

@greptile-apps

greptile-apps Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Both points are valid: the overlay uses cached player_frame_rect bounds, and the comments above render_safe_zone_button and safe_zone_rect just restate the code. Keep the platform-inset explanation.

I can’t edit or push the branch from this review thread—the available repository tools are read-only. Please make those changes and push them; then ping @greptileai for a re-review. I also can’t verify CI from here.

YoavLevavi and others added 2 commits October 25, 2026 16:29
The overlay is a canvas that fits the frame inside its own bounds during
paint, with the same preview_frame_bounds the preview uses, so the guides
follow a resize in the same frame instead of last paint's rect. Drops the
comments that restated the code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@YoavLevavi

Copy link
Copy Markdown
Contributor Author

Thanks @richiemcilroy, both are done in 6b06aaa (on top of your merge and the latest main):

  1. The guides are now a canvas that fits the frame inside its own bounds during paint, using the same preview_frame_bounds that PreviewFrameView now uses (the letterbox maths moved into it). They follow a resize in the same layout pass instead of reading the last paint's rect. There's a test for preview_frame_bounds.
  2. I removed the comments above render_safe_zone_button and safe_zone_rect (and one above the shade colour), and kept the platform-inset explanation. apps/desktop-gpui is rustfmt-clean for these files.

@greptileai review

# Conflicts:
#	apps/desktop-gpui/src/assets.rs
@vercel

vercel Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

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

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Oct 31, 2026 10:02pm UTC

This branch was previously deployed

1 inactive deployment
Preview – cap-status — b135a495 Deployed Oct 31, 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

2 participants