Skip to content

Commit 8f2546f

Browse files
committed
fix: show delete button consistently on task cards (#6494)
- Remove size condition from delete button visibility - Keep size display conditional (only show when size > 0) - Update tests to reflect new behavior - Add tests for undefined size and no item cases
1 parent 3803c29 commit 8f2546f

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
3636
onClick={(e) => copyWithFeedback(item.task, e)}
3737
/>
3838
)}
39-
{!!item?.size && item.size > 0 && (
39+
{item && (
4040
<>
4141
<div className="flex items-center">
4242
<IconButton
@@ -53,7 +53,11 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
5353
}
5454
}}
5555
/>
56-
<span className="ml-1 text-xs text-vscode-foreground opacity-85">{prettyBytes(item.size)}</span>
56+
{!!item.size && item.size > 0 && (
57+
<span className="ml-1 text-xs text-vscode-foreground opacity-85">
58+
{prettyBytes(item.size)}
59+
</span>
60+
)}
5761
</div>
5862
{deleteTaskId && (
5963
<DeleteTaskDialog

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,27 @@ describe("TaskActions", () => {
361361
expect(screen.getByText("1024 B")).toBeInTheDocument()
362362
})
363363

364-
it("does not render delete button when item has no size", () => {
364+
it("renders delete button even when item has no size", () => {
365365
const itemWithoutSize = { ...mockItem, size: 0 }
366366
render(<TaskActions item={itemWithoutSize} buttonsDisabled={false} />)
367367

368+
const deleteButton = screen.queryByLabelText("Delete Task (Shift + Click to skip confirmation)")
369+
expect(deleteButton).toBeInTheDocument()
370+
// File size should not be displayed when size is 0
371+
expect(screen.queryByText("0 B")).not.toBeInTheDocument()
372+
})
373+
374+
it("renders delete button when item has undefined size", () => {
375+
const itemWithUndefinedSize = { ...mockItem, size: undefined }
376+
render(<TaskActions item={itemWithUndefinedSize} buttonsDisabled={false} />)
377+
378+
const deleteButton = screen.queryByLabelText("Delete Task (Shift + Click to skip confirmation)")
379+
expect(deleteButton).toBeInTheDocument()
380+
})
381+
382+
it("does not render delete button when item is undefined", () => {
383+
render(<TaskActions item={undefined} buttonsDisabled={false} />)
384+
368385
const deleteButton = screen.queryByLabelText("Delete Task (Shift + Click to skip confirmation)")
369386
expect(deleteButton).not.toBeInTheDocument()
370387
})

0 commit comments

Comments
 (0)