11import type { SessionNotification } from "@agentclientprotocol/sdk" ;
22import type { SessionEvent } from "@features/sessions/stores/sessionStore" ;
33import { useAutoScroll } from "@hooks/useAutoScroll" ;
4- import { PaperPlaneRight as SendIcon } from "@phosphor-icons/react" ;
4+ import {
5+ PaperPlaneRight as SendIcon ,
6+ Stop as StopIcon ,
7+ } from "@phosphor-icons/react" ;
58import {
69 Box ,
710 Button ,
@@ -21,6 +24,7 @@ interface LogViewProps {
2124 isRunning : boolean ;
2225 isPromptPending ?: boolean ;
2326 onSendPrompt ?: ( text : string ) => Promise < void > ;
27+ onCancelPrompt ?: ( ) => void ;
2428 onStartSession ?: ( ) => void ;
2529}
2630
@@ -56,6 +60,7 @@ export function LogView({
5660 isRunning,
5761 isPromptPending = false ,
5862 onSendPrompt,
63+ onCancelPrompt,
5964 onStartSession,
6065} : LogViewProps ) {
6166 const [ inputValue , setInputValue ] = useState ( "" ) ;
@@ -86,8 +91,12 @@ export function LogView({
8691 e . preventDefault ( ) ;
8792 handleSend ( ) ;
8893 }
94+ if ( e . key === "Escape" && isPromptPending && onCancelPrompt ) {
95+ e . preventDefault ( ) ;
96+ onCancelPrompt ( ) ;
97+ }
8998 } ,
90- [ handleSend ] ,
99+ [ handleSend , isPromptPending , onCancelPrompt ] ,
91100 ) ;
92101
93102 // Build rendered output from events (filter out raw acp_message unless showRawLogs is true)
@@ -205,15 +214,23 @@ export function LogView({
205214 style = { { resize : "none" } }
206215 />
207216 </ Box >
208- < Tooltip content = "Send message (Enter)" >
209- < IconButton
210- size = "3"
211- onClick = { handleSend }
212- disabled = { ! inputValue . trim ( ) || isPromptPending || ! isRunning }
213- >
214- < SendIcon size = { 20 } />
215- </ IconButton >
216- </ Tooltip >
217+ { isPromptPending ? (
218+ < Tooltip content = "Cancel (Esc)" >
219+ < IconButton size = "3" color = "red" onClick = { onCancelPrompt } >
220+ < StopIcon size = { 20 } weight = "fill" />
221+ </ IconButton >
222+ </ Tooltip >
223+ ) : (
224+ < Tooltip content = "Send message (Enter)" >
225+ < IconButton
226+ size = "3"
227+ onClick = { handleSend }
228+ disabled = { ! inputValue . trim ( ) || ! isRunning }
229+ >
230+ < SendIcon size = { 20 } />
231+ </ IconButton >
232+ </ Tooltip >
233+ ) }
217234 </ Flex >
218235 </ Box >
219236 ) }
0 commit comments