Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 22, 2025

The CommitTitle component was showing misleading "Empty commit. Drag changes here" messages in read-only contexts where dragging is not actually possible, such as in BranchCommitList when stackId is undefined.

Problem

Previously, all empty commits displayed the same message regardless of context:

function getTitle() {
  if (title) {
    return title;
  }
  return 'Empty commit. Drag changes here'; // Always showed drag instruction
}

This was confusing in read-only contexts like:

  • BranchCommitList when stackId is undefined
  • TargetCommitList (always read-only)
  • UnappliedCommitView (unapplied commits)
  • Other disabled/read-only commit displays

Solution

Added an optional editable prop to CommitTitle that defaults to true for backward compatibility:

type Props = {
  truncate?: boolean;
  commitMessage: string;
  className?: string;
  editable?: boolean; // New prop
};

function getTitle() {
  if (title) {
    return title;
  }
  return editable ? 'Empty commit. Drag changes here' : 'Empty commit';
}

Updated all usage locations to pass appropriate editable values:

  • Editable contexts: CommitView passes editable={!isReadOnly} based on stackId presence
  • Read-only contexts: BranchCommitList, TargetCommitList, etc. pass editable={false}
  • Context-dependent: BranchCommitList passes editable={!!stackId} since it's only editable when a stackId exists

Result

  • ✅ Empty commits in read-only contexts now show just "Empty commit" without misleading drag instructions
  • ✅ Empty commits in editable contexts continue to show "Empty commit. Drag changes here"
  • ✅ Commits with actual messages are unaffected
  • ✅ Fully backward compatible with existing code

The fix ensures users only see drag instructions when dragging is actually possible, improving the overall user experience and reducing confusion.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI assigned Copilot and Byron Sep 22, 2025
Copy link

vercel bot commented Sep 22, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
gitbutler-web Skipped Skipped Sep 22, 2025 5:31pm

@Copilot Copilot AI changed the title [WIP] The CommitTitle component should know if this is an editable context, and if not, avoid saying that empty commits should be the target of a drag operation. The BranchCommitList is one of such read-only contexts. Fix CommitTitle to show context-appropriate messages for empty commits Sep 22, 2025
@Copilot Copilot AI requested a review from Byron September 22, 2025 15:20
Copilot finished work on behalf of Byron September 22, 2025 15:20
This way we can show empty commits without the 'drag changes here' text.

Co-authored-by: Byron <[email protected]>
@Byron Byron force-pushed the copilot/fix-6bea0204-7557-4d3a-a1a5-92fe21fe0869 branch from 13202f1 to 945ef1c Compare September 22, 2025 17:09
Copy link
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

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

This works perfectly, well done!

Screen.Recording.2025-09-22.at.19.10.08.mov

I'd merge it as is, but maybe editable should rather be something else?
Also I don't know if the places where it is set to false should actually be false.

Screenshot 2025-09-22 at 19 12 27 Screenshot 2025-09-22 at 19 13 05

@Byron Byron requested review from mtsgrd and PavelLaptev September 22, 2025 17:12
@Byron Byron marked this pull request as ready for review September 22, 2025 17:14
disabled,
hasConflicts,
active,
editable = true,
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, let's remove this default value here. The type is already editable?: boolean; so instances don't need the prop specified as false. This means we could remove the explicit editable={false} rows in this pr.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the review! I think I have addressed the this as well as I could, given that… somehow editable = false was needed so editable wouldn't be truthy by default. (I don't understand what's going on here, I hope I am missing something)

In any case, I hope you will merge this PR after taking it to the finishing line 🙏.

Copy link
Contributor

Choose a reason for hiding this comment

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

sure thing, I can I can take of the rest, just ignore my new comment! It shouldn't be truthy by default, but I can make sure. :)

- don't specify what can be implicit
- editable = false is needed as otherwise, not setting the value is `truthy` for some reason.
disabled,
hasConflicts,
active,
editable = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

awesome, i see you deleted the other code. could we still make this just editable,?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is just editable, then it won't work anymore like it's defaulting to true or something truthy. That was my problem, the thing I didn't understand 😁.

@Byron
Copy link
Collaborator

Byron commented Sep 26, 2025

@mtsgrd Is this PR OK to merge?

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