import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import type { TaskState } from "@/hooks/useTaskRunner";
import type { WindowFindResult } from "@/hooks/useWindowFind";
import { apiPath } from "@/lib/api";
import { CheckCircle2, Loader2, XCircle } from "lucide-react";
import { useState } from "react";
type AppStatusStripProps = {
window: WindowFindResult;
dispatch: "foreground" | "background";
onFind: () => void;
};
export function AppStatusStrip({
window: w,
dispatch,
onFind,
}: AppStatusStripProps) {
return (
{w.loading ? (
) : w.found ? (
) : (
)}
{w.title}
{w.found && (
HWND {w.handle}
)}
{dispatch}
{w.error && (
{w.error}
)}
);
}
type EvidencePanelProps = { state: TaskState };
export function EvidencePanel({ state }: EvidencePanelProps) {
if (state.status === "idle") return null;
return (
Evidence trail
{state.loading && (
)}
{state.status === "complete" && (
)}
{state.status === "failed" && (
)}
step {state.currentStep} / {state.totalSteps}
{state.error && (
{state.error}
)}
{state.totalSteps > 0 && (
)}
{[...state.evidence].reverse().map((ev) => (
#{ev.step_index}
{ev.kind}
{ev.error && (
{ev.error}
)}
{ev.before_screenshot && (
)}
{ev.after_screenshot && (
)}
))}
);
}
function EvidenceThumb({ path, label }: { path: string; label: string }) {
const filename = path.replace(/\\/g, "/").split("/").pop() ?? path;
const src = apiPath(`/api/v1/download/${encodeURIComponent(filename)}`);
return (
{
(e.target as HTMLImageElement).style.display = "none";
}}
/>
{label}
);
}
type StepRunnerProps = {
templates: Array<{ label: string; steps: object[] }>;
outputDir: string;
onOutputDirChange: (v: string) => void;
onRun: (steps: object[]) => void;
onCancel: () => void;
running: boolean;
};
export function StepRunner({
templates,
outputDir,
onOutputDirChange,
onRun,
onCancel,
running,
}: StepRunnerProps) {
const [selectedTemplate, setSelectedTemplate] = useState(0);
return (
{templates.length > 0 && (
)}
onOutputDirChange(e.target.value)}
placeholder="C:\Users\sandr\AppData\Local\cua-mcp\evidence"
disabled={running}
/>
{!running ? (
) : (
)}
);
}