mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 09:13:08 +00:00
apply the patches
This commit is contained in:
@@ -8,6 +8,11 @@ import { COLUMNS, ColumnId } from '../constants';
|
||||
|
||||
const logger = createLogger('BoardDragDrop');
|
||||
|
||||
export interface PendingDependencyLink {
|
||||
draggedFeature: Feature;
|
||||
targetFeature: Feature;
|
||||
}
|
||||
|
||||
interface UseBoardDragDropProps {
|
||||
features: Feature[];
|
||||
currentProject: { path: string; id: string } | null;
|
||||
@@ -24,7 +29,10 @@ export function useBoardDragDrop({
|
||||
handleStartImplementation,
|
||||
}: UseBoardDragDropProps) {
|
||||
const [activeFeature, setActiveFeature] = useState<Feature | null>(null);
|
||||
const { moveFeature } = useAppStore();
|
||||
const [pendingDependencyLink, setPendingDependencyLink] = useState<PendingDependencyLink | null>(
|
||||
null
|
||||
);
|
||||
const { moveFeature, updateFeature } = useAppStore();
|
||||
|
||||
// Note: getOrCreateWorktreeForFeature removed - worktrees are now created server-side
|
||||
// at execution time based on feature.branchName
|
||||
@@ -40,6 +48,11 @@ export function useBoardDragDrop({
|
||||
[features]
|
||||
);
|
||||
|
||||
// Clear pending dependency link
|
||||
const clearPendingDependencyLink = useCallback(() => {
|
||||
setPendingDependencyLink(null);
|
||||
}, []);
|
||||
|
||||
const handleDragEnd = useCallback(
|
||||
async (event: DragEndEvent) => {
|
||||
const { active, over } = event;
|
||||
@@ -57,6 +70,85 @@ export function useBoardDragDrop({
|
||||
// Check if this is a running task (non-skipTests, TDD)
|
||||
const isRunningTask = runningAutoTasks.includes(featureId);
|
||||
|
||||
// Check if dropped on another card (for creating dependency links)
|
||||
if (overId.startsWith('card-drop-')) {
|
||||
const cardData = over.data.current as {
|
||||
type: string;
|
||||
featureId: string;
|
||||
};
|
||||
|
||||
if (cardData?.type === 'card') {
|
||||
const targetFeatureId = cardData.featureId;
|
||||
|
||||
// Don't link to self
|
||||
if (targetFeatureId === featureId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const targetFeature = features.find((f) => f.id === targetFeatureId);
|
||||
if (!targetFeature) return;
|
||||
|
||||
// Only allow linking backlog features (both must be in backlog)
|
||||
if (draggedFeature.status !== 'backlog' || targetFeature.status !== 'backlog') {
|
||||
toast.error('Cannot link features', {
|
||||
description: 'Both features must be in the backlog to create a dependency link.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Set pending dependency link to trigger dialog
|
||||
setPendingDependencyLink({
|
||||
draggedFeature,
|
||||
targetFeature,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if dropped on a worktree tab
|
||||
if (overId.startsWith('worktree-drop-')) {
|
||||
// Handle dropping on a worktree - change the feature's branchName
|
||||
const worktreeData = over.data.current as {
|
||||
type: string;
|
||||
branch: string;
|
||||
path: string;
|
||||
isMain: boolean;
|
||||
};
|
||||
|
||||
if (worktreeData?.type === 'worktree') {
|
||||
// Don't allow moving running tasks to a different worktree
|
||||
if (isRunningTask) {
|
||||
logger.debug('Cannot move running feature to different worktree');
|
||||
toast.error('Cannot move feature', {
|
||||
description: 'This feature is currently running and cannot be moved.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const targetBranch = worktreeData.branch;
|
||||
const currentBranch = draggedFeature.branchName;
|
||||
|
||||
// If already on the same branch, nothing to do
|
||||
if (currentBranch === targetBranch) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For main worktree, set branchName to undefined/null to indicate it should use main
|
||||
// For other worktrees, set branchName to the target branch
|
||||
const newBranchName = worktreeData.isMain ? undefined : targetBranch;
|
||||
|
||||
// Update feature's branchName
|
||||
updateFeature(featureId, { branchName: newBranchName });
|
||||
await persistFeatureUpdate(featureId, { branchName: newBranchName });
|
||||
|
||||
const branchDisplay = worktreeData.isMain ? targetBranch : targetBranch;
|
||||
toast.success('Feature moved to branch', {
|
||||
description: `Moved to ${branchDisplay}: ${draggedFeature.description.slice(0, 40)}${draggedFeature.description.length > 40 ? '...' : ''}`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if dragging is allowed based on status and skipTests
|
||||
// - Backlog items can always be dragged
|
||||
// - waiting_approval items can always be dragged (to allow manual verification via drag)
|
||||
@@ -205,12 +297,21 @@ export function useBoardDragDrop({
|
||||
}
|
||||
}
|
||||
},
|
||||
[features, runningAutoTasks, moveFeature, persistFeatureUpdate, handleStartImplementation]
|
||||
[
|
||||
features,
|
||||
runningAutoTasks,
|
||||
moveFeature,
|
||||
updateFeature,
|
||||
persistFeatureUpdate,
|
||||
handleStartImplementation,
|
||||
]
|
||||
);
|
||||
|
||||
return {
|
||||
activeFeature,
|
||||
handleDragStart,
|
||||
handleDragEnd,
|
||||
pendingDependencyLink,
|
||||
clearPendingDependencyLink,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user