@@ -2,7 +2,7 @@ import { memo, useState, useCallback, useEffect } from 'react';
22import dynamic from 'next/dynamic' ;
33
44import type { ArtifactKind } from '@/components/artifact' ;
5- import { FileIcon , LoaderIcon , MessageIcon , PencilEditIcon , CheckIcon , CheckCircleFillIcon } from '@/components/icons' ;
5+ import { FileIcon , LoaderIcon , MessageIcon , PencilEditIcon , CheckIcon , CheckCircleFillIcon , CrossIcon } from '@/components/icons' ;
66import { toast } from 'sonner' ;
77import { useArtifact } from '@/hooks/use-artifact' ;
88import { Button } from '@/components/ui/button' ;
@@ -62,6 +62,7 @@ function PureDocumentToolResult({
6262 }
6363 return false ;
6464 } ) ;
65+ const [ isRejected , setIsRejected ] = useState ( false ) ;
6566
6667 const isUpdateProposal =
6768 type === 'update' &&
@@ -119,6 +120,8 @@ function PureDocumentToolResult({
119120 const handleRejectUpdate = useCallback ( ( ) => {
120121 if ( type !== 'update' || ! result . id || ! result . originalContent ) return ;
121122
123+ setIsRejected ( true ) ;
124+
122125 const event = new CustomEvent ( 'cancel-document-update' , {
123126 detail : {
124127 documentId : result . id ,
@@ -159,7 +162,7 @@ function PureDocumentToolResult({
159162 </ div >
160163 </ div >
161164
162- { ! isApplied ? (
165+ { ! isApplied && ! isRejected ? (
163166 < >
164167 < div className = "p-3 w-full max-h-60 overflow-y-auto text-xs" >
165168 < DiffView
@@ -168,10 +171,20 @@ function PureDocumentToolResult({
168171 />
169172 </ div >
170173 < div className = "p-2 border-t w-full flex justify-end bg-muted/30 gap-2" >
174+ < Button
175+ size = "sm"
176+ variant = "destructive"
177+ onClick = { handleRejectUpdate }
178+ disabled = { isSaving || isApplied || isRejected }
179+ className = "text-xs flex items-center gap-1.5"
180+ >
181+ < CrossIcon size = { 14 } />
182+ Reject
183+ </ Button >
171184 < Button
172185 size = "sm"
173186 onClick = { handleApplyUpdate }
174- disabled = { isSaving || isApplied }
187+ disabled = { isSaving || isApplied || isRejected }
175188 className = "text-xs flex items-center gap-1.5"
176189 >
177190 < CheckIcon size = { 14 } />
@@ -180,10 +193,17 @@ function PureDocumentToolResult({
180193 </ div >
181194 </ >
182195 ) : (
183- < div className = "flex items-center gap-2 p-3 w-full bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300" >
184- < CheckCircleFillIcon size = { 16 } />
185- < span className = "text-sm" > Update applied to document.</ span >
186- </ div >
196+ isApplied ? (
197+ < div className = "flex items-center gap-2 p-3 w-full bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300" >
198+ < CheckCircleFillIcon size = { 16 } />
199+ < span className = "text-sm" > Update applied to document.</ span >
200+ </ div >
201+ ) : (
202+ < div className = "flex items-center gap-2 p-3 w-full bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-300" >
203+ < CrossIcon size = { 16 } />
204+ < span className = "text-sm" > Update proposal rejected.</ span >
205+ </ div >
206+ )
187207 ) }
188208 </ div >
189209 ) ;
0 commit comments