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 <mrubens@users.noreply.github.com>
This commit is contained in:
Roomote Bot 2025-07-12 10:47:13 -07:00 • committed by GitHub
parent 5bffebde58
commit 2220a2d2ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 58 additions and 26 deletions

View file

@ -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 (
<div className="flex flex-col gap-3">
{tasks.length !== 0 && (
<>
{tasks.slice(0, 3).map((item) => (
{tasks.slice(0, 2).map((item) => (
<TaskItem key={item.id} item={item} variant="compact" />
))}
<button
onClick={handleViewAllHistory}
className="text-base text-vscode-descriptionForeground hover:text-vscode-textLink-foreground transition-colors cursor-pointer text-center w-full bg-vscode-editor-background rounded p-3 hover:border-vscode-toolbar-hoverBackground/60"
aria-label={t("history:viewAllHistory")}>
{t("history:viewAllHistory")}
</button>
</>
)}
</div>

View file

@ -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(<HistoryPreview />)
// 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", () => {

View file

@ -47,5 +47,6 @@
"mostExpensive": "Més cares",
"mostTokens": "Més tokens",
"mostRelevant": "Més rellevants"
}
},
"viewAllHistory": "Veure totes les tasques"
}

View file

@ -47,5 +47,6 @@
"mostExpensive": "Teuerste",
"mostTokens": "Meiste Tokens",
"mostRelevant": "Relevanteste"
}
},
"viewAllHistory": "Gesamten Verlauf anzeigen"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "Most Expensive",
"mostTokens": "Most Tokens",
"mostRelevant": "Most Relevant"
}
},
"viewAllHistory": "View all tasks"
}

View file

@ -47,5 +47,6 @@
"mostExpensive": "Más costosas",
"mostTokens": "Más tokens",
"mostRelevant": "Más relevantes"
}
},
"viewAllHistory": "Ver todo el historial"
}

View file

@ -47,5 +47,6 @@
"mostExpensive": "Plus coûteuses",
"mostTokens": "Plus de tokens",
"mostRelevant": "Plus pertinentes"
}
},
"viewAllHistory": "Voir tout l'historique"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "सबसे महंगा",
"mostTokens": "सबसे अधिक टोकन",
"mostRelevant": "सबसे प्रासंगिक"
}
},
"viewAllHistory": "सभी कार्य देखें"
}

View file

@ -49,5 +49,6 @@
"mostExpensive": "Termahal",
"mostTokens": "Token Terbanyak",
"mostRelevant": "Paling Relevan"
}
},
"viewAllHistory": "Lihat semua tugas"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "Più costose",
"mostTokens": "Più token",
"mostRelevant": "Più rilevanti"
}
},
"viewAllHistory": "Visualizza tutta la cronologia"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "最も高価",
"mostTokens": "最多トークン",
"mostRelevant": "最も関連性の高い"
}
},
"viewAllHistory": "すべての履歴を表示"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "가장 비싼순",
"mostTokens": "토큰 많은순",
"mostRelevant": "관련성 높은순"
}
},
"viewAllHistory": "모든 기록 보기"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "Duurste",
"mostTokens": "Meeste tokens",
"mostRelevant": "Meest relevant"
}
},
"viewAllHistory": "Alle geschiedenis bekijken"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "Najdroższe",
"mostTokens": "Najwięcej tokenów",
"mostRelevant": "Najbardziej trafne"
}
},
"viewAllHistory": "Zobacz wszystkie zadania"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "Mais caras",
"mostTokens": "Mais tokens",
"mostRelevant": "Mais relevantes"
}
},
"viewAllHistory": "Ver todo o histórico"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "Самые дорогие",
"mostTokens": "Больше всего токенов",
"mostRelevant": "Наиболее релевантные"
}
},
"viewAllHistory": "Просмотреть всю историю"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "En Pahalı",
"mostTokens": "En Çok Token",
"mostRelevant": "En İlgili"
}
},
"viewAllHistory": "Tüm görevleri görüntüle"
}

View file

@ -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ụ"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "费用最高",
"mostTokens": "最多 Token",
"mostRelevant": "最相关"
}
},
"viewAllHistory": "查看所有历史记录"
}

View file

@ -40,5 +40,6 @@
"mostExpensive": "費用最高",
"mostTokens": "最多 Token",
"mostRelevant": "最相關"
}
},
"viewAllHistory": "檢視所有工作"
}