From ba75463661fed7e9e09127ccc1cecc0c4737409c Mon Sep 17 00:00:00 2001 From: Chaim Date: Sat, 25 Apr 2026 14:15:36 +0000 Subject: [PATCH] feat(kb): topic picker + topic-scoped client (Phase 1, no manifest bump) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wires the EspoCRM extension to the multi-topic backend introduced in shira-hermes commit f03721e. The KB page header now shows a topic in the page header, with a kb-topic-name-suffix span that JS fills with the active name. - src/views/kb/index.js: module-level _topics cache + LS_TOPIC. setup reads localStorage; afterRender gates the picker fill + sources fetch on topics being loaded so a stale id from a deleted topic doesn't fire a 400-ing /sources call. switchTopic clears _activeAsk/Search + _lastAsk/Search + sessionStorage entries + this._sources, then reRenders. Cross-topic guard in afterRender drops cached state whose topicId !== this.topicId. _activeAsk / _lastAsk / _activeSearch / _lastSearch all carry topicId. EventSource URL gains &topicId. Refs Task Master #12. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../knowledge-base/res/templates/kb/index.tpl | 11 +- .../knowledge-base/src/views/kb/index.js | 195 ++++++++++++++++-- .../Controllers/KnowledgeBase.php | 31 ++- .../EntryPoints/KnowledgeBaseAskStream.php | 14 +- .../KnowledgeBase/Resources/routes.json | 8 + .../Services/KnowledgeBaseService.php | 39 +++- 6 files changed, 264 insertions(+), 34 deletions(-) diff --git a/files/client/custom/modules/knowledge-base/res/templates/kb/index.tpl b/files/client/custom/modules/knowledge-base/res/templates/kb/index.tpl index 8a9cc08..535c8e9 100644 --- a/files/client/custom/modules/knowledge-base/res/templates/kb/index.tpl +++ b/files/client/custom/modules/knowledge-base/res/templates/kb/index.tpl @@ -1,6 +1,13 @@
-