MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / pauseActiveBatchTasks

Function pauseActiveBatchTasks

static/js/accounts.js:937–977  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

935}
936
937async function pauseActiveBatchTasks() {
938 const tasks = getPausableBatchTasks();
939 if (!tasks.length || isTaskPausing) return;
940
941 isTaskPausing = true;
942 updateBatchButtons();
943 try {
944 const results = await Promise.allSettled(
945 tasks.map((task) => api.post(`/tasks/${task.domain}/${task.id}/pause`, {}, {
946 timeoutMs: 15000,
947 retry: 0,
948 priority: 'high',
949 })),
950 );
951 let successCount = 0;
952 let failedCount = 0;
953 results.forEach((item, index) => {
954 if (item.status === 'fulfilled') {
955 successCount += 1;
956 patchBatchTask(tasks[index].key, {
957 status: 'paused',
958 paused: true,
959 pause_requested: true,
960 });
961 return;
962 }
963 failedCount += 1;
964 });
965 if (successCount > 0) {
966 toast.success(`已暂停 ${successCount} 个任务`);
967 }
968 if (failedCount > 0) {
969 toast.warning(`${failedCount} 个任务暂停失败`);
970 }
971 } catch (error) {
972 toast.error(`暂停任务失败: ${error.message}`);
973 } finally {
974 isTaskPausing = false;
975 updateBatchButtons();
976 }
977}
978
979async function resumeActiveBatchTasks() {
980 const tasks = getResumableBatchTasks();

Callers

nothing calls this directly

Calls 7

getPausableBatchTasksFunction · 0.85
patchBatchTaskFunction · 0.85
successMethod · 0.80
warningMethod · 0.80
errorMethod · 0.80
updateBatchButtonsFunction · 0.70
postMethod · 0.45

Tested by

no test coverage detected