aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-system.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-10-18 17:01:52 +0200
committerAgando <roduccomm@gmail.com>2026-10-18 17:01:52 +0200
commitd7a1198aa7ac77cbe9d3f0c844245dd08a8ccd12 (patch)
tree0e6851e95a62d05f51966fe29eb784108df0fe4b /modules/core/module-system.js
parent824d6cd3c61488c120c0226d1929324f2741fafc (diff)
newOS4 v4.6.37: bug-report pipeline (report.php, bug command, HTML generator, telemetry-loop fix)
Diffstat (limited to 'modules/core/module-system.js')
-rw-r--r--modules/core/module-system.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/modules/core/module-system.js b/modules/core/module-system.js
index 9dee38c..1a9ad05 100644
--- a/modules/core/module-system.js
+++ b/modules/core/module-system.js
@@ -15,6 +15,7 @@
'errors': 'errors [n] — Show last n ERROR log entries (default: 20)',
'doctor': 'doctor — Run all health checks, rank issues, show top 3 warnings',
'bug-report': 'bug-report — Generate a markdown bug report to /tmp/ for debugging',
+ 'bug': 'bug <title> — File a structured bug report (stored server-side, visible in BUG-REPORT.html)',
'preview': 'preview <file.html> — Render an HTML file from the VFS in a preview pane',
'reset': 'reset [mem|vfs|config|all] — Global reset command (default: mem)',
'factory-reset': 'factory-reset — Alias for reset all',
@@ -305,6 +306,48 @@
}
};
+ // v4.6.37: bug — file a structured report to the backend (Part A)
+ this.commands['bug'] = async (args) => {
+ const title = (args || []).join(' ').trim() || 'Untitled bug report';
+ const diag = {
+ version: window.NEWOS4_VERSION || 'unknown',
+ url: location.href,
+ ua: navigator.userAgent,
+ online: navigator.onLine,
+ modules: Object.keys(this.terminal.moduleManager.modules).length,
+ errors: [],
+ };
+ try {
+ const raw = JSON.parse(localStorage.getItem('webx11_debug_db') || '[]');
+ const list = Array.isArray(raw) ? 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),
+ count: Number(e.count) || 1,
+ }));
+ } catch (_e) {}
+ try {
+ diag.recent_commands = JSON.parse(localStorage.getItem('webx11_command_history') || '[]')
+ .slice(-10)
+ .map(c => String(c).replace(/(password|token|secret|api[_-]?key)\S*/ig, '$1:[redacted]'));
+ } catch (_e) {}
+
+ this.terminal.print('📮 Filing bug report…', 'info');
+ let res = null, err = null;
+ try {
+ const r = await fetch('/spaces/newos4/api/debug/report.php', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ title, diagnostics: diag }),
+ });
+ res = await r.json();
+ if (!r.ok) err = res.error || ('HTTP ' + r.status);
+ } catch (e) { err = e.message; }
+ if (err) { this.terminal.print('❌ Report failed: ' + err, 'error'); return; }
+ this.terminal.print('✅ Report filed: ' + res.id + (res.duplicate ? ' (already known)' : ''), 'success');
+ this.terminal.print(' View: /spaces/newos4/downloads/bugs/BUG-REPORT.html', 'info');
+ };
+
this.commands['preview'] = (args) => this.terminal.openPreview(args);
// v4.5.64: reset — unified reset command superseding factory-reset, reset-vfs, reset-mem, config-reset