(props: {
open: boolean;
setOpen: () => void;
messageData: UIMessageData;
answer: UIAnswerType;
runCode: (code: string) => void;
actions: Action[];
})
| 186 | } |
| 187 | |
| 188 | export function EditCodeModal(props: { |
| 189 | open: boolean; |
| 190 | setOpen: () => void; |
| 191 | messageData: UIMessageData; |
| 192 | answer: UIAnswerType; |
| 193 | runCode: (code: string) => void; |
| 194 | actions: Action[]; |
| 195 | }) { |
| 196 | const [localCode, setLocalCode] = useState( |
| 197 | parseCodeGenv3(props.messageData.raw_text).code, |
| 198 | ); |
| 199 | const [changed, setChanged] = useState<boolean>(false); |
| 200 | const [showPlan, setShowPlan] = useState(false); |
| 201 | const [showFunctions, setShowFunctions] = useState(false); |
| 202 | const [softWrap, setSoftWrap] = useState(true); |
| 203 | useEffect(() => { |
| 204 | setLocalCode(parseCodeGenv3(props.messageData.raw_text).code); |
| 205 | }, [props.messageData.raw_text]); |
| 206 | const [shownError, setShownError] = useState<string | null>(null); |
| 207 | useEffect(() => { |
| 208 | setShowPlan(false); |
| 209 | }, [props.open]); |
| 210 | useEffect(() => { |
| 211 | const error = props.messageData.generated_output.find( |
| 212 | // @ts-ignore |
| 213 | (m) => m.role === "error", |
| 214 | ); |
| 215 | // @ts-ignore |
| 216 | setShownError(error?.content ?? null); |
| 217 | }, [props.messageData]); |
| 218 | |
| 219 | return ( |
| 220 | <Modal |
| 221 | open={props.open} |
| 222 | setOpen={props.setOpen} |
| 223 | classNames={classNames( |
| 224 | showFunctions ? "lg:w-screen" : "max-w-5xl", |
| 225 | "sm:my-2 lg:my-2", |
| 226 | )} |
| 227 | > |
| 228 | <div className="relative w-full flex flex-col"> |
| 229 | <div |
| 230 | className={ |
| 231 | "mb-2 flex flex-row gap-x-2 text-gray-300 place-items-center w-fit" |
| 232 | } |
| 233 | > |
| 234 | <CodeBracketIcon className={"h-6 w-6"} /> |
| 235 | <h1 className="text-lg text-gray-300">Edit Code</h1> |
| 236 | </div> |
| 237 | <div className="absolute top-0 inset-x-32 flex justify-center mb-0.5 text-lg text-gray-300"> |
| 238 | <QuestionText |
| 239 | questionText={props.answer.approval_questions[0]?.text} |
| 240 | /> |
| 241 | </div> |
| 242 | <div |
| 243 | className={classNames( |
| 244 | "mb-1 whitespace-pre-line rounded px-2 py-1 bg-gray-750 text-gray-300 text-sm font-mono", |
| 245 | "flex flex-row place-items-center gap-x-2", |
nothing calls this directly
no test coverage detected