Skip to content

Commit 2220a2d

Browse files
Add navigation link to history tab in HistoryPreview (RooCodeInc#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 <[email protected]>
1 parent 5bffebd commit 2220a2d

File tree

20 files changed

+58
-26
lines changed

20 files changed

+58
-26
lines changed

webview-ui/src/components/history/HistoryPreview.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
import { memo } from "react"
22

3+
import { vscode } from "@src/utils/vscode"
4+
import { useAppTranslation } from "@src/i18n/TranslationContext"
5+
36
import { useTaskSearch } from "./useTaskSearch"
47
import TaskItem from "./TaskItem"
58

69
const HistoryPreview = () => {
710
const { tasks } = useTaskSearch()
11+
const { t } = useAppTranslation()
12+
13+
const handleViewAllHistory = () => {
14+
vscode.postMessage({ type: "switchTab", tab: "history" })
15+
}
816

917
return (
1018
<div className="flex flex-col gap-3">
1119
{tasks.length !== 0 && (
1220
<>
13-
{tasks.slice(0, 3).map((item) => (
21+
{tasks.slice(0, 2).map((item) => (
1422
<TaskItem key={item.id} item={item} variant="compact" />
1523
))}
24+
<button
25+
onClick={handleViewAllHistory}
26+
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"
27+
aria-label={t("history:viewAllHistory")}>
28+
{t("history:viewAllHistory")}
29+
</button>
1630
</>
1731
)}
1832
</div>

webview-ui/src/components/history/__tests__/HistoryPreview.spec.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe("HistoryPreview", () => {
8686
expect(screen.queryByTestId(/task-item-/)).not.toBeInTheDocument()
8787
})
8888

89-
it("renders up to 3 tasks when tasks are available", () => {
89+
it("renders up to 2 tasks when tasks are available", () => {
9090
mockUseTaskSearch.mockReturnValue({
9191
tasks: mockTasks,
9292
searchQuery: "",
@@ -101,17 +101,17 @@ describe("HistoryPreview", () => {
101101

102102
render(<HistoryPreview />)
103103

104-
// Should render only the first 3 tasks
104+
// Should render only the first 2 tasks
105105
expect(screen.getByTestId("task-item-task-1")).toBeInTheDocument()
106106
expect(screen.getByTestId("task-item-task-2")).toBeInTheDocument()
107-
expect(screen.getByTestId("task-item-task-3")).toBeInTheDocument()
107+
expect(screen.queryByTestId("task-item-task-3")).not.toBeInTheDocument()
108108
expect(screen.queryByTestId("task-item-task-4")).not.toBeInTheDocument()
109109
})
110110

111-
it("renders all tasks when there are 3 or fewer", () => {
112-
const threeTasks = mockTasks.slice(0, 3)
111+
it("renders all tasks when there are 2 or fewer", () => {
112+
const twoTasks = mockTasks.slice(0, 2)
113113
mockUseTaskSearch.mockReturnValue({
114-
tasks: threeTasks,
114+
tasks: twoTasks,
115115
searchQuery: "",
116116
setSearchQuery: vi.fn(),
117117
sortOption: "newest",
@@ -126,7 +126,7 @@ describe("HistoryPreview", () => {
126126

127127
expect(screen.getByTestId("task-item-task-1")).toBeInTheDocument()
128128
expect(screen.getByTestId("task-item-task-2")).toBeInTheDocument()
129-
expect(screen.getByTestId("task-item-task-3")).toBeInTheDocument()
129+
expect(screen.queryByTestId("task-item-task-3")).not.toBeInTheDocument()
130130
})
131131

132132
it("renders only 1 task when there is only 1 task", () => {

webview-ui/src/i18n/locales/ca/history.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@
4747
"mostExpensive": "Més cares",
4848
"mostTokens": "Més tokens",
4949
"mostRelevant": "Més rellevants"
50-
}
50+
},
51+
"viewAllHistory": "Veure totes les tasques"
5152
}

webview-ui/src/i18n/locales/de/history.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@
4747
"mostExpensive": "Teuerste",
4848
"mostTokens": "Meiste Tokens",
4949
"mostRelevant": "Relevanteste"
50-
}
50+
},
51+
"viewAllHistory": "Gesamten Verlauf anzeigen"
5152
}

webview-ui/src/i18n/locales/en/history.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
"mostExpensive": "Most Expensive",
4141
"mostTokens": "Most Tokens",
4242
"mostRelevant": "Most Relevant"
43-
}
43+
},
44+
"viewAllHistory": "View all tasks"
4445
}

webview-ui/src/i18n/locales/es/history.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@
4747
"mostExpensive": "Más costosas",
4848
"mostTokens": "Más tokens",
4949
"mostRelevant": "Más relevantes"
50-
}
50+
},
51+
"viewAllHistory": "Ver todo el historial"
5152
}

webview-ui/src/i18n/locales/fr/history.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@
4747
"mostExpensive": "Plus coûteuses",
4848
"mostTokens": "Plus de tokens",
4949
"mostRelevant": "Plus pertinentes"
50-
}
50+
},
51+
"viewAllHistory": "Voir tout l'historique"
5152
}

webview-ui/src/i18n/locales/hi/history.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
"mostExpensive": "सबसे महंगा",
4141
"mostTokens": "सबसे अधिक टोकन",
4242
"mostRelevant": "सबसे प्रासंगिक"
43-
}
43+
},
44+
"viewAllHistory": "सभी कार्य देखें"
4445
}

webview-ui/src/i18n/locales/id/history.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@
4949
"mostExpensive": "Termahal",
5050
"mostTokens": "Token Terbanyak",
5151
"mostRelevant": "Paling Relevan"
52-
}
52+
},
53+
"viewAllHistory": "Lihat semua tugas"
5354
}

webview-ui/src/i18n/locales/it/history.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
"mostExpensive": "Più costose",
4141
"mostTokens": "Più token",
4242
"mostRelevant": "Più rilevanti"
43-
}
43+
},
44+
"viewAllHistory": "Visualizza tutta la cronologia"
4445
}

0 commit comments

Comments
 (0)