fix(frontend): show instruction label only for HITL blocks, clean up messaging

- Only show instruction label when it's in payload (HITL blocks)
- Don't show label for sensitive action blocks (uses review.instructions)
- Add backward compatibility for old format reviews
- Simplify auto-approve message (remove review count)
- Remove obvious code comments
This commit is contained in:
Zamil Majdy
2026-01-24 09:33:37 -06:00
parent 99210549c7
commit 385536c2aa
2 changed files with 32 additions and 29 deletions

View File

@@ -56,7 +56,17 @@ export function PendingReviewCard({
}: PendingReviewCardProps) {
const extractedData = extractReviewData(review.payload);
const isDataEditable = review.editable;
const instructions = extractedData.instructions || review.instructions;
// Get instructions - clean up old format if it exists
let instructions = extractedData.instructions || review.instructions;
if (instructions) {
// Remove old wrapper format: "Review required for X execution" -> "X"
const match = instructions.match(/^Review required for (.+?) execution$/);
if (match) {
instructions = match[1];
}
}
const [currentData, setCurrentData] = useState(extractedData.data);
// Sync with external data value when auto-approve is toggled
@@ -148,19 +158,15 @@ export function PendingReviewCard({
return `${id.slice(0, 4)}...${id.slice(-4)}`;
};
// Use the existing HITL review interface
return (
<div className="space-y-4">
{/* Show node identifier if provided */}
{nodeId && (
<Text variant="small" className="text-gray-500">
Node #{getShortenedNodeId(nodeId)}
</Text>
)}
{/* Show data input/display */}
<div className="space-y-3">
{/* Show label for HITL blocks (when instructions exist) */}
{instructions && (
<Text variant="body" className="font-semibold text-gray-900">
{instructions}

View File

@@ -283,7 +283,17 @@ export function PendingReviewsList({
// Get review title from instructions field
// Only show if it's a HITL block (has custom instructions)
const firstReview = nodeReviews[0];
const reviewTitle = firstReview?.instructions;
let reviewTitle = firstReview?.instructions;
// Clean up old format if it exists: "Review required for X execution" -> "X"
if (reviewTitle) {
const match = reviewTitle.match(
/^Review required for (.+?) execution$/,
);
if (match) {
reviewTitle = match[1];
}
}
// Helper to shorten node ID
const getShortenedNodeId = (id: string) => {
@@ -293,7 +303,6 @@ export function PendingReviewsList({
return (
<div key={nodeId} className="space-y-4">
{/* Group Header - Always show for all groups */}
<button
onClick={() => toggleGroupCollapse(nodeId)}
className="flex w-full items-center gap-2 text-left"
@@ -321,7 +330,6 @@ export function PendingReviewsList({
</span>
</button>
{/* Reviews in this group */}
{!isCollapsed && (
<div className="space-y-4">
{nodeReviews.map((review) => (
@@ -335,27 +343,16 @@ export function PendingReviewsList({
/>
))}
{/* Auto-approve toggle for the entire node group */}
<div className="space-y-2 pt-2">
<div className="flex items-center gap-3">
<Switch
checked={autoApproveFutureMap[nodeId] || false}
onCheckedChange={(enabled: boolean) =>
handleAutoApproveFutureToggle(nodeId, enabled)
}
/>
<Text variant="small" className="text-gray-700">
Auto-approve future executions of{" "}
{reviewTitle || `Node #${getShortenedNodeId(nodeId)}`}
</Text>
</div>
{autoApproveFutureMap[nodeId] && (
<Text variant="small" className="pl-11 text-gray-500">
Original data will be used for all {reviewCount}{" "}
{reviewCount === 1 ? "review" : "reviews"} in future
executions.
</Text>
)}
<div className="flex items-center gap-3 pt-2">
<Switch
checked={autoApproveFutureMap[nodeId] || false}
onCheckedChange={(enabled: boolean) =>
handleAutoApproveFutureToggle(nodeId, enabled)
}
/>
<Text variant="small" className="text-gray-700">
Auto-approve future executions of this node
</Text>
</div>
</div>
)}