From 1a527fca123db20c321a81e2daef90c13f5703a0 Mon Sep 17 00:00:00 2001 From: cte Date: Fri, 7 Feb 2025 23:54:21 -0800 Subject: [PATCH] Checkpoint UI tweaks --- .../chat/checkpoints/CheckpointMenu.tsx | 110 +++++++++++------- .../chat/checkpoints/CheckpointSaved.tsx | 2 +- webview-ui/src/components/ui/popover.tsx | 8 +- 3 files changed, 73 insertions(+), 47 deletions(-) diff --git a/webview-ui/src/components/chat/checkpoints/CheckpointMenu.tsx b/webview-ui/src/components/chat/checkpoints/CheckpointMenu.tsx index 657c292613..39141a6fbf 100644 --- a/webview-ui/src/components/chat/checkpoints/CheckpointMenu.tsx +++ b/webview-ui/src/components/chat/checkpoints/CheckpointMenu.tsx @@ -1,17 +1,9 @@ import { useState, useEffect, useCallback } from "react" -import { DotsHorizontalIcon } from "@radix-ui/react-icons" -import { DropdownMenuItemProps } from "@radix-ui/react-dropdown-menu" +import { CheckIcon, Cross2Icon } from "@radix-ui/react-icons" import { vscode } from "../../../utils/vscode" -import { - Button, - DropdownMenu, - DropdownMenuTrigger, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuShortcut, -} from "@/components/ui" +import { Button, Popover, PopoverContent, PopoverTrigger } from "@/components/ui" type CheckpointMenuProps = { ts: number @@ -20,10 +12,8 @@ type CheckpointMenuProps = { export const CheckpointMenu = ({ ts, commitHash }: CheckpointMenuProps) => { const [portalContainer, setPortalContainer] = useState() - - const onTaskDiff = useCallback(() => { - vscode.postMessage({ type: "checkpointDiff", payload: { ts, commitHash, mode: "full" } }) - }, [ts, commitHash]) + const [isOpen, setIsOpen] = useState(false) + const [isConfirming, setIsConfirming] = useState(false) const onCheckpointDiff = useCallback(() => { vscode.postMessage({ type: "checkpointDiff", payload: { ts, commitHash, mode: "checkpoint" } }) @@ -31,10 +21,12 @@ export const CheckpointMenu = ({ ts, commitHash }: CheckpointMenuProps) => { const onPreview = useCallback(() => { vscode.postMessage({ type: "checkpointRestore", payload: { ts, commitHash, mode: "preview" } }) + setIsOpen(false) }, [ts, commitHash]) const onRestore = useCallback(() => { vscode.postMessage({ type: "checkpointRestore", payload: { ts, commitHash, mode: "restore" } }) + setIsOpen(false) }, [ts, commitHash]) useEffect(() => { @@ -47,34 +39,66 @@ export const CheckpointMenu = ({ ts, commitHash }: CheckpointMenuProps) => { }, []) return ( - - - - - - - - - - - +
+ + { + setIsOpen(open) + setIsConfirming(false) + }}> + + + + +
+
+ +
+ Restores your project's files back to a snapshot taken at this point. +
+
+
+
+ {!isConfirming ? ( + + ) : ( + <> + + + + )} + {isConfirming ? ( +
This action cannot be undone.
+ ) : ( +
+ Restores your project's files back to a snapshot taken at this point and deletes + all messages after this point. +
+ )} +
+
+
+
+
+
) } - -type CheckpointMenuItemProps = DropdownMenuItemProps & { - label: React.ReactNode - icon: "diff-single" | "diff-multiple" | "open-preview" | "history" -} - -const CheckpointMenuItem = ({ label, icon, ...props }: CheckpointMenuItemProps) => ( - -
-
{label}
- - - -
-
-) diff --git a/webview-ui/src/components/chat/checkpoints/CheckpointSaved.tsx b/webview-ui/src/components/chat/checkpoints/CheckpointSaved.tsx index 103f1d172c..5947b6a1fc 100644 --- a/webview-ui/src/components/chat/checkpoints/CheckpointSaved.tsx +++ b/webview-ui/src/components/chat/checkpoints/CheckpointSaved.tsx @@ -8,7 +8,7 @@ type CheckpointSavedProps = { export const CheckpointSaved = (props: CheckpointSavedProps) => (
- + Checkpoint
diff --git a/webview-ui/src/components/ui/popover.tsx b/webview-ui/src/components/ui/popover.tsx index 09c6ba659a..3ab3344689 100644 --- a/webview-ui/src/components/ui/popover.tsx +++ b/webview-ui/src/components/ui/popover.tsx @@ -11,9 +11,11 @@ const PopoverAnchor = PopoverPrimitive.Anchor const PopoverContent = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, align = "center", sideOffset = 4, ...props }, ref) => ( - + React.ComponentPropsWithoutRef & { + container?: HTMLElement + } +>(({ className, align = "center", sideOffset = 4, container, ...props }, ref) => ( +