Skip to content

Commit 5fab852

Browse files
authored
More tweaks to chatview layout (RooCodeInc#5643)
1 parent 10f3e30 commit 5fab852

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,9 +1663,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
16631663

16641664
<RooHero />
16651665
{telemetrySetting === "unset" && <TelemetryBanner />}
1666-
{/* Show the task history preview if expanded and tasks exist */}
1667-
{taskHistory.length > 0 && isExpanded && <HistoryPreview />}
1668-
<p className="text-vscode-editor-foreground leading-tight font-vscode-font-family text-center text-balance max-w-[380px] mx-auto">
1666+
<p className="text-vscode-editor-foreground leading-tight font-vscode-font-family text-center text-balance max-w-[380px] mx-auto my-0">
16691667
<Trans
16701668
i18nKey="chat:about"
16711669
components={{
@@ -1677,7 +1675,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
16771675
}}
16781676
/>
16791677
</p>
1680-
<RooTips cycle={false} />
1678+
<div className="mb-2.5">
1679+
<RooTips cycle={false} />
1680+
</div>
1681+
{/* Show the task history preview if expanded and tasks exist */}
1682+
{taskHistory.length > 0 && isExpanded && <HistoryPreview />}
16811683
</div>
16821684
</div>
16831685
)}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ const HistoryPreview = () => {
1818
<div className="flex flex-col gap-3">
1919
{tasks.length !== 0 && (
2020
<>
21-
{tasks.slice(0, 2).map((item) => (
21+
{tasks.slice(0, 3).map((item) => (
2222
<TaskItem key={item.id} item={item} variant="compact" />
2323
))}
2424
<button
2525
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"
26+
className="text-base text-vscode-descriptionForeground hover:text-vscode-textLink-foreground transition-colors cursor-pointer text-center w-full"
2727
aria-label={t("history:viewAllHistory")}>
2828
{t("history:viewAllHistory")}
2929
</button>

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

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ const mockTasks: HistoryItem[] = [
5959
tokensOut: 150,
6060
totalCost: 0.03,
6161
},
62+
{
63+
id: "task-5",
64+
number: 5,
65+
task: "Fifth task",
66+
ts: Date.now(),
67+
tokensIn: 250,
68+
tokensOut: 125,
69+
totalCost: 0.025,
70+
},
71+
{
72+
id: "task-6",
73+
number: 6,
74+
task: "Sixth task",
75+
ts: Date.now(),
76+
tokensIn: 400,
77+
tokensOut: 200,
78+
totalCost: 0.04,
79+
},
6280
]
6381

6482
describe("HistoryPreview", () => {
@@ -86,7 +104,7 @@ describe("HistoryPreview", () => {
86104
expect(screen.queryByTestId(/task-item-/)).not.toBeInTheDocument()
87105
})
88106

89-
it("renders up to 2 tasks when tasks are available", () => {
107+
it("renders up to 3 tasks when tasks are available", () => {
90108
mockUseTaskSearch.mockReturnValue({
91109
tasks: mockTasks,
92110
searchQuery: "",
@@ -101,17 +119,19 @@ describe("HistoryPreview", () => {
101119

102120
render(<HistoryPreview />)
103121

104-
// Should render only the first 2 tasks
122+
// Should render only the first 3 tasks
105123
expect(screen.getByTestId("task-item-task-1")).toBeInTheDocument()
106124
expect(screen.getByTestId("task-item-task-2")).toBeInTheDocument()
107-
expect(screen.queryByTestId("task-item-task-3")).not.toBeInTheDocument()
125+
expect(screen.getByTestId("task-item-task-3")).toBeInTheDocument()
108126
expect(screen.queryByTestId("task-item-task-4")).not.toBeInTheDocument()
127+
expect(screen.queryByTestId("task-item-task-5")).not.toBeInTheDocument()
128+
expect(screen.queryByTestId("task-item-task-6")).not.toBeInTheDocument()
109129
})
110130

111-
it("renders all tasks when there are 2 or fewer", () => {
112-
const twoTasks = mockTasks.slice(0, 2)
131+
it("renders all tasks when there are 3 or fewer", () => {
132+
const threeTasks = mockTasks.slice(0, 3)
113133
mockUseTaskSearch.mockReturnValue({
114-
tasks: twoTasks,
134+
tasks: threeTasks,
115135
searchQuery: "",
116136
setSearchQuery: vi.fn(),
117137
sortOption: "newest",
@@ -126,7 +146,8 @@ describe("HistoryPreview", () => {
126146

127147
expect(screen.getByTestId("task-item-task-1")).toBeInTheDocument()
128148
expect(screen.getByTestId("task-item-task-2")).toBeInTheDocument()
129-
expect(screen.queryByTestId("task-item-task-3")).not.toBeInTheDocument()
149+
expect(screen.getByTestId("task-item-task-3")).toBeInTheDocument()
150+
expect(screen.queryByTestId("task-item-task-4")).not.toBeInTheDocument()
130151
})
131152

132153
it("renders only 1 task when there is only 1 task", () => {
@@ -151,7 +172,7 @@ describe("HistoryPreview", () => {
151172

152173
it("passes correct props to TaskItem components", () => {
153174
mockUseTaskSearch.mockReturnValue({
154-
tasks: mockTasks.slice(0, 2),
175+
tasks: mockTasks.slice(0, 3),
155176
searchQuery: "",
156177
setSearchQuery: vi.fn(),
157178
sortOption: "newest",
@@ -164,7 +185,7 @@ describe("HistoryPreview", () => {
164185

165186
render(<HistoryPreview />)
166187

167-
// Verify TaskItem was called with correct props
188+
// Verify TaskItem was called with correct props for first 3 tasks
168189
expect(mockTaskItem).toHaveBeenCalledWith(
169190
expect.objectContaining({
170191
item: mockTasks[0],
@@ -179,6 +200,13 @@ describe("HistoryPreview", () => {
179200
}),
180201
expect.anything(),
181202
)
203+
expect(mockTaskItem).toHaveBeenCalledWith(
204+
expect.objectContaining({
205+
item: mockTasks[2],
206+
variant: "compact",
207+
}),
208+
expect.anything(),
209+
)
182210
})
183211

184212
it("renders with correct container classes", () => {

0 commit comments

Comments
 (0)