From c0c1fd17cb9884d589d6e15e321edf20b5af5916 Mon Sep 17 00:00:00 2001 From: dotta Date: Mon, 23 Mar 2026 16:22:22 -0500 Subject: [PATCH] Add "Disable All" button to heartbeats settings page Adds a destructive-variant button at the top of the heartbeats page that disables timer heartbeats for all agents at once. The button only appears when at least one agent has heartbeats enabled, and shows a loading state while processing. Co-Authored-By: Paperclip Co-Authored-By: Claude Opus 4.6 --- ui/src/pages/InstanceSettings.tsx | 42 ++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) 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(); @@ -120,10 +149,21 @@ export function InstanceSettings() {

-
+
{activeCount} active {disabledCount} disabled {grouped.length} {grouped.length === 1 ? "company" : "companies"} + {anyEnabled && ( + + )}
{actionError && (