-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: add button to delete checkpoints only (fixes #10801) #10803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { useCallback } from "react" | ||
|
|
||
| import { Button, StandardTooltip } from "@/components/ui" | ||
| import { useAppTranslation } from "@/i18n/TranslationContext" | ||
| import { vscode } from "@/utils/vscode" | ||
|
|
||
| type DeleteCheckpointsButtonProps = { | ||
| itemId: string | ||
| onDeleteCheckpoints?: (taskId: string) => void | ||
| } | ||
|
|
||
| export const DeleteCheckpointsButton = ({ itemId, onDeleteCheckpoints }: DeleteCheckpointsButtonProps) => { | ||
| const { t } = useAppTranslation() | ||
|
|
||
| const handleDeleteCheckpointsClick = useCallback( | ||
| (e: React.MouseEvent) => { | ||
| e.stopPropagation() | ||
| if (e.shiftKey) { | ||
| vscode.postMessage({ type: "deleteTaskCheckpointsWithId", text: itemId }) | ||
| } else if (onDeleteCheckpoints) { | ||
| onDeleteCheckpoints(itemId) | ||
| } | ||
| }, | ||
| [itemId, onDeleteCheckpoints], | ||
| ) | ||
|
|
||
| return ( | ||
| <StandardTooltip content={t("history:deleteCheckpointsTitle")}> | ||
| <Button | ||
| variant="ghost" | ||
| size="icon" | ||
| data-testid="delete-checkpoints-button" | ||
| onClick={handleDeleteCheckpointsClick} | ||
| className="opacity-70"> | ||
| <span className="codicon codicon-discard size-4 align-middle text-vscode-descriptionForeground" /> | ||
| </Button> | ||
| </StandardTooltip> | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { useCallback, useEffect } from "react" | ||
| import { useKeyPress } from "react-use" | ||
| import { AlertDialogProps } from "@radix-ui/react-alert-dialog" | ||
|
|
||
| import { | ||
| AlertDialog, | ||
| AlertDialogAction, | ||
| AlertDialogCancel, | ||
| AlertDialogContent, | ||
| AlertDialogDescription, | ||
| AlertDialogFooter, | ||
| AlertDialogHeader, | ||
| AlertDialogTitle, | ||
| Button, | ||
| } from "@/components/ui" | ||
| import { useAppTranslation } from "@/i18n/TranslationContext" | ||
|
|
||
| import { vscode } from "@/utils/vscode" | ||
|
|
||
| interface DeleteCheckpointsDialogProps extends AlertDialogProps { | ||
| taskId: string | ||
| } | ||
|
|
||
| export const DeleteCheckpointsDialog = ({ taskId, ...props }: DeleteCheckpointsDialogProps) => { | ||
| const { t } = useAppTranslation() | ||
| const [isEnterPressed] = useKeyPress("Enter") | ||
|
|
||
| const { onOpenChange } = props | ||
|
|
||
| const onDeleteCheckpoints = useCallback(() => { | ||
| if (taskId) { | ||
| vscode.postMessage({ type: "deleteTaskCheckpointsWithId", text: taskId }) | ||
| onOpenChange?.(false) | ||
| } | ||
| }, [taskId, onOpenChange]) | ||
|
|
||
| useEffect(() => { | ||
| if (taskId && isEnterPressed) { | ||
| onDeleteCheckpoints() | ||
| } | ||
| }, [taskId, isEnterPressed, onDeleteCheckpoints]) | ||
|
|
||
| return ( | ||
| <AlertDialog {...props}> | ||
| <AlertDialogContent onEscapeKeyDown={() => onOpenChange?.(false)}> | ||
| <AlertDialogHeader> | ||
| <AlertDialogTitle>{t("history:deleteCheckpoints")}</AlertDialogTitle> | ||
| <AlertDialogDescription>{t("history:deleteCheckpointsMessage")}</AlertDialogDescription> | ||
| </AlertDialogHeader> | ||
| <AlertDialogFooter> | ||
| <AlertDialogCancel asChild> | ||
| <Button variant="secondary">{t("history:cancel")}</Button> | ||
| </AlertDialogCancel> | ||
| <AlertDialogAction asChild> | ||
| <Button variant="destructive" onClick={onDeleteCheckpoints}> | ||
| {t("history:deleteCheckpointsConfirm")} | ||
| </Button> | ||
| </AlertDialogAction> | ||
| </AlertDialogFooter> | ||
| </AlertDialogContent> | ||
| </AlertDialog> | ||
| ) | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The translation key
history:deleteCheckpointsConfirmis not defined in any of the locale files. This will cause the button to display the raw key or be empty. The existingDeleteTaskDialogusest("history:delete")for its confirm button, which is already defined. Consider using the same key for consistency, or adddeleteCheckpointsConfirmto all 18 locale files.Fix it with Roo Code or mention @roomote and request a fix.