app.extensionManager.registerSidebarTab({
id: "dynamicSidebar",
icon: "pi pi-chart-line",
title: "Stats",
type: "custom",
render: (el) => {
const container = document.createElement('div');
container.style.padding = '10px';
el.appendChild(container);
// Function to update stats
function updateStats() {
const stats = {
nodes: app.graph._nodes.length,
connections: Object.keys(app.graph.links).length
};
container.innerHTML = `
<h3>Workflow Stats</h3>
<ul>
<li>Nodes: ${stats.nodes}</li>
<li>Connections: ${stats.connections}</li>
</ul>
`;
}
// Initial update
updateStats();
// Listen for graph changes
const api = app.api;
api.addEventListener("graphChanged", updateStats);
// Clean up listeners when tab is destroyed
return () => {
api.removeEventListener("graphChanged", updateStats);
};
}
});