Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
Display actual backend error messages in variant UI
Abi Raja2457e4276d71
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex f3802428..c30f51c7 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -219,7 +219,7 @@ function App() {},onVariantError: (variantIndex, error) => {console.error(`Error in variant ${variantIndex}:`, error);- updateVariantStatus(commit.hash, variantIndex, "error");+ updateVariantStatus(commit.hash, variantIndex, "error", error);},onCancel: () => {cancelCodeGenerationAndReset(commit);diff --git a/frontend/src/components/commits/types.ts b/frontend/src/components/commits/types.tsindex 38133017..93959240 100644--- a/frontend/src/components/commits/types.ts+++ b/frontend/src/components/commits/types.ts@@ -5,6 +5,7 @@ export type VariantStatus = "generating" | "complete" | "cancelled" | "error";export type Variant = {code: string;status?: VariantStatus;+ errorMessage?: string;};export type BaseCommit = {diff --git a/frontend/src/components/sidebar/Sidebar.tsx b/frontend/src/components/sidebar/Sidebar.tsxindex cfc2eb32..ed0a24f5 100644--- a/frontend/src/components/sidebar/Sidebar.tsx+++ b/frontend/src/components/sidebar/Sidebar.tsx@@ -8,7 +8,7 @@ import KeyboardShortcutBadge from "../core/KeyboardShortcutBadge";import SelectAndEditModeToggleButton from "../select-and-edit/SelectAndEditModeToggleButton";import { Button } from "../ui/button";import { Textarea } from "../ui/textarea";-import { useEffect, useRef } from "react";+import { useEffect, useRef, useState } from "react";import HistoryDisplay from "../history/HistoryDisplay";import Variants from "../variants/Variants";@@ -26,6 +26,7 @@ function Sidebar({cancelCodeGeneration,}: SidebarProps) {const textareaRef = useRef<HTMLTextAreaElement>(null);+ const [isErrorExpanded, setIsErrorExpanded] = useState(false);const { appState, updateInstruction, setUpdateInstruction } = useAppStore();@@ -50,6 +51,12 @@ function Sidebar({commits[head].variants[commits[head].selectedVariantIndex].status ==="error";+ // Get the error message from the selected variant+ const selectedVariantErrorMessage =+ head &&+ commits[head] &&+ commits[head].variants[commits[head].selectedVariantIndex].errorMessage;+// Focus on the update instruction textarea when a variant is completeuseEffect(() => {if (@@ -60,6 +67,11 @@ function Sidebar({}}, [appState, isSelectedVariantComplete]);+ // Reset error expanded state when variant changes+ useEffect(() => {+ setIsErrorExpanded(false);+ }, [head, commits[head || ""]?.selectedVariantIndex]);+return (<><Variants />@@ -96,9 +108,26 @@ function Sidebar({<div className="bg-red-50 border border-red-200 rounded-md p-3 mb-2"><div className="text-red-800 text-sm"><div className="font-medium mb-1">- This option failed to generate+ This option failed to generate because</div>- <div>Switch to a working option above to make updates.</div>+ {selectedVariantErrorMessage && (+ <div className="mb-2">+ <div className="text-red-700 bg-red-100 border border-red-300 rounded px-2 py-1 text-xs font-mono break-words">+ {selectedVariantErrorMessage.length > 200 && !isErrorExpanded+ ? `${selectedVariantErrorMessage.slice(0, 200)}...`+ : selectedVariantErrorMessage}+ </div>+ {selectedVariantErrorMessage.length > 200 && (+ <button+ onClick={() => setIsErrorExpanded(!isErrorExpanded)}+ className="text-red-600 text-xs underline mt-1 hover:text-red-800"+ >+ {isErrorExpanded ? "Show less" : "Show more"}+ </button>+ )}+ </div>+ )}+ <div>Switch to another option above to make updates.</div></div></div>)}diff --git a/frontend/src/store/project-store.ts b/frontend/src/store/project-store.tsindex e45c52b5..bfe19e3e 100644--- a/frontend/src/store/project-store.ts+++ b/frontend/src/store/project-store.ts@@ -29,7 +29,8 @@ interface ProjectStore {updateVariantStatus: (hash: CommitHash,numVariant: number,- status: VariantStatus+ status: VariantStatus,+ errorMessage?: string) => void;setHead: (hash: CommitHash) => void;@@ -150,7 +151,8 @@ export const useProjectStore = create<ProjectStore>((set) => ({updateVariantStatus: (hash: CommitHash,numVariant: number,- status: VariantStatus+ status: VariantStatus,+ errorMessage?: string) =>set((state) => {const commit = state.commits[hash];@@ -162,7 +164,9 @@ export const useProjectStore = create<ProjectStore>((set) => ({[hash]: {...commit,variants: commit.variants.map((variant, index) =>- index === numVariant ? { ...variant, status } : variant+ index === numVariant+ ? { ...variant, status, errorMessage: status === 'error' ? errorMessage : undefined }+ : variant),},},