@kodaris/krubble-app-components 1.0.103 → 1.0.105

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.
@@ -5533,15 +5533,23 @@
5533
5533
  };
5534
5534
  /** Image extensions the chatbot renders as thumbnails (used when MIME is absent). */
5535
5535
  const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
5536
+ /**
5537
+ * Video extensions the picker accepts. The AI cannot watch video — these upload
5538
+ * and store for playback and tool use only, and the backend tells the model so.
5539
+ * Matches what kr-file-preview can play back.
5540
+ */
5541
+ const VIDEO_EXTENSIONS = ['mp4', 'webm', 'ogg', 'mov'];
5536
5542
  /**
5537
5543
  * File extensions the picker accepts. Mirrors what the backend can read: the
5538
5544
  * document/spreadsheet family Bedrock ingests, the plain-text family read as
5539
- * fallback, and the image formats. This is a UX convenience — the backend
5545
+ * fallback, and the image formats. Videos are accepted for upload/storage even
5546
+ * though the model can't read them. This is a UX convenience — the backend
5540
5547
  * accepts anything and just tells the model when a type can't be read.
5541
5548
  */
5542
5549
  const ACCEPTED_FILE_EXTENSIONS = [
5543
5550
  'pdf', 'doc', 'docx', 'xls', 'xlsx', 'csv', 'html', 'md', 'txt', 'json', 'xml',
5544
5551
  ...IMAGE_EXTENSIONS,
5552
+ ...VIDEO_EXTENSIONS,
5545
5553
  ];
5546
5554
  /**
5547
5555
  * AI chatbot component with SSE streaming.
@@ -6051,6 +6059,10 @@
6051
6059
  stop() {
6052
6060
  this._handleStop();
6053
6061
  }
6062
+ /** Whether a turn is in flight — true from send until the stream ends. */
6063
+ isStreaming() {
6064
+ return this._isStreaming;
6065
+ }
6054
6066
  /** Open the chat panel. */
6055
6067
  open() {
6056
6068
  if (!this.opened) {
@@ -6851,8 +6863,9 @@
6851
6863
  return;
6852
6864
  }
6853
6865
  files.forEach((file) => {
6854
- // Only images get a local preview thumbnail; documents render an icon.
6855
- // Prefer the File's MIME, falling back to the extension when it's absent.
6866
+ // Only images get a local preview thumbnail; documents (and videos, which are
6867
+ // tiles too) render an icon. Prefer the File's MIME, falling back to the
6868
+ // extension when it's absent.
6856
6869
  let previewUrl;
6857
6870
  if (file.type.startsWith('image/') || IMAGE_EXTENSIONS.includes(this._getFileExtension(file.name))) {
6858
6871
  previewUrl = URL.createObjectURL(file);
@@ -6883,22 +6896,25 @@
6883
6896
  });
6884
6897
  this._pendingConversationFiles = [];
6885
6898
  }
6886
- /** Open the shared full-screen previewer for a message image. */
6887
- _handleImageOpen(img) {
6899
+ /** Open the shared full-screen previewer for a message attachment (image or video). */
6900
+ _handleFileOpen(file) {
6888
6901
  // Use the local preview if the upload hasn't finished yet; otherwise the
6889
6902
  // backend view URL (prefixed with the base URL — a raw fetch of a relative
6890
6903
  // path would hit the page origin, e.g. the dev server, not the backend).
6891
- const src = img.previewUrl
6892
- || `${krubbleHttp.Http.getBaseUrl()}/api/system/conversationFile/${img.conversationFileID}/view`;
6904
+ // The previewer picks image vs video playback off the name's extension, so
6905
+ // niceName has to carry it — hence the generic fallback keeps no extension
6906
+ // only when there's no name at all.
6907
+ const src = file.previewUrl
6908
+ || `${krubbleHttp.Http.getBaseUrl()}/api/system/conversationFile/${file.conversationFileID}/view`;
6893
6909
  const preview = krubbleComponents.FilePreview.open({
6894
6910
  src,
6895
- name: img.niceName || 'image',
6911
+ name: file.niceName || 'file',
6896
6912
  });
6897
6913
  // The previewer's download button only fires a `download` event — the
6898
6914
  // consumer performs the actual download. Hit the view endpoint with
6899
6915
  // `?download=true` (Content-Disposition: attachment) in a new tab.
6900
6916
  preview.addEventListener('download', () => {
6901
- window.open(`${krubbleHttp.Http.getBaseUrl()}/api/system/conversationFile/${img.conversationFileID}/view?download=true`, '_blank');
6917
+ window.open(`${krubbleHttp.Http.getBaseUrl()}/api/system/conversationFile/${file.conversationFileID}/view?download=true`, '_blank');
6902
6918
  });
6903
6919
  }
6904
6920
  _handleSubmit() {
@@ -7833,15 +7849,18 @@
7833
7849
  if (file.mimeType) {
7834
7850
  isImage = file.mimeType.startsWith('image/');
7835
7851
  }
7836
- // Images open in the previewer; documents just show a tile
7837
- // (the previewer is image-only).
7852
+ // An image shows its thumbnail; everything else shows a
7853
+ // file-type tile. Both open the previewer on click — it renders
7854
+ // images, video, PDFs, and text inline, and shows a download
7855
+ // tile for the rest (Office formats), so a click always does
7856
+ // something useful.
7838
7857
  if (isImage) {
7839
7858
  return b `
7840
7859
  <button
7841
7860
  class="attachment"
7842
7861
  type="button"
7843
7862
  title=${file.niceName || 'View image'}
7844
- @click=${() => this._handleImageOpen(file)}
7863
+ @click=${() => this._handleFileOpen(file)}
7845
7864
  >
7846
7865
  <img
7847
7866
  src=${file.previewUrl || `${krubbleHttp.Http.getBaseUrl()}/api/system/conversationFile/${file.conversationFileID}/view`}
@@ -7851,13 +7870,15 @@
7851
7870
  `;
7852
7871
  }
7853
7872
  return b `
7854
- <div
7855
- class="attachment attachment--doc"
7873
+ <button
7874
+ class="attachment attachment--doc attachment--openable"
7875
+ type="button"
7856
7876
  title=${fileName}
7877
+ @click=${() => this._handleFileOpen(file)}
7857
7878
  >
7858
7879
  <span class="attachment__type">${this._getFileExtension(fileName) || 'File'}</span>
7859
7880
  <span class="attachment__name">${fileName}</span>
7860
- </div>
7881
+ </button>
7861
7882
  `;
7862
7883
  })}
7863
7884
  </div>
@@ -9129,15 +9150,22 @@
9129
9150
  display: block;
9130
9151
  }
9131
9152
 
9132
- /* Non-image attachment in a sent message — file-type label above the filename
9133
- (the previewer is image-only, so this isn't clickable). */
9153
+ /* Non-image attachment in a sent message — file-type label above the filename. */
9134
9154
  .attachment--doc {
9135
9155
  display: flex;
9136
9156
  flex-direction: column;
9137
9157
  padding: 16px 14px;
9138
9158
  box-sizing: border-box;
9139
9159
  text-align: left;
9140
- cursor: default;
9160
+ }
9161
+
9162
+ /* Opens the previewer on click — same affordance as the composer's doc chip. */
9163
+ .attachment--openable {
9164
+ cursor: pointer;
9165
+ }
9166
+
9167
+ .attachment--openable:hover {
9168
+ background: #dfdddd;
9141
9169
  }
9142
9170
 
9143
9171
  .attachment__type {