@kodaris/krubble-app-components 1.0.88 → 1.0.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chatbot.d.ts +1 -0
- package/dist/chatbot.d.ts.map +1 -1
- package/dist/chatbot.js +18 -19
- package/dist/chatbot.js.map +1 -1
- package/dist/krubble-app.bundled.js +18 -19
- package/dist/krubble-app.bundled.js.map +1 -1
- package/dist/krubble-app.bundled.min.js +1 -1
- package/dist/krubble-app.bundled.min.js.map +1 -1
- package/dist/krubble-app.umd.js +18 -19
- package/dist/krubble-app.umd.js.map +1 -1
- package/dist/krubble-app.umd.min.js +1 -1
- package/dist/krubble-app.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/krubble-app.umd.js
CHANGED
|
@@ -5592,6 +5592,7 @@
|
|
|
5592
5592
|
*
|
|
5593
5593
|
* @fires message-submit - When the user sends a message. Cancelable. Detail: `{ message: string }`
|
|
5594
5594
|
* @fires stream-event - Dispatched for every SSE message received. Detail contains the parsed event data.
|
|
5595
|
+
* @fires conversation-created - When a turn with no target creates a new conversation and the chatbot pins it. Detail: `{ conversation }` (the full conversation object).
|
|
5595
5596
|
*/
|
|
5596
5597
|
exports.Chatbot = class KRChatbot extends i$3 {
|
|
5597
5598
|
constructor() {
|
|
@@ -5864,29 +5865,17 @@
|
|
|
5864
5865
|
super.connectedCallback();
|
|
5865
5866
|
// Default to loading a conversation's messages when the consumer hasn't
|
|
5866
5867
|
// provided their own `load`. With `conversationId` set we rebuild that
|
|
5867
|
-
// conversation; with none set
|
|
5868
|
-
//
|
|
5869
|
-
//
|
|
5870
|
-
// already match KRChatbotMessage ({ type, content }); we only parse each row's
|
|
5868
|
+
// conversation; with none set the user wants a NEW conversation, so we start
|
|
5869
|
+
// blank (no resume — the first message creates one via `send`). Rows already
|
|
5870
|
+
// match KRChatbotMessage ({ type, content }); we only parse each row's
|
|
5871
5871
|
// `conversationFileIDs` (a JSON array string of ids) into `conversationFiles`.
|
|
5872
5872
|
if (!this.load) {
|
|
5873
5873
|
this.load = () => {
|
|
5874
|
-
let resolve = Promise.resolve();
|
|
5875
5874
|
if (this.conversationId == null) {
|
|
5876
|
-
|
|
5877
|
-
.then((r) => r.json())
|
|
5878
|
-
.then((res) => {
|
|
5879
|
-
this.conversationId = res?.data?.conversationID ?? null;
|
|
5880
|
-
})
|
|
5881
|
-
.catch(() => { });
|
|
5875
|
+
return Promise.resolve([]);
|
|
5882
5876
|
}
|
|
5883
|
-
return
|
|
5884
|
-
.then(() =>
|
|
5885
|
-
if (this.conversationId == null) {
|
|
5886
|
-
return { data: [] };
|
|
5887
|
-
}
|
|
5888
|
-
return krubbleHttp.Http.fetch({ url: `/api/system/conversation/${this.conversationId}/messages` }).then((r) => r.json());
|
|
5889
|
-
})
|
|
5877
|
+
return krubbleHttp.Http.fetch({ url: `/api/system/conversation/${this.conversationId}/messages` })
|
|
5878
|
+
.then((r) => r.json())
|
|
5890
5879
|
.then((res) => Promise.all((res?.data || []).map((msg) => {
|
|
5891
5880
|
// Resolve this message's `conversationFileIDs` (a JSON array string of
|
|
5892
5881
|
// ids) into full file objects — each fetch response IS the
|
|
@@ -6859,9 +6848,19 @@
|
|
|
6859
6848
|
krubbleHttp.Http.fetch({ url: '/api/system/conversation/last' })
|
|
6860
6849
|
.then((r) => r.json())
|
|
6861
6850
|
.then((res) => {
|
|
6862
|
-
const
|
|
6851
|
+
const conversation = res?.data;
|
|
6852
|
+
const id = conversation?.conversationID;
|
|
6863
6853
|
if (typeof id === 'number') {
|
|
6864
6854
|
this.conversationId = id;
|
|
6855
|
+
// Announce the newly-created conversation so consumers can react
|
|
6856
|
+
// (e.g. update the route from /chat/new to /chat/{id}). The full
|
|
6857
|
+
// conversation object is passed, not just the id, so consumers
|
|
6858
|
+
// have the title/timestamps too.
|
|
6859
|
+
this.dispatchEvent(new CustomEvent('conversation-created', {
|
|
6860
|
+
detail: { conversation },
|
|
6861
|
+
bubbles: true,
|
|
6862
|
+
composed: true,
|
|
6863
|
+
}));
|
|
6865
6864
|
}
|
|
6866
6865
|
})
|
|
6867
6866
|
.catch(() => { });
|