@kodaris/krubble-app-components 1.0.86 → 1.0.87

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.
@@ -5862,16 +5862,32 @@
5862
5862
  // --- Lifecycle ---
5863
5863
  connectedCallback() {
5864
5864
  super.connectedCallback();
5865
- // Default to loading existing messages from the Kodaris Bedrock conversation
5866
- // when the consumer hasn't provided their own `load`. The endpoint returns
5867
- // messages already in KRChatbotMessage shape ({ type, content, images }), so
5868
- // they pass straight through.
5865
+ // Default to loading a specific conversation's messages when the consumer
5866
+ // hasn't provided their own `load`. With `conversationId` set we rebuild that
5867
+ // conversation from `/conversation/{id}/messages`; with none set there's
5868
+ // nothing to resume, so start empty. Rows already match KRChatbotMessage
5869
+ // ({ type, content }); we only parse each row's `conversationFileIDs` (a JSON
5870
+ // array string of ids) into the `conversationFiles` the render iterates.
5869
5871
  if (!this.load) {
5870
- this.load = () => krubbleHttp.Http.fetch({
5871
- url: '/api/system/integration/aws/bedrock/getConversationMessages',
5872
- })
5873
- .then((r) => r.json())
5874
- .then((res) => res.data || []);
5872
+ this.load = () => {
5873
+ if (this.conversationId == null) {
5874
+ return Promise.resolve([]);
5875
+ }
5876
+ return krubbleHttp.Http.fetch({
5877
+ url: `/api/system/conversation/${this.conversationId}/messages`,
5878
+ })
5879
+ .then((r) => r.json())
5880
+ .then((res) => (res?.data || []).map((msg) => {
5881
+ try {
5882
+ const ids = JSON.parse(msg.conversationFileIDs || '[]');
5883
+ if (ids.length) {
5884
+ msg.conversationFiles = ids.map((id) => ({ conversationFileID: id }));
5885
+ }
5886
+ }
5887
+ catch { /* no/invalid attachments — leave empty */ }
5888
+ return msg;
5889
+ }));
5890
+ };
5875
5891
  }
5876
5892
  this.load().then((messages) => {
5877
5893
  if (messages && messages.length) {