@widgetic/creator 0.4.49 → 0.4.51

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.
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import {
11
11
  Button,
12
+ CanvasBoardStatusChip,
12
13
  CreatorBar,
13
14
  DropdownMenu,
14
15
  PasswordInput,
@@ -60,7 +61,12 @@
60
61
  sketchBarShowsCustomize,
61
62
  sketchBarShowsPublish,
62
63
  sketchSavedStatusLabel,
64
+ widgetRowHeadIsAheadOfLive,
63
65
  } from './sketchBarState.js';
66
+ import { resolveSketchBoardStatusChip } from './sketchBoardStatusChip.js';
67
+ import { shouldHideDrawingToolbarForSelector } from './sketchToolbarMode.js';
68
+ import { stepAfterBoardChange } from './sketchBoardAfterDelete.js';
69
+ import { mergeBatchWidgetOntoListRecord } from './mergeBatchWidgetOntoListRecord.js';
64
70
  import { isDebugTabVisible } from './debug/debugUiVisibility.js';
65
71
  import { shouldNudgeSendBeforePublish } from './publish/publishGenerationGate.js';
66
72
 
@@ -417,6 +423,17 @@
417
423
  $: editorLanguage.update({ locale, messages: languageSlices.editor });
418
424
  $: chatMessages = languageSlices.chat;
419
425
  $: canvasMessages = languageSlices.canvas;
426
+ /**
427
+ * The people and the sound of the chat (see `CreatorAppProps.chatMembers` and `CreatorAppProps.agentSoundEnabled`).
428
+ * The person who is signed in is known from the session; the rest of the team, and whether the agent's mascot makes
429
+ * sound, come from the page.
430
+ */
431
+ export let chatMembers: CreatorAppProps['chatMembers'] = undefined;
432
+ export let agentSoundEnabled: CreatorAppProps['agentSoundEnabled'] = true;
433
+ /** Whether the assistant is drawn as the Scribble Mascot, with its sounds (see `CreatorAppProps.agentMascot`). On unless the page says false. */
434
+ export let agentMascot: CreatorAppProps['agentMascot'] = true;
435
+ /** "Desired Chat Person": the signed-in person as the chat knows people, or null when the session has nobody to draw. */
436
+ $: chatCurrentUser = chatPersonFromSession($userSession?.user);
420
437
  /** The creator's own area of the page (see `eventIsFromCreator`). */
421
438
  let creatorRootEl: HTMLElement | null = null;
422
439
  const partnerMode = typeof getAccessToken === 'function';
@@ -1110,7 +1127,12 @@
1110
1127
 
1111
1128
  // Chat module for code generation conversation UI
1112
1129
  import { Chat, ContextType } from '@widgetic/chat';
1113
- import type { ClarificationSuggestion } from '@widgetic/chat';
1130
+ import type { AgentAvatarRenderProps, ClarificationSuggestion } from '@widgetic/chat';
1131
+ // The agent's face in the chat (the brand's mascot), its sound, and the person the chat draws a face for
1132
+ import { Mascot } from '@widgetic/brand/mascot';
1133
+ import { createCreatorAgentSound, type CreatorAgentSound } from './agentSound.js';
1134
+ import { warmUpAgentMascot } from './agentMascotWarmUp.js';
1135
+ import { chatPersonFromSession } from './chatPeople.js';
1114
1136
  import DesignQuickEdit from './components/DesignQuickEdit.svelte';
1115
1137
  import { collectDesignProperties, resolveDesignIntent, toDesignControlRequest, type DesignControlRequest } from './utils/designIntentResolver';
1116
1138
  import { isDesignCardAttached } from './utils/designQuickEditValues';
@@ -1445,7 +1467,11 @@
1445
1467
  let deleteDialogWidgetId = '';
1446
1468
  let deleteDialogStep: 'confirm-remove' | 'confirm-delete-db' = 'confirm-remove';
1447
1469
  let deleteDialogResolve: ((result: { proceed: boolean; deleteFromDb: boolean }) => void) | null = null;
1448
- /** Keep second-step UI/code; MVP deletes the DB widget after the first confirm. */
1470
+ /**
1471
+ * Delete recovery (item 21, option A): first confirm removes the canvas shape only (`deleteFromDb: false`).
1472
+ * Gateway `DELETE /widgets/:id` hard-deletes CDN, compositions, and the DB row — not called unless this flag enables step 2.
1473
+ * Undo restores the shape from canvas history; the widget row stays in the project list.
1474
+ */
1449
1475
  const ASK_DELETE_FROM_DB_CONFIRM = false;
1450
1476
 
1451
1477
  function showDeleteWidgetDialog(widgetId: string, widgetName: string): Promise<{ proceed: boolean; deleteFromDb: boolean }> {
@@ -1472,7 +1498,7 @@
1472
1498
  return;
1473
1499
  }
1474
1500
  deleteDialogOpen = false;
1475
- if (deleteDialogResolve) deleteDialogResolve({ proceed: true, deleteFromDb: true });
1501
+ if (deleteDialogResolve) deleteDialogResolve({ proceed: true, deleteFromDb: false });
1476
1502
  break;
1477
1503
  case 'keep-in-db':
1478
1504
  deleteDialogOpen = false;
@@ -1500,7 +1526,6 @@
1500
1526
  if (selectedWidgetId === widgetId) {
1501
1527
  selectedWidgetId = null;
1502
1528
  }
1503
- showToast('success', $t('creator.widget.widgetDeletedFromDatabase'));
1504
1529
  } catch (err) {
1505
1530
  // A shape can outlive its widget row (deleted from the Projects page or
1506
1531
  // another session). The canvas only needs the shape and local entry gone,
@@ -1583,8 +1608,30 @@
1583
1608
  'Create a widget from the attached image (short description inside).';
1584
1609
  /** Prefilled prompt for Convert-to-Widget — user edits or presses Send to start. */
1585
1610
  const CONVERT_PROMPT = 'Create a widget starting from the attached image';
1586
- /** Id of the one model the docked chat offers when the person is not in debug mode (its label is a message: `creator.codegen.assistantModelLabel`). */
1587
- const ASSISTANT_MODEL_ID = 'assistant';
1611
+ /** "Agent Sound": the sound of the agent's mascot in the chat. Null until the creator is open, and where it could not be made. */
1612
+ let agentSound: CreatorAgentSound | null = null;
1613
+ onMount(() => {
1614
+ // The sounds belong to the mascot: with it off the player is made off, so its sound material is never even loaded
1615
+ agentSound = createCreatorAgentSound({ enabled: agentSoundEnabled !== false && agentMascot !== false });
1616
+ return () => {
1617
+ agentSound?.dispose();
1618
+ agentSound = null;
1619
+ };
1620
+ });
1621
+ // The page may mute the agent, or bring the sound back, while the creator is open (and the mascot, which the sound belongs to)
1622
+ $: agentSound?.setEnabled(agentSoundEnabled !== false && agentMascot !== false);
1623
+
1624
+ /** "Agent Mascot warm-up": the first mascot of a page waits for Three.js, the WebGL context and the shader (a still picture until then). */
1625
+ let isCreatorMounted = false;
1626
+ onMount(() => {
1627
+ isCreatorMounted = true;
1628
+ return () => {
1629
+ isCreatorMounted = false;
1630
+ };
1631
+ });
1632
+ // Got ready on an idle moment once the creator is open, so the agent's first turn starts moving at once, and again if the page brings the
1633
+ // mascot back. Asking more than once only keeps it warm longer, and with the mascot off nothing is fetched.
1634
+ $: if (isCreatorMounted && agentMascot !== false) void warmUpAgentMascot();
1588
1635
  let codeGenerationPrompt = DEFAULT_PROMPT;
1589
1636
  let isGeneratingCode = false;
1590
1637
  let generatingWidgetIds: Record<string, boolean> = {};
@@ -2469,6 +2516,11 @@
2469
2516
  function handleChatConversationChange(conversationId: string | null, sourceWidgetId?: string) {
2470
2517
  const widgetId = sourceWidgetId ?? selectedWidgetId;
2471
2518
  if (!widgetId) return;
2519
+ if (conversationId) {
2520
+ creatorStorage.setItem(CHAT_CONVERSATION_STORAGE_PREFIX + widgetId, conversationId);
2521
+ } else {
2522
+ creatorStorage.removeItem(CHAT_CONVERSATION_STORAGE_PREFIX + widgetId);
2523
+ }
2472
2524
  patchPanelSnapshot(widgetId, { currentChatConversationId: conversationId });
2473
2525
  if (widgetId === focusedPanelWidgetId) {
2474
2526
  currentChatConversationId = conversationId;
@@ -4150,6 +4202,7 @@
4150
4202
  const PROMPT_TEXT_STORAGE_PREFIX = 'widgetCreator_promptText_';
4151
4203
  const PROMPT_IMAGES_STORAGE_PREFIX = 'widgetCreator_promptImages_';
4152
4204
  const CHAT_DRAFT_STORAGE_PREFIX = 'widgetCreator_chatDraft_';
4205
+ const CHAT_CONVERSATION_STORAGE_PREFIX = 'widgetCreator_chatConversationId_';
4153
4206
 
4154
4207
  let isGenerateDisabled = true;
4155
4208
  // Publish state: true while the build job is running
@@ -6411,9 +6464,20 @@
6411
6464
  return isSketchGenerationFailed(getPanelDisplayState(widgetId), w);
6412
6465
  }
6413
6466
 
6414
- $: sketchBarGenerationFailed = sketchPrimaryGenerationFailed(canvasPrimaryWidgetId);
6467
+ /**
6468
+ * What the bar above the sketch shows (title, status, Publish, Live badge, board chip, drawing tools or selector) is worked
6469
+ * out by functions that read the widget record (`widgetsById`) and the panel state (`panelDisplayRevision`). Svelte 4 re-runs
6470
+ * a `$:` line only when a variable named in the line itself changes, so a line that named only `canvasPrimaryWidgetId` kept
6471
+ * the answer it had when the id was set, and an answer that arrived afterwards (the widgets of the canvas, the canvas
6472
+ * document, the publish history) never reached the bar: a published widget with changes showed "Live" and no Publish, and a
6473
+ * widget whose build failed lost its drawing tools. Every line of the bar names this object, which is new whenever either
6474
+ * of the two changes. Pinned by `sketchBarReactivity.test.ts`.
6475
+ */
6476
+ $: sketchBarSources = { panelDisplayRevision, widgetsById };
6477
+
6478
+ $: sketchBarGenerationFailed = (void sketchBarSources, sketchPrimaryGenerationFailed(canvasPrimaryWidgetId));
6415
6479
 
6416
- $: sketchBarTitleLabel = (void panelDisplayRevision, void sketchBarGenerationFailed, void canvasPrimaryWidgetId, sketchBarTitle());
6480
+ $: sketchBarTitleLabel = (void sketchBarSources, void panelDisplayRevision, void sketchBarGenerationFailed, void canvasPrimaryWidgetId, void sketchWidgetNamesFromBatch, void sketchCanvasPersistenceName, void activeCanvasName, sketchBarTitle());
6417
6481
 
6418
6482
  function sketchBarTitle(): string {
6419
6483
  const untitled = $t('creator.widget.untitledName');
@@ -6464,6 +6528,23 @@
6464
6528
  return resolvePublishedVersionFromWidget(widget as WidgetSummary | null) !== null;
6465
6529
  }
6466
6530
 
6531
+ /**
6532
+ * A published widget whose row says HEAD is not the live commit. The panel's own answer can lag on embed load, and it
6533
+ * cannot know a build made on another device (it trusts a head that differs from live only when this browser saw the
6534
+ * build finish), so the row's two commits are asked as well.
6535
+ */
6536
+ function sketchWidgetRowHeadIsAheadOfLive(widgetId: string | null): boolean {
6537
+ if (!widgetId || !sketchPrimaryShowsLiveBadge(widgetId)) return false;
6538
+ return widgetRowHeadIsAheadOfLive(getWidgetById(widgetId) as Record<string, unknown> | null, commitsMatch);
6539
+ }
6540
+
6541
+ /** Sketch header publish: panel diff can lag on embed load — fall back to widget commit SHAs. */
6542
+ function sketchPrimaryHasUnpublishedChanges(widgetId: string | null): boolean {
6543
+ if (!widgetId) return false;
6544
+ if (hasUnpublishedChangesForPanel(widgetId)) return true;
6545
+ return sketchWidgetRowHeadIsAheadOfLive(widgetId);
6546
+ }
6547
+
6467
6548
  function sketchWidgetHasActiveCodegenOperation(widgetId: string | null): boolean {
6468
6549
  if (!widgetId) return false;
6469
6550
  const w = getWidgetById(widgetId) as Record<string, unknown> | null;
@@ -6473,52 +6554,154 @@
6473
6554
  return !!op;
6474
6555
  }
6475
6556
 
6476
- $: sketchBarCanvasGenerating =
6557
+ $: sketchBarCanvasGenerating = (void sketchBarSources,
6477
6558
  !!canvasPrimaryWidgetId &&
6478
6559
  (!!generatingWidgetIds[canvasPrimaryWidgetId] ||
6479
- sketchWidgetHasActiveCodegenOperation(canvasPrimaryWidgetId));
6560
+ sketchWidgetHasActiveCodegenOperation(canvasPrimaryWidgetId)));
6561
+
6562
+ $: sketchBarHasUnpublishedLive = (void sketchBarSources,
6563
+ !!canvasPrimaryWidgetId &&
6564
+ sketchPrimaryShowsLiveBadge(canvasPrimaryWidgetId) &&
6565
+ sketchPrimaryHasUnpublishedChanges(canvasPrimaryWidgetId));
6480
6566
 
6481
- $: sketchBarStatusLabel = !embeddedSketchShell
6567
+ $: sketchBarStatusLabel = (void sketchBarSources, !embeddedSketchShell
6482
6568
  ? ''
6483
6569
  : !canvasPrimaryWidgetId
6484
- ? $t('creator.common.draft')
6485
- : sketchPrimaryShowsLiveBadge(canvasPrimaryWidgetId)
6486
- ? $t('creator.sketch.publishedJustNow')
6487
- : sketchBarGenerationFailed
6488
- ? $t('creator.common.draft')
6489
- : sketchPrimaryHasGeneratedCode(canvasPrimaryWidgetId)
6490
- ? sketchSavedStatusLabel(
6491
- $t('creator.general.saved'),
6492
- (getWidgetById(canvasPrimaryWidgetId) as { updatedAt?: string; updated_at?: string } | null)
6493
- ?.updatedAt ?? (getWidgetById(canvasPrimaryWidgetId) as { updated_at?: string } | null)?.updated_at,
6494
- )
6495
- : $t('creator.common.draft');
6496
-
6497
- $: sketchBarShowPublish = sketchBarShowsPublish({
6570
+ ? ''
6571
+ : sketchBarGenerationFailed
6572
+ ? sketchPrimaryHasGeneratedCode(canvasPrimaryWidgetId)
6573
+ ? $t('creator.general.saved')
6574
+ : ''
6575
+ : sketchBarCanvasGenerating
6576
+ ? sketchPrimaryHasGeneratedCode(canvasPrimaryWidgetId)
6577
+ ? $t('creator.general.saved')
6578
+ : ''
6579
+ : sketchBarHasUnpublishedLive
6580
+ ? $t('creator.general.saved')
6581
+ : sketchPrimaryShowsLiveBadge(canvasPrimaryWidgetId)
6582
+ ? $t('creator.sketch.publishedJustNow')
6583
+ : sketchPrimaryHasGeneratedCode(canvasPrimaryWidgetId)
6584
+ ? $t('creator.general.saved')
6585
+ : '');
6586
+
6587
+ $: sketchBarShowPublish = (void sketchBarSources, sketchBarShowsPublish({
6498
6588
  embedded: embeddedSketchShell,
6499
6589
  widgetId: canvasPrimaryWidgetId,
6500
6590
  hasGeneratedCode: sketchPrimaryHasGeneratedCode(canvasPrimaryWidgetId),
6501
6591
  showsLive: sketchPrimaryShowsLiveBadge(canvasPrimaryWidgetId),
6502
6592
  generating: sketchBarCanvasGenerating,
6503
6593
  failed: sketchBarGenerationFailed,
6504
- });
6594
+ hasUnpublishedChanges: canvasPrimaryWidgetId
6595
+ ? sketchPrimaryHasUnpublishedChanges(canvasPrimaryWidgetId)
6596
+ : false,
6597
+ }));
6505
6598
 
6506
- $: sketchBarShowCustomize = sketchBarShowsCustomize({
6599
+ $: sketchBoardStatusChip = (void sketchBarSources, resolveSketchBoardStatusChip({
6600
+ embedded: embeddedSketchShell,
6601
+ generating: sketchBarCanvasGenerating,
6602
+ failed: sketchBarGenerationFailed,
6603
+ hasGeneratedCode: sketchPrimaryHasGeneratedCode(canvasPrimaryWidgetId),
6604
+ showsLive:
6605
+ sketchPrimaryShowsLiveBadge(canvasPrimaryWidgetId) && !sketchBarHasUnpublishedLive,
6606
+ }));
6607
+
6608
+ function sketchBoardStatusChipLabel(variant: 'generating' | 'ready' | 'failed'): string {
6609
+ if (variant === 'generating') return $t('creator.sketch.boardChipGenerating');
6610
+ if (variant === 'ready') return $t('creator.sketch.boardChipReady');
6611
+ return $t('creator.sketch.boardChipFailed');
6612
+ }
6613
+
6614
+ function sketchBoardStatusChipActionLabel(variant: 'generating' | 'failed'): string {
6615
+ return variant === 'generating' ? $t('creator.sketch.boardChipStop') : $t('creator.sketch.boardChipTryAgain');
6616
+ }
6617
+
6618
+ function handleSketchBoardStatusChipAction(): void {
6619
+ const widgetId = canvasPrimaryWidgetId;
6620
+ if (!widgetId) return;
6621
+ if (sketchBarCanvasGenerating) {
6622
+ stopGeneration(widgetId);
6623
+ return;
6624
+ }
6625
+ if (sketchBarGenerationFailed) {
6626
+ const ps = getPanelDisplayState(widgetId);
6627
+ void handleChatRetryMessage(lastGenerationPrompt || ps.codeGenerationPrompt, widgetId);
6628
+ }
6629
+ }
6630
+
6631
+ $: sketchBarShowCustomize = (void sketchBarSources, sketchBarShowsCustomize({
6507
6632
  embedded: embeddedSketchShell,
6508
6633
  widgetId: canvasPrimaryWidgetId,
6509
6634
  hasGeneratedCode: sketchPrimaryHasGeneratedCode(canvasPrimaryWidgetId),
6510
6635
  generating: !!canvasPrimaryWidgetId && !!generatingWidgetIds[canvasPrimaryWidgetId],
6511
6636
  failed: sketchBarGenerationFailed,
6512
6637
  hasActiveCodegen: sketchWidgetHasActiveCodegenOperation(canvasPrimaryWidgetId),
6513
- });
6638
+ }));
6514
6639
 
6515
- $: sketchBarShowLiveBadge =
6516
- embeddedSketchShell && sketchPrimaryShowsLiveBadge(canvasPrimaryWidgetId);
6640
+ $: sketchBarShowLiveBadge = (void sketchBarSources,
6641
+ embeddedSketchShell
6642
+ && sketchPrimaryShowsLiveBadge(canvasPrimaryWidgetId)
6643
+ && !sketchBarHasUnpublishedLive);
6517
6644
 
6518
- $: sketchBarPublishLabel =
6519
- sketchBarShowLiveBadge
6520
- ? $t('creator.common.update')
6521
- : $t('creator.common.publish');
6645
+ $: sketchBarLoading = embeddedSketchShell && !isCanvasStateLoaded && !canvasUnavailable;
6646
+
6647
+ let sketchTitleMenuOpen = false;
6648
+
6649
+ function handleSketchTitleMenuRename(): void {
6650
+ sketchTitleMenuOpen = false;
6651
+ const widgetId = canvasPrimaryWidgetId;
6652
+ if (widgetId) {
6653
+ const widget = getWidgetById(widgetId);
6654
+ if (widget) {
6655
+ startRenameWidget(widget);
6656
+ return;
6657
+ }
6658
+ }
6659
+ void startCanvasNameEdit();
6660
+ }
6661
+
6662
+ async function handleSketchTitleMenuDuplicate(): Promise<void> {
6663
+ sketchTitleMenuOpen = false;
6664
+ await handleHostDuplicateWidgetEvent();
6665
+ }
6666
+
6667
+ async function handleSketchTitleMenuDelete(): Promise<void> {
6668
+ sketchTitleMenuOpen = false;
6669
+ await handleHostDeleteWidgetEvent();
6670
+ }
6671
+
6672
+ $: sketchBarPublishLabel = (void sketchBarSources, (() => {
6673
+ if (!canvasPrimaryWidgetId) return $t('creator.common.publish');
6674
+ const panel = getPanelDisplayState(canvasPrimaryWidgetId);
6675
+ const widget = getWidgetById(canvasPrimaryWidgetId) as { hasLiveVersion?: boolean; has_live_version?: boolean } | null;
6676
+ const wasPublished =
6677
+ panel.lastPublishedVersion != null
6678
+ || !!(widget?.hasLiveVersion || widget?.has_live_version);
6679
+ const unpublishedChanges =
6680
+ wasPublished
6681
+ && (sketchBarShowLiveBadge || sketchPrimaryHasUnpublishedChanges(canvasPrimaryWidgetId));
6682
+ return unpublishedChanges ? $t('creator.publish.publishChanges') : $t('creator.common.publish');
6683
+ })());
6684
+
6685
+ /**
6686
+ * Whether the Publish button of the bar is disabled. `getPublishGateForPanel` reads the publish state of the panel (the head
6687
+ * commit, the live commit, a build that is running, a publish that is open, the session); the template's own call of it is not
6688
+ * tracked, so the button kept the answer it got the first time, "No new version to publish" while the head commit had not
6689
+ * reached the panel yet, and a widget with changes showed "Publish changes" on a button that could not be clicked. The
6690
+ * variables the gate reads are named here, with the two sources of the bar.
6691
+ */
6692
+ $: sketchBarPublishDisabled = (void sketchBarSources,
6693
+ void isPublishing,
6694
+ void publishingWidgetId,
6695
+ void generatingWidgetIds,
6696
+ void previewReadyAnnouncedByWidgetId,
6697
+ void publishHeldByWidgetId,
6698
+ void hasValidToken,
6699
+ void $userSession,
6700
+ void canvasId,
6701
+ void sessionCanvasId,
6702
+ void lastCommitId,
6703
+ void focusedPanelWidgetId,
6704
+ !!canvasPrimaryWidgetId && isPublishDisabledForPanel(canvasPrimaryWidgetId));
6522
6705
 
6523
6706
  $: if (embeddedSketchShell && canvasRef?.saveCanvas && isCanvasStateLoaded) {
6524
6707
  try {
@@ -6549,11 +6732,7 @@
6549
6732
  }
6550
6733
 
6551
6734
  function handleSketchBarTitleClick() {
6552
- if (canvasPrimaryWidgetId) {
6553
- void openWidgetDetailsPanel(canvasPrimaryWidgetId);
6554
- return;
6555
- }
6556
- startCanvasNameEdit();
6735
+ void startCanvasNameEdit();
6557
6736
  }
6558
6737
 
6559
6738
  function handleSketchCustomize() {
@@ -6839,12 +7018,16 @@
6839
7018
  return !!(panel.hasGeneratedCode || panel.lastCommitId || panel.lastPublishedVersion != null);
6840
7019
  }
6841
7020
 
7021
+ $: hideDrawingToolbarForSelector = (void sketchBarSources,
7022
+ panelDisplayRevision >= 0
7023
+ && !!canvasPrimaryWidgetId
7024
+ && shouldHideDrawingToolbarForSelector({
7025
+ hasBuiltArtifact: primaryWidgetHasGeneratedCode(),
7026
+ generating: sketchBarCanvasGenerating,
7027
+ generationFailed: sketchBarGenerationFailed,
7028
+ }));
6842
7029
  $: showDrawingTools = (multipleWidgetsAllowed || singleWidgetChromeReady) && (
6843
- sketchToolbarAfterRestore || !(
6844
- panelDisplayRevision >= 0
6845
- && !!canvasPrimaryWidgetId
6846
- && primaryWidgetHasGeneratedCode()
6847
- )
7030
+ sketchToolbarAfterRestore || !hideDrawingToolbarForSelector
6848
7031
  );
6849
7032
  $: sketchCanvasShowDrawingTools = embeddedSketchShell
6850
7033
  ? !canvasPrimaryWidgetId || showDrawingTools
@@ -6933,7 +7116,7 @@
6933
7116
  }
6934
7117
  const widgetName = getWidgetById(widgetId)?.name || 'Widget';
6935
7118
  const result = await showDeleteWidgetDialog(widgetId, widgetName);
6936
- if (result.proceed) {
7119
+ if (result.proceed && result.deleteFromDb) {
6937
7120
  await deleteWidgetFromDb(widgetId);
6938
7121
  }
6939
7122
  }
@@ -6943,10 +7126,85 @@
6943
7126
  announceToSite('widgetic:creator-save-state', { dirty });
6944
7127
  }
6945
7128
 
7129
+ /**
7130
+ * The widget whose card Delete widget took off this one-widget canvas (item 21). The bar, the status chip, the toolbar and the
7131
+ * chat all follow `canvasPrimaryWidgetId`, so the canvas is empty again only when that id is empty too, and Undo gives the
7132
+ * widget back its name, chip and chat only when the id comes back with the card. The widget row itself stays: the delete
7133
+ * takes the card off the board, and Undo (or Restore shapes) brings it back.
7134
+ */
7135
+ let widgetDeletedFromBoardId: string | null = null;
7136
+
7137
+ /**
7138
+ * The draft chat that docks after Delete widget puts the cursor in its composer (a new chat does that), and a focused text box
7139
+ * keeps Cmd+Z for its own undo. The person's next key is most likely Cmd+Z for the delete they just made, so for a moment the
7140
+ * composer cannot take the focus from the page, unless the person goes there themselves (a click or a key press).
7141
+ */
7142
+ const KEYS_STAY_ON_PAGE_AFTER_DELETE_MS = 2500;
7143
+ let stopKeepingKeysOnPage: (() => void) | null = null;
7144
+
7145
+ function keepKeysOnPageAfterDelete(): void {
7146
+ if (typeof document === 'undefined') return;
7147
+ stopKeepingKeysOnPage?.();
7148
+ const keepingTimer = setTimeout(() => stopKeepingKeysOnPage?.(), KEYS_STAY_ON_PAGE_AFTER_DELETE_MS);
7149
+ const keepKeysOnPage = (event: FocusEvent) => {
7150
+ const target = (event.composedPath?.()[0] ?? event.target) as Element | null;
7151
+ if (target instanceof HTMLTextAreaElement && target.closest('.floating-panels-overlay')) {
7152
+ console.log('[CreatorApp] The chat composer asked for the focus right after Delete widget: the keys stay on the page for Undo');
7153
+ target.blur();
7154
+ }
7155
+ };
7156
+ const personActs = () => stopKeepingKeysOnPage?.();
7157
+ document.addEventListener('focusin', keepKeysOnPage, true);
7158
+ document.addEventListener('pointerdown', personActs, true);
7159
+ document.addEventListener('keydown', personActs, true);
7160
+ stopKeepingKeysOnPage = () => {
7161
+ clearTimeout(keepingTimer);
7162
+ document.removeEventListener('focusin', keepKeysOnPage, true);
7163
+ document.removeEventListener('pointerdown', personActs, true);
7164
+ document.removeEventListener('keydown', personActs, true);
7165
+ stopKeepingKeysOnPage = null;
7166
+ };
7167
+ }
7168
+
7169
+ /** The one-widget canvas goes back to the empty canvas: no widget name, no chip, the drawing tools, and the draft chat takes the chat's place. */
7170
+ function takeWidgetOffSketchBoard(widgetId: string): void {
7171
+ console.log('[CreatorApp] Widget card is off the board: back to the empty canvas', widgetId.slice(0, 8));
7172
+ widgetDeletedFromBoardId = widgetId;
7173
+ closeWidgetDetailsPanel(widgetId, { fromShapeSwitch: true });
7174
+ if (canvasPrimaryWidgetId === widgetId) canvasPrimaryWidgetId = null;
7175
+ if (selectedWidgetId === widgetId) selectedWidgetId = null;
7176
+ keepKeysOnPageAfterDelete();
7177
+ }
7178
+
7179
+ /** After every change of the board: follow the card of the widget the person deleted (Undo puts it back, Redo takes it off again). */
7180
+ function reconcileSketchBoardWithDeletedWidget(): void {
7181
+ if (!widgetDeletedFromBoardId || !embeddedSketchShell || !isCanvasStateLoaded) return;
7182
+ try {
7183
+ const step = stepAfterBoardChange({
7184
+ deletedWidgetId: widgetDeletedFromBoardId,
7185
+ primaryWidgetId: canvasPrimaryWidgetId,
7186
+ linkedWidgetIds: canvasRef?.getLinkedWidgetIds?.() ?? new Set<string>(),
7187
+ });
7188
+ if (step.kind === 'forget') {
7189
+ widgetDeletedFromBoardId = null;
7190
+ } else if (step.kind === 'clear') {
7191
+ takeWidgetOffSketchBoard(step.widgetId);
7192
+ } else if (step.kind === 'restore') {
7193
+ console.log('[CreatorApp] Widget card is back on the board: the canvas speaks for its widget again', step.widgetId.slice(0, 8));
7194
+ canvasPrimaryWidgetId = step.widgetId;
7195
+ panelDisplayRevision += 1;
7196
+ }
7197
+ } catch (error) {
7198
+ console.warn('[CreatorApp] Could not follow the card of the deleted widget', error);
7199
+ }
7200
+ }
7201
+
6946
7202
  /** The canvas says the person changed the board (a shape, a property, the letters of a text): it is unsaved until a save goes through. */
6947
7203
  function handleCanvasDirty(): void {
6948
7204
  canvasEditRevision += 1;
6949
7205
  emitCreatorSaveState(true);
7206
+ // After the canvas has finished the change it is telling us about: follow the card of a widget the person deleted (Undo, Redo).
7207
+ if (widgetDeletedFromBoardId) queueMicrotask(reconcileSketchBoardWithDeletedWidget);
6950
7208
  scheduleSketchPrefillFromCanvasDirty();
6951
7209
  }
6952
7210
 
@@ -7147,10 +7405,34 @@
7147
7405
  async function resumeEmbeddedSketchScenario(primaryId: string): Promise<void> {
7148
7406
  if (!embeddedSketchShell || !primaryId) return;
7149
7407
  ensurePanelState(primaryId);
7150
- const widget = getWidgetById(primaryId) as Record<string, unknown> | null;
7408
+ const widget = getWidgetById(primaryId) as WidgetSummary | null;
7409
+ if (widget) {
7410
+ hydrateWidgetVersionAndCommitState(widget);
7411
+ }
7412
+ const widgetRecord = widget as Record<string, unknown> | null;
7413
+ if (widgetRecord && isSketchGenerationFailed(getPanelState(primaryId), widgetRecord)) {
7414
+ patchCodegenUiState(primaryId, {
7415
+ lastGenerationFailed: true,
7416
+ lastGenerationError:
7417
+ String(widgetRecord.lastGenerationError ?? widgetRecord.last_generation_error ?? '').trim()
7418
+ || 'Code generation failed',
7419
+ hasGeneratedCode: sketchPrimaryHasGeneratedCode(primaryId),
7420
+ });
7421
+ widgets = widgets.map((w) =>
7422
+ w.id === primaryId
7423
+ ? {
7424
+ ...w,
7425
+ codegenStatus: 'failed',
7426
+ codegen_status: 'failed',
7427
+ generationFailed: true,
7428
+ generation_failed: true,
7429
+ }
7430
+ : w,
7431
+ );
7432
+ }
7151
7433
  const opId = String(
7152
- (widget?.activeOperationId as string | undefined)
7153
- ?? (widget?.active_operation_id as string | undefined)
7434
+ (widgetRecord?.activeOperationId as string | undefined)
7435
+ ?? (widgetRecord?.active_operation_id as string | undefined)
7154
7436
  ?? '',
7155
7437
  ).trim();
7156
7438
  if (opId && operationsClient) {
@@ -7249,6 +7531,11 @@
7249
7531
  emitCanvasWidgetsList('hydrate-primary');
7250
7532
  if (embeddedSketchShell) {
7251
7533
  await mergeWidgetsLinkedOnCanvas([primaryId]);
7534
+ const recordedPrimary = await resolvePrimaryWidgetIdForCanvas(targetCanvasId);
7535
+ if (recordedPrimary && recordedPrimary !== primaryId) {
7536
+ primaryId = recordedPrimary;
7537
+ canvasPrimaryWidgetId = recordedPrimary;
7538
+ }
7252
7539
  }
7253
7540
  }
7254
7541
  return primaryId || canvasPrimaryWidgetId || null;
@@ -9270,7 +9557,14 @@
9270
9557
  }
9271
9558
  for (const widget of fetched) {
9272
9559
  if (widget?.id) {
9273
- mergedById.set(widget.id, preserveRepositoryOnWidget(widget, previousById.get(widget.id)));
9560
+ // The batch row is read through the generated model and carries fewer fields than the list row
9561
+ // (`hasLiveVersion`, `lastPublishCommitSha`, `thumbnailUrl`, ...): it goes onto the list row, not over it,
9562
+ // or a published widget with changes loses the live commit and the bar reads "Live" with no Publish.
9563
+ const previousListRow = previousById.get(widget.id);
9564
+ mergedById.set(
9565
+ widget.id,
9566
+ preserveRepositoryOnWidget(mergeBatchWidgetOntoListRecord(previousListRow, widget), previousListRow),
9567
+ );
9274
9568
  const batchName = String(widget.name ?? '').trim();
9275
9569
  if (embeddedSketchShell && batchName) {
9276
9570
  sketchWidgetNamesFromBatch = { ...sketchWidgetNamesFromBatch, [widget.id]: batchName };
@@ -10952,6 +11246,19 @@
10952
11246
  pendingReferenceImageDataUrl = null;
10953
11247
  chatMethods.restoreAttachmentsFromDataUrls?.([dataUrl]);
10954
11248
  }
11249
+ const storedConversationId = ownerWidgetId
11250
+ ? creatorStorage.getItem(CHAT_CONVERSATION_STORAGE_PREFIX + ownerWidgetId)
11251
+ : null;
11252
+ if (storedConversationId && methods.selectConversation) {
11253
+ // The method may answer at once or with a promise; a failed restore leaves the chat on its own latest conversation.
11254
+ void (async () => {
11255
+ try {
11256
+ await methods.selectConversation?.(storedConversationId);
11257
+ } catch (error) {
11258
+ console.debug('[CreatorApp] Could not restore the last conversation of this widget', error);
11259
+ }
11260
+ })();
11261
+ }
10955
11262
  }
10956
11263
 
10957
11264
  /**
@@ -13584,6 +13891,7 @@ Requirements:
13584
13891
  clearTimeout(sketchPrefillDirtyTimer);
13585
13892
  sketchPrefillDirtyTimer = null;
13586
13893
  }
13894
+ stopKeepingKeysOnPage?.();
13587
13895
  if (tokenCheckInterval) clearInterval(tokenCheckInterval);
13588
13896
  if (tokenDisplayInterval) clearInterval(tokenDisplayInterval);
13589
13897
  if (hydrationSafetyTimeout) clearTimeout(hydrationSafetyTimeout);
@@ -16794,7 +17102,11 @@ Requirements:
16794
17102
  || !!(pendingSha && liveSha && !commitsMatch(pendingSha, liveSha));
16795
17103
  const unpublishedAhead = hasUnpublishedChangesForPanel(widgetId)
16796
17104
  || !!(pendingPublish && ps.lastCommitId && liveSha && !commitsMatch(ps.lastCommitId, liveSha))
16797
- || !!(ps.lastCommitId && liveSha && !commitsMatch(ps.lastCommitId, liveSha));
17105
+ || !!(ps.lastCommitId && liveSha && !commitsMatch(ps.lastCommitId, liveSha))
17106
+ // The bar above the sketch says "Publish changes" when the widget row's HEAD is not its live commit, also for a
17107
+ // build this browser never saw finish (made on another device): the button follows the bar. The server publishes
17108
+ // its own HEAD whatever commit is sent, so nothing older can go live through this.
17109
+ || (embeddedSketchShell && sketchWidgetRowHeadIsAheadOfLive(widgetId));
16798
17110
 
16799
17111
  // Pending codegen SHA wins over a stale GitLab HEAD that still matches live.
16800
17112
  if (headSha && liveSha && commitsMatch(headSha, liveSha) && !pendingPublish && !unpublishedAhead) {
@@ -18220,12 +18532,16 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
18220
18532
 
18221
18533
  if (!result.proceed) return false;
18222
18534
 
18223
- closeWidgetDetailsPanel(widgetId);
18535
+ if (embeddedSketchShell && widgetId === canvasPrimaryWidgetId) {
18536
+ // One-widget canvas: the card leaves the board, so the canvas is empty again and the draft chat takes the chat's place.
18537
+ // (Closing the panel and opening it again for the same id in one go leaves the panel without a ref: the chat stayed blank.)
18538
+ takeWidgetOffSketchBoard(widgetId);
18539
+ } else {
18540
+ closeWidgetDetailsPanel(widgetId);
18541
+ }
18224
18542
 
18225
18543
  if (result.deleteFromDb) {
18226
18544
  await deleteWidgetFromDb(widgetId);
18227
- } else {
18228
- showToast('info', $t('creator.canvas.shapeRemovedFromCanvas'), { description: $t('creator.widget.widgetKeptInDatabase2', { name: widgetName }) });
18229
18545
  }
18230
18546
  return true;
18231
18547
  }
@@ -19966,28 +20282,63 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
19966
20282
  data-testid="embedded-sketch-panel-wrap"
19967
20283
  >
19968
20284
  <section
20285
+ data-testid={embeddedSketchShell ? 'embedded-sketch-canvas-panel' : undefined}
19969
20286
  data-sketch-mobile-tab={embeddedSketchShell ? embeddedSketchMobileTab : undefined}
19970
20287
  class="{embeddedSketchShell
19971
- ? 'embedded-sketch-canvas-panel border-border bg-background flex min-h-0 min-w-0 w-full flex-1 flex-col overflow-hidden rounded-panel max-md:data-[sketch-mobile-tab=chat]:hidden md:max-lg:row-start-1 md:max-lg:h-[600px] md:max-lg:max-h-[600px] md:max-lg:min-h-0 md:max-lg:w-full md:max-lg:flex-none max-md:flex-1 max-md:min-h-0 lg:min-h-0 lg:min-w-0'
20288
+ ? 'embedded-sketch-canvas-panel bg-background flex min-h-0 min-w-0 w-full flex-1 flex-col overflow-hidden rounded-panel max-md:data-[sketch-mobile-tab=chat]:hidden md:max-lg:row-start-1 md:max-lg:h-[600px] md:max-lg:max-h-[600px] md:max-lg:min-h-0 md:max-lg:w-full md:max-lg:flex-none max-md:flex-1 max-md:min-h-0 lg:min-h-0 lg:min-w-0'
19972
20289
  : 'contents'}"
19973
20290
  >
19974
20291
  {#if embeddedSketchShell}
20292
+ {#snippet sketchTitleMenu()}
20293
+ <DropdownMenu.Content
20294
+ class="w-[12.5rem] p-1"
20295
+ data-testid="creator-sketch-title-menu"
20296
+ align="start"
20297
+ sideOffset={4}
20298
+ >
20299
+ <DropdownMenu.Item
20300
+ data-testid="creator-title-menu-rename"
20301
+ class="h-8"
20302
+ onclick={handleSketchTitleMenuRename}
20303
+ >
20304
+ {$t('creator.name.renameWidget')}
20305
+ </DropdownMenu.Item>
20306
+ {#if canvasPrimaryWidgetId}
20307
+ <DropdownMenu.Item
20308
+ data-testid="creator-title-menu-duplicate"
20309
+ class="h-8"
20310
+ onclick={() => void handleSketchTitleMenuDuplicate()}
20311
+ >
20312
+ {$t('creator.name.duplicateWidget')}
20313
+ </DropdownMenu.Item>
20314
+ <DropdownMenu.Separator />
20315
+ <DropdownMenu.Item
20316
+ data-testid="creator-title-menu-delete"
20317
+ class="h-8 text-destructive"
20318
+ onclick={() => void handleSketchTitleMenuDelete()}
20319
+ >
20320
+ {$t('creator.widget.deleteWidget')}
20321
+ </DropdownMenu.Item>
20322
+ {/if}
20323
+ </DropdownMenu.Content>
20324
+ {/snippet}
19975
20325
  <CreatorBar
19976
20326
  class="shrink-0"
19977
20327
  title={sketchBarTitleLabel}
20328
+ titleButtonClass="min-w-0"
19978
20329
  status={sketchBarStatusLabel}
19979
- showStatus={true}
19980
- showTitleChevron={true}
20330
+ showStatus={!!sketchBarStatusLabel && !sketchBarLoading && !sketchBarCanvasGenerating}
20331
+ titleAsCaption={sketchBarLoading}
20332
+ showTitleChevron={!sketchBarLoading}
19981
20333
  showLiveBadge={sketchBarShowLiveBadge}
19982
20334
  liveLabel={$t('creator.common.live')}
19983
- showCustomize={sketchBarShowCustomize}
19984
- customizeLabel={$t('creator.sketch.customize')}
19985
- showPublish={sketchBarShowPublish}
19986
- publishLabel={sketchBarPublishLabel}
19987
- publishDisabled={!!canvasPrimaryWidgetId && isPublishDisabledForPanel(canvasPrimaryWidgetId)}
20335
+ showCustomize={false}
20336
+ showPublish={sketchBarLoading ? true : sketchBarShowPublish}
20337
+ publishLabel={sketchBarLoading ? $t('creator.common.publish') : sketchBarPublishLabel}
20338
+ publishDisabled={sketchBarLoading || sketchBarPublishDisabled}
20339
+ bind:titleMenuOpen={sketchTitleMenuOpen}
20340
+ titleMenu={sketchBarLoading ? undefined : sketchTitleMenu}
19988
20341
  onBack={() => window.dispatchEvent(new CustomEvent('widgetic:host-request-back'))}
19989
- onTitleClick={handleSketchBarTitleClick}
19990
- onCustomize={handleSketchCustomize}
19991
20342
  onPublish={() => void publish()}
19992
20343
  />
19993
20344
  {/if}
@@ -19997,6 +20348,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
19997
20348
  : 'contents'}"
19998
20349
  >
19999
20350
  <div
20351
+ data-testid="embedded-sketch-canvas-stage"
20000
20352
  class="embedded-sketch-canvas-stage flex-1 min-h-0 relative min-w-0 {embeddedSketchShell
20001
20353
  ? 'rounded-card bg-muted overflow-hidden max-md:absolute max-md:inset-0 max-md:z-0'
20002
20354
  : ''} {embeddedSketchShell && embeddedSketchMobileTab !== 'canvas'
@@ -20004,7 +20356,16 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
20004
20356
  : ''}"
20005
20357
  aria-hidden={embeddedSketchShell && embeddedSketchMobileTab !== 'canvas' ? 'true' : undefined}
20006
20358
  >
20007
- <!-- Generating, ready and failed are said in the side chat only: nothing about the generation is drawn over the canvas. -->
20359
+ {#if sketchBoardStatusChip}
20360
+ <CanvasBoardStatusChip
20361
+ variant={sketchBoardStatusChip.variant}
20362
+ label={sketchBoardStatusChipLabel(sketchBoardStatusChip.variant)}
20363
+ actionLabel={sketchBoardStatusChip.showAction
20364
+ ? sketchBoardStatusChipActionLabel(sketchBoardStatusChip.variant as 'generating' | 'failed')
20365
+ : ''}
20366
+ onAction={sketchBoardStatusChip.showAction ? handleSketchBoardStatusChipAction : undefined}
20367
+ />
20368
+ {/if}
20008
20369
  <!-- Embedded: Debug toggle lives in site AppHeader (avoids overlapping Props Panel). -->
20009
20370
  {#if canvasApiLoadError || canvasShapesMissingWarning}
20010
20371
  <div class="canvas-state-warning-ct absolute top-3 left-1/2 -translate-x-1/2 z-30 max-w-lg w-[calc(100%-2rem)] pointer-events-auto">
@@ -20037,7 +20398,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
20037
20398
  bind:this={canvasRef}
20038
20399
  locale={locale}
20039
20400
  messages={canvasMessages}
20040
- showContainerFrame={embeddedSketchShell || !embedded}
20401
+ showContainerFrame={!embedded}
20041
20402
  widgetSelectionLayerTarget="floating-panels-overlay"
20042
20403
  bind:wireframeMode={canvasWireframeMode}
20043
20404
  advancedFeatures={canvasAdvancedFeatures}
@@ -20115,6 +20476,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
20115
20476
 
20116
20477
  <!-- FLOATING PANELS OVERLAY (pointer-events-none container, each panel is pointer-events-auto) -->
20117
20478
  <div
20479
+ data-testid={embeddedSketchShell ? 'embedded-sketch-chat-panel' : undefined}
20118
20480
  class="floating-panels-overlay z-2003 {embeddedSketchShell
20119
20481
  ? 'md:max-lg:pointer-events-auto md:max-lg:relative md:max-lg:row-start-2 md:max-lg:flex md:max-lg:h-[400px] md:max-lg:max-h-[400px] md:max-lg:min-h-0 md:max-lg:w-full md:max-lg:min-w-0 md:max-lg:flex-none md:max-lg:flex-col max-md:absolute max-md:inset-x-2 max-md:bottom-0 max-md:top-0 max-md:z-[1] max-md:flex max-md:flex-1 max-md:min-h-0 lg:pointer-events-none lg:relative lg:flex lg:w-chat-panel lg:max-w-full lg:shrink-0 lg:flex-col'
20120
20482
  : 'pointer-events-none absolute inset-0'} {embeddedSketchShell && embeddedSketchMobileTab !== 'chat'
@@ -21138,6 +21500,19 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
21138
21500
  onChange={(id, value) => applyDesignValuesToPreview(panelWidgetId, { [id]: value })}
21139
21501
  />
21140
21502
  {/snippet}
21503
+ <!-- The agent's face: the brand's mascot, drawn when the chat asks for it (`renderAgentAvatar`). A turn that is
21504
+ not the newest comes as `live={false}`: a still picture, so a long history does not run dozens of mascots.
21505
+ Where the mascot cannot be drawn, or the page turned it off (`agentMascot`), the chat shows its plain avatar
21506
+ instead. Cast to any, as for renderDesignControls. -->
21507
+ {#snippet renderAgentAvatar(avatar: AgentAvatarRenderProps)}
21508
+ <Mascot
21509
+ state={avatar.state}
21510
+ size={avatar.size}
21511
+ label={avatar.label}
21512
+ frozenAt={avatar.live ? undefined : 0.5}
21513
+ settleTo="idle"
21514
+ />
21515
+ {/snippet}
21141
21516
  {#snippet generationOptionChecks()}
21142
21517
  <BrandKitPanel
21143
21518
  part="checks"
@@ -21163,11 +21538,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
21163
21538
  <!-- Svelte 5: `{@const}` must be the direct child of a block; this wrapper exists only for dockedChatPanel and composerModelOptions. -->
21164
21539
  {#if true}
21165
21540
  {@const dockedChatPanel = embedded && !canvasAdvancedFeatures}
21166
- {@const composerModelOptions = dockedChatPanel
21167
- ? debugMode
21168
- ? availableModels.map((model) => ({ id: model.id, label: model.name }))
21169
- : [{ id: ASSISTANT_MODEL_ID, label: $t('creator.codegen.assistantModelLabel') }]
21170
- : debugMode
21541
+ {@const composerModelOptions =
21542
+ debugMode && debugModeAvailable
21171
21543
  ? availableModels.map((model) => ({ id: model.id, label: model.name }))
21172
21544
  : []}
21173
21545
  <Chat class="code-generation-chat h-full w-full max-w-full rounded-none border-0"
@@ -21179,6 +21551,10 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
21179
21551
  style="height: 100%; min-height: {chatUserHeight == null ? CHAT_AUTO_MIN_HEIGHT : CHAT_MIN_HEIGHT}px;"
21180
21552
  resizeExpandsContainer={true}
21181
21553
  renderDesignControls={renderDesignControls as any}
21554
+ renderAgentAvatar={agentMascot === false ? undefined : (renderAgentAvatar as any)}
21555
+ agentSound={agentMascot === false ? undefined : agentSound?.player}
21556
+ members={chatMembers ?? undefined}
21557
+ currentUser={chatCurrentUser}
21182
21558
  onMessagesResize={(deltaPx) => handleChatMessagesResize(panelWidgetId, deltaPx)}
21183
21559
  showLogs={debugMode}
21184
21560
  showHeader={false}
@@ -21773,26 +22149,17 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
21773
22149
  <Dialog.Root bind:open={deleteDialogOpen} onOpenChange={(open) => { if (!open) handleDeleteDialogResponse('cancel'); }}>
21774
22150
  <Dialog.Content closeLabel={$t('creator.common.close')} layerBase={creatorDialogLayerBase} class="confirm-delete-dialog-content max-w-md bg-white z-9999">
21775
22151
  <Dialog.Header class="confirm-delete-dialog-header">
21776
- <Dialog.Title>{$t('creator.widget.deleteWidgetShape')}</Dialog.Title>
21777
- <Dialog.Description>
21778
- {#each sentenceParts(deleteDialogStep === 'confirm-remove' ? 'creator.dialog.removeShape' : 'creator.dialog.alsoDeleteWidget', ['name'], $t) as part}
21779
- {#if 'text' in part}{part.text}{:else}<strong>"{deleteDialogWidgetName}"</strong>{/if}
21780
- {/each}
21781
- </Dialog.Description>
22152
+ <Dialog.Title>{$t('creator.widget.deleteWidget')}</Dialog.Title>
21782
22153
  </Dialog.Header>
21783
22154
 
21784
22155
  <div class="confirm-delete-dialog-action-ct flex justify-end gap-2 pt-2">
21785
22156
  {#if deleteDialogStep === 'confirm-remove'}
21786
- <button
21787
- type="button"
21788
- class="px-4 py-2 text-sm rounded-lg border border-gray-300 hover:bg-gray-100 cursor-pointer"
21789
- onclick={() => handleDeleteDialogResponse('cancel')}
21790
- >{$t('creator.general.cancel')}</button>
21791
- <button
21792
- type="button"
21793
- class="px-4 py-2 text-sm rounded-lg bg-red-600 hover:bg-red-700 text-white cursor-pointer"
21794
- onclick={() => handleDeleteDialogResponse('remove-and-ask-db')}
21795
- >{$t('creator.common.delete')}</button>
22157
+ <Button variant="outline" size="sm" onclick={() => handleDeleteDialogResponse('cancel')}>
22158
+ {$t('creator.general.cancel')}
22159
+ </Button>
22160
+ <Button variant="destructive" size="sm" onclick={() => handleDeleteDialogResponse('remove-and-ask-db')}>
22161
+ {$t('creator.widget.deleteWidget')}
22162
+ </Button>
21796
22163
  {:else if ASK_DELETE_FROM_DB_CONFIRM}
21797
22164
  <button
21798
22165
  type="button"