@kodaris/krubble-app-components 1.0.89 → 1.0.91

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.
@@ -685,6 +685,19 @@
685
685
  *
686
686
  * @param itemId - The unique identifier of the nav group to toggle
687
687
  */
688
+ /**
689
+ * Expand a nav group by id. Public so consumers can keep a group open after
690
+ * adding it dynamically — the scaffold only auto-expands groups once at startup,
691
+ * so a group added later (e.g. an async "Recent" list) would otherwise stay
692
+ * collapsed. Idempotent; a no-op if the group is already expanded.
693
+ */
694
+ expandNavGroup(groupId) {
695
+ if (this.navItemsExpanded.has(groupId)) {
696
+ return;
697
+ }
698
+ this.navItemsExpanded.add(groupId);
699
+ this.requestUpdate();
700
+ }
688
701
  toggleNavItem(itemId) {
689
702
  const navItem = this.shadowRoot?.querySelector(`.nav-item[data-id="${itemId}"]`);
690
703
  const groupEl = navItem?.nextElementSibling;
@@ -5592,6 +5605,7 @@
5592
5605
  *
5593
5606
  * @fires message-submit - When the user sends a message. Cancelable. Detail: `{ message: string }`
5594
5607
  * @fires stream-event - Dispatched for every SSE message received. Detail contains the parsed event data.
5608
+ * @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
5609
  */
5596
5610
  exports.Chatbot = class KRChatbot extends i$3 {
5597
5611
  constructor() {
@@ -6814,16 +6828,31 @@
6814
6828
  body: form,
6815
6829
  })
6816
6830
  .then((r) => r.json())
6817
- .then((res) => res?.data?.conversationFileID);
6818
- })).then((ids) => ids.filter((id) => typeof id === 'number'));
6831
+ // Keep the whole file DTO the upload returns (id + niceName +
6832
+ // mimeType + …), not just the id — it's attached to the sent message
6833
+ // below so the attachment shows immediately.
6834
+ .then((res) => res.data);
6835
+ }));
6819
6836
  }
6820
- return uploaded.then((fileIds) => {
6837
+ return uploaded.then((files) => {
6838
+ // Attach the uploaded files to the just-sent user message so its
6839
+ // thumbnails show right away (no reload). The last user message is the
6840
+ // one _send appended before the trailing empty assistant message.
6841
+ if (files.length) {
6842
+ for (let i = this.messages.length - 1; i >= 0; i--) {
6843
+ if (this.messages[i].type === 'user') {
6844
+ this.messages[i].conversationFiles = files;
6845
+ this.requestUpdate();
6846
+ break;
6847
+ }
6848
+ }
6849
+ }
6821
6850
  // Conversation targeting: continue `conversationId` when set, else
6822
6851
  // start a fresh conversation (createNew) for this turn. The pin below
6823
6852
  // means createNew only fires on the very first untargeted turn.
6824
6853
  const body = {
6825
6854
  userText: params.message,
6826
- fileIds,
6855
+ fileIds: files.map((f) => f.conversationFileID),
6827
6856
  };
6828
6857
  if (this.conversationId != null) {
6829
6858
  body.conversationID = this.conversationId;
@@ -6847,9 +6876,19 @@
6847
6876
  krubbleHttp.Http.fetch({ url: '/api/system/conversation/last' })
6848
6877
  .then((r) => r.json())
6849
6878
  .then((res) => {
6850
- const id = res?.data?.conversationID;
6879
+ const conversation = res?.data;
6880
+ const id = conversation?.conversationID;
6851
6881
  if (typeof id === 'number') {
6852
6882
  this.conversationId = id;
6883
+ // Announce the newly-created conversation so consumers can react
6884
+ // (e.g. update the route from /chat/new to /chat/{id}). The full
6885
+ // conversation object is passed, not just the id, so consumers
6886
+ // have the title/timestamps too.
6887
+ this.dispatchEvent(new CustomEvent('conversation-created', {
6888
+ detail: { conversation },
6889
+ bubbles: true,
6890
+ composed: true,
6891
+ }));
6853
6892
  }
6854
6893
  })
6855
6894
  .catch(() => { });