MCPcopy Create free account
hub / github.com/WJX20/claude-code / kill

Function kill

src/tasks/RemoteAgentTask/RemoteAgentTask.tsx:818–854  ·  view source on GitHub ↗
(taskId, setAppState)

Source from the content-addressed store, hash-verified

816 name: 'RemoteAgentTask',
817 type: 'remote_agent',
818 async kill(taskId, setAppState) {
819 let toolUseId: string | undefined;
820 let description: string | undefined;
821 let sessionId: string | undefined;
822 let killed = false;
823 updateTaskState<RemoteAgentTaskState>(taskId, setAppState, task => {
824 if (task.status !== 'running') {
825 return task;
826 }
827 toolUseId = task.toolUseId;
828 description = task.description;
829 sessionId = task.sessionId;
830 killed = true;
831 return {
832 ...task,
833 status: 'killed',
834 notified: true,
835 endTime: Date.now()
836 };
837 });
838
839 // Close the task_started bookend for SDK consumers. The poll loop's
840 // early-return when status!=='running' won't emit a notification.
841 if (killed) {
842 emitTaskTerminatedSdk(taskId, 'stopped', {
843 toolUseId,
844 summary: description
845 });
846 // Archive the remote session so it stops consuming cloud resources.
847 if (sessionId) {
848 void archiveRemoteSession(sessionId).catch(e => logForDebugging(`RemoteAgentTask archive failed: ${String(e)}`));
849 }
850 }
851 void evictTaskOutput(taskId);
852 void removeRemoteAgentMetadata(taskId);
853 logForDebugging(`RemoteAgentTask ${taskId} killed, archiving session ${sessionId ?? 'unknown'}`);
854 }
855};
856
857/**

Callers

nothing calls this directly

Calls 6

emitTaskTerminatedSdkFunction · 0.85
archiveRemoteSessionFunction · 0.85
logForDebuggingFunction · 0.85
evictTaskOutputFunction · 0.85
updateTaskStateFunction · 0.50

Tested by

no test coverage detected