From 2220a2d2ba7a1c2a5a579857b767d01130221853 Mon Sep 17 00:00:00 2001 From: Roomote Bot Date: Sat, 12 Jul 2025 10:47:13 -0700 Subject: [PATCH] Add navigation link to history tab in HistoryPreview (#5630) * feat: add navigation link to history tab in HistoryPreview - Add 'View all history' link at bottom of history preview - Include internationalization support with new translation key - Use consistent styling with VSCode theme colors - Navigate to history tab using switchTab message format * feat: add viewAllHistory translation to all language files * Tweaks and translations * Fix test --------- Co-authored-by: Matt Rubens --- .../src/components/history/HistoryPreview.tsx | 16 +++++++++++++++- .../history/__tests__/HistoryPreview.spec.tsx | 14 +++++++------- webview-ui/src/i18n/locales/ca/history.json | 3 ++- webview-ui/src/i18n/locales/de/history.json | 3 ++- webview-ui/src/i18n/locales/en/history.json | 3 ++- webview-ui/src/i18n/locales/es/history.json | 3 ++- webview-ui/src/i18n/locales/fr/history.json | 3 ++- webview-ui/src/i18n/locales/hi/history.json | 3 ++- webview-ui/src/i18n/locales/id/history.json | 3 ++- webview-ui/src/i18n/locales/it/history.json | 3 ++- webview-ui/src/i18n/locales/ja/history.json | 3 ++- webview-ui/src/i18n/locales/ko/history.json | 3 ++- webview-ui/src/i18n/locales/nl/history.json | 3 ++- webview-ui/src/i18n/locales/pl/history.json | 3 ++- webview-ui/src/i18n/locales/pt-BR/history.json | 3 ++- webview-ui/src/i18n/locales/ru/history.json | 3 ++- webview-ui/src/i18n/locales/tr/history.json | 3 ++- webview-ui/src/i18n/locales/vi/history.json | 3 ++- webview-ui/src/i18n/locales/zh-CN/history.json | 3 ++- webview-ui/src/i18n/locales/zh-TW/history.json | 3 ++- 20 files changed, 58 insertions(+), 26 deletions(-) diff --git a/webview-ui/src/components/history/HistoryPreview.tsx b/webview-ui/src/components/history/HistoryPreview.tsx index 892a8a220f..7b9ff68c18 100644 --- a/webview-ui/src/components/history/HistoryPreview.tsx +++ b/webview-ui/src/components/history/HistoryPreview.tsx @@ -1,18 +1,32 @@ import { memo } from "react" +import { vscode } from "@src/utils/vscode" +import { useAppTranslation } from "@src/i18n/TranslationContext" + import { useTaskSearch } from "./useTaskSearch" import TaskItem from "./TaskItem" const HistoryPreview = () => { const { tasks } = useTaskSearch() + const { t } = useAppTranslation() + + const handleViewAllHistory = () => { + vscode.postMessage({ type: "switchTab", tab: "history" }) + } return (
{tasks.length !== 0 && ( <> - {tasks.slice(0, 3).map((item) => ( + {tasks.slice(0, 2).map((item) => ( ))} + )}
diff --git a/webview-ui/src/components/history/__tests__/HistoryPreview.spec.tsx b/webview-ui/src/components/history/__tests__/HistoryPreview.spec.tsx index 6118509702..0874fecec7 100644 --- a/webview-ui/src/components/history/__tests__/HistoryPreview.spec.tsx +++ b/webview-ui/src/components/history/__tests__/HistoryPreview.spec.tsx @@ -86,7 +86,7 @@ describe("HistoryPreview", () => { expect(screen.queryByTestId(/task-item-/)).not.toBeInTheDocument() }) - it("renders up to 3 tasks when tasks are available", () => { + it("renders up to 2 tasks when tasks are available", () => { mockUseTaskSearch.mockReturnValue({ tasks: mockTasks, searchQuery: "", @@ -101,17 +101,17 @@ describe("HistoryPreview", () => { render() - // Should render only the first 3 tasks + // Should render only the first 2 tasks expect(screen.getByTestId("task-item-task-1")).toBeInTheDocument() expect(screen.getByTestId("task-item-task-2")).toBeInTheDocument() - expect(screen.getByTestId("task-item-task-3")).toBeInTheDocument() + expect(screen.queryByTestId("task-item-task-3")).not.toBeInTheDocument() expect(screen.queryByTestId("task-item-task-4")).not.toBeInTheDocument() }) - it("renders all tasks when there are 3 or fewer", () => { - const threeTasks = mockTasks.slice(0, 3) + it("renders all tasks when there are 2 or fewer", () => { + const twoTasks = mockTasks.slice(0, 2) mockUseTaskSearch.mockReturnValue({ - tasks: threeTasks, + tasks: twoTasks, searchQuery: "", setSearchQuery: vi.fn(), sortOption: "newest", @@ -126,7 +126,7 @@ describe("HistoryPreview", () => { expect(screen.getByTestId("task-item-task-1")).toBeInTheDocument() expect(screen.getByTestId("task-item-task-2")).toBeInTheDocument() - expect(screen.getByTestId("task-item-task-3")).toBeInTheDocument() + expect(screen.queryByTestId("task-item-task-3")).not.toBeInTheDocument() }) it("renders only 1 task when there is only 1 task", () => { diff --git a/webview-ui/src/i18n/locales/ca/history.json b/webview-ui/src/i18n/locales/ca/history.json index 99b39ec044..bd7dafe3da 100644 --- a/webview-ui/src/i18n/locales/ca/history.json +++ b/webview-ui/src/i18n/locales/ca/history.json @@ -47,5 +47,6 @@ "mostExpensive": "Més cares", "mostTokens": "Més tokens", "mostRelevant": "Més rellevants" - } + }, + "viewAllHistory": "Veure totes les tasques" } diff --git a/webview-ui/src/i18n/locales/de/history.json b/webview-ui/src/i18n/locales/de/history.json index fe9df63f2c..ed1a166d11 100644 --- a/webview-ui/src/i18n/locales/de/history.json +++ b/webview-ui/src/i18n/locales/de/history.json @@ -47,5 +47,6 @@ "mostExpensive": "Teuerste", "mostTokens": "Meiste Tokens", "mostRelevant": "Relevanteste" - } + }, + "viewAllHistory": "Gesamten Verlauf anzeigen" } diff --git a/webview-ui/src/i18n/locales/en/history.json b/webview-ui/src/i18n/locales/en/history.json index 964d19d734..8d00433170 100644 --- a/webview-ui/src/i18n/locales/en/history.json +++ b/webview-ui/src/i18n/locales/en/history.json @@ -40,5 +40,6 @@ "mostExpensive": "Most Expensive", "mostTokens": "Most Tokens", "mostRelevant": "Most Relevant" - } + }, + "viewAllHistory": "View all tasks" } diff --git a/webview-ui/src/i18n/locales/es/history.json b/webview-ui/src/i18n/locales/es/history.json index 3294eeff90..cde9a2e182 100644 --- a/webview-ui/src/i18n/locales/es/history.json +++ b/webview-ui/src/i18n/locales/es/history.json @@ -47,5 +47,6 @@ "mostExpensive": "Más costosas", "mostTokens": "Más tokens", "mostRelevant": "Más relevantes" - } + }, + "viewAllHistory": "Ver todo el historial" } diff --git a/webview-ui/src/i18n/locales/fr/history.json b/webview-ui/src/i18n/locales/fr/history.json index 6c4612199f..80f08341a5 100644 --- a/webview-ui/src/i18n/locales/fr/history.json +++ b/webview-ui/src/i18n/locales/fr/history.json @@ -47,5 +47,6 @@ "mostExpensive": "Plus coûteuses", "mostTokens": "Plus de tokens", "mostRelevant": "Plus pertinentes" - } + }, + "viewAllHistory": "Voir tout l'historique" } diff --git a/webview-ui/src/i18n/locales/hi/history.json b/webview-ui/src/i18n/locales/hi/history.json index cbde12035a..198a774a37 100644 --- a/webview-ui/src/i18n/locales/hi/history.json +++ b/webview-ui/src/i18n/locales/hi/history.json @@ -40,5 +40,6 @@ "mostExpensive": "सबसे महंगा", "mostTokens": "सबसे अधिक टोकन", "mostRelevant": "सबसे प्रासंगिक" - } + }, + "viewAllHistory": "सभी कार्य देखें" } diff --git a/webview-ui/src/i18n/locales/id/history.json b/webview-ui/src/i18n/locales/id/history.json index 912d0c2b02..6459566e5a 100644 --- a/webview-ui/src/i18n/locales/id/history.json +++ b/webview-ui/src/i18n/locales/id/history.json @@ -49,5 +49,6 @@ "mostExpensive": "Termahal", "mostTokens": "Token Terbanyak", "mostRelevant": "Paling Relevan" - } + }, + "viewAllHistory": "Lihat semua tugas" } diff --git a/webview-ui/src/i18n/locales/it/history.json b/webview-ui/src/i18n/locales/it/history.json index dd0c97925b..0688c1f118 100644 --- a/webview-ui/src/i18n/locales/it/history.json +++ b/webview-ui/src/i18n/locales/it/history.json @@ -40,5 +40,6 @@ "mostExpensive": "Più costose", "mostTokens": "Più token", "mostRelevant": "Più rilevanti" - } + }, + "viewAllHistory": "Visualizza tutta la cronologia" } diff --git a/webview-ui/src/i18n/locales/ja/history.json b/webview-ui/src/i18n/locales/ja/history.json index 2f60ab97d0..17ea86b74a 100644 --- a/webview-ui/src/i18n/locales/ja/history.json +++ b/webview-ui/src/i18n/locales/ja/history.json @@ -40,5 +40,6 @@ "mostExpensive": "最も高価", "mostTokens": "最多トークン", "mostRelevant": "最も関連性の高い" - } + }, + "viewAllHistory": "すべての履歴を表示" } diff --git a/webview-ui/src/i18n/locales/ko/history.json b/webview-ui/src/i18n/locales/ko/history.json index f1bedad5cb..4b8cde8c32 100644 --- a/webview-ui/src/i18n/locales/ko/history.json +++ b/webview-ui/src/i18n/locales/ko/history.json @@ -40,5 +40,6 @@ "mostExpensive": "가장 비싼순", "mostTokens": "토큰 많은순", "mostRelevant": "관련성 높은순" - } + }, + "viewAllHistory": "모든 기록 보기" } diff --git a/webview-ui/src/i18n/locales/nl/history.json b/webview-ui/src/i18n/locales/nl/history.json index 5e46b12ab9..a25d1ff195 100644 --- a/webview-ui/src/i18n/locales/nl/history.json +++ b/webview-ui/src/i18n/locales/nl/history.json @@ -40,5 +40,6 @@ "mostExpensive": "Duurste", "mostTokens": "Meeste tokens", "mostRelevant": "Meest relevant" - } + }, + "viewAllHistory": "Alle geschiedenis bekijken" } diff --git a/webview-ui/src/i18n/locales/pl/history.json b/webview-ui/src/i18n/locales/pl/history.json index 1ebd60ff3c..29063b2895 100644 --- a/webview-ui/src/i18n/locales/pl/history.json +++ b/webview-ui/src/i18n/locales/pl/history.json @@ -40,5 +40,6 @@ "mostExpensive": "Najdroższe", "mostTokens": "Najwięcej tokenów", "mostRelevant": "Najbardziej trafne" - } + }, + "viewAllHistory": "Zobacz wszystkie zadania" } diff --git a/webview-ui/src/i18n/locales/pt-BR/history.json b/webview-ui/src/i18n/locales/pt-BR/history.json index 14aa987ef9..85006b2d93 100644 --- a/webview-ui/src/i18n/locales/pt-BR/history.json +++ b/webview-ui/src/i18n/locales/pt-BR/history.json @@ -40,5 +40,6 @@ "mostExpensive": "Mais caras", "mostTokens": "Mais tokens", "mostRelevant": "Mais relevantes" - } + }, + "viewAllHistory": "Ver todo o histórico" } diff --git a/webview-ui/src/i18n/locales/ru/history.json b/webview-ui/src/i18n/locales/ru/history.json index 4228895c85..3fa10b88c2 100644 --- a/webview-ui/src/i18n/locales/ru/history.json +++ b/webview-ui/src/i18n/locales/ru/history.json @@ -40,5 +40,6 @@ "mostExpensive": "Самые дорогие", "mostTokens": "Больше всего токенов", "mostRelevant": "Наиболее релевантные" - } + }, + "viewAllHistory": "Просмотреть всю историю" } diff --git a/webview-ui/src/i18n/locales/tr/history.json b/webview-ui/src/i18n/locales/tr/history.json index acbe2984cd..854ac127ef 100644 --- a/webview-ui/src/i18n/locales/tr/history.json +++ b/webview-ui/src/i18n/locales/tr/history.json @@ -40,5 +40,6 @@ "mostExpensive": "En Pahalı", "mostTokens": "En Çok Token", "mostRelevant": "En İlgili" - } + }, + "viewAllHistory": "Tüm görevleri görüntüle" } diff --git a/webview-ui/src/i18n/locales/vi/history.json b/webview-ui/src/i18n/locales/vi/history.json index 62acb34e29..97d339e789 100644 --- a/webview-ui/src/i18n/locales/vi/history.json +++ b/webview-ui/src/i18n/locales/vi/history.json @@ -40,5 +40,6 @@ "mostExpensive": "Đắt nhất", "mostTokens": "Nhiều token nhất", "mostRelevant": "Liên quan nhất" - } + }, + "viewAllHistory": "Xem tất cả nhiệm vụ" } diff --git a/webview-ui/src/i18n/locales/zh-CN/history.json b/webview-ui/src/i18n/locales/zh-CN/history.json index be04868d52..5bbe176439 100644 --- a/webview-ui/src/i18n/locales/zh-CN/history.json +++ b/webview-ui/src/i18n/locales/zh-CN/history.json @@ -40,5 +40,6 @@ "mostExpensive": "费用最高", "mostTokens": "最多 Token", "mostRelevant": "最相关" - } + }, + "viewAllHistory": "查看所有历史记录" } diff --git a/webview-ui/src/i18n/locales/zh-TW/history.json b/webview-ui/src/i18n/locales/zh-TW/history.json index 7b68ba1902..447a1e7ef2 100644 --- a/webview-ui/src/i18n/locales/zh-TW/history.json +++ b/webview-ui/src/i18n/locales/zh-TW/history.json @@ -40,5 +40,6 @@ "mostExpensive": "費用最高", "mostTokens": "最多 Token", "mostRelevant": "最相關" - } + }, + "viewAllHistory": "檢視所有工作" }