MCPcopy Create free account
hub / github.com/winfunc/opcode / handleStop

Function handleStop

src/components/AgentRunView.tsx:176–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

174 };
175
176 const handleStop = async () => {
177 if (!runId) {
178 console.error('[AgentRunView] No run ID available to stop');
179 return;
180 }
181
182 try {
183 // Call the API to kill the agent session
184 const success = await api.killAgentSession(runId);
185
186 if (success) {
187 console.log(`[AgentRunView] Successfully stopped agent session ${runId}`);
188
189 // Update the run status locally
190 if (run) {
191 setRun({ ...run, status: 'cancelled' });
192 }
193
194 // Add a message indicating execution was stopped
195 const stopMessage: ClaudeStreamMessage = {
196 type: "result",
197 subtype: "error",
198 is_error: true,
199 result: "Execution stopped by user",
200 duration_ms: 0,
201 usage: {
202 input_tokens: 0,
203 output_tokens: 0
204 }
205 };
206 setMessages(prev => [...prev, stopMessage]);
207
208 // Reload the run data after a short delay
209 setTimeout(() => {
210 loadRun();
211 }, 1000);
212 } else {
213 console.warn(`[AgentRunView] Failed to stop agent session ${runId} - it may have already finished`);
214 }
215 } catch (err) {
216 console.error('[AgentRunView] Failed to stop agent:', err);
217 }
218 };
219
220 const renderIcon = (iconName: string) => {
221 const Icon = AGENT_ICONS[iconName as keyof typeof AGENT_ICONS] || Bot;

Callers

nothing calls this directly

Calls 1

loadRunFunction · 0.85

Tested by

no test coverage detected