feat: implement plan approval functionality in board view

- Introduced PlanApprovalDialog for reviewing and approving feature plans.
- Added state management for pending plan approvals and loading states.
- Enhanced BoardView to handle plan approval actions, including approve and reject functionalities.
- Updated KanbanCard and KanbanBoard components to include buttons for viewing and approving plans.
- Integrated plan approval logic into the auto mode service, allowing for user feedback and plan edits.
- Updated app state to manage default plan approval settings and integrate with existing feature workflows.
This commit is contained in:
SuperComboGamer
2025-12-17 19:39:09 -05:00
parent 01098545cf
commit b112747073
22 changed files with 1290 additions and 57 deletions

View File

@@ -4,6 +4,11 @@ import { useAppStore } from "@/store/app-store";
import { getElectronAPI } from "@/lib/electron";
import type { AutoModeEvent } from "@/types/electron";
// Type guard for plan_approval_required event
function isPlanApprovalEvent(event: AutoModeEvent): event is Extract<AutoModeEvent, { type: "plan_approval_required" }> {
return event.type === "plan_approval_required";
}
/**
* Hook for managing auto mode (scoped per project)
*/
@@ -18,6 +23,7 @@ export function useAutoMode() {
addAutoModeActivity,
maxConcurrency,
projects,
setPendingPlanApproval,
} = useAppStore(
useShallow((state) => ({
autoModeByProject: state.autoModeByProject,
@@ -29,6 +35,7 @@ export function useAutoMode() {
addAutoModeActivity: state.addAutoModeActivity,
maxConcurrency: state.maxConcurrency,
projects: state.projects,
setPendingPlanApproval: state.setPendingPlanApproval,
}))
);
@@ -147,8 +154,26 @@ export function useAutoMode() {
break;
case "auto_mode_error":
console.error("[AutoMode Error]", event.error);
if (event.featureId && event.error) {
// Check if this is a user-initiated cancellation (not a real error)
const isCancellation =
event.error.includes("cancelled") ||
event.error.includes("stopped") ||
event.error.includes("aborted");
if (isCancellation) {
// User cancelled the feature - just log as info, not an error
console.log("[AutoMode] Feature cancelled:", event.error);
// Remove from running tasks
if (eventProjectId) {
removeRunningTask(eventProjectId, event.featureId);
}
break;
}
// Real error - log and show to user
console.error("[AutoMode Error]", event.error);
// Check for authentication errors and provide a more helpful message
const isAuthError =
event.errorType === "authentication" ||
@@ -210,6 +235,64 @@ export function useAutoMode() {
});
}
break;
case "plan_approval_required":
// Plan requires user approval before proceeding
if (isPlanApprovalEvent(event)) {
console.log(
`[AutoMode] Plan approval required for ${event.featureId}`
);
setPendingPlanApproval({
featureId: event.featureId,
projectPath: event.projectPath || currentProject?.path || "",
planContent: event.planContent,
planningMode: event.planningMode,
});
}
break;
case "planning_started":
// Log when planning phase begins
if (event.featureId && event.mode && event.message) {
console.log(
`[AutoMode] Planning started (${event.mode}) for ${event.featureId}`
);
addAutoModeActivity({
featureId: event.featureId,
type: "planning",
message: event.message,
phase: "planning",
});
}
break;
case "plan_approved":
// Log when plan is approved by user
if (event.featureId) {
console.log(`[AutoMode] Plan approved for ${event.featureId}`);
addAutoModeActivity({
featureId: event.featureId,
type: "action",
message: event.hasEdits
? "Plan approved with edits, starting implementation..."
: "Plan approved, starting implementation...",
phase: "action",
});
}
break;
case "plan_auto_approved":
// Log when plan is auto-approved (requirePlanApproval=false)
if (event.featureId) {
console.log(`[AutoMode] Plan auto-approved for ${event.featureId}`);
addAutoModeActivity({
featureId: event.featureId,
type: "action",
message: "Plan auto-approved, starting implementation...",
phase: "action",
});
}
break;
}
});
@@ -222,6 +305,8 @@ export function useAutoMode() {
setAutoModeRunning,
addAutoModeActivity,
getProjectIdFromPath,
setPendingPlanApproval,
currentProject?.path,
]);
// Restore auto mode for all projects that were running when app was closed