From 1e7af9f5c8beb9a134d8bbf9a6cb79e83e7f5cad Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Mon, 3 Mar 2025 08:54:08 -0800 Subject: [PATCH] Support feedback for individual prompts (#43) --- app/components/chat/ApproveChange.tsx | 121 ++++++++++++++++++++++ app/components/chat/BaseChat.tsx | 54 ++++------ app/components/chat/Chat.client.tsx | 107 ++++++++++++++++++- app/components/chat/Messages.client.tsx | 53 +++++++++- app/components/chat/SendButton.client.tsx | 21 ++-- app/lib/.server/llm/chat-anthropic.ts | 16 +-- app/lib/hooks/pingTelemetry.ts | 13 +++ app/lib/hooks/useSimulation.ts | 16 +++ app/routes/api.ping-telemetry.ts | 28 +++++ app/routes/api.use-simulation.ts | 55 ++++++++++ 10 files changed, 427 insertions(+), 57 deletions(-) create mode 100644 app/components/chat/ApproveChange.tsx create mode 100644 app/lib/hooks/pingTelemetry.ts create mode 100644 app/lib/hooks/useSimulation.ts create mode 100644 app/routes/api.ping-telemetry.ts create mode 100644 app/routes/api.use-simulation.ts diff --git a/app/components/chat/ApproveChange.tsx b/app/components/chat/ApproveChange.tsx new file mode 100644 index 00000000..a15ba08d --- /dev/null +++ b/app/components/chat/ApproveChange.tsx @@ -0,0 +1,121 @@ +import React, { useRef, useState } from 'react'; +import { classNames } from '~/utils/classNames'; +import { TEXTAREA_MIN_HEIGHT } from './BaseChat'; + +export interface RejectChangeData { + explanation: string; + shareProject: boolean; + retry: boolean; +} + +interface ApproveChangeProps { + onApprove: () => void; + onReject: (data: RejectChangeData) => void; +} + +const ApproveChange: React.FC = ({ onApprove, onReject }) => { + const textareaRef = useRef(null); + const [hasRejected, setHasRejected] = useState(false); + const [shareProject, setShareProject] = useState(false); + + if (hasRejected) { + const performReject = (retry: boolean) => { + const explanation = textareaRef.current?.value ?? ''; + onReject({ + explanation, + shareProject, + retry, + }); + }; + + return ( + <> +
+