From b4aa929451296acaf4983e8dd306f954a640e7b3 Mon Sep 17 00:00:00 2001 From: Steve Androulakis Date: Mon, 21 Apr 2025 09:00:06 -0700 Subject: [PATCH] confirm box is pretty now --- frontend/src/components/ConfirmInline.jsx | 194 ++++++++++++++++------ 1 file changed, 141 insertions(+), 53 deletions(-) diff --git a/frontend/src/components/ConfirmInline.jsx b/frontend/src/components/ConfirmInline.jsx index c126fee..4bd88c4 100644 --- a/frontend/src/components/ConfirmInline.jsx +++ b/frontend/src/components/ConfirmInline.jsx @@ -1,65 +1,153 @@ -import React, { memo } from "react"; +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 || {}; + const { args = {}, tool } = data || {}; - const renderArgs = () => { - if (!args) return null; - - return ( -
- Args: -
-                    {JSON.stringify(args, null, 2)}
-                
-
- ); - }; + // 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; - if (confirmed) { - return ( -
-
-
- Tool: {tool ?? "Unknown"} -
- {renderArgs()} -
-
- Running {tool}... -
-
- ); + /** 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) => ( +
  1. + +
  2. + ))} +
+ ); } + if (typeof value === "object") { + return ( + + ); + } + + 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 ( -
-
-
- Agent is ready to run the tool: {tool ?? "Unknown"} -
- {renderArgs()} -
- Please confirm to proceed. -
-
-
- -
-
+
+ + + 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'; +ConfirmInline.displayName = "ConfirmInline"; export default ConfirmInline;