MCPcopy Index your code
hub / github.com/codeaashu/claude-code / kill

Function kill

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

Source from the content-addressed store, hash-verified

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

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