import React, { useState } from 'react'; import { useIsProposeChangesModalOpen, useProposeChangesRequest, useUISelector, } from '../../contexts/UIContext'; const prettyJson = (obj: any) => { try { return JSON.stringify(obj, null, 2); } catch { return String(obj); } }; const ProposeChangesModal = function ProposeChangesModal() { const open = useIsProposeChangesModalOpen(); // const setOpen = useSetIsProposeChangesModalOpen(); const req = useProposeChangesRequest(); const resolve = useUISelector((s) => s.resolveProposeChanges); const [userReason, setUserReason] = useState(''); const goal = (req && (req.arguments?.goal ?? req.goal)) || ''; const actions = (req && (req.arguments?.actions ?? req.actions)) || []; const checks = (req && (req.arguments?.checks ?? req.checks)) || []; if (!open) return null; // Decision is communicated via a custom event the ChatContext listens to (by ref), // or via a resolver in UIContext that is handled when the modal closes. Here we // emit a DOM event; ChatContext doesn't need to import this component directly. const resolveDecision = (approved: boolean) => { resolve({ approved, user_reason: approved ? undefined : (userReason || undefined) }); }; return (
resolveDecision(false)} />

Review proposed changes

{goal && (
Goal
{goal}
)} {Array.isArray(actions) && actions.length > 0 && (
Actions ({actions.length})
                {prettyJson(actions)}
              
)} {Array.isArray(checks) && checks.length > 0 && (
Post-apply checks
                {prettyJson(checks)}
              
)}
setUserReason(e.target.value)} placeholder="Optional" className="w-full text-sm px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-blue-500" />
); } export default React.memo(ProposeChangesModal);