fix: Fix review task completion bug + add initiative-level Request Changes

Critical: review/merge tasks hit an early return in handleTaskCompleted()
that skipped the phase completion check, leaving phases stuck in
in_progress forever. Changed to an if-block wrapping only the merge step.

Also adds requestChangesOnInitiative() which creates/reuses a
"Finalization" phase for initiative-level review feedback, with dedup
guards for both phase and initiative request-changes flows.
This commit is contained in:
Lukas May
2026-03-06 09:41:28 +01:00
parent 1b8e496d39
commit 65bcbf1a35
6 changed files with 152 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
import { useCallback, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import { Loader2, GitBranch, ArrowRight, FileCode, Plus, Minus, Upload, GitMerge } from "lucide-react";
import { Loader2, GitBranch, ArrowRight, FileCode, Plus, Minus, Upload, GitMerge, RotateCcw } from "lucide-react";
import { Button } from "@/components/ui/button";
import { trpc } from "@/lib/trpc";
import { parseUnifiedDiff } from "./parse-diff";
@@ -82,6 +82,14 @@ export function InitiativeReview({ initiativeId, onCompleted }: InitiativeReview
onError: (err) => toast.error(`Failed to stop: ${err.message}`),
});
const requestChangesMutation = trpc.requestInitiativeChanges.useMutation({
onSuccess: () => {
toast.success("Changes requested — review task created");
onCompleted();
},
onError: (err) => toast.error(err.message),
});
const approveMutation = trpc.approveInitiativeReview.useMutation({
onSuccess: (_data, variables) => {
const msg = variables.strategy === "merge_and_push"
@@ -189,6 +197,24 @@ export function InitiativeReview({ initiativeId, onCompleted }: InitiativeReview
{/* Right: preview + action buttons */}
<div className="flex items-center gap-2 shrink-0">
{previewState && <PreviewControls preview={previewState} />}
<Button
variant="outline"
size="sm"
onClick={() => {
const summary = window.prompt("Describe the changes needed:");
if (!summary?.trim()) return;
requestChangesMutation.mutate({ initiativeId, summary: summary.trim() });
}}
disabled={requestChangesMutation.isPending}
className="h-8 text-xs px-3 text-status-error-fg border-status-error-border hover:bg-status-error-bg"
>
{requestChangesMutation.isPending ? (
<Loader2 className="h-3 w-3 animate-spin" />
) : (
<RotateCcw className="h-3 w-3" />
)}
Request Changes
</Button>
<Button
variant="outline"
size="sm"