aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-aiasm.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/module-aiasm.js')
-rw-r--r--modules/core/module-aiasm.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/modules/core/module-aiasm.js b/modules/core/module-aiasm.js
index 60e1757..34c1582 100644
--- a/modules/core/module-aiasm.js
+++ b/modules/core/module-aiasm.js
@@ -17,10 +17,19 @@
if (!args[0]) {
this.terminal.print("Usage: webxai <your-question>", "warning"); return;
}
- if (this.terminal.moduleManager.modules['WebX11AIAssistantModule']) {
- this.terminal.moduleManager.modules['WebX11AIAssistantModule'].chat(args);
- } else {
- this.terminal.ollamaManager.chat(args.join(' '));
+ const ai = this.terminal.moduleManager.modules['WebX11AIAssistantModule'];
+ let p;
+ try {
+ p = ai ? ai.chat(args) : this.terminal.ollamaManager.chat(args.join(' '));
+ } catch (e) {
+ // Synchronous throw — report it through the same path as a rejection.
+ p = Promise.reject(e);
}
+ // Chat-lock timeouts are normal UX (user sent twice). Print, don't let the rejection
+ // reach window.unhandledrejection → debug-supervisor auto-report. chat() releases its
+ // own lock in finally, so nothing is cleared here.
+ return Promise.resolve(p).catch((e) => {
+ this.terminal.print('AI error: ' + (e && e.message ? e.message : e), 'error');
+ });
}
}