From 4b52fa1b745fca963eff56a39388afd4ab0d5921 Mon Sep 17 00:00:00 2001 From: hannesrudolph Date: Fri, 18 Apr 2025 17:12:42 -0600 Subject: [PATCH] Update welcome screen UI components and fix unused variable --- webview-ui/src/components/chat/ChatView.tsx | 2 +- .../src/components/history/HistoryPreview.tsx | 161 +++++++++++------- webview-ui/src/components/welcome/RooHero.tsx | 36 +++- .../src/components/welcome/WelcomeView.tsx | 2 +- 4 files changed, 130 insertions(+), 71 deletions(-) diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index a3bca8d03b..d65fa868bb 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -1225,8 +1225,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction} {showAnnouncement && } - {taskHistory.length > 0 && } + )} diff --git a/webview-ui/src/components/history/HistoryPreview.tsx b/webview-ui/src/components/history/HistoryPreview.tsx index a49eda9998..47b8c62ebf 100644 --- a/webview-ui/src/components/history/HistoryPreview.tsx +++ b/webview-ui/src/components/history/HistoryPreview.tsx @@ -1,4 +1,4 @@ -import { memo } from "react" +import { memo, useState, useEffect } from "react" import { vscode } from "@/utils/vscode" import { formatLargeNumber, formatDate } from "@/utils/format" @@ -16,20 +16,50 @@ type HistoryPreviewProps = { const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => { const { tasks, showAllWorkspaces } = useTaskSearch() const { t } = useAppTranslation() + // Use a consistent key for localStorage + const STORAGE_KEY = "historyPreview.minimized" + + // Initialize state from localStorage with fallback + const [minimized, setMinimized] = useState(() => { + try { + const savedState = localStorage.getItem(STORAGE_KEY) + return savedState === "true" + } catch (e) { + console.error("Failed to access localStorage:", e) + return false + } + }) + + // Persist state changes to localStorage and notify VSCode + useEffect(() => { + try { + localStorage.setItem(STORAGE_KEY, minimized.toString()) + + // Notify VSCode about state change to persist across sessions + vscode.postMessage({ + type: "historyPreviewState", + minimized, + }) + } catch (e) { + console.error("Failed to save history preview state:", e) + } + }, [minimized]) + + const toggleMinimized = () => { + setMinimized(!minimized) + } return ( <> -
- {!!tasks.length && ( -
-
- - {t("history:recentTasks")} -
- -
+
+ {tasks.length > 0 && ( + )} {tasks.length === 0 && ( <> @@ -54,63 +84,62 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => { )} - {tasks.slice(0, 3).map((item) => ( -
vscode.postMessage({ type: "showTaskWithId", text: item.id })}> -
-
- - {formatDate(item.ts)} - - -
-
- {item.task} -
-
- - {t("history:tokens", { - in: formatLargeNumber(item.tokensIn || 0), - out: formatLargeNumber(item.tokensOut || 0), - })} - - {!!item.cacheWrites && ( - <> - {" • "} - - {t("history:cache", { - writes: formatLargeNumber(item.cacheWrites || 0), - reads: formatLargeNumber(item.cacheReads || 0), - })} - - - )} - {!!item.totalCost && ( - <> - {" • "} - {t("history:apiCost", { cost: item.totalCost?.toFixed(4) })} - + {!minimized && + tasks.slice(0, 3).map((item) => ( +
vscode.postMessage({ type: "showTaskWithId", text: item.id })}> +
+
+ + {formatDate(item.ts)} + + +
+
+ {item.task} +
+
+ + Tokens: ↑{formatLargeNumber(item.tokensIn || 0)} ↓ + {formatLargeNumber(item.tokensOut || 0)} + + {!!item.totalCost && ( + <> + {" • "} + API Cost: ${item.totalCost?.toFixed(4)} + + )} +
+ {showAllWorkspaces && item.workspace && ( +
+ + {item.workspace} +
)}
- {showAllWorkspaces && item.workspace && ( -
- - {item.workspace} -
- )}
-
- ))} + ))} + + {/* View All History button */} + {!minimized && tasks.length > 0 && ( + + )}
) diff --git a/webview-ui/src/components/welcome/RooHero.tsx b/webview-ui/src/components/welcome/RooHero.tsx index 1381fb5d8f..98c0cad0d9 100644 --- a/webview-ui/src/components/welcome/RooHero.tsx +++ b/webview-ui/src/components/welcome/RooHero.tsx @@ -1,8 +1,10 @@ import { useState } from "react" import { useAppTranslation } from "../../i18n/TranslationContext" +import { VSCodeLink } from "@vscode/webview-ui-toolkit/react" const WelcomeView = () => { - const { t } = useAppTranslation() + // Import translation but don't use it yet + useAppTranslation() const [imagesBaseUri] = useState(() => { const w = window as any @@ -10,7 +12,7 @@ const WelcomeView = () => { }) return ( -
+
{ className="mx-auto"> Roo logo
-

{t("chat:greeting")}

+ +

+ Roo Code +

+ +

+ Generate, refactor, and debug code with AI assistance. +
+ Check out our documentation to learn more. +

+ +
+
+ + + + Boomerang Tasks + + : Orchestrate complex workflows with subtasks + +
+
+ + + Sticky Models: + Each mode remembers your last used model + +
+
) } diff --git a/webview-ui/src/components/welcome/WelcomeView.tsx b/webview-ui/src/components/welcome/WelcomeView.tsx index 83f1670466..7b40ff2bcf 100644 --- a/webview-ui/src/components/welcome/WelcomeView.tsx +++ b/webview-ui/src/components/welcome/WelcomeView.tsx @@ -36,7 +36,7 @@ const WelcomeView = () => { return ( - +