From 34ad5cd0230f910bf7757be454075cbd14f7191e Mon Sep 17 00:00:00 2001 From: Chaim Date: Fri, 24 Apr 2026 12:06:29 +0000 Subject: [PATCH] feat(ask): progress panel + 240s ajax timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ask mode goes through the full agent loop (hybrid search + rerank + Claude). Typical runs land at 30-90s; long queries reach 90-120s. With the previous UX the user saw only "Loading…" on the submit button and "מחפש…" in the results area — indistinguishable from a stuck request. - Render a dedicated progress panel on ask with a spinner, a description of what shira is doing, and a live elapsed-seconds counter. - After 2 minutes, append a "taking longer than usual" warning so users know the request is still running. - Override Espo.Ajax timeout to 240s; jQuery's default (undefined) or EspoCRM's request-level default would kill the browser request well before shira finishes on a cold cache. - Version 0.1.7. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../knowledge-base/src/views/kb/index.js | 59 ++++++++++++++++++- manifest.json | 2 +- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/files/client/custom/modules/knowledge-base/src/views/kb/index.js b/files/client/custom/modules/knowledge-base/src/views/kb/index.js index 1e87adc..f5e15f0 100644 --- a/files/client/custom/modules/knowledge-base/src/views/kb/index.js +++ b/files/client/custom/modules/knowledge-base/src/views/kb/index.js @@ -103,17 +103,68 @@ define('modules/knowledge-base/views/kb/index', ['view'], function (Dep) { runAsk: function (message) { this.setLoading(true); + this.startAskProgress(); + // Ask goes through the full agent loop (search + rerank + LLM), + // which routinely takes 30-90s. The default jQuery Ajax timeout + // is too short; override it here so the browser doesn't give up + // before shira-hermes responds. Espo.Ajax.postRequest('KnowledgeBase/action/ask', { message: message, - }).then(res => { + }, {timeout: 240000}).then(res => { + this.stopAskProgress(); this.setLoading(false); this.renderAskAnswer(res.text || ''); }).catch(err => { + this.stopAskProgress(); this.setLoading(false); this.showError(err); }); }, + startAskProgress: function () { + // Show a live elapsed-time indicator so users know the request + // is still running rather than stuck. Typical answers arrive in + // 30-90s; we warn after 2 minutes. + if (this.mode !== 'ask') return; + const $results = this.$el.find('.kb-results'); + $results.html( + '
' + + '
' + + ' ' + + ' שירה חושבת…' + + '
' + + ' שירה מחפשת בבסיס הידע, מסכמת ומציגה ציטוטים מדויקים.' + + ' זה יכול לקחת בין 30 ל-90 שניות.' + + '
' + + '
' + + ' זמן שעבר: ' + + ' 0' + + ' שניות' + + '
' + + '
' + + '
' + ); + const startedAt = Date.now(); + this._askTimer = setInterval(() => { + const sec = Math.round((Date.now() - startedAt) / 1000); + const $elapsed = this.$el.find('.kb-elapsed'); + if ($elapsed.length) $elapsed.text(sec); + if (sec === 120) { + this.$el.find('.kb-ask-progress .panel-body').append( + '
' + + 'לוקח יותר זמן מהרגיל. עדיין ממתינים…
' + ); + } + }, 1000); + }, + + stopAskProgress: function () { + if (this._askTimer) { + clearInterval(this._askTimer); + this._askTimer = null; + } + }, + renderSearchResults: function (hits) { const $results = this.$el.find('.kb-results'); if (!hits.length) { @@ -260,7 +311,11 @@ define('modules/knowledge-base/views/kb/index', ['view'], function (Dep) { const $btn = this.$el.find('[data-action="submit"]'); if (loading) { $btn.prop('disabled', true).text(this.translate('Loading', 'labels')); - this.$el.find('.kb-results').html('
מחפש…
'); + // Only overwrite results with "מחפש…" for search. For ask, + // startAskProgress() renders a richer progress panel. + if (this.mode !== 'ask') { + this.$el.find('.kb-results').html('
מחפש…
'); + } } else { $btn.prop('disabled', false).text(this.getSubmitLabel()); } diff --git a/manifest.json b/manifest.json index 6384e0a..9eed14c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "KnowledgeBase", "module": "KnowledgeBase", - "version": "0.1.6", + "version": "0.1.7", "acceptableVersions": [ ">=8.0.0" ],