@@ -8,13 +8,16 @@ import { Button, Popover, PopoverContent, PopoverTrigger } from "@/components/ui
88type CheckpointMenuProps = {
99 ts : number
1010 commitHash : string
11+ currentCheckpointHash ?: string
1112}
1213
13- export const CheckpointMenu = ( { ts, commitHash } : CheckpointMenuProps ) => {
14+ export const CheckpointMenu = ( { ts, commitHash, currentCheckpointHash } : CheckpointMenuProps ) => {
1415 const [ portalContainer , setPortalContainer ] = useState < HTMLElement > ( )
1516 const [ isOpen , setIsOpen ] = useState ( false )
1617 const [ isConfirming , setIsConfirming ] = useState ( false )
1718
19+ const isCurrent = currentCheckpointHash === commitHash
20+
1821 const onCheckpointDiff = useCallback ( ( ) => {
1922 vscode . postMessage ( { type : "checkpointDiff" , payload : { ts, commitHash, mode : "checkpoint" } } )
2023 } , [ ts , commitHash ] )
@@ -43,62 +46,64 @@ export const CheckpointMenu = ({ ts, commitHash }: CheckpointMenuProps) => {
4346 < Button variant = "ghost" size = "icon" onClick = { onCheckpointDiff } >
4447 < span className = "codicon codicon-diff-single" />
4548 </ Button >
46- < Popover
47- open = { isOpen }
48- onOpenChange = { ( open ) => {
49- setIsOpen ( open )
50- setIsConfirming ( false )
51- } } >
52- < PopoverTrigger asChild >
53- < Button variant = "ghost" size = "icon" >
54- < span className = "codicon codicon-history" />
55- </ Button >
56- </ PopoverTrigger >
57- < PopoverContent align = "end" container = { portalContainer } >
58- < div className = "flex flex-col gap-2" >
59- < div className = "flex flex-col gap-1 group hover:text-foreground" >
60- < Button variant = "secondary" onClick = { onPreview } >
61- Restore Files
62- </ Button >
63- < div className = "text-muted transition-colors group-hover:text-foreground" >
64- Restores your project's files back to a snapshot taken at this point.
49+ { ! isCurrent && (
50+ < Popover
51+ open = { isOpen }
52+ onOpenChange = { ( open ) => {
53+ setIsOpen ( open )
54+ setIsConfirming ( false )
55+ } } >
56+ < PopoverTrigger asChild >
57+ < Button variant = "ghost" size = "icon" >
58+ < span className = "codicon codicon-history" />
59+ </ Button >
60+ </ PopoverTrigger >
61+ < PopoverContent align = "end" container = { portalContainer } >
62+ < div className = "flex flex-col gap-2" >
63+ < div className = "flex flex-col gap-1 group hover:text-foreground" >
64+ < Button variant = "secondary" onClick = { onPreview } >
65+ Restore Files
66+ </ Button >
67+ < div className = "text-muted transition-colors group-hover:text-foreground" >
68+ Restores your project's files back to a snapshot taken at this point.
69+ </ div >
6570 </ div >
66- </ div >
67- < div className = "flex flex-col gap-1 group hover:text-foreground" >
6871 < div className = "flex flex-col gap-1 group hover:text-foreground" >
69- { ! isConfirming ? (
70- < Button variant = "secondary" onClick = { ( ) => setIsConfirming ( true ) } >
71- Restore Files & Task
72- </ Button >
73- ) : (
74- < >
75- < Button variant = "default" onClick = { onRestore } className = "grow" >
76- < div className = "flex flex-row gap-1" >
77- < CheckIcon />
78- < div > Confirm</ div >
79- </ div >
80- </ Button >
81- < Button variant = "secondary" onClick = { ( ) => setIsConfirming ( false ) } >
82- < div className = "flex flex-row gap-1" >
83- < Cross2Icon />
84- < div > Cancel</ div >
85- </ div >
72+ < div className = "flex flex-col gap-1 group hover:text-foreground" >
73+ { ! isConfirming ? (
74+ < Button variant = "secondary" onClick = { ( ) => setIsConfirming ( true ) } >
75+ Restore Files & Task
8676 </ Button >
87- </ >
88- ) }
89- { isConfirming ? (
90- < div className = "text-destructive font-bold" > This action cannot be undone.</ div >
91- ) : (
92- < div className = "text-muted transition-colors group-hover:text-foreground" >
93- Restores your project's files back to a snapshot taken at this point and deletes
94- all messages after this point.
95- </ div >
96- ) }
77+ ) : (
78+ < >
79+ < Button variant = "default" onClick = { onRestore } className = "grow" >
80+ < div className = "flex flex-row gap-1" >
81+ < CheckIcon />
82+ < div > Confirm</ div >
83+ </ div >
84+ </ Button >
85+ < Button variant = "secondary" onClick = { ( ) => setIsConfirming ( false ) } >
86+ < div className = "flex flex-row gap-1" >
87+ < Cross2Icon />
88+ < div > Cancel</ div >
89+ </ div >
90+ </ Button >
91+ </ >
92+ ) }
93+ { isConfirming ? (
94+ < div className = "text-destructive font-bold" > This action cannot be undone.</ div >
95+ ) : (
96+ < div className = "text-muted transition-colors group-hover:text-foreground" >
97+ Restores your project's files back to a snapshot taken at this point and
98+ deletes all messages after this point.
99+ </ div >
100+ ) }
101+ </ div >
97102 </ div >
98103 </ div >
99- </ div >
100- </ PopoverContent >
101- </ Popover >
104+ </ PopoverContent >
105+ </ Popover >
106+ ) }
102107 </ div >
103108 )
104109}
0 commit comments