import React, { memo, useState } from "react";
/** Inline SVG icons so we don’t need an extra library */
const PlayIcon = ({ className }) => (
);
const SpinnerIcon = ({ className }) => (
);
/**
* User‑friendly confirmation card that surfaces tool invocation details
* without developer jargon. Tweaks include:
* • Left green accent‑border + compact heading (visual hierarchy)
* • Collapsible arg list & array support (argument‑list UX)
* • Mobile‑first, pulsing confirm button (button affordance)
*/
const ConfirmInline = memo(({ data, confirmed, onConfirm }) => {
const { args = {}, tool } = data || {};
// Collapsible argument list if we have more than 4 root keys
const [showAll, setShowAll] = useState(false);
const argEntries = Object.entries(args);
const shouldCollapse = argEntries.length > 4 && !showAll;
/** Recursively pretty‑print argument values (objects & arrays). */
const RenderValue = ({ value }) => {
if (value === null || value === undefined) return ‑;
if (Array.isArray(value)) {
return (
{value.map((v, i) => (
-
))}
);
}
if (typeof value === "object") {
return (
{Object.entries(value).map(([k, v]) => (
-
{k}:
))}
);
}
return {String(value)};
};
const cardBase =
"mt-2 p-3 rounded-lg border-l-4 border-green-500 bg-gray-100/60 dark:bg-gray-800/60 shadow-sm";
// ===== Running state =====
if (confirmed) {
return (
Running {tool ?? "Unknown"} …
);
}
// ===== Confirmation state =====
return (
{/* Heading */}
Ready to run {tool ?? "Unknown"}
{/* Dynamic argument list */}
{argEntries.length > 0 && (
{argEntries
.slice(0, shouldCollapse ? 4 : argEntries.length)
.map(([k, v]) => (
{k}:
))}
{shouldCollapse && (
)}
{showAll && argEntries.length > 4 && (
)}
)}
{/* Confirm button */}
);
});
ConfirmInline.displayName = "ConfirmInline";
export default ConfirmInline;