mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
Merge remote-tracking branch 'origin/master' into feat/task-decomposition-enforce-floor
This commit is contained in:
@@ -41,8 +41,13 @@ export function ResolveWaitDialog({ agentId }: ResolveWaitDialogProps) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenChange = (newOpen: boolean) => {
|
||||
if (!newOpen) setResolution("");
|
||||
setOpen(newOpen);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<DialogTrigger asChild>
|
||||
<Button>
|
||||
<Send className="h-4 w-4 mr-2" />
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Message } from "@/types";
|
||||
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Markdown } from "@/components/ui/markdown";
|
||||
import { CopyButton } from "@/components/ui/copy-button";
|
||||
import { MessageTypeBadge } from "./message-type-badge";
|
||||
import { Clock, Link2 } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
@@ -23,7 +24,7 @@ function formatTime(timestamp: string): string {
|
||||
|
||||
export function MessageItem({ message }: MessageItemProps) {
|
||||
return (
|
||||
<div className="flex gap-3 py-3 hover:bg-muted/30 px-2 rounded-lg">
|
||||
<div className="group relative flex gap-3 py-3 hover:bg-muted/30 px-2 rounded-lg">
|
||||
<Avatar className="h-8 w-8 shrink-0">
|
||||
<AvatarFallback className="bg-primary/10 text-primary text-xs">
|
||||
{getAgentInitials(message.agent_id)}
|
||||
@@ -61,6 +62,11 @@ export function MessageItem({ message }: MessageItemProps) {
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
{/* Copy button — visible on hover */}
|
||||
<CopyButton
|
||||
value={message.content}
|
||||
className="absolute right-2 top-3 opacity-0 transition-opacity group-hover:opacity-100"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
GitCommit,
|
||||
Upload,
|
||||
GitPullRequest,
|
||||
GitMerge,
|
||||
RefreshCw,
|
||||
ArrowUp,
|
||||
} from "lucide-react";
|
||||
@@ -31,9 +32,11 @@ interface GitActionsPanelProps {
|
||||
onCommit: (message: string) => void;
|
||||
onPush: (force?: boolean) => void;
|
||||
onCreatePR: (title: string, body: string) => void;
|
||||
onMergePR: (prNumber: number) => void;
|
||||
isCommitting: boolean;
|
||||
isPushing: boolean;
|
||||
isCreatingPR: boolean;
|
||||
isMerging: boolean;
|
||||
}
|
||||
|
||||
export function GitActionsPanel({
|
||||
@@ -44,22 +47,53 @@ export function GitActionsPanel({
|
||||
onCommit,
|
||||
onPush,
|
||||
onCreatePR,
|
||||
onMergePR,
|
||||
isCommitting,
|
||||
isPushing,
|
||||
isCreatingPR,
|
||||
isMerging,
|
||||
}: GitActionsPanelProps) {
|
||||
void _agentId; // Reserved for future use
|
||||
const [showCommitDialog, setShowCommitDialog] = useState(false);
|
||||
const [showPRDialog, setShowPRDialog] = useState(false);
|
||||
const [showMergeDialog, setShowMergeDialog] = useState(false);
|
||||
const [commitMessage, setCommitMessage] = useState("");
|
||||
const [prTitle, setPrTitle] = useState("");
|
||||
const [prBody, setPrBody] = useState("");
|
||||
const [mergePrNumber, setMergePrNumber] = useState("");
|
||||
|
||||
const hasStagedChanges = (status?.staged_files.length ?? 0) > 0;
|
||||
const hasUnpushedCommits = (status?.ahead ?? 0) > 0;
|
||||
const canPush = hasUnpushedCommits;
|
||||
const canCreatePR = hasUnpushedCommits || status?.current_branch !== "main";
|
||||
|
||||
const handleCommitDialogOpenChange = (newOpen: boolean) => {
|
||||
if (!newOpen) setCommitMessage("");
|
||||
setShowCommitDialog(newOpen);
|
||||
};
|
||||
|
||||
const handlePRDialogOpenChange = (newOpen: boolean) => {
|
||||
if (!newOpen) {
|
||||
setPrTitle("");
|
||||
setPrBody("");
|
||||
}
|
||||
setShowPRDialog(newOpen);
|
||||
};
|
||||
|
||||
const handleMergeDialogOpenChange = (newOpen: boolean) => {
|
||||
if (!newOpen) setMergePrNumber("");
|
||||
setShowMergeDialog(newOpen);
|
||||
};
|
||||
|
||||
const handleMergePR = () => {
|
||||
const prNum = parseInt(mergePrNumber, 10);
|
||||
if (!isNaN(prNum) && prNum > 0) {
|
||||
onMergePR(prNum);
|
||||
setShowMergeDialog(false);
|
||||
setMergePrNumber("");
|
||||
}
|
||||
};
|
||||
|
||||
const handleCommit = () => {
|
||||
if (commitMessage.trim()) {
|
||||
onCommit(commitMessage.trim());
|
||||
@@ -84,7 +118,7 @@ export function GitActionsPanel({
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
{/* Commit Action */}
|
||||
<Dialog open={showCommitDialog} onOpenChange={setShowCommitDialog}>
|
||||
<Dialog open={showCommitDialog} onOpenChange={handleCommitDialogOpenChange}>
|
||||
<DialogTrigger asChild>
|
||||
<Button
|
||||
className="w-full justify-start"
|
||||
@@ -168,7 +202,7 @@ export function GitActionsPanel({
|
||||
</Button>
|
||||
|
||||
{/* Create PR Action */}
|
||||
<Dialog open={showPRDialog} onOpenChange={setShowPRDialog}>
|
||||
<Dialog open={showPRDialog} onOpenChange={handlePRDialogOpenChange}>
|
||||
<DialogTrigger asChild>
|
||||
<Button
|
||||
className="w-full justify-start"
|
||||
@@ -222,6 +256,52 @@ export function GitActionsPanel({
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* Merge PR Action */}
|
||||
<Dialog open={showMergeDialog} onOpenChange={handleMergeDialogOpenChange}>
|
||||
<DialogTrigger asChild>
|
||||
<Button
|
||||
className="w-full justify-start"
|
||||
variant="outline"
|
||||
>
|
||||
{isMerging ? (
|
||||
<RefreshCw className="h-4 w-4 mr-2 animate-spin" />
|
||||
) : (
|
||||
<GitMerge className="h-4 w-4 mr-2" />
|
||||
)}
|
||||
Merge PR
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Merge Pull Request</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4 py-4">
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium">PR Number</label>
|
||||
<Input
|
||||
type="number"
|
||||
placeholder="e.g. 42"
|
||||
value={mergePrNumber}
|
||||
onChange={(e) => setMergePrNumber(e.target.value)}
|
||||
min={1}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setShowMergeDialog(false)}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleMergePR}
|
||||
disabled={!mergePrNumber.trim() || isNaN(parseInt(mergePrNumber, 10)) || isMerging}
|
||||
>
|
||||
{isMerging && <RefreshCw className="h-4 w-4 mr-2 animate-spin" />}
|
||||
Merge
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* Status Summary */}
|
||||
{status && (
|
||||
<div className="pt-2 border-t text-xs text-muted-foreground space-y-1">
|
||||
|
||||
@@ -49,7 +49,7 @@ function GitBrowserContent() {
|
||||
const { data: unstagedDiff, isLoading: loadingUnstagedDiff } = useGitDiff(projectSlug, false, undefined, !!projectSlug);
|
||||
|
||||
// Git operations
|
||||
const { commit, push, createBranch, checkout, createPR } = useGitOperations();
|
||||
const { commit, push, createBranch, checkout, createPR, mergePR } = useGitOperations();
|
||||
|
||||
// Update URL params
|
||||
const updateParams = useCallback(
|
||||
@@ -160,6 +160,20 @@ function GitBrowserContent() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleMergePR = async (prNumber: number) => {
|
||||
try {
|
||||
const result = await mergePR.mutateAsync({
|
||||
project_slug: projectSlug,
|
||||
pr_number: prNumber,
|
||||
task_id: taskId || "manual",
|
||||
agent_id: "ceo",
|
||||
});
|
||||
toast.success(`Merged PR #${result.pr_number} → ${result.target_branch}`);
|
||||
} catch {
|
||||
toast.error("Failed to merge PR");
|
||||
}
|
||||
};
|
||||
|
||||
// Check offline
|
||||
const isOffline = projectsError && (
|
||||
projectsError.message?.includes("Network Error") ||
|
||||
@@ -243,9 +257,11 @@ function GitBrowserContent() {
|
||||
onCommit={handleCommit}
|
||||
onPush={handlePush}
|
||||
onCreatePR={handleCreatePR}
|
||||
onMergePR={handleMergePR}
|
||||
isCommitting={commit.isPending}
|
||||
isPushing={push.isPending}
|
||||
isCreatingPR={createPR.isPending}
|
||||
isMerging={mergePR.isPending}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -91,8 +91,12 @@ export function ChatMessages({
|
||||
if (msg.role === "user") {
|
||||
return (
|
||||
<div key={msg.id} className="flex justify-end">
|
||||
<div className="max-w-[70%] rounded-2xl rounded-tr-sm bg-primary px-4 py-3 text-sm text-primary-foreground">
|
||||
<div className="group relative max-w-[70%] rounded-2xl rounded-tr-sm bg-primary px-4 py-3 text-sm text-primary-foreground">
|
||||
<MarkdownBody content={msg.content} />
|
||||
<CopyButton
|
||||
value={msg.content}
|
||||
className="absolute right-1.5 top-1.5 bg-primary-foreground/10 text-primary-foreground opacity-0 transition-opacity group-hover:opacity-100"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -101,9 +105,13 @@ export function ChatMessages({
|
||||
if (msg.role === "error") {
|
||||
return (
|
||||
<div key={msg.id} className="flex justify-start">
|
||||
<div className="flex max-w-[70%] items-start gap-2 rounded-2xl rounded-tl-sm border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive">
|
||||
<div className="group relative flex max-w-[70%] items-start gap-2 rounded-2xl rounded-tl-sm border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive">
|
||||
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0" />
|
||||
<span>{msg.content}</span>
|
||||
<CopyButton
|
||||
value={msg.content}
|
||||
className="absolute right-1.5 top-1.5 bg-background/80 opacity-0 transition-opacity group-hover:opacity-100"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -115,11 +123,15 @@ export function ChatMessages({
|
||||
<div className="flex justify-start">
|
||||
<div
|
||||
className={cn(
|
||||
"max-w-[70%] rounded-2xl rounded-tl-sm bg-muted px-4 py-3 text-sm text-foreground",
|
||||
"group relative max-w-[70%] rounded-2xl rounded-tl-sm bg-muted px-4 py-3 text-sm text-foreground",
|
||||
msg.draft && "max-w-[85%]"
|
||||
)}
|
||||
>
|
||||
<MarkdownBody content={msg.content} />
|
||||
<CopyButton
|
||||
value={msg.content}
|
||||
className="absolute right-1.5 top-1.5 bg-background/80 opacity-0 transition-opacity group-hover:opacity-100"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -44,8 +44,13 @@ export function EscalateToCeoDialog({
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenChange = (newOpen: boolean) => {
|
||||
if (!newOpen) setReason("");
|
||||
onOpenChange(newOpen);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Escalate to CEO</DialogTitle>
|
||||
@@ -101,8 +106,13 @@ export function CeoRejectDialog({
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenChange = (newOpen: boolean) => {
|
||||
if (!newOpen) setNotes("");
|
||||
onOpenChange(newOpen);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Request Changes</DialogTitle>
|
||||
@@ -139,6 +149,44 @@ export function CeoRejectDialog({
|
||||
);
|
||||
}
|
||||
|
||||
// Approve & Merge Dialog — simple confirmation for POST /tasks/{id}/approve-and-merge.
|
||||
// The backend endpoint accepts NO notes parameter, so no text input is needed here.
|
||||
interface ApproveAndMergeDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
onConfirm: () => void;
|
||||
isPending?: boolean;
|
||||
}
|
||||
|
||||
export function ApproveAndMergeDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
onConfirm,
|
||||
isPending,
|
||||
}: ApproveAndMergeDialogProps) {
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Approve & Merge</DialogTitle>
|
||||
<DialogDescription>
|
||||
This will approve the completed work and merge the pull request into the
|
||||
target branch. This action cannot be undone.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => onOpenChange(false)} disabled={isPending}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={onConfirm} disabled={isPending}>
|
||||
{isPending ? "Merging..." : "Approve & Merge"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
// CEO Approve Dialog — the sign-off note is the audit record for merging to
|
||||
// production, so it is REQUIRED and must be substantive (>= 20 chars), matching
|
||||
// the server's CEO_NOTES_REQUIRED gate.
|
||||
@@ -167,8 +215,13 @@ export function CeoApproveDialog({
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenChange = (newOpen: boolean) => {
|
||||
if (!newOpen) setNotes("");
|
||||
onOpenChange(newOpen);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Approve & Merge</DialogTitle>
|
||||
@@ -244,8 +297,13 @@ export function RequiredNotesDialog({
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenChange = (newOpen: boolean) => {
|
||||
if (!newOpen) setText("");
|
||||
onOpenChange(newOpen);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
@@ -304,8 +362,14 @@ export function CreateBranchDialog({
|
||||
onConfirm(branchType);
|
||||
};
|
||||
|
||||
// Reset branchType to 'feature' when dialog is dismissed without confirming
|
||||
const handleOpenChange = (newOpen: boolean) => {
|
||||
if (!newOpen) setBranchType("feature");
|
||||
onOpenChange(newOpen);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Create Branch</DialogTitle>
|
||||
@@ -373,10 +437,14 @@ export function CreatePRDialog({
|
||||
}
|
||||
};
|
||||
|
||||
// Reset title when dialog opens with new default
|
||||
// On open: seed title from defaultTitle. On close without confirming: reset both fields to empty.
|
||||
const handleOpenChange = (newOpen: boolean) => {
|
||||
if (newOpen && defaultTitle) {
|
||||
setTitle(defaultTitle);
|
||||
if (newOpen) {
|
||||
if (defaultTitle) setTitle(defaultTitle);
|
||||
} else {
|
||||
// Reset both fields when dismissed without confirming
|
||||
setTitle("");
|
||||
setBody("");
|
||||
}
|
||||
onOpenChange(newOpen);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Task, TaskStatus, Team } from "@/types";
|
||||
import { useDeleteTask, useUpdateTask } from "@/hooks/use-tasks";
|
||||
import { useDeleteTask, useUpdateTask, useTaskValidTransitions } from "@/hooks/use-tasks";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import {
|
||||
@@ -40,6 +40,7 @@ import {
|
||||
AlertTriangle,
|
||||
Trash2,
|
||||
GitBranch,
|
||||
GitMerge,
|
||||
GitPullRequest,
|
||||
FileCheck,
|
||||
Send,
|
||||
@@ -94,6 +95,10 @@ export function TaskHeader({ task, onAction }: TaskHeaderProps) {
|
||||
const router = useRouter();
|
||||
const deleteTask = useDeleteTask();
|
||||
const updateTask = useUpdateTask();
|
||||
// Fetch valid next statuses from GET /tasks/{id}/valid-transitions.
|
||||
// Falls back to [] while loading or on error — the Select is disabled during loading.
|
||||
const { data: validTransitionsData, isLoading: isTransitionsLoading } = useTaskValidTransitions(task.id);
|
||||
const nextStatuses: TaskStatus[] = validTransitionsData ?? [];
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
// Inline editing states
|
||||
@@ -256,7 +261,7 @@ export function TaskHeader({ task, onAction }: TaskHeaderProps) {
|
||||
actions.push({ label: "Request Changes", action: "request-changes", icon: <ThumbsDown className="h-4 w-4 mr-2" /> });
|
||||
break;
|
||||
case TaskStatus.AWAITING_CEO_APPROVAL:
|
||||
actions.push({ label: "Approve & Merge", action: "ceo-approve", icon: <ThumbsUp className="h-4 w-4 mr-2" /> });
|
||||
actions.push({ label: "Approve & Merge", action: "approve-and-merge", icon: <ThumbsUp className="h-4 w-4 mr-2" /> });
|
||||
actions.push({ label: "Request Changes", action: "ceo-reject", icon: <ThumbsDown className="h-4 w-4 mr-2" /> });
|
||||
break;
|
||||
case TaskStatus.CANCELLED:
|
||||
@@ -269,6 +274,11 @@ export function TaskHeader({ task, onAction }: TaskHeaderProps) {
|
||||
actions.push({ label: "Cancel Task", action: "cancel", icon: <XCircle className="h-4 w-4 mr-2" /> });
|
||||
}
|
||||
|
||||
// Merge PR is available whenever task.pr_number is set and the task is not in a terminal state
|
||||
if (task.pr_number && task.status !== TaskStatus.COMPLETED && task.status !== TaskStatus.CANCELLED) {
|
||||
actions.push({ label: "Merge PR", action: "merge-pr", icon: <GitMerge className="h-4 w-4 mr-2" /> });
|
||||
}
|
||||
|
||||
return actions;
|
||||
};
|
||||
|
||||
@@ -307,13 +317,24 @@ export function TaskHeader({ task, onAction }: TaskHeaderProps) {
|
||||
</h1>
|
||||
)}
|
||||
|
||||
{/* Status Dropdown */}
|
||||
{/* Status Dropdown — only current status + valid next statuses from backend */}
|
||||
<Select value={task.status} onValueChange={(v) => handleStatusChange(v as TaskStatus)}>
|
||||
<SelectTrigger className={`w-auto h-7 text-xs font-medium border-0 ${statusColors[task.status]}`}>
|
||||
<SelectTrigger
|
||||
className={`w-auto h-7 text-xs font-medium border-0 ${statusColors[task.status]}`}
|
||||
disabled={isTransitionsLoading}
|
||||
>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{Object.values(TaskStatus).map((status) => (
|
||||
{/* Always render the current status first so the trigger value is always present */}
|
||||
<SelectItem key={task.status} value={task.status}>
|
||||
<span className={`px-2 py-0.5 rounded ${statusColors[task.status]}`}>
|
||||
{statusLabels[task.status]}
|
||||
</span>
|
||||
</SelectItem>
|
||||
{/* nextStatuses sourced exclusively from useTaskValidTransitions
|
||||
(GET /tasks/{id}/valid-transitions) — no local fallback array */}
|
||||
{nextStatuses.map((status) => (
|
||||
<SelectItem key={status} value={status}>
|
||||
<span className={`px-2 py-0.5 rounded ${statusColors[status]}`}>
|
||||
{statusLabels[status]}
|
||||
|
||||
Reference in New Issue
Block a user