Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion webview-ui/src/__tests__/ContextWindowProgress.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// npm run test ContextWindowProgress.spec.tsx

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

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

// First expand the TaskHeader to access ContextWindowProgress
const taskHeader = screen.getByText("Test task")
fireEvent.click(taskHeader)

// Check for basic elements
// The context-window-label is not part of the ContextWindowProgress component
// but rather part of the parent TaskHeader component in expanded state
Expand All @@ -83,6 +87,10 @@ describe("ContextWindowProgress", () => {
it("handles zero context window gracefully", () => {
renderComponent({ contextTokens: 0, contextWindow: 0 })

// First expand the TaskHeader to access ContextWindowProgress
const taskHeader = screen.getByText("Test task")
fireEvent.click(taskHeader)

// In the current implementation, the component is still displayed with zero values
// rather than being hidden completely
// The context-window-label is not part of the ContextWindowProgress component
Expand All @@ -93,6 +101,10 @@ describe("ContextWindowProgress", () => {
it("handles edge cases with negative values", () => {
renderComponent({ contextTokens: -100, contextWindow: 4000 })

// First expand the TaskHeader to access ContextWindowProgress
const taskHeader = screen.getByText("Test task")
fireEvent.click(taskHeader)

// Should show 0 instead of -100
expect(screen.getByTestId("context-tokens-count")).toHaveTextContent("0")
// The actual context window might be different than what we pass in
Expand All @@ -102,6 +114,10 @@ describe("ContextWindowProgress", () => {
it("calculates percentages correctly", () => {
renderComponent({ contextTokens: 1000, contextWindow: 4000 })

// First expand the TaskHeader to access ContextWindowProgress
const taskHeader = screen.getByText("Test task")
fireEvent.click(taskHeader)

// Verify that the token count and window size are displayed correctly
const tokenCount = screen.getByTestId("context-tokens-count")
const windowSize = screen.getByTestId("context-window-size")
Expand Down
3 changes: 0 additions & 3 deletions webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
[clineAsk, startNewTask, isStreaming],
)

const handleTaskCloseButtonClick = useCallback(() => startNewTask(), [startNewTask])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onClose prop and this handler were removed from TaskHeader. Was this intentional? If the close functionality is being moved elsewhere or removed entirely, could you clarify where users will now be able to close tasks?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is.


const { info: model } = useSelectedModel(apiConfiguration)

const selectImages = useCallback(() => vscode.postMessage({ type: "selectImages" }), [])
Expand Down Expand Up @@ -1765,7 +1763,6 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
contextTokens={apiMetrics.contextTokens}
buttonsDisabled={sendingDisabled}
handleCondenseContext={handleCondenseContext}
onClose={handleTaskCloseButtonClick}
todos={latestTodos}
/>

Expand Down
2 changes: 1 addition & 1 deletion webview-ui/src/components/chat/ContextWindowProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const ContextWindowProgress = ({ contextWindow, contextTokens, maxTokens

return (
<>
<div className="flex items-center gap-2 flex-1 whitespace-nowrap px-2">
<div className="flex items-center gap-2 flex-1 whitespace-nowrap">
<div data-testid="context-tokens-count">{formatLargeNumber(safeContextTokens)}</div>
<StandardTooltip content={tooltipContent} side="top" sideOffset={8}>
<div className="flex-1 relative">
Expand Down
33 changes: 24 additions & 9 deletions webview-ui/src/components/chat/ShareButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState, useEffect, useRef } from "react"
import { useTranslation } from "react-i18next"
import { SquareArrowOutUpRightIcon } from "lucide-react"

import type { HistoryItem, ShareVisibility } from "@roo-code/types"
import { TelemetryEventName } from "@roo-code/types"
Expand All @@ -26,9 +27,10 @@ import {
interface ShareButtonProps {
item?: HistoryItem
disabled?: boolean
showLabel?: boolean
}

export const ShareButton = ({ item, disabled = false }: ShareButtonProps) => {
export const ShareButton = ({ item, disabled = false, showLabel = false }: ShareButtonProps) => {
const [shareDropdownOpen, setShareDropdownOpen] = useState(false)
const [connectModalOpen, setConnectModalOpen] = useState(false)
const [shareSuccess, setShareSuccess] = useState<{ visibility: ShareVisibility; url: string } | null>(null)
Expand Down Expand Up @@ -155,14 +157,21 @@ export const ShareButton = ({ item, disabled = false }: ShareButtonProps) => {
<PopoverTrigger asChild>
<Button
variant="ghost"
size="icon"
size={showLabel ? "sm" : "icon"}
disabled={disabled || shareButtonState.disabled}
className="h-7 w-7 p-1.5 hover:bg-vscode-toolbar-hoverBackground"
onClick={handleShareButtonClick}>
<span className="codicon codicon-link"></span>
className={
showLabel
? "h-7 px-2 hover:bg-vscode-toolbar-hoverBackground"
: "h-7 w-7 p-1.5 hover:bg-vscode-toolbar-hoverBackground"
}
onClick={handleShareButtonClick}
data-testid="share-button">
<SquareArrowOutUpRightIcon />
{showLabel && <span className="ml-0">{t("chat:task.share")}</span>}
</Button>
</PopoverTrigger>
</StandardTooltip>

<PopoverContent className="w-56 p-0" align="start">
{shareSuccess ? (
<div className="p-3">
Expand Down Expand Up @@ -217,11 +226,17 @@ export const ShareButton = ({ item, disabled = false }: ShareButtonProps) => {
<StandardTooltip content={shareButtonState.title}>
<Button
variant="ghost"
size="icon"
size={showLabel ? "sm" : "icon"}
disabled={disabled || shareButtonState.disabled}
className="h-7 w-7 p-1.5 hover:bg-vscode-toolbar-hoverBackground"
onClick={handleShareButtonClick}>
<span className="codicon codicon-link"></span>
className={
showLabel
? "h-7 px-2 hover:bg-vscode-toolbar-hoverBackground"
: "h-7 w-7 p-1.5 hover:bg-vscode-toolbar-hoverBackground"
}
onClick={handleShareButtonClick}
data-testid="share-button">
<SquareArrowOutUpRightIcon />
{showLabel && <span className="ml-1">{t("chat:task.share")}</span>}
</Button>
</StandardTooltip>
)}
Expand Down
6 changes: 2 additions & 4 deletions webview-ui/src/components/chat/TaskActions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState } from "react"
import prettyBytes from "pretty-bytes"
import { useTranslation } from "react-i18next"

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

return (
<div className="flex flex-row gap-1">
<ShareButton item={item} disabled={false} />
<div className="flex flex-row items-center">
<IconButton
iconClass="codicon-desktop-download"
title={t("chat:task.export")}
Expand Down Expand Up @@ -53,7 +51,6 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
}
}}
/>
<span className="ml-1 text-xs text-vscode-foreground opacity-85">{prettyBytes(item.size)}</span>
</div>
{deleteTaskId && (
<DeleteTaskDialog
Expand All @@ -64,6 +61,7 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
)}
</>
)}
<ShareButton item={item} disabled={false} showLabel={false} />
</div>
)
}
Loading
Loading