From 44094aa16379627dbd5dd53e2626d21acd6b58ea Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 30 Jun 2025 22:11:57 -0700 Subject: [PATCH] feat: streaming input w/ history to rule dialog --- gui/src/components/FeedbackButtons.tsx | 6 +- .../GenerateRuleDialog/GenerationScreen.tsx | 95 ++++++++++++++ .../GenerateRuleDialog/InputScreen.tsx | 81 ++++++++++++ .../components/GenerateRuleDialog/index.tsx | 124 +++++++++--------- .../GenerateRuleDialog/useRuleGeneration.ts | 96 ++++++++++++++ .../StepContainer/ResponseActions.tsx | 14 +- gui/src/components/dialogs/index.tsx | 30 ++--- .../belowMainInput/ContextItemsPeek.tsx | 8 +- .../mainInput/belowMainInput/RulesPeek.tsx | 6 +- .../belowMainInput/ThinkingBlockPeek.tsx | 2 +- 10 files changed, 368 insertions(+), 94 deletions(-) create mode 100644 gui/src/components/GenerateRuleDialog/GenerationScreen.tsx create mode 100644 gui/src/components/GenerateRuleDialog/InputScreen.tsx create mode 100644 gui/src/components/GenerateRuleDialog/useRuleGeneration.ts diff --git a/gui/src/components/FeedbackButtons.tsx b/gui/src/components/FeedbackButtons.tsx index 6ad0992df..009666859 100644 --- a/gui/src/components/FeedbackButtons.tsx +++ b/gui/src/components/FeedbackButtons.tsx @@ -12,7 +12,7 @@ export interface FeedbackButtonsProps { item: ChatHistoryItem; } -export default function FeedbackButtons({ item }: FeedbackButtonsProps) { +export function FeedbackButtons({ item }: FeedbackButtonsProps) { const [feedback, setFeedback] = useState(undefined); const ideMessenger = useContext(IdeMessengerContext); const sessionId = useAppSelector((store) => store.session.id); @@ -41,7 +41,7 @@ export default function FeedbackButtons({ item }: FeedbackButtonsProps) { onClick={() => sendFeedback(true)} > sendFeedback(false)} > diff --git a/gui/src/components/GenerateRuleDialog/GenerationScreen.tsx b/gui/src/components/GenerateRuleDialog/GenerationScreen.tsx new file mode 100644 index 000000000..317873d5c --- /dev/null +++ b/gui/src/components/GenerateRuleDialog/GenerationScreen.tsx @@ -0,0 +1,95 @@ +import { useEffect, useRef, useState } from "react"; +import Spinner from "../gui/Spinner"; +import { Button } from "../ui"; + +interface GenerationScreenProps { + generatedContent: string; + isGenerating: boolean; + error: string | null; + onBack: () => void; + onContinue: () => void; +} + +export function GenerationScreen({ + generatedContent, + isGenerating, + error, + onBack, + onContinue, +}: GenerationScreenProps) { + const [editableContent, setEditableContent] = useState(""); + const textareaRef = useRef(null); + + // Update editable content when generation completes + useEffect(() => { + if (!isGenerating && generatedContent) { + setEditableContent(generatedContent); + } + }, [isGenerating, generatedContent]); + + // Auto-scroll textarea as content streams in + useEffect(() => { + if (textareaRef.current && isGenerating) { + textareaRef.current.scrollTop = textareaRef.current.scrollHeight; + } + }, [generatedContent, isGenerating]); + + const displayContent = isGenerating ? generatedContent : editableContent; + const showSpinner = isGenerating && !generatedContent; + + return ( +
+
+
+

Your rule

+

+ Review and edit your generated rule below +

+
+
+
+
+