Skip to content

Commit b9110dc

Browse files
authored
fix: always show checkpoint restore options regardless of change detection (#8758)
1 parent 8187a8e commit b9110dc

File tree

2 files changed

+45
-63
lines changed

2 files changed

+45
-63
lines changed

webview-ui/src/components/chat/checkpoints/CheckpointMenu.tsx

Lines changed: 43 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { Checkpoint } from "./schema"
1111
type CheckpointMenuBaseProps = {
1212
ts: number
1313
commitHash: string
14-
currentHash?: string
1514
checkpoint: Checkpoint
1615
}
1716
type CheckpointMenuControlledProps = {
@@ -24,21 +23,12 @@ type CheckpointMenuUncontrolledProps = {
2423
}
2524
type CheckpointMenuProps = CheckpointMenuBaseProps & (CheckpointMenuControlledProps | CheckpointMenuUncontrolledProps)
2625

27-
export const CheckpointMenu = ({
28-
ts,
29-
commitHash,
30-
currentHash,
31-
checkpoint,
32-
open,
33-
onOpenChange,
34-
}: CheckpointMenuProps) => {
26+
export const CheckpointMenu = ({ ts, commitHash, checkpoint, open, onOpenChange }: CheckpointMenuProps) => {
3527
const { t } = useTranslation()
3628
const [internalOpen, setInternalOpen] = useState(false)
3729
const [isConfirming, setIsConfirming] = useState(false)
3830
const portalContainer = useRooPortal("roo-portal")
3931

40-
const isCurrent = currentHash === commitHash
41-
4232
const previousCommitHash = checkpoint?.from
4333

4434
const isOpen = open ?? internalOpen
@@ -88,60 +78,52 @@ export const CheckpointMenu = ({
8878
</StandardTooltip>
8979
<PopoverContent align="end" container={portalContainer}>
9080
<div className="flex flex-col gap-2">
91-
{!isCurrent && (
92-
<div className="flex flex-col gap-1 group hover:text-foreground">
93-
<Button variant="secondary" onClick={onPreview} data-testid="restore-files-btn">
94-
{t("chat:checkpoint.menu.restoreFiles")}
95-
</Button>
96-
<div className="text-muted transition-colors group-hover:text-foreground">
97-
{t("chat:checkpoint.menu.restoreFilesDescription")}
98-
</div>
81+
<div className="flex flex-col gap-1 group hover:text-foreground">
82+
<Button variant="secondary" onClick={onPreview} data-testid="restore-files-btn">
83+
{t("chat:checkpoint.menu.restoreFiles")}
84+
</Button>
85+
<div className="text-muted transition-colors group-hover:text-foreground">
86+
{t("chat:checkpoint.menu.restoreFilesDescription")}
9987
</div>
100-
)}
101-
{!isCurrent && (
102-
<div className="flex flex-col gap-1 group hover:text-foreground">
103-
<div className="flex flex-col gap-1 group hover:text-foreground">
104-
{!isConfirming ? (
105-
<Button
106-
variant="secondary"
107-
onClick={() => setIsConfirming(true)}
108-
data-testid="restore-files-and-task-btn">
109-
{t("chat:checkpoint.menu.restoreFilesAndTask")}
110-
</Button>
111-
) : (
112-
<>
113-
<Button
114-
variant="default"
115-
onClick={onRestore}
116-
className="grow"
117-
data-testid="confirm-restore-btn">
118-
<div className="flex flex-row gap-1">
119-
<CheckIcon />
120-
<div>{t("chat:checkpoint.menu.confirm")}</div>
121-
</div>
122-
</Button>
123-
<Button variant="secondary" onClick={() => setIsConfirming(false)}>
124-
<div className="flex flex-row gap-1">
125-
<Cross2Icon />
126-
<div>{t("chat:checkpoint.menu.cancel")}</div>
127-
</div>
128-
</Button>
129-
</>
130-
)}
131-
{isConfirming ? (
132-
<div
133-
data-testid="checkpoint-confirm-warning"
134-
className="text-destructive font-bold">
135-
{t("chat:checkpoint.menu.cannotUndo")}
88+
</div>
89+
<div className="flex flex-col gap-1 group hover:text-foreground">
90+
{!isConfirming ? (
91+
<Button
92+
variant="secondary"
93+
onClick={() => setIsConfirming(true)}
94+
data-testid="restore-files-and-task-btn">
95+
{t("chat:checkpoint.menu.restoreFilesAndTask")}
96+
</Button>
97+
) : (
98+
<>
99+
<Button
100+
variant="default"
101+
onClick={onRestore}
102+
className="grow"
103+
data-testid="confirm-restore-btn">
104+
<div className="flex flex-row gap-1">
105+
<CheckIcon />
106+
<div>{t("chat:checkpoint.menu.confirm")}</div>
136107
</div>
137-
) : (
138-
<div className="text-muted transition-colors group-hover:text-foreground">
139-
{t("chat:checkpoint.menu.restoreFilesAndTaskDescription")}
108+
</Button>
109+
<Button variant="secondary" onClick={() => setIsConfirming(false)}>
110+
<div className="flex flex-row gap-1">
111+
<Cross2Icon />
112+
<div>{t("chat:checkpoint.menu.cancel")}</div>
140113
</div>
141-
)}
114+
</Button>
115+
</>
116+
)}
117+
{isConfirming ? (
118+
<div data-testid="checkpoint-confirm-warning" className="text-destructive font-bold">
119+
{t("chat:checkpoint.menu.cannotUndo")}
142120
</div>
143-
</div>
144-
)}
121+
) : (
122+
<div className="text-muted transition-colors group-hover:text-foreground">
123+
{t("chat:checkpoint.menu.restoreFilesAndTaskDescription")}
124+
</div>
125+
)}
126+
</div>
145127
</div>
146128
</PopoverContent>
147129
</Popover>

webview-ui/src/components/chat/checkpoints/CheckpointSaved.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ type CheckpointSavedProps = {
1313
checkpoint?: Record<string, unknown>
1414
}
1515

16-
export const CheckpointSaved = ({ checkpoint, ...props }: CheckpointSavedProps) => {
16+
export const CheckpointSaved = ({ checkpoint, currentHash, ...props }: CheckpointSavedProps) => {
1717
const { t } = useTranslation()
18-
const isCurrent = props.currentHash === props.commitHash
18+
const isCurrent = currentHash === props.commitHash
1919
const [isPopoverOpen, setIsPopoverOpen] = useState(false)
2020
const [isClosing, setIsClosing] = useState(false)
2121
const closeTimer = useRef<number | null>(null)

0 commit comments

Comments
 (0)