mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-01 19:03:18 +00:00
125 lines
3.5 KiB
TypeScript
125 lines
3.5 KiB
TypeScript
|
|
"use client";
|
||
|
|
|
||
|
|
import "../app/globals.css";
|
||
|
|
import { useState } from "react";
|
||
|
|
import {
|
||
|
|
CheckCircle,
|
||
|
|
Loader2,
|
||
|
|
ChevronDown,
|
||
|
|
ChevronUp,
|
||
|
|
MessageSquare,
|
||
|
|
FileText,
|
||
|
|
} from "lucide-react";
|
||
|
|
|
||
|
|
type TaskSummaryProps = {
|
||
|
|
status: "loading" | "generating" | "done";
|
||
|
|
summary?: string;
|
||
|
|
reasoningText?: string;
|
||
|
|
summaryText?: string;
|
||
|
|
};
|
||
|
|
|
||
|
|
export function TaskSummary({
|
||
|
|
status,
|
||
|
|
summary,
|
||
|
|
reasoningText,
|
||
|
|
summaryText,
|
||
|
|
}: TaskSummaryProps) {
|
||
|
|
const [expanded, setExpanded] = useState(false);
|
||
|
|
const [showReasoning, setShowReasoning] = useState(false);
|
||
|
|
const [showSummary, setShowSummary] = useState(false);
|
||
|
|
|
||
|
|
const getStatusIcon = () => {
|
||
|
|
switch (status) {
|
||
|
|
case "loading":
|
||
|
|
return (
|
||
|
|
<div className="h-3.5 w-3.5 rounded-full border border-gray-300" />
|
||
|
|
);
|
||
|
|
case "generating":
|
||
|
|
return <Loader2 className="h-3.5 w-3.5 animate-spin text-gray-500" />;
|
||
|
|
case "done":
|
||
|
|
return <CheckCircle className="h-3.5 w-3.5 text-green-500" />;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
const getStatusText = () => {
|
||
|
|
switch (status) {
|
||
|
|
case "loading":
|
||
|
|
return "Preparing task summary...";
|
||
|
|
case "generating":
|
||
|
|
return "Generating summary...";
|
||
|
|
case "done":
|
||
|
|
return "Task completed";
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
return (
|
||
|
|
<div className="overflow-hidden rounded-md border border-gray-200">
|
||
|
|
{reasoningText && (
|
||
|
|
<div className="border-b border-blue-100 bg-blue-50 p-2">
|
||
|
|
<button
|
||
|
|
onClick={() => setShowReasoning(!showReasoning)}
|
||
|
|
className="flex items-center gap-1 text-xs font-normal text-blue-700 hover:text-blue-800"
|
||
|
|
>
|
||
|
|
<MessageSquare className="h-3 w-3" />
|
||
|
|
{showReasoning ? "Hide reasoning" : "Show reasoning"}
|
||
|
|
</button>
|
||
|
|
{showReasoning && (
|
||
|
|
<p className="mt-1 text-xs font-normal text-blue-800">
|
||
|
|
{reasoningText}
|
||
|
|
</p>
|
||
|
|
)}
|
||
|
|
</div>
|
||
|
|
)}
|
||
|
|
|
||
|
|
<div
|
||
|
|
className={`flex items-center bg-gray-50 p-2 ${status === "done" && summary ? "cursor-pointer" : ""}`}
|
||
|
|
onClick={
|
||
|
|
status === "done" && summary
|
||
|
|
? () => setExpanded(!expanded)
|
||
|
|
: undefined
|
||
|
|
}
|
||
|
|
>
|
||
|
|
{getStatusIcon()}
|
||
|
|
<span className="ml-2 flex-1 text-xs font-normal text-gray-800">
|
||
|
|
{getStatusText()}
|
||
|
|
</span>
|
||
|
|
{status === "done" && summary && (
|
||
|
|
<button className="text-gray-500 hover:text-gray-700">
|
||
|
|
{expanded ? (
|
||
|
|
<ChevronUp className="h-3.5 w-3.5" />
|
||
|
|
) : (
|
||
|
|
<ChevronDown className="h-3.5 w-3.5" />
|
||
|
|
)}
|
||
|
|
</button>
|
||
|
|
)}
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{expanded && summary && status === "done" && (
|
||
|
|
<div className="border-t border-gray-200 p-2">
|
||
|
|
<h3 className="mb-1 text-xs font-normal text-gray-500">
|
||
|
|
Task Summary
|
||
|
|
</h3>
|
||
|
|
<p className="text-xs font-normal text-gray-800">{summary}</p>
|
||
|
|
</div>
|
||
|
|
)}
|
||
|
|
|
||
|
|
{summaryText && status === "done" && (
|
||
|
|
<div className="border-t border-green-100 bg-green-50 p-2">
|
||
|
|
<button
|
||
|
|
onClick={() => setShowSummary(!showSummary)}
|
||
|
|
className="flex items-center gap-1 text-xs font-normal text-green-700 hover:text-green-800"
|
||
|
|
>
|
||
|
|
<FileText className="h-3 w-3" />
|
||
|
|
{showSummary ? "Hide summary" : "Show summary"}
|
||
|
|
</button>
|
||
|
|
{showSummary && (
|
||
|
|
<p className="mt-1 text-xs font-normal text-green-800">
|
||
|
|
{summaryText}
|
||
|
|
</p>
|
||
|
|
)}
|
||
|
|
</div>
|
||
|
|
)}
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|