Skip to content

Commit ea79dfe

Browse files
brunobergherBruno Bergher
andauthored
Redesigned Task Header (#6561)
* Reorganizes the task header for cleanliness and in preparation for Cloud link * More task ehader visual tweaks * Translations for new task header * Fixes TaskHeader color * Removes stray string * Fixes tests * Iterates on visual details * More visual tweaks * Missing localization call * Fixes tests --------- Co-authored-by: Bruno Bergher <[email protected]>
1 parent d90bab7 commit ea79dfe

File tree

27 files changed

+381
-270
lines changed

27 files changed

+381
-270
lines changed

webview-ui/src/__tests__/ContextWindowProgress.spec.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// npm run test ContextWindowProgress.spec.tsx
22

3-
import { render, screen } from "@/utils/test-utils"
3+
import { render, screen, fireEvent } from "@/utils/test-utils"
44
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
55

66
import TaskHeader from "@src/components/chat/TaskHeader"
@@ -70,6 +70,10 @@ describe("ContextWindowProgress", () => {
7070
it("renders correctly with valid inputs", () => {
7171
renderComponent({ contextTokens: 1000, contextWindow: 4000 })
7272

73+
// First expand the TaskHeader to access ContextWindowProgress
74+
const taskHeader = screen.getByText("Test task")
75+
fireEvent.click(taskHeader)
76+
7377
// Check for basic elements
7478
// The context-window-label is not part of the ContextWindowProgress component
7579
// but rather part of the parent TaskHeader component in expanded state
@@ -83,6 +87,10 @@ describe("ContextWindowProgress", () => {
8387
it("handles zero context window gracefully", () => {
8488
renderComponent({ contextTokens: 0, contextWindow: 0 })
8589

90+
// First expand the TaskHeader to access ContextWindowProgress
91+
const taskHeader = screen.getByText("Test task")
92+
fireEvent.click(taskHeader)
93+
8694
// In the current implementation, the component is still displayed with zero values
8795
// rather than being hidden completely
8896
// The context-window-label is not part of the ContextWindowProgress component
@@ -93,6 +101,10 @@ describe("ContextWindowProgress", () => {
93101
it("handles edge cases with negative values", () => {
94102
renderComponent({ contextTokens: -100, contextWindow: 4000 })
95103

104+
// First expand the TaskHeader to access ContextWindowProgress
105+
const taskHeader = screen.getByText("Test task")
106+
fireEvent.click(taskHeader)
107+
96108
// Should show 0 instead of -100
97109
expect(screen.getByTestId("context-tokens-count")).toHaveTextContent("0")
98110
// The actual context window might be different than what we pass in
@@ -102,6 +114,10 @@ describe("ContextWindowProgress", () => {
102114
it("calculates percentages correctly", () => {
103115
renderComponent({ contextTokens: 1000, contextWindow: 4000 })
104116

117+
// First expand the TaskHeader to access ContextWindowProgress
118+
const taskHeader = screen.getByText("Test task")
119+
fireEvent.click(taskHeader)
120+
105121
// Verify that the token count and window size are displayed correctly
106122
const tokenCount = screen.getByTestId("context-tokens-count")
107123
const windowSize = screen.getByTestId("context-window-size")

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
805805
[clineAsk, startNewTask, isStreaming],
806806
)
807807

808-
const handleTaskCloseButtonClick = useCallback(() => startNewTask(), [startNewTask])
809-
810808
const { info: model } = useSelectedModel(apiConfiguration)
811809

812810
const selectImages = useCallback(() => vscode.postMessage({ type: "selectImages" }), [])
@@ -1765,7 +1763,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
17651763
contextTokens={apiMetrics.contextTokens}
17661764
buttonsDisabled={sendingDisabled}
17671765
handleCondenseContext={handleCondenseContext}
1768-
onClose={handleTaskCloseButtonClick}
17691766
todos={latestTodos}
17701767
/>
17711768

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const ContextWindowProgress = ({ contextWindow, contextTokens, maxTokens
5555

5656
return (
5757
<>
58-
<div className="flex items-center gap-2 flex-1 whitespace-nowrap px-2">
58+
<div className="flex items-center gap-2 flex-1 whitespace-nowrap">
5959
<div data-testid="context-tokens-count">{formatLargeNumber(safeContextTokens)}</div>
6060
<StandardTooltip content={tooltipContent} side="top" sideOffset={8}>
6161
<div className="flex-1 relative">

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState, useEffect, useRef } from "react"
22
import { useTranslation } from "react-i18next"
3+
import { SquareArrowOutUpRightIcon } from "lucide-react"
34

45
import type { HistoryItem, ShareVisibility } from "@roo-code/types"
56
import { TelemetryEventName } from "@roo-code/types"
@@ -26,9 +27,10 @@ import {
2627
interface ShareButtonProps {
2728
item?: HistoryItem
2829
disabled?: boolean
30+
showLabel?: boolean
2931
}
3032

31-
export const ShareButton = ({ item, disabled = false }: ShareButtonProps) => {
33+
export const ShareButton = ({ item, disabled = false, showLabel = false }: ShareButtonProps) => {
3234
const [shareDropdownOpen, setShareDropdownOpen] = useState(false)
3335
const [connectModalOpen, setConnectModalOpen] = useState(false)
3436
const [shareSuccess, setShareSuccess] = useState<{ visibility: ShareVisibility; url: string } | null>(null)
@@ -155,14 +157,21 @@ export const ShareButton = ({ item, disabled = false }: ShareButtonProps) => {
155157
<PopoverTrigger asChild>
156158
<Button
157159
variant="ghost"
158-
size="icon"
160+
size={showLabel ? "sm" : "icon"}
159161
disabled={disabled || shareButtonState.disabled}
160-
className="h-7 w-7 p-1.5 hover:bg-vscode-toolbar-hoverBackground"
161-
onClick={handleShareButtonClick}>
162-
<span className="codicon codicon-link"></span>
162+
className={
163+
showLabel
164+
? "h-7 px-2 hover:bg-vscode-toolbar-hoverBackground"
165+
: "h-7 w-7 p-1.5 hover:bg-vscode-toolbar-hoverBackground"
166+
}
167+
onClick={handleShareButtonClick}
168+
data-testid="share-button">
169+
<SquareArrowOutUpRightIcon />
170+
{showLabel && <span className="ml-0">{t("chat:task.share")}</span>}
163171
</Button>
164172
</PopoverTrigger>
165173
</StandardTooltip>
174+
166175
<PopoverContent className="w-56 p-0" align="start">
167176
{shareSuccess ? (
168177
<div className="p-3">
@@ -217,11 +226,17 @@ export const ShareButton = ({ item, disabled = false }: ShareButtonProps) => {
217226
<StandardTooltip content={shareButtonState.title}>
218227
<Button
219228
variant="ghost"
220-
size="icon"
229+
size={showLabel ? "sm" : "icon"}
221230
disabled={disabled || shareButtonState.disabled}
222-
className="h-7 w-7 p-1.5 hover:bg-vscode-toolbar-hoverBackground"
223-
onClick={handleShareButtonClick}>
224-
<span className="codicon codicon-link"></span>
231+
className={
232+
showLabel
233+
? "h-7 px-2 hover:bg-vscode-toolbar-hoverBackground"
234+
: "h-7 w-7 p-1.5 hover:bg-vscode-toolbar-hoverBackground"
235+
}
236+
onClick={handleShareButtonClick}
237+
data-testid="share-button">
238+
<SquareArrowOutUpRightIcon />
239+
{showLabel && <span className="ml-1">{t("chat:task.share")}</span>}
225240
</Button>
226241
</StandardTooltip>
227242
)}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useState } from "react"
2-
import prettyBytes from "pretty-bytes"
32
import { useTranslation } from "react-i18next"
43

54
import type { HistoryItem } from "@roo-code/types"
@@ -22,8 +21,7 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
2221
const { copyWithFeedback, showCopyFeedback } = useCopyToClipboard()
2322

2423
return (
25-
<div className="flex flex-row gap-1">
26-
<ShareButton item={item} disabled={false} />
24+
<div className="flex flex-row items-center">
2725
<IconButton
2826
iconClass="codicon-desktop-download"
2927
title={t("chat:task.export")}
@@ -53,7 +51,6 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
5351
}
5452
}}
5553
/>
56-
<span className="ml-1 text-xs text-vscode-foreground opacity-85">{prettyBytes(item.size)}</span>
5754
</div>
5855
{deleteTaskId && (
5956
<DeleteTaskDialog
@@ -64,6 +61,7 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
6461
)}
6562
</>
6663
)}
64+
<ShareButton item={item} disabled={false} showLabel={false} />
6765
</div>
6866
)
6967
}

0 commit comments

Comments
 (0)