From 65937e198fe8ef88ef8dd02cf5b91e211b8f380e Mon Sep 17 00:00:00 2001 From: AndyMik90 Date: Tue, 16 Dec 2025 13:12:04 +0100 Subject: [PATCH] better conflict handling in the frontend app for merge contlicts (better UX) --- .../components/task-detail/TaskReview.tsx | 55 +++++++++++-------- .../task-detail/hooks/useTaskDetail.ts | 23 +++++--- 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/auto-claude-ui/src/renderer/components/task-detail/TaskReview.tsx b/auto-claude-ui/src/renderer/components/task-detail/TaskReview.tsx index 45d49ebd..fde4c003 100644 --- a/auto-claude-ui/src/renderer/components/task-detail/TaskReview.tsx +++ b/auto-claude-ui/src/renderer/components/task-detail/TaskReview.tsx @@ -227,28 +227,26 @@ export function TaskReview({ View Changes - + {/* Refresh conflicts button - conflicts are auto-loaded but user can refresh */} + {mergePreview && ( + + )} {worktreeStatus.worktreePath && ( )} + {/* Loading indicator while checking conflicts */} + {isLoadingPreview && !mergePreview && ( +
+ + Checking for conflicts... +
+ )} + {/* Merge Preview Summary */} {mergePreview && (
- {stageOnly ? 'Stage Anyway' : 'Merge Anyway'} + {stageOnly ? 'Stage with AI Merge' : 'Merge with AI'} diff --git a/auto-claude-ui/src/renderer/components/task-detail/hooks/useTaskDetail.ts b/auto-claude-ui/src/renderer/components/task-detail/hooks/useTaskDetail.ts index 68dd721e..77070842 100644 --- a/auto-claude-ui/src/renderer/components/task-detail/hooks/useTaskDetail.ts +++ b/auto-claude-ui/src/renderer/components/task-detail/hooks/useTaskDetail.ts @@ -191,9 +191,7 @@ export function useTaskDetail({ task }: UseTaskDetailOptions) { const previewData = JSON.parse(stored); console.log('%c[useTaskDetail] Restored merge preview from sessionStorage:', 'color: magenta;', previewData); setMergePreview(previewData); - if (previewData.conflicts?.length > 0) { - setShowConflictDialog(true); - } + // Don't auto-popup - restored data stays silent } catch (e) { console.warn('[useTaskDetail] Failed to parse stored merge preview'); sessionStorage.removeItem(storageKey); @@ -218,10 +216,7 @@ export function useTaskDetail({ task }: UseTaskDetailOptions) { setMergePreview(previewData); // Persist to sessionStorage to survive HMR reloads sessionStorage.setItem(`mergePreview-${task.id}`, JSON.stringify(previewData)); - // Show conflict dialog if there are conflicts that need attention - if (previewData.conflicts.length > 0) { - setShowConflictDialog(true); - } + // Don't auto-popup conflict dialog - let user click to see details if curious } else { console.warn('%c[useTaskDetail] Preview not successful or no preview data:', 'color: orange;', result); console.warn(' - success:', result.success); @@ -236,6 +231,20 @@ export function useTaskDetail({ task }: UseTaskDetailOptions) { } }, [task.id]); + // Auto-load merge preview when worktree is ready (eliminates need to click "Check Conflicts") + // NOTE: This must be placed AFTER loadMergePreview definition since it depends on that callback + useEffect(() => { + // Only auto-load if: + // 1. Task needs review + // 2. Worktree exists + // 3. We haven't already loaded the preview + // 4. We're not currently loading + if (needsReview && worktreeStatus?.exists && !mergePreview && !isLoadingPreview) { + console.log('[useTaskDetail] Auto-loading merge preview for task:', task.id); + loadMergePreview(); + } + }, [needsReview, worktreeStatus?.exists, mergePreview, isLoadingPreview, task.id, loadMergePreview]); + return { // State feedback,