feat: Add a stop button to halt agent execution when processing.

This commit is contained in:
Stephan Cho
2025-12-22 21:08:04 -05:00
parent 524a9736b4
commit 51281095ea

View File

@@ -17,6 +17,7 @@ import {
ImageIcon, ImageIcon,
ChevronDown, ChevronDown,
FileText, FileText,
Square,
} from 'lucide-react'; } from 'lucide-react';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { useElectronAgent } from '@/hooks/use-electron-agent'; import { useElectronAgent } from '@/hooks/use-electron-agent';
@@ -83,6 +84,7 @@ export function AgentView() {
isConnected, isConnected,
sendMessage, sendMessage,
clearHistory, clearHistory,
stopExecution,
error: agentError, error: agentError,
} = useElectronAgent({ } = useElectronAgent({
sessionId: currentSessionId || '', sessionId: currentSessionId || '',
@@ -914,21 +916,33 @@ export function AgentView() {
<Paperclip className="w-4 h-4" /> <Paperclip className="w-4 h-4" />
</Button> </Button>
{/* Send Button */} {/* Send / Stop Button */}
<Button {isProcessing ? (
onClick={handleSend} <Button
disabled={ onClick={stopExecution}
(!input.trim() && disabled={!isConnected}
selectedImages.length === 0 && className="h-11 px-4 rounded-xl"
selectedTextFiles.length === 0) || variant="destructive"
isProcessing || data-testid="stop-agent"
!isConnected title="Stop generation"
} >
className="h-11 px-4 rounded-xl" <Square className="w-4 h-4 fill-current" />
data-testid="send-message" </Button>
> ) : (
<Send className="w-4 h-4" /> <Button
</Button> onClick={handleSend}
disabled={
(!input.trim() &&
selectedImages.length === 0 &&
selectedTextFiles.length === 0) ||
!isConnected
}
className="h-11 px-4 rounded-xl"
data-testid="send-message"
>
<Send className="w-4 h-4" />
</Button>
)}
</div> </div>
{/* Keyboard hint */} {/* Keyboard hint */}