Skip to content

feat(desktop-gpui): copy and paste text segment styles from the timeline menu - #2822

Merged
richiemcilroy merged 7 commits into
CapSoftware:mainfrom
chrvasile:chrvasile/text-style-copy-paste
Oct 24, 2026
Merged

richiemcilroy merged 7 commits into
CapSoftware:mainfrom
chrvasile:chrvasile/text-style-copy-paste

Conversation

@chrvasile

@chrvasile chrvasile commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

There was no way to carry a text segment's look over to another one. The only options were redoing every setting by hand or picking a preset, so a project with several captions that should match took a lot of repeated clicks.

Now right-clicking a text segment on the timeline opens a menu with Copy style, Paste style and Delete text segment. Paste copies the font, size, weight, italic, uppercase, alignment, letter spacing, line height, colour, background, outline, glow, shadow, opacity and the in/out animations with their durations. Content, timing, lane, position and layout stay with the target, and the box rescales from its top edge the way presets already do. Right-clicking a segment that's part of a multi-selection pastes onto the whole selection. The copied style lives in the editor window only and doesn't touch the system clipboard.

The menu reuses the clip popover's card and rows at a narrower width, and adds Lucide's clipboard-paste glyph next to the existing copy and trash icons. Paste is dimmed with a hint until something has been copied.

Screenshots:
Screenshot 2026-10-21 at 13 13 47
Screenshot 2026-10-21 at 13 13 51

Three tests cover that the paste keeps content, timing, position and layout, that the box scales about its top edge, and that pasting a style back onto its own source changes nothing.

Validation

  • cargo fmt -p cap-desktop-gpui
  • cargo check -p cap-desktop-gpui
  • cargo test -p cap-desktop-gpui editor_panels::tests: 36 passed
  • cargo clippy -p cap-desktop-gpui --bin cap-gpui -- -D warnings: no new warnings in the touched files
  • git diff --check
  • Verified by hand on macOS: copy and paste between segments, paste onto a multi-selection, paste disabled before a copy, menu closing on backspace and undo, single Cmd+Z after a no-op paste

How this was made

The change was written with Claude Code, reviewed with Codex, with a design decision review, fixes, and manual testing done by me.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with all previous findings addressed and no new actionable issues found.

Summary

Adds Copy style and Paste style to the timeline menu for text segments.

  • Text segments can copy and paste styles from the timeline menu.

Reviews (5) · Last reviewed commit: "chore(desktop-gpui): trim the track_cont..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@chrvasile

Copy link
Copy Markdown
Contributor Author

@richiemcilroy Hey there, big fan and user of Cap. As I was using it today, I realised something that was annoying me, and I submitted here a suggestion. I'm new to OSS and I hope I've done this the right way and that you're willing to take a look at this. Thank you!

@richiemcilroy

Copy link
Copy Markdown
Member

@greptileai review

Comment thread apps/desktop-gpui/src/editor_panels.rs Outdated
let previous_style = Self::of(segment);
let previous_center = segment.center;
let previous_size = segment.size;
scale_text_box(segment, self.font_size);

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 Unchanged paste adds undo

TextStyle::apply_to rescales the box even when the font size is unchanged. With center.y = 0.9 and size.y = 0.4, the calculation changes center.y to 0.8999999999999999. Pasting a style back onto its source then returns true and adds an undo step despite making no visible change.

Skip scale_text_box when the font sizes match, and add this case to the no-op test.

Suggested change
scale_text_box(segment, self.font_size);
if segment.font_size != self.font_size {
scale_text_box(segment, self.font_size);
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/editor_panels.rs
Line: 733

Comment:
**Unchanged paste adds undo**

`TextStyle::apply_to` rescales the box even when the font size is unchanged. With `center.y = 0.9` and `size.y = 0.4`, the calculation changes `center.y` to `0.8999999999999999`. Pasting a style back onto its source then returns `true` and adds an undo step despite making no visible change.

Skip `scale_text_box` when the font sizes match, and add this case to the no-op test.

```suggestion
        if segment.font_size != self.font_size {
            scale_text_box(segment, self.font_size);
        }
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@richiemcilroy

Copy link
Copy Markdown
Member

Hey @chrvasile, thanks for this, copy and paste for text styles is a really nice quality-of-life addition and the no-op test is a good touch.

Greptile's one finding this round is valid: TextStyle::apply_to (apps/desktop-gpui/src/editor_panels.rs:733) always calls scale_text_box, even when the font size is unchanged. With a scale of 1.0 the top-edge round trip in scale_text_box (center.y - size.y / 2. then + size.y / 2.) can still change center.y by a rounding error (for example 0.9 becomes 0.8999999999999999 with size.y = 0.4), so pasting a style onto its own source returns true and adds an undo step with no visible change. Greptile's suggestion is the right fix: only call scale_text_box(segment, self.font_size) when segment.font_size != self.font_size, and add that center.y = 0.9, size.y = 0.4 case to the no-op test.

After pushing, could you comment @greptileai review so it re-scores the latest commit? Thanks!

@chrvasile

Copy link
Copy Markdown
Contributor Author

@greptileai review

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks @chrvasile, the font size check in TextStyle::apply_to is exactly right, and the extra center.y = 0.9, size.y = 0.4 case in pasting_a_text_style_onto_its_own_source_changes_nothing covers it nicely. One thing before we can run CI: the branch now conflicts with main in apps/desktop-gpui/src/editor_panels.rs. Main added a new test, unchanged_timing_fields_preserve_redo, at the top of the same mod tests block where your three tests go, so it is only a keep-both resolution. Could you rebase onto (or merge) the latest main, keep both sets of tests, and push? Once it merges cleanly we'll approve the workflows and take it from there.

…copy-paste

# Conflicts:
#	apps/desktop-gpui/src/editor_panels.rs
@chrvasile

Copy link
Copy Markdown
Contributor Author

@greptileai review

Comment thread apps/desktop-gpui/src/editor_panels.rs Outdated
Comment on lines +671 to +674
/// The look of one text segment, lifted off it by "Copy Style" on the
/// timeline. Content, timing, lane, position and layout stay with the target
/// when it is pasted; the box is rescaled with the font size the same way a
/// preset does it.

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 Comment repeats the feature

The new TextStyle overview describes the feature and repeats what its methods do. AGENTS.md allows comments for non-obvious context and explicitly bans comments that describe the change being made. Remove this overview, or keep only a specific invariant that the code cannot explain. This repository requirement must be satisfied before merging.

Suggested change
/// The look of one text segment, lifted off it by "Copy Style" on the
/// timeline. Content, timing, lane, position and layout stay with the target
/// when it is pasted; the box is rescaled with the font size the same way a
/// preset does it.

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_panels.rs
Line: 671-674

Comment:
**Comment repeats the feature**

The new `TextStyle` overview describes the feature and repeats what its methods do. `AGENTS.md` allows comments for non-obvious context and explicitly bans comments that describe the change being made. Remove this overview, or keep only a specific invariant that the code cannot explain. This repository requirement must be satisfied before merging.

```suggestion

```

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

chrvasile and others added 2 commits October 23, 2026 20:05
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chrvasile

Copy link
Copy Markdown
Contributor Author

@greptileai review

Comment thread apps/desktop-gpui/src/editor_window.rs Outdated
Comment on lines +7924 to +7926
/// the segment unless it is already part of the selection, then open its
/// menu at the pointer. Clips get the speed popover, text segments the
/// Copy / Paste Style menu; other tracks have no context menu, and split

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 Comment repeats the menu behavior

The added description above track_context_menu repeats what the function does. AGENTS.md bans comments that narrate behavior or describe the current change. Remove the added narration; keep only non-obvious context. This repository requirement must be satisfied before merging.

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.rs
Line: 7924-7926

Comment:
**Comment repeats the menu behavior**

The added description above `track_context_menu` repeats what the function does. `AGENTS.md` bans comments that narrate behavior or describe the current change. Remove the added narration; keep only non-obvious context. This repository requirement must be satisfied before merging.

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

…original note

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chrvasile

Copy link
Copy Markdown
Contributor Author

@greptileai review

@chrvasile

Copy link
Copy Markdown
Contributor Author

Thanks @richiemcilroy, and apologies for the back and forth. I think it's all fixed now.

@richiemcilroy
richiemcilroy merged commit 8127c1a into CapSoftware:main Oct 24, 2026
38 of 40 checks passed
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.

2 participants