File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed
Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {
2121 Sun ,
2222 Trash ,
2323 PaperPlaneTilt ,
24+ Stop ,
2425} from "@phosphor-icons/react" ;
2526
2627// List of tools that require human confirmation
@@ -77,6 +78,8 @@ export default function Chat() {
7778 handleSubmit : handleAgentSubmit ,
7879 addToolResult,
7980 clearHistory,
81+ isLoading,
82+ stop,
8083 } = useAgentChat ( {
8184 agent,
8285 maxSteps : 5 ,
@@ -342,13 +345,25 @@ export default function Chat() {
342345 style = { { height : textareaHeight } }
343346 />
344347 < div className = "absolute bottom-0 right-0 p-2 w-fit flex flex-row justify-end" >
345- < button
346- type = "submit"
347- className = "inline-flex items-center cursor-pointer justify-center gap-2 whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 bg-primary text-primary-foreground hover:bg-primary/90 rounded-full p-1.5 h-fit border border-neutral-200 dark:border-neutral-800"
348- disabled = { pendingToolCallConfirmation || ! agentInput . trim ( ) }
349- >
350- < PaperPlaneTilt size = { 16 } />
351- </ button >
348+ { isLoading ? (
349+ < button
350+ type = "button"
351+ onClick = { stop }
352+ className = "inline-flex items-center cursor-pointer justify-center gap-2 whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 bg-primary text-primary-foreground hover:bg-primary/90 rounded-full p-1.5 h-fit border border-neutral-200 dark:border-neutral-800"
353+ aria-label = "Stop generation"
354+ >
355+ < Stop size = { 16 } />
356+ </ button >
357+ ) : (
358+ < button
359+ type = "submit"
360+ className = "inline-flex items-center cursor-pointer justify-center gap-2 whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 bg-primary text-primary-foreground hover:bg-primary/90 rounded-full p-1.5 h-fit border border-neutral-200 dark:border-neutral-800"
361+ disabled = { pendingToolCallConfirmation || ! agentInput . trim ( ) }
362+ aria-label = "Send message"
363+ >
364+ < PaperPlaneTilt size = { 16 } />
365+ </ button >
366+ ) }
352367 </ div >
353368 </ div >
354369 </ div >
You can’t perform that action at this time.
0 commit comments