@widgetic/chat 0.1.32 → 0.1.33

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.
@@ -635,7 +635,12 @@
635
635
  });
636
636
 
637
637
  // chatLog('[Chat] Sending message:', content.substring(0, 60));
638
- const submittedContent = content;
638
+ const noteLines = (selectedElements ?? [])
639
+ .map((element) => element.note?.trim())
640
+ .filter((note): note is string => !!note);
641
+ const submittedContent = content.trim()
642
+ ? content
643
+ : noteLines.join('\n');
639
644
  const submittedAttachments = normalizedAttachments;
640
645
  const submittedSelectedElements =
641
646
  selectedElements && selectedElements.length > 0 ? [...selectedElements] : undefined;
@@ -1977,7 +1982,12 @@
1977
1982
  <span class="rounded bg-[#7BA668]/15 px-1 py-0.5 font-mono text-[11px] font-medium text-[#3C632C]">
1978
1983
  &lt;{item.tagName}{item.idAttr ? `#${item.idAttr}` : ''}&gt;
1979
1984
  </span>
1980
- {#if item.textSnippet}
1985
+ {#if item.note?.trim()}
1986
+ <span class="text-gray-400">·</span>
1987
+ <span class="max-w-[220px] truncate text-[11px] text-[#3C632C]" title={item.note}>
1988
+ {item.note.trim()}
1989
+ </span>
1990
+ {:else if item.textSnippet}
1981
1991
  <span class="text-gray-400">·</span>
1982
1992
  <span class="max-w-[180px] truncate text-[11px] text-gray-600">
1983
1993
  {item.textSnippet}
@@ -2081,6 +2091,7 @@
2081
2091
  onFilesDropped={(files) => {
2082
2092
  void addFilesAsAttachments(files);
2083
2093
  }}
2094
+ canSendWithoutText={(selectedElements ?? []).some((element) => !!element.note?.trim())}
2084
2095
  />
2085
2096
  </div>
2086
2097
 
@@ -29,6 +29,8 @@
29
29
  onAttachmentsChange: (attachments: AttachmentInput[]) => void;
30
30
  /** OS file drag-and-drop onto the input area (not attachment reorder). */
31
31
  onFilesDropped?: (files: File[]) => void;
32
+ /** A selected part already carries a note, so Send works with an empty box. */
33
+ canSendWithoutText?: boolean;
32
34
  /** What the empty box says. Left out, it says the chat's own words (`chat.input.placeholder`). */
33
35
  placeholder?: string;
34
36
  class?: string;
@@ -48,6 +50,7 @@
48
50
  onInputChange,
49
51
  onAttachmentsChange,
50
52
  onFilesDropped,
53
+ canSendWithoutText = false,
51
54
  placeholder,
52
55
  class: className = '',
53
56
  style = '',
@@ -107,8 +110,12 @@
107
110
  // chatLog('ChatInput destroyed for value:', value);
108
111
  });
109
112
 
113
+ function hasSomethingToSend(): boolean {
114
+ return value.trim().length > 0 || attachments.length > 0 || canSendWithoutText;
115
+ }
116
+
110
117
  function handleSubmit() {
111
- if (!value.trim() && attachments.length === 0) return;
118
+ if (!hasSomethingToSend()) return;
112
119
  if (isSending) return;
113
120
 
114
121
  onSend(value.trim(), attachments.length > 0 ? attachments : undefined);
@@ -339,8 +346,8 @@
339
346
  class:hover:bg-blue-700={!isGenerating}
340
347
  class:bg-red-600={isGenerating}
341
348
  class:hover:bg-red-700={isGenerating}
342
- class:bg-gray-300={!isGenerating && ((!value.trim() && attachments.length === 0) || isSending)}
343
- class:cursor-not-allowed={!isGenerating && ((!value.trim() && attachments.length === 0) || isSending)}
349
+ class:bg-gray-300={!isGenerating && (!hasSomethingToSend() || isSending)}
350
+ class:cursor-not-allowed={!isGenerating && (!hasSomethingToSend() || isSending)}
344
351
  onclick={() => {
345
352
  if (isGenerating) {
346
353
  onStop?.();
@@ -348,7 +355,7 @@
348
355
  }
349
356
  handleSubmit();
350
357
  }}
351
- disabled={!isGenerating && ((!value.trim() && attachments.length === 0) || isSending)}
358
+ disabled={!isGenerating && (!hasSomethingToSend() || isSending)}
352
359
  aria-label={sendLabel}
353
360
  title={sendLabel}
354
361
  >
@@ -17,6 +17,8 @@ interface Props {
17
17
  onAttachmentsChange: (attachments: AttachmentInput[]) => void;
18
18
  /** OS file drag-and-drop onto the input area (not attachment reorder). */
19
19
  onFilesDropped?: (files: File[]) => void;
20
+ /** A selected part already carries a note, so Send works with an empty box. */
21
+ canSendWithoutText?: boolean;
20
22
  /** What the empty box says. Left out, it says the chat's own words (`chat.input.placeholder`). */
21
23
  placeholder?: string;
22
24
  class?: string;
@@ -1544,6 +1544,7 @@
1544
1544
  {/if}
1545
1545
  {#if showCommitMetaOnUserTurn(turn)}
1546
1546
  {@const commitTitle = getTurnCommitTitle(turn)}
1547
+ {@const versionLabel = getTurnVersionLabel(turn)}
1547
1548
  {#if showCommitMeta && commitTitle}
1548
1549
  <div class="wc-user-commit-title-row flex w-full min-w-0 mt-1">
1549
1550
  <span class="wc-user-commit-title text-xs text-gray-600" title={commitTitle}>
@@ -1553,9 +1554,10 @@
1553
1554
  {/if}
1554
1555
  <div class="wc-user-commit-meta-ct flex w-full items-center justify-between gap-2 mt-1">
1555
1556
  <div class="wc-user-commit-meta-left flex items-center gap-2 min-w-0">
1556
- {#if getTurnVersionLabel(turn)}
1557
+ <!-- Version 1 is the sketch turn. The words read as a second message, so they stay off. Restore stays. -->
1558
+ {#if versionLabel && versionNumberFromLabel(versionLabel) !== 1}
1557
1559
  <span class="wc-user-version-label text-xs text-gray-500">
1558
- {versionLabelText(getTurnVersionLabel(turn), $t)}
1560
+ {versionLabelText(versionLabel, $t)}
1559
1561
  </span>
1560
1562
  {/if}
1561
1563
  {#if showCommitMeta && getTurnCommitShort(turn)}
@@ -1565,7 +1567,7 @@
1565
1567
  {/if}
1566
1568
  </div>
1567
1569
  {#if !turn.user?.id?.startsWith('version-fork-') && !isLoading && ((commitReply && (canRestoreToMessage(commitReply) || isHeadCommitReply(commitReply))) || canRestoreFailedLastTurn(turn))}
1568
- {@const restoreIsCurrentHead = !!(commitReply && isHeadCommitReply(commitReply) && versionNumberFromLabel(getTurnVersionLabel(turn)) !== 1)}
1570
+ {@const restoreIsCurrentHead = !!(commitReply && isHeadCommitReply(commitReply) && versionNumberFromLabel(versionLabel) !== 1)}
1569
1571
  <button
1570
1572
  class="restore-checkpoint-btn shrink-0"
1571
1573
  disabled={restoreIsCurrentHead}
@@ -28,6 +28,8 @@ export interface SelectedElementChatReference {
28
28
  height: number;
29
29
  };
30
30
  label: string;
31
+ /** A note typed on the preview, sent with this part. */
32
+ note?: string;
31
33
  }
32
34
  /**
33
35
  * Input for creating attachments
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/chat",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",