Skip to content

feat(gpui): drag music from the library onto the timeline - #2848

Open
YoavLevavi wants to merge 4 commits into
CapSoftware:mainfrom
YoavLevavi:feat/gpui-library-drag
Open

YoavLevavi wants to merge 4 commits into
CapSoftware:mainfrom
YoavLevavi:feat/gpui-library-drag

Conversation

@YoavLevavi

@YoavLevavi YoavLevavi commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Drag music from the audio library onto the timeline.

  • Library rows are draggable (gpui on_drag) with a small chip preview. Clicking still adds at the playhead as before.
  • Every timeline row is a drop target. On an audio lane the track lands on that lane; anywhere else it gets a new lane. It starts at the time under the pointer instead of the playhead.
  • The drop goes through the existing import request and generation checks. The drop time is tied to that request's generation, so a stale drop can't place a later import. Dragging is off while the picker is replacing a segment.

Testing: cargo test --bin cap-gpui, clippy clean on the touched files.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with the previous finding addressed and no new findings.

Summary

The PR lets users drag library music onto the timeline.

  • Library tracks land where users drop them on the timeline.

Reviews (2) · Last reviewed commit: "Library drag: drop comments that restate..." · Reviewed by Greptile

A library row can be dragged onto the timeline: dropped on an audio lane it
lands there, anywhere else it gets a new lane, and it starts at the time
under the pointer instead of the playhead.

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

Copy link
Copy Markdown
Contributor Author

@greptileai

@vercel

vercel Bot commented Oct 21, 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.

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks @YoavLevavi, dragging music onto the timeline feels natural, and routing the drop through the existing import request and generation checks is the right call. The drop time doesn't survive the clamp in commit_audio_import, though: length is capped at the project duration, and then start is clamped to max_start = (total - length).max(0.0) (apps/desktop-gpui/src/editor_window.rs:7775). The bundled library tracks run 78 s to 189 s, so on any recording shorter than the track, max_start is 0 and a drop anywhere lands at 0:00. On longer projects it gets pulled back to total - length. Could you keep the dropped start and shorten the segment to fit when a drop time is given, e.g. start = dropped.clamp(0.0, (total - MIN_AUDIO_SEGMENT_DURATION).max(0.0)) and length = length.min(total - start)? A test for a drop at mid-project with a track longer than the project would cover it. Also, if the copy fails, audio_drop_start is never cleared (it is only taken on the success path at editor_window.rs:5561), and the picker stays open with the same generation. A later click on a library row then lands at the old drop time instead of the playhead. Please clear it on the error and Ok(None) paths too.

YoavLevavi and others added 2 commits October 25, 2026 17:27
- audio_import_placement keeps a dropped track's start (pulled in only far
  enough to leave a minimum segment) and shortens it to end with the
  project, instead of sliding it back to 0:00 when the track is longer than
  the project. Picker imports still start at the playhead and slide to fit.
- finish_audio_import takes audio_drop_start on every path, so a failed or
  empty copy can't make a later click land at the old drop time.

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

Copy link
Copy Markdown
Contributor Author

Thanks @richiemcilroy, both are in 7431f96 (also merged main):

  1. Drop time. Placement moved into audio_import_placement. A drop keeps its start (clamped to total - MIN_AUDIO_SEGMENT_DURATION) and shortens the segment to end with the project. Picker imports still start at the playhead and slide back to fit. a_dropped_track_keeps_its_drop_time_and_is_cut_to_fit covers a 120s track dropped mid-way into a 60s project, a drop near the end, a short track and the picker path.
  2. Stale drop time. finish_audio_import now takes audio_drop_start at the top, on every path (stale, error, Ok(None), success), so a failed copy can't make a later click land at the old drop time.

@greptileai review

Comment thread apps/desktop-gpui/src/editor_audio.rs Outdated
this.add_library_track(id, name, window, cx);
}))
})
// Drag the row onto a timeline lane to add the track where it lands.

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

This comment repeats what the next on_drag call does. AGENTS.md prohibits comments that merely describe the code or the current change. Remove it and the similar descriptions above LibraryDrag and LibraryDragPreview to satisfy that requirement 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_audio.rs
Line: 302

Comment:
**Comments repeat the code**

This comment repeats what the next `on_drag` call does. `AGENTS.md` prohibits comments that merely describe the code or the current change. Remove it and the similar descriptions above `LibraryDrag` and `LibraryDragPreview` to satisfy that requirement 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!

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks! Can you get Greptile to 5/5? Then we'll take a look.

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

Copy link
Copy Markdown
Contributor Author

@greptile-apps review

@richiemcilroy

Copy link
Copy Markdown
Member

Thanks! Can you add a screenshot or short video showing it working?

This branch has not been deployed

No deployments
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