mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-09 22:31:08 +00:00
fix: always show checkpoint restore options regardless of change detection (#8758)
This commit is contained in:
parent
8187a8e189
commit
b9110dc243
2 changed files with 46 additions and 64 deletions
|
|
@ -11,7 +11,6 @@ import { Checkpoint } from "./schema"
|
|||
type CheckpointMenuBaseProps = {
|
||||
ts: number
|
||||
commitHash: string
|
||||
currentHash?: string
|
||||
checkpoint: Checkpoint
|
||||
}
|
||||
type CheckpointMenuControlledProps = {
|
||||
|
|
@ -24,21 +23,12 @@ type CheckpointMenuUncontrolledProps = {
|
|||
}
|
||||
type CheckpointMenuProps = CheckpointMenuBaseProps & (CheckpointMenuControlledProps | CheckpointMenuUncontrolledProps)
|
||||
|
||||
export const CheckpointMenu = ({
|
||||
ts,
|
||||
commitHash,
|
||||
currentHash,
|
||||
checkpoint,
|
||||
open,
|
||||
onOpenChange,
|
||||
}: CheckpointMenuProps) => {
|
||||
export const CheckpointMenu = ({ ts, commitHash, checkpoint, open, onOpenChange }: CheckpointMenuProps) => {
|
||||
const { t } = useTranslation()
|
||||
const [internalOpen, setInternalOpen] = useState(false)
|
||||
const [isConfirming, setIsConfirming] = useState(false)
|
||||
const portalContainer = useRooPortal("roo-portal")
|
||||
|
||||
const isCurrent = currentHash === commitHash
|
||||
|
||||
const previousCommitHash = checkpoint?.from
|
||||
|
||||
const isOpen = open ?? internalOpen
|
||||
|
|
@ -88,60 +78,52 @@ export const CheckpointMenu = ({
|
|||
</StandardTooltip>
|
||||
<PopoverContent align="end" container={portalContainer}>
|
||||
<div className="flex flex-col gap-2">
|
||||
{!isCurrent && (
|
||||
<div className="flex flex-col gap-1 group hover:text-foreground">
|
||||
<Button variant="secondary" onClick={onPreview} data-testid="restore-files-btn">
|
||||
{t("chat:checkpoint.menu.restoreFiles")}
|
||||
<div className="flex flex-col gap-1 group hover:text-foreground">
|
||||
<Button variant="secondary" onClick={onPreview} data-testid="restore-files-btn">
|
||||
{t("chat:checkpoint.menu.restoreFiles")}
|
||||
</Button>
|
||||
<div className="text-muted transition-colors group-hover:text-foreground">
|
||||
{t("chat:checkpoint.menu.restoreFilesDescription")}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1 group hover:text-foreground">
|
||||
{!isConfirming ? (
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => setIsConfirming(true)}
|
||||
data-testid="restore-files-and-task-btn">
|
||||
{t("chat:checkpoint.menu.restoreFilesAndTask")}
|
||||
</Button>
|
||||
) : (
|
||||
<>
|
||||
<Button
|
||||
variant="default"
|
||||
onClick={onRestore}
|
||||
className="grow"
|
||||
data-testid="confirm-restore-btn">
|
||||
<div className="flex flex-row gap-1">
|
||||
<CheckIcon />
|
||||
<div>{t("chat:checkpoint.menu.confirm")}</div>
|
||||
</div>
|
||||
</Button>
|
||||
<Button variant="secondary" onClick={() => setIsConfirming(false)}>
|
||||
<div className="flex flex-row gap-1">
|
||||
<Cross2Icon />
|
||||
<div>{t("chat:checkpoint.menu.cancel")}</div>
|
||||
</div>
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{isConfirming ? (
|
||||
<div data-testid="checkpoint-confirm-warning" className="text-destructive font-bold">
|
||||
{t("chat:checkpoint.menu.cannotUndo")}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-muted transition-colors group-hover:text-foreground">
|
||||
{t("chat:checkpoint.menu.restoreFilesDescription")}
|
||||
{t("chat:checkpoint.menu.restoreFilesAndTaskDescription")}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{!isCurrent && (
|
||||
<div className="flex flex-col gap-1 group hover:text-foreground">
|
||||
<div className="flex flex-col gap-1 group hover:text-foreground">
|
||||
{!isConfirming ? (
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => setIsConfirming(true)}
|
||||
data-testid="restore-files-and-task-btn">
|
||||
{t("chat:checkpoint.menu.restoreFilesAndTask")}
|
||||
</Button>
|
||||
) : (
|
||||
<>
|
||||
<Button
|
||||
variant="default"
|
||||
onClick={onRestore}
|
||||
className="grow"
|
||||
data-testid="confirm-restore-btn">
|
||||
<div className="flex flex-row gap-1">
|
||||
<CheckIcon />
|
||||
<div>{t("chat:checkpoint.menu.confirm")}</div>
|
||||
</div>
|
||||
</Button>
|
||||
<Button variant="secondary" onClick={() => setIsConfirming(false)}>
|
||||
<div className="flex flex-row gap-1">
|
||||
<Cross2Icon />
|
||||
<div>{t("chat:checkpoint.menu.cancel")}</div>
|
||||
</div>
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{isConfirming ? (
|
||||
<div
|
||||
data-testid="checkpoint-confirm-warning"
|
||||
className="text-destructive font-bold">
|
||||
{t("chat:checkpoint.menu.cannotUndo")}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-muted transition-colors group-hover:text-foreground">
|
||||
{t("chat:checkpoint.menu.restoreFilesAndTaskDescription")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ type CheckpointSavedProps = {
|
|||
checkpoint?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export const CheckpointSaved = ({ checkpoint, ...props }: CheckpointSavedProps) => {
|
||||
export const CheckpointSaved = ({ checkpoint, currentHash, ...props }: CheckpointSavedProps) => {
|
||||
const { t } = useTranslation()
|
||||
const isCurrent = props.currentHash === props.commitHash
|
||||
const isCurrent = currentHash === props.commitHash
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState(false)
|
||||
const [isClosing, setIsClosing] = useState(false)
|
||||
const closeTimer = useRef<number | null>(null)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue