aboutsummaryrefslogtreecommitdiff
path: root/modules/core/virtual-fs.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-06-07 18:00:19 +0200
committerAgando <roduccomm@gmail.com>2026-06-07 18:00:19 +0200
commit0fa227601d51263b0eb787d53225de3f0b44cad1 (patch)
tree2d9f440af92f5b3ead1bea66bd2270a6eb270131 /modules/core/virtual-fs.js
parentab235396568a7e61f02eed436e2400975c752d01 (diff)
auto: 2026-06-07_18:00 changes
Diffstat (limited to 'modules/core/virtual-fs.js')
-rw-r--r--modules/core/virtual-fs.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/core/virtual-fs.js b/modules/core/virtual-fs.js
index 59ab18b..12bb7f1 100644
--- a/modules/core/virtual-fs.js
+++ b/modules/core/virtual-fs.js
@@ -83,6 +83,14 @@ class VirtualFileSystem {
} catch (e) { console.error('FS save error:', e); }
}, 2000);
}
+ _emitChange(path) {
+ // Notify NeuralVFS via window event — zero coupling
+ // Skip internal index/system files to prevent re-trigger loops
+ if (path && (path.startsWith('/.semantic_index') || path.startsWith('/.memory_graph') || path.startsWith('/.trash') || path.startsWith('/_snapshots') || path.startsWith('/_sessions') || path.startsWith('/logs') || path.startsWith('/memory') || path.startsWith('/system') || path.startsWith('/_mods') || path.startsWith('/backups'))) return;
+ if (typeof window !== 'undefined' && window.__nvfsMarkDirty) {
+ window.__nvfsMarkDirty(path);
+ }
+ }
getCurrentPath() {
return '/' + this.currentPath.join('/');
}
@@ -192,6 +200,7 @@ class VirtualFileSystem {
if (resolved.dir.content[name] && resolved.dir.content[name].type === 'dir') return false;
resolved.dir.content[name] = { type: 'file', content: content, modified: new Date() };
this.saveToStorage();
+ this._emitChange(path);
return true;
}
readFile(path) {
@@ -242,6 +251,7 @@ class VirtualFileSystem {
const resolved = this._resolvePath(path);
if (resolved) delete resolved.dir.content[resolved.name];
this.saveToStorage();
+ this._emitChange(path);
} catch (e) { console.error('Trash error:', e); }
}
trashDir(path) {
@@ -272,6 +282,7 @@ class VirtualFileSystem {
flatten(node, ts + '-dir-' + name);
delete resolved.dir.content[resolved.name];
this.saveToStorage();
+ this._emitChange(path);
return true;
} catch (e) { console.error('Trash dir error:', e); }
}
@@ -290,6 +301,7 @@ class VirtualFileSystem {
dir = dir.content[seg];
}
this.saveToStorage();
+ this._emitChange(path);
return true;
}
rename(oldPath, newPath) {
@@ -302,6 +314,8 @@ class VirtualFileSystem {
dst.dir.content[dst.name] = node;
delete src.dir.content[src.name];
this.saveToStorage();
+ this._emitChange(oldPath);
+ this._emitChange(newPath);
return true;
}
copy(srcPath, dstPath) {
@@ -313,6 +327,7 @@ class VirtualFileSystem {
if (!node) return false;
dst.dir.content[dst.name] = JSON.parse(JSON.stringify(node));
this.saveToStorage();
+ this._emitChange(dstPath);
return true;
}
move(srcPath, dstPath) {
@@ -347,6 +362,7 @@ class VirtualFileSystem {
if (Object.keys(node.content).length > 0) return false;
delete resolved.dir.content[resolved.name];
this.saveToStorage();
+ this._emitChange(path);
return true;
}
return false;