can now add nodes

This commit is contained in:
2026-04-19 05:45:33 +10:00
parent 7e7e6f2c22
commit 34c2aa4316
23 changed files with 864 additions and 1 deletions

View File

@@ -114,6 +114,51 @@ export class NodeRenderer {
this.#renderNode(node);
}
/**
* Removes a node from the graph and DOM.
*
* @param {string} nodeId
*/
removeNode(nodeId) {
const element = this.#nodeElements.get(nodeId);
if (element) {
element.remove();
this.#nodeElements.delete(nodeId);
}
// Remove all connections touching this node
const connIds = [];
for (const [id, conn] of this.#connections) {
if (conn.from.nodeId === nodeId || conn.to.nodeId === nodeId) {
connIds.push(id);
}
}
for (const id of connIds) {
this.#connections.delete(id);
}
// Stop any active timers
const intervalHandle = this.#timerIntervals.get(nodeId);
if (intervalHandle !== undefined) {
clearInterval(intervalHandle);
this.#timerIntervals.delete(nodeId);
}
// Clean up chat instances
const chatInstance = this.#chatInstances.get(nodeId);
if (chatInstance) {
this.#chatInstances.delete(nodeId);
}
this.#nodes.delete(nodeId);
// Notify connections need refresh
if (connIds.length > 0) {
this.#onConnectionRemoved?.();
}
}
/**
* Adds a comment box to the graph and renders it into the DOM.
*