fix: preserve empty Grok hook groups

This commit is contained in:
ZacharyZhang-NY committed 2026-07-19 07:57:42 -04:00
1 parent b2c4b4cdb4
commit 9b7b7f5959
2 files changed
+10 -5

No files matched your search

+7 -2
View File
@@ -241,14 +241,19 @@ function removeManaged(
result.push(group);
continue;
}
let groupChanged = false;
const handlers = group.hooks.filter((handler) => {
const managedId = managedAgentId(handler, scriptName);
const remove = managedId !== undefined
&& (agentId === undefined || sameAgentId(managedId, agentId));
if (remove) changed = true;
if (remove) {
changed = true;
groupChanged = true;
}
return !remove;
});
if (handlers.length > 0) result.push(handlers.length === group.hooks.length ? group : { ...group, hooks: handlers });
if (!groupChanged) result.push(group);
else if (handlers.length > 0) result.push({ ...group, hooks: handlers });
}
return { groups: result, changed };
}