From 8eeec4976f3335e959982e1f4e6e67796aa1fd00 Mon Sep 17 00:00:00 2001 From: Louis Knight-Webb Date: Fri, 4 Jul 2025 00:42:31 +0100 Subject: [PATCH] Changes to branches (vibe-kanban) (#68) * Perfect! I've successfully completed all the requested changes: ## Summary of Changes Made: 1. **Removed Branch Status Panel**: Completely removed the branch status display panel that showed commit information, uncommitted changes, and merge status. 2. **Removed Branch Status Logic**: Eliminated all branch status fetching logic, state variables, and related useEffect hooks. 3. **Simplified Git Operations**: - Removed branch status dependencies from merge/rebase buttons - Merge now executes directly without confirmation dialogs - Rebase button is always available for non-merged attempts - Removed merge confirmation and uncommitted changes warning dialogs 4. **Enhanced PR Functionality**: - If a PR already exists (`selectedAttempt.pr_url`), the button shows "Open PR" and opens the existing PR - If no PR exists, it shows "Create PR" and opens the creation dialog - Updated button text to reflect the current state 5. **Cleaned Up Code**: - Removed unused imports (`BranchStatus`, `FileText`, `useCallback`) - Removed unused state variables and functions - Added simple error display for git operations The toolbar now provides a cleaner interface focused on the essential git operations while maintaining all the merge, rebase, and PR functionality as requested. * prettier * Perfect! Now the functionality works correctly: ## Fixed Implementation: 1. **Kept Branch Status Panel Hidden**: The branch status panel display is still removed - users don't see the detailed status information. 2. **Restored Smart Git Operations**: - **Rebase button**: Only appears when `branchStatus.is_behind === true` and `!branchStatus.merged` - **Merge button**: Only appears when `!branchStatus.merged` and not behind (can't merge if behind) - **PR button**: Always shows when not merged, but disabled when behind (need to rebase first) 3. **Enhanced PR Logic**: - Shows "Open PR" and opens existing PR if `selectedAttempt.pr_url` exists - Shows "Create PR" for new PRs - Disabled when branch is behind (need to rebase first) 4. **Branch Status Fetching**: Restored the background fetching logic to determine button states, but the status panel remains hidden from users. The interface now shows only the relevant buttons based on the actual git state - no more confusing unnecessary buttons! * prettier --- .../components/tasks/TaskDetailsToolbar.tsx | 175 ++---------------- 1 file changed, 18 insertions(+), 157 deletions(-) diff --git a/frontend/src/components/tasks/TaskDetailsToolbar.tsx b/frontend/src/components/tasks/TaskDetailsToolbar.tsx index 4040e920..b9c16a06 100644 --- a/frontend/src/components/tasks/TaskDetailsToolbar.tsx +++ b/frontend/src/components/tasks/TaskDetailsToolbar.tsx @@ -11,7 +11,6 @@ import { ArrowDown, Plus, RefreshCw, - FileText, GitPullRequest, } from 'lucide-react'; import { Button } from '@/components/ui/button'; @@ -128,9 +127,6 @@ export function TaskDetailsToolbar({ const [branchStatusLoading, setBranchStatusLoading] = useState(false); const [merging, setMerging] = useState(false); const [rebasing, setRebasing] = useState(false); - const [rebaseSuccess, setRebaseSuccess] = useState(false); - const [showUncommittedWarning, setShowUncommittedWarning] = useState(false); - const [showMergeConfirmDialog, setShowMergeConfirmDialog] = useState(false); const [creatingPR, setCreatingPR] = useState(false); const [showCreatePRDialog, setShowCreatePRDialog] = useState(false); const [prTitle, setPrTitle] = useState(''); @@ -181,14 +177,8 @@ export function TaskDetailsToolbar({ const handleMergeClick = async () => { if (!projectId || !task.id || !selectedAttempt?.id) return; - // Check for uncommitted changes and show warning dialog - if (branchStatus?.has_uncommitted_changes) { - setShowUncommittedWarning(true); - return; - } - - // Show confirmation dialog for regular merge - setShowMergeConfirmDialog(true); + // Directly perform merge without checking branch status + await performMerge(); }; const performMerge = async () => { @@ -209,7 +199,7 @@ export function TaskDetailsToolbar({ // Refetch branch status to show updated state fetchBranchStatus(); } else { - setError('Failed to merge changes'); + setError(result.message || 'Failed to merge changes'); } } else { setError('Failed to merge changes'); @@ -221,24 +211,6 @@ export function TaskDetailsToolbar({ } }; - const handleConfirmMergeWithUncommitted = async () => { - setShowUncommittedWarning(false); - await performMerge(); - }; - - const handleCancelMergeWithUncommitted = () => { - setShowUncommittedWarning(false); - }; - - const handleConfirmMerge = async () => { - setShowMergeConfirmDialog(false); - await performMerge(); - }; - - const handleCancelMerge = () => { - setShowMergeConfirmDialog(false); - }; - const handleRebaseClick = async () => { if (!projectId || !task.id || !selectedAttempt?.id) return; @@ -254,7 +226,6 @@ export function TaskDetailsToolbar({ if (response.ok) { const result: ApiResponse = await response.json(); if (result.success) { - setRebaseSuccess(true); // Refresh branch status after rebase fetchBranchStatus(); } else { @@ -273,6 +244,12 @@ export function TaskDetailsToolbar({ const handleCreatePRClick = async () => { if (!projectId || !task.id || !selectedAttempt?.id) return; + // If PR already exists, open it + if (selectedAttempt.pr_url) { + window.open(selectedAttempt.pr_url, '_blank'); + return; + } + // Auto-fill with task details if available setPrTitle(`${task.title} (vibe-kanban)`); setPrBody(task.description || ''); @@ -540,52 +517,10 @@ export function TaskDetailsToolbar({ return ( <>
- {/* Branch Status Display */} - {selectedAttempt && branchStatus && ( -
-
-
-
- - {branchStatus.up_to_date ? ( - Up to date - ) : branchStatus.is_behind === true ? ( - - {branchStatus.commits_behind} commit - {branchStatus.commits_behind !== 1 ? 's' : ''} behind{' '} - {branchStatus.base_branch_name} - - ) : ( - - {branchStatus.commits_ahead} commit - {branchStatus.commits_ahead !== 1 ? 's' : ''} ahead of{' '} - {branchStatus.base_branch_name} - - )} -
- {branchStatus.has_uncommitted_changes && ( -
- - Uncommitted changes -
- )} -
- - {/* Status Messages */} -
- {branchStatus.merged && ( -
- ✓ Changes have been merged -
- )} - {rebaseSuccess && ( -
- Branch rebased successfully! -
- )} - {error &&
{error}
} -
-
+ {/* Error Display */} + {error && ( +
+
{error}
)} @@ -859,7 +794,11 @@ export function TaskDetailsToolbar({ className="border-blue-300 text-blue-700 hover:bg-blue-50 gap-1" > - {creatingPR ? 'Creating...' : 'Create PR'} + {selectedAttempt.pr_url + ? 'Open PR' + : creatingPR + ? 'Creating...' + : 'Create PR'} - - - - - - {/* Uncommitted Changes Warning Dialog */} - handleCancelMergeWithUncommitted()} - > - - - Uncommitted Changes Detected - - There are uncommitted changes in the worktree that will be - included in the merge. - - -
-
-

- Warning: The worktree contains uncommitted - changes (modified, added, or deleted files) that have not been - committed to git. These changes will be permanently merged into - the {branchStatus?.base_branch_name || 'base'} branch. -

-
-
- - - - -
-
- {/* Create PR Dialog */}