Merge pull request #231 from stephan271c/add-pause-button

feat: Add a stop button to halt agent execution when processing.
This commit is contained in:
Web Dev Cody
2025-12-22 21:49:43 -05:00
committed by GitHub

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,14 +916,25 @@ export function AgentView() {
<Paperclip className="w-4 h-4" /> <Paperclip className="w-4 h-4" />
</Button> </Button>
{/* Send Button */} {/* Send / Stop Button */}
{isProcessing ? (
<Button
onClick={stopExecution}
disabled={!isConnected}
className="h-11 px-4 rounded-xl"
variant="destructive"
data-testid="stop-agent"
title="Stop generation"
>
<Square className="w-4 h-4 fill-current" />
</Button>
) : (
<Button <Button
onClick={handleSend} onClick={handleSend}
disabled={ disabled={
(!input.trim() && (!input.trim() &&
selectedImages.length === 0 && selectedImages.length === 0 &&
selectedTextFiles.length === 0) || selectedTextFiles.length === 0) ||
isProcessing ||
!isConnected !isConnected
} }
className="h-11 px-4 rounded-xl" className="h-11 px-4 rounded-xl"
@@ -929,6 +942,7 @@ export function AgentView() {
> >
<Send className="w-4 h-4" /> <Send className="w-4 h-4" />
</Button> </Button>
)}
</div> </div>
{/* Keyboard hint */} {/* Keyboard hint */}