Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
Add working indicator to chat
Abi Rajac6b6a21e8da9
diff --git a/frontend/src/components/agent/AgentActivity.tsx b/frontend/src/components/agent/AgentActivity.tsxindex 53ae6ea7..c9747107 100644--- a/frontend/src/components/agent/AgentActivity.tsx+++ b/frontend/src/components/agent/AgentActivity.tsx@@ -21,6 +21,7 @@ import ReactMarkdown from "react-markdown";import { Light as SyntaxHighlighterBase } from "react-syntax-highlighter";import html from "react-syntax-highlighter/dist/esm/languages/hljs/xml";import { vs2015 } from "react-syntax-highlighter/dist/esm/styles/hljs";+import Spinner from "../core/Spinner";SyntaxHighlighterBase.registerLanguage("html", html);const SyntaxHighlighter = SyntaxHighlighterBase as any;@@ -80,6 +81,11 @@ function formatTotalDuration(events: AgentEvent[]): string {return totalMs > 0 ? formatDurationMs(totalMs) : "";}+function formatElapsedSince(timestampMs: number | undefined, nowMs: number): string {+ if (!isFiniteNumber(timestampMs)) return "";+ return formatDurationMs(Math.max(0, nowMs - timestampMs));+}+function getEventIcon(type: AgentEventType, toolName?: string) {if (type === "thinking") {@@ -413,8 +419,15 @@ function AgentEventCard({function AgentActivity() {const { head, commits, latestCommitHash } = useProjectStore();const [stepsExpanded, setStepsExpanded] = useState(false);+ const [nowMs, setNowMs] = useState(() => Date.now());const appState = useAppStore((s) => s.appState);+ useEffect(() => {+ if (appState !== AppState.CODING) return;+ const intervalId = window.setInterval(() => setNowMs(Date.now()), 1000);+ return () => window.clearInterval(intervalId);+ }, [appState]);+const currentCommit = head ? commits[head] : null;const selectedVariant = currentCommit? currentCommit.variants[currentCommit.selectedVariantIndex]@@ -426,6 +439,10 @@ function AgentActivity() {.reverse().find((event) => event.type === "assistant")?.id;const totalDuration = formatTotalDuration(events);+ const requestStartMs = currentCommit?.dateCreated+ ? new Date(currentCommit.dateCreated).getTime()+ : undefined;+ const runningDuration = formatElapsedSince(requestStartMs, nowMs);const isLatestCommit = head === latestCommitHash;if (!isLatestCommit || events.length === 0) {@@ -473,11 +490,14 @@ function AgentActivity() {) : (<><div className="flex items-center justify-between rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900/60 px-3 py-2">- <div className="text-xs uppercase tracking-wide text-gray-400">- Agent activity+ <div className="flex items-center gap-2 text-sm text-gray-600 dark:text-gray-300">+ <div className="scale-75">+ <Spinner />+ </div>+ <span>Working...</span></div><div className="text-xs font-semibold text-gray-700 dark:text-gray-200">- Time so far {totalDuration || "--"}+ Time so far {runningDuration || "--"}</div></div>{events.map((event) => (diff --git a/frontend/src/components/sidebar/Sidebar.tsx b/frontend/src/components/sidebar/Sidebar.tsxindex f1286f46..b1797a1a 100644--- a/frontend/src/components/sidebar/Sidebar.tsx+++ b/frontend/src/components/sidebar/Sidebar.tsx@@ -9,6 +9,7 @@ import { toast } from "react-hot-toast";import Variants from "../variants/Variants";import UpdateImageUpload, { UpdateImagePreview } from "../UpdateImageUpload";import AgentActivity from "../agent/AgentActivity";+import Spinner from "../core/Spinner";interface SidebarProps {showSelectAndEditFeature: boolean;@@ -29,6 +30,7 @@ function Sidebar({const middlePaneRef = useRef<HTMLDivElement>(null);const [isErrorExpanded, setIsErrorExpanded] = useState(false);const [isDragging, setIsDragging] = useState(false);+ const [nowMs, setNowMs] = useState(() => Date.now());const { appState, updateInstruction, setUpdateInstruction, updateImages, setUpdateImages, inSelectAndEditMode, toggleInSelectAndEditMode } = useAppStore();@@ -86,6 +88,16 @@ function Sidebar({const currentCommit = head ? commits[head] : null;const selectedVariantIndex = currentCommit?.selectedVariantIndex ?? 0;+ const selectedVariant = currentCommit?.variants[selectedVariantIndex];+ const selectedVariantEvents = selectedVariant?.agentEvents ?? [];+ const showWorkingIndicator =+ appState === AppState.CODING && selectedVariantEvents.length === 0;+ const requestStartMs = currentCommit?.dateCreated+ ? new Date(currentCommit.dateCreated).getTime()+ : undefined;+ const elapsedSeconds = requestStartMs+ ? Math.max(1, Math.round((nowMs - requestStartMs) / 1000))+ : undefined;const isFirstGeneration = currentCommit?.type === "ai_create";@@ -146,6 +158,12 @@ function Sidebar({});}, [head, selectedVariantIndex]);+ useEffect(() => {+ if (appState !== AppState.CODING) return;+ const intervalId = window.setInterval(() => setNowMs(Date.now()), 1000);+ return () => window.clearInterval(intervalId);+ }, [appState]);+return (<div className="flex flex-col h-full">@@ -158,6 +176,22 @@ function Sidebar({ref={middlePaneRef}className="flex-1 min-h-0 overflow-y-auto sidebar-scrollbar-stable px-6 pt-4">+ {showWorkingIndicator && (+ <div className="mb-3 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900/60 px-3 py-2">+ <div className="flex items-center justify-between">+ <div className="flex items-center gap-2 text-sm text-gray-600 dark:text-gray-300">+ <div className="scale-75">+ <Spinner />+ </div>+ <span>Working...</span>+ </div>+ <div className="text-xs font-semibold text-gray-700 dark:text-gray-200">+ Time so far {elapsedSeconds ? `${elapsedSeconds}s` : "--"}+ </div>+ </div>+ </div>+ )}+<AgentActivity />{/* Regenerate button for first generation */}