Keep git panel when branchstatus fails (vibe-kanban) (#913)
* Done! I've updated the code to keep the Git panel visible when `branchStatus` fails:
**Changes made:**
1. **GitOperations.tsx:253-256**: Changed the early return condition to only hide the panel when PR is merged, not when `branchStatus` is null
2. **GitOperations.tsx:438-505**: Wrapped the merge/PR/rebase buttons in a conditional `{branchStatus && ...}` so they only display when branch status is available
3. **TaskDetailsToolbar.tsx:227-238**: Removed the `branchStatus` condition from the parent, so `GitOperations` is always rendered when `selectedAttempt` exists
**Result:**
- The Git panel (showing branch names and the arrow) will now always display when there's a selected attempt
- The merge, PR, and rebase buttons will only show when branch status loads successfully
- The panel still hides completely if the PR has been merged
* Updated! Now the target branch will fallback to `selectedAttempt.target_branch` if `branchStatus` doesn't load, ensuring the target branch label always displays correctly.
This commit is contained in:
@@ -250,7 +250,8 @@ function GitOperations({
|
||||
});
|
||||
};
|
||||
|
||||
if (!branchStatus || mergeInfo.hasMergedPR) {
|
||||
// Hide entire panel only if PR is merged
|
||||
if (mergeInfo.hasMergedPR) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -298,6 +299,7 @@ function GitOperations({
|
||||
<GitBranchIcon className="h-3 w-3 text-muted-foreground" />
|
||||
<span className="text-sm font-medium truncate">
|
||||
{branchStatus?.target_branch_name ||
|
||||
selectedAttempt.target_branch ||
|
||||
selectedBranch ||
|
||||
t('git.branch.current')}
|
||||
</span>
|
||||
@@ -434,72 +436,74 @@ function GitOperations({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Git Operations */}
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
onClick={handleMergeClick}
|
||||
disabled={
|
||||
mergeInfo.hasOpenPR ||
|
||||
merging ||
|
||||
hasConflictsCalculated ||
|
||||
Boolean((branchStatus.commits_behind ?? 0) > 0) ||
|
||||
isAttemptRunning ||
|
||||
((branchStatus.commits_ahead ?? 0) === 0 &&
|
||||
!pushSuccess &&
|
||||
!mergeSuccess)
|
||||
}
|
||||
variant="outline"
|
||||
size="xs"
|
||||
className="border-success text-success hover:bg-success gap-1 flex-1"
|
||||
>
|
||||
<GitBranchIcon className="h-3 w-3" />
|
||||
{mergeButtonLabel}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handlePRButtonClick}
|
||||
disabled={
|
||||
pushing ||
|
||||
Boolean((branchStatus.commits_behind ?? 0) > 0) ||
|
||||
isAttemptRunning ||
|
||||
hasConflictsCalculated ||
|
||||
(mergeInfo.hasOpenPR &&
|
||||
branchStatus.remote_commits_ahead === 0) ||
|
||||
((branchStatus.commits_ahead ?? 0) === 0 &&
|
||||
(branchStatus.remote_commits_ahead ?? 0) === 0 &&
|
||||
!pushSuccess &&
|
||||
!mergeSuccess)
|
||||
}
|
||||
variant="outline"
|
||||
size="xs"
|
||||
className="border-info text-info hover:bg-info gap-1 flex-1"
|
||||
>
|
||||
<GitPullRequest className="h-3 w-3" />
|
||||
{mergeInfo.hasOpenPR
|
||||
? pushSuccess
|
||||
? t('git.states.pushed')
|
||||
: pushing
|
||||
? t('git.states.pushing')
|
||||
: t('git.states.push')
|
||||
: t('git.states.createPr')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleRebaseDialogOpen}
|
||||
disabled={
|
||||
rebasing ||
|
||||
isAttemptRunning ||
|
||||
hasConflictsCalculated ||
|
||||
(branchStatus.commits_behind ?? 0) === 0
|
||||
}
|
||||
variant="outline"
|
||||
size="xs"
|
||||
className="border-warning text-warning hover:bg-warning gap-1 flex-1"
|
||||
>
|
||||
<RefreshCw
|
||||
className={`h-3 w-3 ${rebasing ? 'animate-spin' : ''}`}
|
||||
/>
|
||||
{rebaseButtonLabel}
|
||||
</Button>
|
||||
</div>
|
||||
{/* Git Operations - only show when branchStatus is available */}
|
||||
{branchStatus && (
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
onClick={handleMergeClick}
|
||||
disabled={
|
||||
mergeInfo.hasOpenPR ||
|
||||
merging ||
|
||||
hasConflictsCalculated ||
|
||||
Boolean((branchStatus.commits_behind ?? 0) > 0) ||
|
||||
isAttemptRunning ||
|
||||
((branchStatus.commits_ahead ?? 0) === 0 &&
|
||||
!pushSuccess &&
|
||||
!mergeSuccess)
|
||||
}
|
||||
variant="outline"
|
||||
size="xs"
|
||||
className="border-success text-success hover:bg-success gap-1 flex-1"
|
||||
>
|
||||
<GitBranchIcon className="h-3 w-3" />
|
||||
{mergeButtonLabel}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handlePRButtonClick}
|
||||
disabled={
|
||||
pushing ||
|
||||
Boolean((branchStatus.commits_behind ?? 0) > 0) ||
|
||||
isAttemptRunning ||
|
||||
hasConflictsCalculated ||
|
||||
(mergeInfo.hasOpenPR &&
|
||||
branchStatus.remote_commits_ahead === 0) ||
|
||||
((branchStatus.commits_ahead ?? 0) === 0 &&
|
||||
(branchStatus.remote_commits_ahead ?? 0) === 0 &&
|
||||
!pushSuccess &&
|
||||
!mergeSuccess)
|
||||
}
|
||||
variant="outline"
|
||||
size="xs"
|
||||
className="border-info text-info hover:bg-info gap-1 flex-1"
|
||||
>
|
||||
<GitPullRequest className="h-3 w-3" />
|
||||
{mergeInfo.hasOpenPR
|
||||
? pushSuccess
|
||||
? t('git.states.pushed')
|
||||
: pushing
|
||||
? t('git.states.pushing')
|
||||
: t('git.states.push')
|
||||
: t('git.states.createPr')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleRebaseDialogOpen}
|
||||
disabled={
|
||||
rebasing ||
|
||||
isAttemptRunning ||
|
||||
hasConflictsCalculated ||
|
||||
(branchStatus.commits_behind ?? 0) === 0
|
||||
}
|
||||
variant="outline"
|
||||
size="xs"
|
||||
className="border-warning text-warning hover:bg-warning gap-1 flex-1"
|
||||
>
|
||||
<RefreshCw
|
||||
className={`h-3 w-3 ${rebasing ? 'animate-spin' : ''}`}
|
||||
/>
|
||||
{rebaseButtonLabel}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user