Skip to content

Conversation

@estib-vega
Copy link
Contributor

@estib-vega estib-vega commented Feb 3, 2026

Add a drop handler that initiates the commit process, staging the
dragged changes.

Screen.Recording.2026-02-03.at.14.58.01.mov

This is part 1 of 2 in a stack made with GitButler:

Copilot AI review requested due to automatic review settings February 3, 2026 12:56
@vercel
Copy link

vercel bot commented Feb 3, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Feb 3, 2026 5:13pm

Request Review

@estib-vega
Copy link
Contributor Author

cc @PavelLaptev

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds the ability to drag uncommitted changes (files, folders, or hunks) to a branch card to initiate the commit process. The dropped changes are automatically staged when the commit UI opens.

Changes:

  • Added StartCommitDzHandler class to handle drop events for starting commits
  • Integrated the new drop handler into BranchList.svelte by creating an instance for each branch
  • Refactored BranchCard.svelte to use a function for determining overlay labels instead of inline ternary expressions

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
apps/desktop/src/lib/branches/dropHandler.ts Added StartCommitDzHandler class that accepts uncommitted file/folder/hunk drops and initiates commit mode while staging the dropped changes
apps/desktop/src/components/BranchList.svelte Instantiated StartCommitDzHandler for each branch and added it to the dropzones array
apps/desktop/src/components/BranchCard.svelte Refactored overlay label logic into getCardOverlayLabel() function and added support for StartCommitDzHandler label

Comment on lines +127 to +128
this.startCommitting();
await this.checkDropData(data);
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The order of operations may cause a race condition. The method calls startCommitting() to set the UI state to commit mode, then immediately calls checkDropData() to stage the changes. However, if the UI responds to the state change before the changes are checked/staged, users might see an empty commit form briefly. Consider awaiting checkDropData() before calling startCommitting() to ensure the changes are staged before the commit UI appears.

Suggested change
this.startCommitting();
await this.checkDropData(data);
await this.checkDropData(data);
this.startCommitting();

Copilot uses AI. Check for mistakes.

accepts(data: unknown): boolean {
if (data instanceof FileChangeDropData || data instanceof FolderChangeDropData) {
// Only accept uncomitted files/folders
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

Spelling error: "uncomitted" should be "uncommitted"

Suggested change
// Only accept uncomitted files/folders
// Only accept uncommitted files/folders

Copilot uses AI. Check for mistakes.
if (data instanceof FileChangeDropData || data instanceof FolderChangeDropData) {
// Only accept uncomitted files/folders
if (data.isCommitted) return false;
// Only accept unassinged files/folders or those assigned to the same stack
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

Spelling error: "unassinged" should be "unassigned"

Suggested change
// Only accept unassinged files/folders or those assigned to the same stack
// Only accept unassigned files/folders or those assigned to the same stack

Copilot uses AI. Check for mistakes.
Comment on lines +112 to +123
): Promise<true> {
if (data instanceof FileChangeDropData || data instanceof FolderChangeDropData) {
const changes = await data.treeChanges();
const paths = changes.map((c) => c.path);
if (paths.length === 0) return true;
this.uncommittedService.checkFiles(data.stackId ?? null, paths);
return true;
}

// Handle hunk data
this.uncommittedService.checkHunk(data.stackId ?? null, data.change.path, data.hunk);
return true;
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The return type Promise<true> is overly specific. Since this method always returns true and doesn't seem to need a return value, consider changing the return type to Promise<void> and removing the return true statements. This would make the intent clearer that this method is called for its side effects rather than its return value.

Suggested change
): Promise<true> {
if (data instanceof FileChangeDropData || data instanceof FolderChangeDropData) {
const changes = await data.treeChanges();
const paths = changes.map((c) => c.path);
if (paths.length === 0) return true;
this.uncommittedService.checkFiles(data.stackId ?? null, paths);
return true;
}
// Handle hunk data
this.uncommittedService.checkHunk(data.stackId ?? null, data.change.path, data.hunk);
return true;
): Promise<void> {
if (data instanceof FileChangeDropData || data instanceof FolderChangeDropData) {
const changes = await data.treeChanges();
const paths = changes.map((c) => c.path);
if (paths.length === 0) return;
this.uncommittedService.checkFiles(data.stackId ?? null, paths);
return;
}
// Handle hunk data
this.uncommittedService.checkHunk(data.stackId ?? null, data.change.path, data.hunk);
return;

Copilot uses AI. Check for mistakes.
Add a drop handler that initiates the commit process, staging the
dragged changes.
Copilot AI review requested due to automatic review settings February 3, 2026 17:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment on lines +84 to +86
// Only accept uncomitted files/folders
if (data.isCommitted) return false;
// Only accept unassinged files/folders or those assigned to the same stack
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

There are two spelling errors in the comments: "uncomitted" should be "uncommitted" and "unassinged" should be "unassigned".

Suggested change
// Only accept uncomitted files/folders
if (data.isCommitted) return false;
// Only accept unassinged files/folders or those assigned to the same stack
// Only accept uncommitted files/folders
if (data.isCommitted) return false;
// Only accept unassigned files/folders or those assigned to the same stack

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@PavelLaptev PavelLaptev left a comment

Choose a reason for hiding this comment

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

Look good, thank you! :-)

@estib-vega estib-vega merged commit e8ff537 into master Feb 3, 2026
31 checks passed
@estib-vega estib-vega deleted the drop-to-stage branch February 3, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants