Skip to content
Open
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
6 changes: 3 additions & 3 deletions webview-ui/src/components/chat/TaskActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useExtensionState } from "@/context/ExtensionStateContext"
import { DeleteTaskDialog } from "../history/DeleteTaskDialog"
import { ShareButton } from "./ShareButton"
import { CloudTaskButton } from "./CloudTaskButton"
import { CopyIcon, DownloadIcon, Trash2Icon, FileJsonIcon, MessageSquareCodeIcon } from "lucide-react"
import { CheckIcon, CopyIcon, DownloadIcon, Trash2Icon, FileJsonIcon, MessageSquareCodeIcon } from "lucide-react"
import { LucideIconButton } from "./LucideIconButton"

interface TaskActionsProps {
Expand All @@ -21,7 +21,7 @@ interface TaskActionsProps {
export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
const [deleteTaskId, setDeleteTaskId] = useState<string | null>(null)
const { t } = useTranslation()
const { copyWithFeedback } = useCopyToClipboard()
const { copyWithFeedback, showCopyFeedback } = useCopyToClipboard()
Copy link
Contributor

Choose a reason for hiding this comment

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

The icon swap is the core behavior of this PR but there is no test covering it. TaskActions.spec.tsx already has thorough coverage for copy, delete, export, and share -- adding a test that mocks useCopyToClipboard to return showCopyFeedback: true and asserts that the button's rendered icon changes would keep parity. The issue investigation also called this out explicitly.

Fix it with Roo Code or mention @roomote and request a fix.

const { debug } = useExtensionState()

return (
Expand All @@ -34,7 +34,7 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {

{item?.task && (
<LucideIconButton
icon={CopyIcon}
icon={showCopyFeedback ? CheckIcon : CopyIcon}
title={t("history:copyPrompt")}
onClick={(e) => copyWithFeedback(item.task, e)}
/>
Expand Down
34 changes: 34 additions & 0 deletions webview-ui/src/components/chat/__tests__/TaskActions.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { HistoryItem } from "@roo-code/types"
import { render, screen, fireEvent } from "@/utils/test-utils"
import { vscode } from "@/utils/vscode"
import { useExtensionState } from "@/context/ExtensionStateContext"
import { useCopyToClipboard } from "@/utils/clipboard"

import { TaskActions } from "../TaskActions"

Expand All @@ -24,8 +25,14 @@ vi.mock("@/context/ExtensionStateContext", () => ({
useExtensionState: vi.fn(),
}))

// Mock the useCopyToClipboard hook
vi.mock("@/utils/clipboard", () => ({
useCopyToClipboard: vi.fn(),
}))

const mockPostMessage = vi.mocked(vscode.postMessage)
const mockUseExtensionState = vi.mocked(useExtensionState)
const mockUseCopyToClipboard = vi.mocked(useCopyToClipboard)

// Mock react-i18next
vi.mock("react-i18next", () => ({
Expand Down Expand Up @@ -87,6 +94,10 @@ describe("TaskActions", () => {
organizationName: "Test Organization",
},
} as any)
mockUseCopyToClipboard.mockReturnValue({
copyWithFeedback: vi.fn(),
showCopyFeedback: false,
})
})

describe("Share Button Visibility", () => {
Expand Down Expand Up @@ -353,6 +364,29 @@ describe("TaskActions", () => {
const deleteButton = screen.queryByLabelText("Delete Task (Shift + Click to skip confirmation)")
expect(deleteButton).not.toBeInTheDocument()
})

it("shows check icon when showCopyFeedback is true", () => {
// First render with showCopyFeedback: false (default)
const { rerender } = render(<TaskActions item={mockItem} buttonsDisabled={false} />)

// Verify copy icon is shown initially
const copyButton = screen.getByLabelText("Copy")
expect(copyButton).toBeInTheDocument()
expect(copyButton.querySelector("svg.lucide-copy")).toBeInTheDocument()
expect(copyButton.querySelector("svg.lucide-check")).not.toBeInTheDocument()

// Mock showCopyFeedback: true to simulate successful copy
mockUseCopyToClipboard.mockReturnValue({
copyWithFeedback: vi.fn(),
showCopyFeedback: true,
})

rerender(<TaskActions item={mockItem} buttonsDisabled={false} />)

// Verify check icon is shown after successful copy
expect(copyButton.querySelector("svg.lucide-check")).toBeInTheDocument()
expect(copyButton.querySelector("svg.lucide-copy")).not.toBeInTheDocument()
})
})

describe("Button States", () => {
Expand Down
Loading