@widgetic/workflows 0.2.17 → 0.2.18

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.
@@ -2,8 +2,9 @@
2
2
  Collapsible workflows assistant: plans journeys, asks questions, and approves widget creation.
3
3
  -->
4
4
  <script lang="ts">
5
- import { onMount, tick } from 'svelte';
6
- import { Button, Chip } from '@widgetic/design-system/components';
5
+ import { onMount, tick, untrack } from 'svelte';
6
+ import { prefersReducedMotion } from 'svelte/motion';
7
+ import { Button, Chip, MessageRatingActions, ScrollToBottom } from '@widgetic/design-system/components';
7
8
  import { useWorkflowsApi } from '../../api/apiContext.js';
8
9
  import type { CompositionOption, OpenMcpOption } from '../../api/types.js';
9
10
  // The grey words after what the person has typed, which Tab takes: the engine is the design system's, one box's part is below
@@ -30,9 +31,37 @@
30
31
  type ReferenceMenuStatus
31
32
  } from '@widgetic/design-system/prompt-references';
32
33
  // The assistant's face: the chat's turn (the avatar with its content beside it) and its rules for the avatar's look, with the
33
- // brand's mascot as the drawing. The chat itself is not used: this panel keeps its own transcript, cards and composer.
34
- import { AgentTurn, liveAgentLook, settledAgentLook } from '@widgetic/chat';
35
- import type { AgentAvatarRenderProps, AgentLook } from '@widgetic/chat';
34
+ // brand's mascot as the drawing. The chat itself is not used: this panel keeps its own transcript, cards and composer. What the
35
+ // chat draws around the words (the assistant's markdown with the widgets and compositions it names as chips, a long message of
36
+ // the person folded to its first lines, the notice that the workspace is out of AI credits, the card with the Support ID) and what
37
+ // it does for a list that grows (follow the end, the arrow that glides back) is the chat's too, so every chat of the product behaves alike.
38
+ import {
39
+ AgentTurn,
40
+ ChatMarkdown,
41
+ CreditsNotice,
42
+ FoldedBubbleText,
43
+ SupportIdDialog,
44
+ copyTextToClipboard,
45
+ createCreditsNoticeKeeper,
46
+ createEndFollower,
47
+ creditsResetTimeMs,
48
+ creditsShortageOfAnswer,
49
+ liveAgentLook,
50
+ provideChatLanguage,
51
+ resolveSupportId,
52
+ settledAgentLook,
53
+ textToCopy,
54
+ watchCreditsNotice,
55
+ watchEndGrowth,
56
+ } from '@widgetic/chat';
57
+ import type {
58
+ AgentAvatarRenderProps,
59
+ AgentLook,
60
+ ChatCreditsNotice,
61
+ CreditsAreBackContext,
62
+ CreditsShortage,
63
+ EndFollower,
64
+ } from '@widgetic/chat';
36
65
  import { Mascot, warmUpMascot } from '@widgetic/brand/mascot';
37
66
  import { useEditorState } from '../../editor/editorState.svelte.js';
38
67
  import {
@@ -138,6 +167,12 @@
138
167
  const editor = useEditorState();
139
168
  const api = useWorkflowsApi();
140
169
  const { t, locale } = useWorkflowsLanguage();
170
+ // The parts of the chat below (the markdown, the notice about credits, the Support ID card) speak the language of this screen: the
171
+ // words of the chat's own catalog in English, and the dates and the direction in the locale the page chose. The page can set it again.
172
+ const chatLanguage = provideChatLanguage(untrack(() => ({ locale: $locale })));
173
+ $effect(() => {
174
+ chatLanguage.update({ locale: $locale });
175
+ });
141
176
  const journal = createAssistantTranscriptJournal();
142
177
 
143
178
  let collapsed = $state(false);
@@ -505,11 +540,170 @@
505
540
  /** What one event of a stream says about how the run is going, for the face. The screen itself is the reducer's business. */
506
541
  function noteRunEvent(action: AssistantUiAction): void {
507
542
  if (action.type === 'assistant_text' && action.failed) hasRunFailed = true;
543
+ // A refusal for credits also puts the notice above the box (the words of the failure are in the transcript already)
544
+ if (action.type === 'assistant_text' && action.creditsShortage) showCreditsNotice(action.creditsShortage);
508
545
  if (action.type === 'plan_step' && action.status === 'failed') hasRunFailed = true;
509
546
  if (action.type === 'question_card' || action.type === 'plan_card') hasRunBroughtCard = true;
510
547
  if (action.type === 'workflow_ready') hasRunSucceeded = true;
511
548
  }
512
549
 
550
+ // ─── The workspace is out of AI credits ───────────────────────────────────────────────────────────────────────────
551
+ // The approval of a plan is what costs credits, and the gateway refuses it with the workspace and the day the credits reset. The
552
+ // notice above the box says so and has "Manage credits"; it stays until the credits are back or reset on their own, and until then
553
+ // the box and the buttons that would ask the gateway for anything are shut. It is the chat package's notice and keeper, the same
554
+ // behaviour as every chat of the product.
555
+
556
+ /** The notice as the keeper holds it: none, or what to say above the box. */
557
+ let creditsNotice = $state<ChatCreditsNotice | null>(null);
558
+
559
+ /**
560
+ * The one holder of the notice. A reload brings it back only when the host can say that the credits are back (`credits.scope` and
561
+ * `credits.creditsAreBack`): a notice nobody could lift would shut the box for good. The panel belongs to one workspace (the root
562
+ * draws it again for another), so the scope is read once.
563
+ */
564
+ const creditsKeeper = untrack(() =>
565
+ createCreditsNoticeKeeper({
566
+ scope: config.credits?.scope ?? 'workflows-assistant',
567
+ storage: config.credits?.scope && config.credits.creditsAreBack ? undefined : null,
568
+ creditsAreBack: readCreditsAreBack,
569
+ onChange: (next) => {
570
+ creditsNotice = next;
571
+ },
572
+ }),
573
+ );
574
+
575
+ /** What the notice says, with the workspace's name from the host when the refusal did not give it (the list of workspaces can arrive late). */
576
+ const displayedCreditsNotice = $derived.by((): ChatCreditsNotice | null => {
577
+ if (creditsNotice === null) return null;
578
+ if (creditsNotice.workspaceName) return creditsNotice;
579
+ return { ...creditsNotice, workspaceName: config.credits?.workspaceName?.() ?? null };
580
+ });
581
+ /** The workspace is out of credits: the box, Send, the welcome chips, the answers and the plan's buttons are off. */
582
+ const isOutOfCredits = $derived(displayedCreditsNotice !== null);
583
+ // What "Manage credits" does is the host's: no handler, no button
584
+ const manageCredits = $derived(config.credits?.onManage ? () => config.credits?.onManage?.() : undefined);
585
+
586
+ /** Looks at the balance for the keeper. A host that cannot is told so by `null`; one with no such look lifts the notice when the person comes back. */
587
+ async function readCreditsAreBack(context: CreditsAreBackContext): Promise<boolean | null> {
588
+ const look = config.credits?.creditsAreBack;
589
+ // Without a look the notice cannot be checked: it goes when the person comes back to the page (or on the reset day), and the next
590
+ // refusal puts it up again
591
+ if (!look) return true;
592
+ try {
593
+ return await look(context);
594
+ } catch (error) {
595
+ console.debug('[workflows-assistant] the balance could not be read, so the notice stays', error);
596
+ return null;
597
+ }
598
+ }
599
+
600
+ /** A refusal for credits: the notice goes up (the gateway names the workspace by its id; the host knows what it is called). */
601
+ function showCreditsNotice(shortage: CreditsShortage): void {
602
+ const scope = config.credits?.scope;
603
+ const isOfAnotherWorkspace = !!shortage.workspaceId && !!scope && shortage.workspaceId !== scope;
604
+ creditsKeeper.show(
605
+ {
606
+ workspaceName: isOfAnotherWorkspace ? null : (config.credits?.workspaceName?.() ?? null),
607
+ resetsAt: shortage.resetsAt ?? null,
608
+ },
609
+ { required: shortage.required ?? null },
610
+ );
611
+ }
612
+
613
+ /**
614
+ * The words for an answer with an error status instead of a stream. A 402 that says the credits are used up puts the notice up and
615
+ * is told in the words of that; any other status, a 402 for another reason included, is told as it always was.
616
+ */
617
+ async function failureTextOfAnswer(response: Response): Promise<string> {
618
+ if (response.status === 402) {
619
+ try {
620
+ const shortage = creditsShortageOfAnswer(response.status, await response.json());
621
+ if (shortage) {
622
+ showCreditsNotice(shortage);
623
+ return $t('workflows.assistant.errorOutOfCredits');
624
+ }
625
+ } catch (error) {
626
+ console.debug('[workflows-assistant] the 402 could not be read as a shortage of credits', error);
627
+ }
628
+ }
629
+ return assistantFailureTextForStatus(response.status);
630
+ }
631
+
632
+ // A notice that is up is watched: the reset day lifts it without looking, and the person coming back to the tab (from where they
633
+ // manage their credits) is a moment to look at the balance
634
+ const creditsResetsAt = $derived(creditsNotice?.resetsAt ?? null);
635
+ $effect(() => {
636
+ if (creditsNotice === null) return;
637
+ return watchCreditsNotice({
638
+ resetsAt: creditsResetTimeMs(creditsResetsAt),
639
+ onReset: () => void creditsKeeper.recheck(),
640
+ onReturn: () => void creditsKeeper.recheck(),
641
+ });
642
+ });
643
+
644
+ onMount(() => {
645
+ // A person who reloaded the page is still out of credits: the notice is back before the box can be used for one more refused message
646
+ creditsKeeper.restore();
647
+ });
648
+
649
+ // ─── The Support ID ────────────────────────────────────────────────────────────────────────────────────────────────
650
+ // "Copy debug details": the id the gateway gave the latest request of this conversation (it echoes `X-Correlation-Id`) is what a
651
+ // person hands to support, so the team finds that exact request. The panel only reads the header: it never sends one, because a
652
+ // gateway older than this change would refuse the preflight of a custom header and the assistant would not work at all.
653
+ let latestRequestId = $state<string | null>(null);
654
+ let isSupportDialogOpen = $state(false);
655
+ /** The id for the card, or null while no request has been answered (then there is no "i": a card with nothing to copy would only be in the way). */
656
+ const supportId = $derived(resolveSupportId(latestRequestId, null));
657
+
658
+ /** Keeps the id the gateway echoed for the request this answer belongs to. A gateway that does not expose it leaves the last one. */
659
+ function rememberRequestId(response: Response): void {
660
+ try {
661
+ const echoed = response.headers.get('X-Correlation-Id')?.trim();
662
+ if (echoed) latestRequestId = echoed;
663
+ } catch (error) {
664
+ console.debug('[workflows-assistant] the id of the request could not be read', error);
665
+ }
666
+ }
667
+
668
+ // ─── The end of the list ───────────────────────────────────────────────────────────────────────────────────────────
669
+ // The list follows its end while the person is there, lets go as soon as they scroll up to read, and shows the arrow that glides
670
+ // them back down (it slides and fades in and out). The chat's own rules for this (`createEndFollower`), not a second copy.
671
+ let listElement = $state<HTMLElement | null>(null);
672
+ /** The person has scrolled up from the end: the arrow shows. */
673
+ let isAwayFromEnd = $state(false);
674
+ /** The follower of the list that is on the screen (it is made again when the list is drawn again, e.g. after the panel was folded). */
675
+ let endFollower: EndFollower | null = null;
676
+
677
+ $effect(() => {
678
+ const list = listElement;
679
+ if (!list) return;
680
+ const follower = createEndFollower({
681
+ list,
682
+ onAwayChange: (isAway) => {
683
+ isAwayFromEnd = isAway;
684
+ },
685
+ prefersReducedMotion: () => prefersReducedMotion.current,
686
+ });
687
+ endFollower = follower;
688
+ const stopWatchingGrowth = watchEndGrowth(follower, list);
689
+ // A conversation that was kept opens at its end
690
+ follower.jumpToEnd();
691
+ return () => {
692
+ stopWatchingGrowth();
693
+ follower.destroy();
694
+ endFollower = null;
695
+ isAwayFromEnd = false;
696
+ };
697
+ });
698
+
699
+ /** What the person copies from an assistant turn: its words, one paragraph after the other. */
700
+ function wordsOfTurn(messages: ReadonlyArray<{ text: string }>): string {
701
+ return textToCopy(
702
+ messages.map((message) => message.text),
703
+ null,
704
+ );
705
+ }
706
+
513
707
  async function ensureCompositionCatalog(): Promise<void> {
514
708
  if (compositionCatalog.length > 0) return;
515
709
  try {
@@ -642,6 +836,8 @@
642
836
  // The words a person wrote ("use #hero_banner as the header"): the room each badge takes in the box is not part of the message
643
837
  const messageText = normalizeForSend(text);
644
838
  if (!messageText.trim() || ui.isStreaming) return;
839
+ // A workspace that is out of AI credits sends nothing until they are back (the box and the buttons are off; this is for any other way in)
840
+ if (isOutOfCredits) return;
645
841
  const history = streamHistory();
646
842
  // The files this message carries, and which of them its words name: read from the box's own text, badges and words typed by hand alike
647
843
  const sentMediaIds = readyMediaIdsOfChips(attachments);
@@ -660,6 +856,8 @@
660
856
  ...(mcpRefs.length > 0 ? { mcpReferences: mcpRefs } : {}),
661
857
  });
662
858
  ui = reduceAssistantUiState(ui, { type: 'streaming', value: true });
859
+ // The person's own message: the list goes to its end and follows the answer from there
860
+ endFollower?.jumpToEnd();
663
861
  persistTranscript();
664
862
  const body = {
665
863
  message: messageText,
@@ -682,13 +880,16 @@
682
880
  headers: { 'Content-Type': 'application/json', ...(await authHeaders()) },
683
881
  body: JSON.stringify(body),
684
882
  });
883
+ rememberRequestId(response);
685
884
  if (!response.ok) {
686
885
  console.debug('[workflows-assistant] the stream answered with an error status', response.status);
687
886
  hasRunFailed = true;
887
+ // The words first: the screen is read after the wait, not before it
888
+ const failureText = await failureTextOfAnswer(response);
688
889
  ui = reduceAssistantUiState(ui, {
689
890
  type: 'assistant_text',
690
891
  id: crypto.randomUUID(),
691
- text: assistantFailureTextForStatus(response.status),
892
+ text: failureText,
692
893
  });
693
894
  } else {
694
895
  for await (const action of parseAssistantSseStream(response)) {
@@ -804,7 +1005,8 @@
804
1005
 
805
1006
  async function approvePlan(): Promise<void> {
806
1007
  const planCard = ui.planCard;
807
- if (!planCard || isApproving) return;
1008
+ // The approval is what costs credits: with none left it is not asked (the button is off; this is for any other way in)
1009
+ if (!planCard || isApproving || isOutOfCredits) return;
808
1010
  // A plan with live data is approved only with the person's yes (the gateway refuses it without): the button is off until then.
809
1011
  const hasLiveData = (planCard.bindings?.length ?? 0) > 0;
810
1012
  if (hasLiveData && !exposureAcknowledged) return;
@@ -826,13 +1028,16 @@
826
1028
  ...(hasLiveData ? { exposureAcknowledged: true } : {}),
827
1029
  }),
828
1030
  });
1031
+ rememberRequestId(response);
829
1032
  if (!response.ok) {
830
1033
  console.debug('[workflows-assistant] the approval answered with an error status', response.status);
831
1034
  hasRunFailed = true;
1035
+ // The words first: the screen is read after the wait, not before it
1036
+ const failureText = await failureTextOfAnswer(response);
832
1037
  ui = reduceAssistantUiState(ui, {
833
1038
  type: 'assistant_text',
834
1039
  id: crypto.randomUUID(),
835
- text: assistantFailureTextForStatus(response.status),
1040
+ text: failureText,
836
1041
  });
837
1042
  } else {
838
1043
  for await (const action of parseAssistantApproveStream(response)) {
@@ -885,6 +1090,11 @@
885
1090
  draft = '';
886
1091
  mentionOpen = false;
887
1092
  pickedTemplateProject = null;
1093
+ // The new conversation has no request yet, so there is nothing for support to look at (the notice about credits is the
1094
+ // workspace's, not the conversation's: it stays)
1095
+ latestRequestId = null;
1096
+ isSupportDialogOpen = false;
1097
+ endFollower?.jumpToEnd();
888
1098
  // The draft starts over: its numbers, its pictures and what it was pointing at
889
1099
  referenceGenericFloor = 0;
890
1100
  hoveredReferenceLabel = null;
@@ -939,7 +1149,7 @@
939
1149
  class="mt-2"
940
1150
  variant={dsButtonVariant('secondary')}
941
1151
  size="sm"
942
- disabled={!selectedOptionId}
1152
+ disabled={!selectedOptionId || isOutOfCredits}
943
1153
  onclick={() =>
944
1154
  selectedOptionId &&
945
1155
  void sendMessage($t('workflows.assistant.answerSent'), {
@@ -1026,7 +1236,7 @@
1026
1236
  <Button
1027
1237
  variant={dsButtonVariant('secondary')}
1028
1238
  size="sm"
1029
- disabled={isApproving || liveDataIsOn || needsExposureConsent}
1239
+ disabled={isApproving || liveDataIsOn || needsExposureConsent || isOutOfCredits}
1030
1240
  onclick={() => void approvePlan()}
1031
1241
  >
1032
1242
  {isLiveDataOnlyPlan ? $t('workflows.assistant.turnOnLiveData') : $t('workflows.assistant.createWorkflow')}
@@ -1035,7 +1245,12 @@
1035
1245
  {$t('workflows.assistant.notNow')}
1036
1246
  </Button>
1037
1247
  {#if hasFailedPlanStep}
1038
- <Button variant={dsButtonVariant('outline')} size="sm" onclick={() => void retryWithAssistant()}>
1248
+ <Button
1249
+ variant={dsButtonVariant('outline')}
1250
+ size="sm"
1251
+ disabled={isOutOfCredits}
1252
+ onclick={() => void retryWithAssistant()}
1253
+ >
1039
1254
  {$t('workflows.assistant.retry')}
1040
1255
  </Button>
1041
1256
  {/if}
@@ -1063,7 +1278,14 @@
1063
1278
  </div>
1064
1279
  </header>
1065
1280
  {#if !collapsed}
1066
- <div class="flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-3">
1281
+ <!-- The list keeps its end in view while the person is at the end, lets go when they scroll up to read, and the arrow at its
1282
+ bottom glides them back (`endFollower`: the chat's own rules for a list that grows). -->
1283
+ <div
1284
+ bind:this={listElement}
1285
+ class="flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-3"
1286
+ data-testid="workflow-assistant-list"
1287
+ onscroll={() => endFollower?.handleScroll()}
1288
+ >
1067
1289
  <p class="text-caption text-muted-foreground">
1068
1290
  {$t('workflows.assistant.welcome')}
1069
1291
  </p>
@@ -1072,6 +1294,7 @@
1072
1294
  <Button
1073
1295
  variant={dsButtonVariant('secondary')}
1074
1296
  size="sm"
1297
+ disabled={isOutOfCredits}
1075
1298
  onclick={() => void sendMessage($t(chip.send))}
1076
1299
  >
1077
1300
  {$t(chip.key)}
@@ -1082,8 +1305,10 @@
1082
1305
  {#each transcriptTurns as turn (turn.key)}
1083
1306
  {#if turn.kind === 'user'}
1084
1307
  <li class="flex flex-col gap-1.5">
1085
- <div class="rounded-lg bg-muted px-2 py-1 text-body">
1086
- <span dir="auto">{turn.message.text}</span>
1308
+ <!-- The person's words sit at the end of the row, as wide as they need up to most of the panel, so they stand
1309
+ beside the assistant's. A long message is folded to its first lines, with "Show more" under them. -->
1310
+ <div class="ms-auto flex w-fit max-w-[85%] flex-col rounded-lg bg-muted px-3 py-2 text-body text-foreground">
1311
+ <FoldedBubbleText>{turn.message.text}</FoldedBubbleText>
1087
1312
  </div>
1088
1313
  {#if turn.message.compositionReferences?.length}
1089
1314
  <!-- The compositions the person picked with @, as chips under their message (the design's "Mention sent" frame). -->
@@ -1122,9 +1347,15 @@
1122
1347
  renderAgentAvatar={isMascotEnabled ? assistantAvatar : undefined}
1123
1348
  >
1124
1349
  {#each turn.messages as message, messageIndex (message.id)}
1125
- <p class="text-body text-foreground {messageIndex === 0 ? 'flex min-h-7 items-center' : ''}">
1126
- <span dir="auto">{message.text}</span>
1127
- </p>
1350
+ <!-- The assistant writes markdown (lists, bold, links); a link to a widget or a composition is a chip in the line. -->
1351
+ <div class="text-body text-foreground {messageIndex === 0 ? 'flex min-h-7 items-center' : ''}">
1352
+ <ChatMarkdown
1353
+ class={messageIndex === 0 ? 'flex-1' : ''}
1354
+ source={message.text}
1355
+ resolveReference={config.references?.resolve}
1356
+ onOpenReference={config.references?.open}
1357
+ />
1358
+ </div>
1128
1359
  {/each}
1129
1360
  {#if turn.isNewest}
1130
1361
  {#if ui.isStreaming}
@@ -1133,14 +1364,51 @@
1133
1364
  </p>
1134
1365
  {/if}
1135
1366
  {@render liveAssistantContent()}
1367
+ {#if !ui.isStreaming}
1368
+ <!-- The row under the newest answer: copy it, and the "i" that opens the card with the Support ID. -->
1369
+ <MessageRatingActions
1370
+ class="mt-1"
1371
+ copyText={wordsOfTurn(turn.messages)}
1372
+ messages={{
1373
+ rateGroup: $t('workflows.assistant.messageActions'),
1374
+ copy: $t('workflows.assistant.copyMessage'),
1375
+ copied: $t('workflows.assistant.copiedMessage'),
1376
+ details: $t('workflows.assistant.copyDebugDetails'),
1377
+ }}
1378
+ onCopy={async () => {
1379
+ await copyTextToClipboard(wordsOfTurn(turn.messages));
1380
+ }}
1381
+ onDetails={supportId ? () => (isSupportDialogOpen = true) : undefined}
1382
+ />
1383
+ {/if}
1136
1384
  {/if}
1137
1385
  </AgentTurn>
1138
1386
  </li>
1139
1387
  {/if}
1140
1388
  {/each}
1141
1389
  </ul>
1390
+ <!-- The arrow to the newest message. Its row has no height: the arrow sits above the bottom edge of the list and slides and
1391
+ fades in when the person scrolls up and out when they are back at the end (see ScrollToBottom), so the list never grows or
1392
+ shrinks under their eyes as it comes and goes. (`-mt-3` takes back the gap that `gap-3` leaves above a last row.) -->
1393
+ <div
1394
+ class="pointer-events-none sticky bottom-2 z-10 -mt-3 h-0 shrink-0"
1395
+ data-testid="workflow-assistant-scroll-to-end"
1396
+ >
1397
+ <div class="absolute inset-x-0 bottom-1 flex justify-center">
1398
+ <ScrollToBottom
1399
+ visible={isAwayFromEnd}
1400
+ label={$t('workflows.assistant.scrollToLatest')}
1401
+ onScroll={() => endFollower?.glideToEnd()}
1402
+ />
1403
+ </div>
1404
+ </div>
1142
1405
  </div>
1143
1406
  <footer class="border-t border-border p-3">
1407
+ {#if displayedCreditsNotice}
1408
+ <!-- The workspace is out of AI credits: what it means, when they reset and "Manage credits" (the chat's notice). It stays
1409
+ until the credits are back or reset, and the box below is off meanwhile. -->
1410
+ <CreditsNotice class="mb-3" notice={displayedCreditsNotice} onManage={manageCredits} />
1411
+ {/if}
1144
1412
  <!-- The files attached: the design's chip (the "Attachment" frame). While a file goes up, the chip's own background fills
1145
1413
  with the share done; there is no separate bar. A file named with a `#` in the box (or hovered in its menu) has a ring. -->
1146
1414
  <div class="mb-2 flex flex-wrap gap-1.5" data-workflows-assistant-attachments>
@@ -1219,11 +1487,13 @@
1219
1487
  onselect={(entry) => void chooseMention(entry)}
1220
1488
  />
1221
1489
  {/if}
1222
- <!-- A message the page left in the composer can be long: where the browser allows, the box grows to show it (up to a limit). -->
1490
+ <!-- A message the page left in the composer can be long: where the browser allows, the box grows to show it (up to a limit).
1491
+ The box is shut for one reason only: the workspace is out of AI credits (a grey ground, as every box of the product is then). -->
1223
1492
  <textarea
1224
1493
  bind:this={composerElement}
1225
- class="max-h-48 min-h-16 w-full field-sizing-content rounded-lg border border-border bg-background p-2 text-body"
1494
+ class="max-h-48 min-h-16 w-full field-sizing-content rounded-lg border border-border bg-background p-2 text-body disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground"
1226
1495
  bind:value={draft}
1496
+ disabled={isOutOfCredits}
1227
1497
  placeholder={$t('workflows.assistant.composerPlaceholder')}
1228
1498
  aria-describedby={referenceItems.length > 0 ? referenceHintId : undefined}
1229
1499
  data-workflows-assistant-composer
@@ -1272,7 +1542,7 @@
1272
1542
  <Button
1273
1543
  class="mt-2 w-full"
1274
1544
  variant={dsButtonVariant('primary')}
1275
- disabled={ui.isStreaming}
1545
+ disabled={ui.isStreaming || isOutOfCredits}
1276
1546
  onclick={() => void sendMessage(draft)}
1277
1547
  >
1278
1548
  {$t('workflows.assistant.send')}
@@ -1280,3 +1550,7 @@
1280
1550
  </footer>
1281
1551
  {/if}
1282
1552
  </aside>
1553
+ {#if supportId}
1554
+ <!-- "Copy debug details": the card with the Support ID of this conversation's latest request, for the person to send to support. -->
1555
+ <SupportIdDialog open={isSupportDialogOpen} {supportId} onClose={() => (isSupportDialogOpen = false)} />
1556
+ {/if}