diff --git a/ui/src/pages/InstanceSettings.tsx b/ui/src/pages/InstanceSettings.tsx
index a4781e1f..1a48bf0a 100644
--- a/ui/src/pages/InstanceSettings.tsx
+++ b/ui/src/pages/InstanceSettings.tsx
@@ -77,9 +77,38 @@ export function InstanceSettings() {
},
});
+ const disableAllMutation = useMutation({
+ mutationFn: async (agentRows: InstanceSchedulerHeartbeatAgent[]) => {
+ const enabled = agentRows.filter((a) => a.heartbeatEnabled);
+ for (const agentRow of enabled) {
+ const agent = await agentsApi.get(agentRow.id, agentRow.companyId);
+ const runtimeConfig = asRecord(agent.runtimeConfig) ?? {};
+ const heartbeat = asRecord(runtimeConfig.heartbeat) ?? {};
+ await agentsApi.update(
+ agentRow.id,
+ {
+ runtimeConfig: {
+ ...runtimeConfig,
+ heartbeat: { ...heartbeat, enabled: false },
+ },
+ },
+ agentRow.companyId,
+ );
+ }
+ },
+ onSuccess: async () => {
+ setActionError(null);
+ await queryClient.invalidateQueries({ queryKey: queryKeys.instance.schedulerHeartbeats });
+ },
+ onError: (error) => {
+ setActionError(error instanceof Error ? error.message : "Failed to disable all heartbeats.");
+ },
+ });
+
const agents = heartbeatsQuery.data ?? [];
const activeCount = agents.filter((agent) => agent.schedulerActive).length;
const disabledCount = agents.length - activeCount;
+ const anyEnabled = agents.some((a) => a.heartbeatEnabled);
const grouped = useMemo(() => {
const map = new Map