MCPcopy
hub / github.com/codeaashu/claude-code / unassignTeammateTasks

Function unassignTeammateTasks

src/utils/tasks.ts:818–860  ·  view source on GitHub ↗
(
  teamName: string,
  teammateId: string,
  teammateName: string,
  reason: 'terminated' | 'shutdown',
)

Source from the content-addressed store, hash-verified

816 * @returns The unassigned tasks and a formatted notification message
817 */
818export async function unassignTeammateTasks(
819 teamName: string,
820 teammateId: string,
821 teammateName: string,
822 reason: 'terminated' | 'shutdown',
823): Promise<UnassignTasksResult> {
824 const tasks = await listTasks(teamName)
825 const unresolvedAssignedTasks = tasks.filter(
826 t =>
827 t.status !== 'completed' &&
828 (t.owner === teammateId || t.owner === teammateName),
829 )
830
831 // Unassign each task and reset status to open
832 for (const task of unresolvedAssignedTasks) {
833 await updateTask(teamName, task.id, { owner: undefined, status: 'pending' })
834 }
835
836 if (unresolvedAssignedTasks.length > 0) {
837 logForDebugging(
838 `[Tasks] Unassigned ${unresolvedAssignedTasks.length} task(s) from ${teammateName}`,
839 )
840 }
841
842 // Build notification message
843 const actionVerb =
844 reason === 'terminated' ? 'was terminated' : 'has shut down'
845 let notificationMessage = `${teammateName} ${actionVerb}.`
846 if (unresolvedAssignedTasks.length > 0) {
847 const taskList = unresolvedAssignedTasks
848 .map(t => `#${t.id} "${t.subject}"`)
849 .join(', ')
850 notificationMessage += ` ${unresolvedAssignedTasks.length} task(s) were unassigned: ${taskList}. Use TaskList to check availability and TaskUpdate with owner to reassign them to idle teammates.`
851 }
852
853 return {
854 unassignedTasks: unresolvedAssignedTasks.map(t => ({
855 id: t.id,
856 subject: t.subject,
857 })),
858 notificationMessage,
859 }
860}
861
862export const DEFAULT_TASKS_MODE_TASK_LIST_ID = 'tasklist'
863

Callers 4

killTeammateFunction · 0.85
runFunction · 0.85
useInboxPollerFunction · 0.85

Calls 3

listTasksFunction · 0.85
updateTaskFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected