aboutsummaryrefslogtreecommitdiff
path: root/modules/core
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core')
-rw-r--r--modules/core/core-bundle.js35
-rw-r--r--modules/core/module-loader.js2
-rw-r--r--modules/core/module-system.js14
-rw-r--r--modules/core/virtual-fs.js21
4 files changed, 39 insertions, 33 deletions
diff --git a/modules/core/core-bundle.js b/modules/core/core-bundle.js
index 025572c..f275a1f 100644
--- a/modules/core/core-bundle.js
+++ b/modules/core/core-bundle.js
@@ -615,20 +615,13 @@ class VirtualFileSystem {
this.root.content['.trash'] = { type: 'dir', content: {} };
}
const trash = this.root.content['.trash'];
- const flatten = (n, prefix) => {
- if (n.type === 'file') {
- const flatName = prefix + '-' + name;
- let ctr = 0;
- let unique = flatName;
- while (trash.content[unique]) { unique = flatName + '-' + (++ctr); }
- trash.content[unique] = JSON.parse(JSON.stringify(n));
- } else if (n.type === 'dir') {
- for (const [childName, child] of Object.entries(n.content || {})) {
- flatten(child, prefix + '-' + childName);
- }
- }
- };
- flatten(node, ts + '-dir-' + name);
+ // Keep the subtree intact so it can be restored later; the old flatten loop
+ // turned every descendant into a sibling file and lost empty dirs entirely.
+ const baseName = ts + '-dir-' + name;
+ let unique = baseName;
+ let ctr = 0;
+ while (trash.content[unique]) { unique = baseName + '-' + (++ctr); }
+ trash.content[unique] = JSON.parse(JSON.stringify(node));
delete resolved.dir.content[resolved.name];
this.saveToStorage();
this._emitChange(path);
@@ -5758,8 +5751,18 @@ Only output XML function calls for tool tasks. If no tool is needed, answer norm
errors: [],
};
try {
- const raw = JSON.parse(localStorage.getItem('webx11_debug_db') || '[]');
- const list = Array.isArray(raw) ? raw : (raw.errors || []);
+ // Prefer the LIVE error DB: localStorage writes are debounced, so a report
+ // filed right after an error would otherwise carry an empty list.
+ let list = [];
+ try {
+ const ds = Object.values(this.terminal.moduleManager.modules)
+ .find(m => m && m._errorDB && m._errorDB.errors);
+ if (ds) list = Object.values(ds._errorDB.errors);
+ } catch (_e) {}
+ if (!list.length) {
+ const raw = JSON.parse(localStorage.getItem('webx11_debug_db') || '[]');
+ list = Array.isArray(raw) ? raw : Object.values((raw && raw.errors) || {});
+ }
diag.errors = list.slice(-20).map(e => ({
message: String(e.message || e.msg || '').slice(0, 300),
source: String(e.source || e.url || '').slice(0, 200),
diff --git a/modules/core/module-loader.js b/modules/core/module-loader.js
index f9b4c9b..0913d6a 100644
--- a/modules/core/module-loader.js
+++ b/modules/core/module-loader.js
@@ -4,7 +4,7 @@
// Core module bundle loaded synchronously in main.html.
// This loader only handles version cache-busting, splash, terminal init, and optional ext modules.
- const LATEST_VER = 'v4.6.38';
+ const LATEST_VER = 'v4.6.40';
const CACHE = '?v=' + LATEST_VER;
const stored = localStorage.getItem('webx11_cache_ver');
if (stored !== LATEST_VER) {
diff --git a/modules/core/module-system.js b/modules/core/module-system.js
index 1a9ad05..bedceef 100644
--- a/modules/core/module-system.js
+++ b/modules/core/module-system.js
@@ -318,8 +318,18 @@
errors: [],
};
try {
- const raw = JSON.parse(localStorage.getItem('webx11_debug_db') || '[]');
- const list = Array.isArray(raw) ? raw : (raw.errors || []);
+ // Prefer the LIVE error DB: localStorage writes are debounced, so a report
+ // filed right after an error would otherwise carry an empty list.
+ let list = [];
+ try {
+ const ds = Object.values(this.terminal.moduleManager.modules)
+ .find(m => m && m._errorDB && m._errorDB.errors);
+ if (ds) list = Object.values(ds._errorDB.errors);
+ } catch (_e) {}
+ if (!list.length) {
+ const raw = JSON.parse(localStorage.getItem('webx11_debug_db') || '[]');
+ list = Array.isArray(raw) ? raw : Object.values((raw && raw.errors) || {});
+ }
diag.errors = list.slice(-20).map(e => ({
message: String(e.message || e.msg || '').slice(0, 300),
source: String(e.source || e.url || '').slice(0, 200),
diff --git a/modules/core/virtual-fs.js b/modules/core/virtual-fs.js
index d8b5098..8f11d25 100644
--- a/modules/core/virtual-fs.js
+++ b/modules/core/virtual-fs.js
@@ -613,20 +613,13 @@ class VirtualFileSystem {
this.root.content['.trash'] = { type: 'dir', content: {} };
}
const trash = this.root.content['.trash'];
- const flatten = (n, prefix) => {
- if (n.type === 'file') {
- const flatName = prefix + '-' + name;
- let ctr = 0;
- let unique = flatName;
- while (trash.content[unique]) { unique = flatName + '-' + (++ctr); }
- trash.content[unique] = JSON.parse(JSON.stringify(n));
- } else if (n.type === 'dir') {
- for (const [childName, child] of Object.entries(n.content || {})) {
- flatten(child, prefix + '-' + childName);
- }
- }
- };
- flatten(node, ts + '-dir-' + name);
+ // Keep the subtree intact so it can be restored later; the old flatten loop
+ // turned every descendant into a sibling file and lost empty dirs entirely.
+ const baseName = ts + '-dir-' + name;
+ let unique = baseName;
+ let ctr = 0;
+ while (trash.content[unique]) { unique = baseName + '-' + (++ctr); }
+ trash.content[unique] = JSON.parse(JSON.stringify(node));
delete resolved.dir.content[resolved.name];
this.saveToStorage();
this._emitChange(path);