@designcrowd/library.brand-page 5.18.2 → 5.18.3-actionable-buttons-1

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.
Files changed (78) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-DB2oJ5vl.js → CreatedOnBrandCrowd-de-de-B27yG7Im.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-fbk0Gf2G.js → CreatedOnBrandCrowd-en-us-D-Qt-E8d.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-Ch4Q9__I.js → CreatedOnBrandCrowd-es-es-BQ1ZfmeW.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-DaHJ6OMH.js → CreatedOnBrandCrowd-fr-ca-Cx3bWshs.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-DaHJ6OMH.js → CreatedOnBrandCrowd-fr-fr-Cx3bWshs.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-BgF8UCqy.js → CreatedOnBrandCrowd-pt-br-DBIvSND9.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-BgF8UCqy.js → CreatedOnBrandCrowd-pt-pt-DBIvSND9.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-j3rcGaGp.js → CreatedOnDcom-de-de-Dm_1xPJE.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-Cx4eQPRU.js → CreatedOnDcom-en-us-Dx86ZBPI.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-D-1APCL9.js → CreatedOnDcom-es-es-FVsEih0c.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-DAHdBw0D.js → CreatedOnDcom-fr-ca-wQ_ZXFlw.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-BYAw2kXr.js → CreatedOnDcom-fr-fr-C17s3Cri.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-CdSknjZg.js → CreatedOnDcom-pt-br-CIGrEeSH.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-DzyZ2j80.js → CreatedOnDcom-pt-pt-BGvzTd4W.js} +1 -1
  15. package/lib/src/brand-page-maker/composables/ai-chat/types.d.ts +3 -0
  16. package/lib/src/brand-page-maker/composables/ai-chat/ui-actions.d.ts +29 -0
  17. package/lib/src/brand-page-maker/composables/ai-chat/ui-actions.js +32 -0
  18. package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.js +33 -7
  19. package/lib/src/brand-page-maker/composables/useEventTracker.d.ts +1 -0
  20. package/lib/src/brand-page-maker/composables/useEventTracker.js +1 -0
  21. package/lib/src/{bundled-translations-CnareLWC.js → bundled-translations-B5Fkt3qd.js} +1 -1
  22. package/lib/src/{bundled-translations.de-DE-2Ys7epLO.js → bundled-translations.de-DE-DpdVePM9.js} +1 -1
  23. package/lib/src/bundled-translations.es-ES-BsIcrzZF.js +175 -0
  24. package/lib/src/bundled-translations.fr-CA-G1XCp2Qh.js +175 -0
  25. package/lib/src/bundled-translations.fr-FR-BdwLXOnB.js +175 -0
  26. package/lib/src/bundled-translations.pt-BR-Bvn5ePe7.js +175 -0
  27. package/lib/src/bundled-translations.pt-PT-CDtkb2k1.js +175 -0
  28. package/lib/src/bundles/bundled-translations.de-DE.json +2 -0
  29. package/lib/src/bundles/bundled-translations.es-ES.json +2 -0
  30. package/lib/src/bundles/bundled-translations.fr-CA.json +2 -0
  31. package/lib/src/bundles/bundled-translations.fr-FR.json +2 -0
  32. package/lib/src/bundles/bundled-translations.json +2 -0
  33. package/lib/src/bundles/bundled-translations.pt-BR.json +2 -0
  34. package/lib/src/bundles/bundled-translations.pt-PT.json +2 -0
  35. package/lib/src/css/library.brand-page-brandCrowd.min.css +93 -19
  36. package/lib/src/css/library.brand-page-brandPage.min.css +93 -19
  37. package/lib/src/css/library.brand-page-designCom.min.css +93 -19
  38. package/lib/src/css/library.brand-page-preview.min.css +93 -19
  39. package/lib/src/index.mjs +1 -1
  40. package/lib/src/{lib-mcvVokSM.js → lib-MtnS_D2m.js} +16357 -16221
  41. package/lib/src/plugins/google-maps-plugin/google-maps-plugin.d.ts +14 -2
  42. package/lib/src/plugins/google-maps-plugin/google-maps-plugin.js +43 -13
  43. package/package.json +2 -2
  44. package/src/brand-page-maker/components/ai-text-edit/AiActionButtons.vue +22 -7
  45. package/src/brand-page-maker/components/ai-text-edit/AiChatbox.vue +3 -0
  46. package/src/brand-page-maker/components/ai-text-edit/TextBubble.vue +7 -1
  47. package/src/brand-page-maker/components/ai-website-builder/AiWebsiteBuilder.vue +21 -1
  48. package/src/brand-page-maker/components/brandpage-settings/BrandPageSettings.vue +8 -0
  49. package/src/brand-page-maker/composables/ai-chat/types.ts +6 -0
  50. package/src/brand-page-maker/composables/ai-chat/ui-actions.test.ts +80 -0
  51. package/src/brand-page-maker/composables/ai-chat/ui-actions.ts +58 -0
  52. package/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.ts +287 -248
  53. package/src/brand-page-maker/composables/useEventTracker.ts +1 -0
  54. package/src/brand-page-maker/constants/i18n/constants.de-DE.json +2 -0
  55. package/src/brand-page-maker/constants/i18n/constants.es-ES.json +2 -0
  56. package/src/brand-page-maker/constants/i18n/constants.fr-CA.json +2 -0
  57. package/src/brand-page-maker/constants/i18n/constants.fr-FR.json +2 -0
  58. package/src/brand-page-maker/constants/i18n/constants.json +2 -0
  59. package/src/brand-page-maker/constants/i18n/constants.pt-BR.json +2 -0
  60. package/src/brand-page-maker/constants/i18n/constants.pt-PT.json +2 -0
  61. package/src/bundles/bundled-translations.de-DE.json +2 -0
  62. package/src/bundles/bundled-translations.es-ES.json +2 -0
  63. package/src/bundles/bundled-translations.fr-CA.json +2 -0
  64. package/src/bundles/bundled-translations.fr-FR.json +2 -0
  65. package/src/bundles/bundled-translations.json +2 -0
  66. package/src/bundles/bundled-translations.pt-BR.json +2 -0
  67. package/src/bundles/bundled-translations.pt-PT.json +2 -0
  68. package/src/plugins/google-maps-plugin/google-maps-plugin.ts +58 -18
  69. package/src/shared/content-settings/components/google-address-field/GoogleAddressField.vue +148 -15
  70. package/src/shared/font-family-selector/FontPicker.vue +91 -4
  71. package/lib/src/bundled-translations.es-ES-Cjp-G8rT.js +0 -175
  72. package/lib/src/bundled-translations.fr-CA-CsaW4Oae.js +0 -175
  73. package/lib/src/bundled-translations.fr-FR-DIT2dd8J.js +0 -175
  74. package/lib/src/bundled-translations.pt-BR-BamoBpDW.js +0 -175
  75. package/lib/src/bundled-translations.pt-PT-C9A4hY_e.js +0 -175
  76. package/lib/src/shared/content-settings/components/google-address-field/GoogleAddressField.mixin.d.ts +0 -54
  77. package/lib/src/shared/content-settings/components/google-address-field/GoogleAddressField.mixin.js +0 -67
  78. package/src/shared/content-settings/components/google-address-field/GoogleAddressField.mixin.ts +0 -84
@@ -44,7 +44,9 @@ import type {
44
44
  ThreadMessage,
45
45
  TextThreadMessage,
46
46
  SendMessageOptions,
47
+ AgentAction,
47
48
  } from './types';
49
+ import { partitionAiToolCalls } from './ui-actions';
48
50
 
49
51
  const BUILD_TIMEOUT_MS = 600000;
50
52
 
@@ -454,7 +456,11 @@ export function useAiWebsiteBuilderChat(): UseAiChatResult {
454
456
  const callApiBuildAsync = async (
455
457
  userPrompt: string,
456
458
  userMessageId: string,
457
- ): Promise<{ text: string | null; isError?: boolean }> => {
459
+ ): Promise<{
460
+ text: string | null;
461
+ isError?: boolean;
462
+ actions?: AgentAction[];
463
+ }> => {
458
464
  const connectionId = await ensureConnectedAsync();
459
465
  const wsClient = activeBuildWsClient!;
460
466
 
@@ -525,297 +531,313 @@ export function useAiWebsiteBuilderChat(): UseAiChatResult {
525
531
  });
526
532
  }
527
533
 
528
- return new Promise<{ text: string | null; isError?: boolean }>(
529
- (resolve, reject) => {
530
- let settled = false;
531
- let retryCount = 0;
532
- let lastAiMessage: string | null = null;
533
- let handler: ((msg: WebSocketMessage) => void) | null = null;
534
- // Vacant-slot queue scoped to this build session. Persists across
535
- // retry rounds so a failed CREATE returns to its planned slot via
536
- // a synthesised `move_before_content_id`.
537
- const vacantSlots: VacantSlotMap = new Map();
538
-
539
- const finishBuild = () => {
540
- aiThreadStore.isBuildInProgress = false;
541
- wsClient.setBuildActive(false);
542
- wsClient.stopResponseHeartbeat();
543
-
544
- if (handler) wsClient.offMessage(handler);
545
- };
546
-
547
- const timeout = setTimeout(() => {
548
- if (settled) return;
549
-
550
- settled = true;
551
- finishBuild();
552
- reject(new Error('Build timeout'));
553
- }, BUILD_TIMEOUT_MS);
554
-
555
- handler = (msg: WebSocketMessage) => {
556
- if (settled) return;
557
-
558
- try {
559
- if (msg.buildId !== aiThreadStore.buildId) return;
560
-
561
- if (isStopped.value) {
562
- settled = true;
563
- clearTimeout(timeout);
564
- finishBuild();
565
- resolve({ text: null });
566
-
567
- return;
568
- }
534
+ return new Promise<{
535
+ text: string | null;
536
+ isError?: boolean;
537
+ actions?: AgentAction[];
538
+ }>((resolve, reject) => {
539
+ let settled = false;
540
+ let retryCount = 0;
541
+ let lastAiMessage: string | null = null;
542
+ let lastActions: AgentAction[] | undefined;
543
+ let handler: ((msg: WebSocketMessage) => void) | null = null;
544
+ // Vacant-slot queue scoped to this build session. Persists across
545
+ // retry rounds so a failed CREATE returns to its planned slot via
546
+ // a synthesised `move_before_content_id`.
547
+ const vacantSlots: VacantSlotMap = new Map();
548
+
549
+ const finishBuild = () => {
550
+ aiThreadStore.isBuildInProgress = false;
551
+ wsClient.setBuildActive(false);
552
+ wsClient.stopResponseHeartbeat();
553
+
554
+ if (handler) wsClient.offMessage(handler);
555
+ };
569
556
 
570
- if (msg.type === 'chat_started' && msg.message) {
571
- withTypingMessage((m) => {
572
- m.initialMessage = msg.message;
573
- });
557
+ const timeout = setTimeout(() => {
558
+ if (settled) return;
574
559
 
575
- return;
576
- }
560
+ settled = true;
561
+ finishBuild();
562
+ reject(new Error('Build timeout'));
563
+ }, BUILD_TIMEOUT_MS);
577
564
 
578
- if (msg.type === 'plan_announced' && msg.items) {
579
- withTypingMessage((m) => {
580
- if (!m.planItems) m.planItems = msg.items as PlanItem[];
581
- });
565
+ handler = (msg: WebSocketMessage) => {
566
+ if (settled) return;
582
567
 
583
- return;
584
- }
568
+ try {
569
+ if (msg.buildId !== aiThreadStore.buildId) return;
585
570
 
586
- if (msg.type === 'item_complete' && msg.itemId) {
587
- const itemId = msg.itemId;
571
+ if (isStopped.value) {
572
+ settled = true;
573
+ clearTimeout(timeout);
574
+ finishBuild();
575
+ resolve({ text: null });
588
576
 
589
- withTypingMessage((m) => {
590
- if (!m.completedItemIds?.includes(itemId)) {
591
- m.completedItemIds = [
592
- ...(m.completedItemIds ?? []),
593
- itemId,
594
- ];
595
- }
596
- });
577
+ return;
578
+ }
597
579
 
598
- return;
599
- }
580
+ if (msg.type === 'chat_started' && msg.message) {
581
+ withTypingMessage((m) => {
582
+ m.initialMessage = msg.message;
583
+ });
600
584
 
601
- if (msg.type === 'server_response') {
602
- const toolCalls = (msg.toolCalls ||
603
- []) as AiAssistantToolCall[];
604
- const aiResponse: AiAssistantResponse = {
605
- threadId: aiThreadStore.threadId || '',
606
- toolCalls,
607
- message: msg.message || null,
608
- type: 'tool_calls',
609
- totalPaidToolCalls: 0,
610
- timestamp: Date.now(),
611
- };
612
-
613
- (async () => {
614
- try {
615
- // No tool calls = build cycle complete (success, max retries, or no retryable sections)
616
- if (toolCalls.length === 0) {
617
- // Defence-in-depth: a server_response with no toolCalls AND
618
- // no message text is a degenerate response — it means the
619
- // backend graph reached END without producing anything
620
- // actionable. The server-side fix in stream_with_push now
621
- // converts this to a build_error frame, but if a future
622
- // regression slips through we must NOT show "Your website
623
- // has been updated" — that hides real failures from users
624
- // and from monitoring.
625
- const hasMeaningfulMessage = Boolean(
626
- aiResponse.message || lastAiMessage,
627
- );
585
+ return;
586
+ }
628
587
 
629
- if (!hasMeaningfulMessage) {
630
- raygunUtil.safeSendRaygunError(
631
- new Error(
632
- 'AI build server_response had empty toolCalls and empty message',
633
- ),
634
- {
635
- tags: [
636
- 'feature:ai-website-builder',
637
- 'failure:degenerate_server_response',
638
- ],
639
- customData: {
640
- build_id: aiThreadStore.buildId ?? null,
641
- thread_id: aiThreadStore.threadId ?? null,
642
- },
643
- },
644
- );
645
- settled = true;
646
- clearTimeout(timeout);
647
- finishBuild();
648
- resolve({
649
- text: 'Something went wrong while updating your website. Please try again.',
650
- isError: true,
651
- });
652
-
653
- return;
654
- }
588
+ if (msg.type === 'plan_announced' && msg.items) {
589
+ withTypingMessage((m) => {
590
+ if (!m.planItems) m.planItems = msg.items as PlanItem[];
591
+ });
655
592
 
656
- settled = true;
657
- clearTimeout(timeout);
658
- finishBuild();
659
- await snapshotStore.refreshSnapshotAsync();
660
- resolve({
661
- text: aiResponse.message || lastAiMessage || '',
662
- });
593
+ return;
594
+ }
663
595
 
664
- return;
665
- }
596
+ if (msg.type === 'item_complete' && msg.itemId) {
597
+ const itemId = msg.itemId;
666
598
 
667
- // Tool calls present — apply locally and submit results back
668
- const { toolResults, aiMessage } =
669
- await applyToolCallsAsync(
670
- aiResponse,
671
- userMessageId,
672
- vacantSlots,
673
- );
599
+ withTypingMessage((m) => {
600
+ if (!m.completedItemIds?.includes(itemId)) {
601
+ m.completedItemIds = [...(m.completedItemIds ?? []), itemId];
602
+ }
603
+ });
674
604
 
675
- lastAiMessage = aiMessage;
605
+ return;
606
+ }
676
607
 
677
- // Submit all tool results (success + failure) so the AI pipeline
678
- // persists ToolMessages matching every tool_call in the conversation.
679
- const failedResults = toolResults.filter(
680
- (tr) => tr.success !== 'success',
681
- );
608
+ if (msg.type === 'server_response') {
609
+ // CTA buttons (e.g. Upgrade) ride in toolCalls alongside page
610
+ // mutations, but they are presentation, not page edits. Split them
611
+ // so only real mutations reach the metadata-builder and the tool-
612
+ // result submission — a UI action must never be answered with a tool
613
+ // result (it isn't in the agent's conversation), or the next turn fails.
614
+ const { mutationToolCalls, actions: extractedActions } =
615
+ partitionAiToolCalls(
616
+ (msg.toolCalls || []) as AiAssistantToolCall[],
617
+ );
682
618
 
683
- aiLogger.log('tool submission for results', {
684
- total: toolResults.length,
685
- failed: failedResults.length,
686
- failedResults,
687
- retryCount,
688
- });
619
+ if (extractedActions.length) {
620
+ lastActions = extractedActions;
621
+ }
689
622
 
690
- const submitResult =
691
- await client.submitToolResultsBuildAsync(
692
- aiThreadStore.threadId!,
623
+ const toolCalls = mutationToolCalls;
624
+ const aiResponse: AiAssistantResponse = {
625
+ threadId: aiThreadStore.threadId || '',
626
+ toolCalls,
627
+ message: msg.message || null,
628
+ type: 'tool_calls',
629
+ totalPaidToolCalls: 0,
630
+ timestamp: Date.now(),
631
+ };
632
+
633
+ (async () => {
634
+ try {
635
+ // No tool calls = build cycle complete (success, max retries, or no retryable sections)
636
+ if (toolCalls.length === 0) {
637
+ // Defence-in-depth: a server_response with no toolCalls AND
638
+ // no message text is a degenerate response — it means the
639
+ // backend graph reached END without producing anything
640
+ // actionable. The server-side fix in stream_with_push now
641
+ // converts this to a build_error frame, but if a future
642
+ // regression slips through we must NOT show "Your website
643
+ // has been updated" — that hides real failures from users
644
+ // and from monitoring.
645
+ const hasMeaningfulMessage = Boolean(
646
+ aiResponse.message || lastAiMessage,
647
+ );
648
+
649
+ if (!hasMeaningfulMessage) {
650
+ raygunUtil.safeSendRaygunError(
651
+ new Error(
652
+ 'AI build server_response had empty toolCalls and empty message',
653
+ ),
693
654
  {
694
- toolCalls: toolResults,
695
- agentType: AI_ASSISTANT_AGENT_TYPES.WEBSITE_BUILDER,
696
- connectionId,
697
- retryCount,
698
- userPlan,
655
+ tags: [
656
+ 'feature:ai-website-builder',
657
+ 'failure:degenerate_server_response',
658
+ ],
659
+ customData: {
660
+ build_id: aiThreadStore.buildId ?? null,
661
+ thread_id: aiThreadStore.threadId ?? null,
662
+ },
699
663
  },
700
664
  );
701
-
702
- if (failedResults.length === 0) {
703
665
  settled = true;
704
666
  clearTimeout(timeout);
705
667
  finishBuild();
706
668
  resolve({
707
- text: aiMessage || 'Your website has been updated.',
669
+ text: 'Something went wrong while updating your website. Please try again.',
670
+ isError: true,
708
671
  });
709
672
 
710
673
  return;
711
674
  }
712
675
 
713
- // Update buildId so the handler matches subsequent WS messages
714
- if (submitResult.buildId) {
715
- aiThreadStore.buildId = submitResult.buildId;
716
- }
676
+ settled = true;
677
+ clearTimeout(timeout);
678
+ finishBuild();
679
+ await snapshotStore.refreshSnapshotAsync();
680
+ resolve({
681
+ text: aiResponse.message || lastAiMessage || '',
682
+ actions: lastActions,
683
+ });
717
684
 
718
- // eslint-disable-next-line no-plusplus
719
- retryCount++;
720
- } catch (err) {
721
- aiLogger.log('server_response apply error', { err });
722
- // Client-side apply failure (metadata builder, tool-call parser,
723
- // missing field, etc.) — server thinks the build succeeded but we
724
- // couldn't materialise the changes. Mark the chat bubble as an
725
- // error so the user sees the real outcome, and report to Raygun
726
- // so the failure is visible in monitoring (the server didn't see it).
727
- raygunUtil.safeSendRaygunError(
728
- err instanceof Error
729
- ? err
730
- : new Error('AI apply failed: non-Error thrown'),
731
- {
732
- tags: [
733
- 'feature:ai-website-builder',
734
- 'failure:apply_error',
735
- 'stage:client_apply',
736
- ],
737
- customData: {
738
- thread_id: aiThreadStore.threadId ?? null,
739
- build_id: aiThreadStore.buildId ?? null,
740
- },
741
- },
742
- );
685
+ return;
686
+ }
687
+
688
+ // Tool calls present — apply locally and submit results back
689
+ const { toolResults, aiMessage } = await applyToolCallsAsync(
690
+ aiResponse,
691
+ userMessageId,
692
+ vacantSlots,
693
+ );
694
+
695
+ lastAiMessage = aiMessage;
696
+
697
+ // Submit all tool results (success + failure) so the AI pipeline
698
+ // persists ToolMessages matching every tool_call in the conversation.
699
+ const failedResults = toolResults.filter(
700
+ (tr) => tr.success !== 'success',
701
+ );
702
+
703
+ aiLogger.log('tool submission for results', {
704
+ total: toolResults.length,
705
+ failed: failedResults.length,
706
+ failedResults,
707
+ retryCount,
708
+ });
709
+
710
+ const submitResult = await client.submitToolResultsBuildAsync(
711
+ aiThreadStore.threadId!,
712
+ {
713
+ toolCalls: toolResults,
714
+ agentType: AI_ASSISTANT_AGENT_TYPES.WEBSITE_BUILDER,
715
+ connectionId,
716
+ retryCount,
717
+ userPlan,
718
+ },
719
+ );
720
+
721
+ if (failedResults.length === 0) {
743
722
  settled = true;
744
723
  clearTimeout(timeout);
745
724
  finishBuild();
746
725
  resolve({
747
- text: "I couldn't apply those changes to your website. Please try again.",
748
- isError: true,
726
+ text: aiMessage || 'Your website has been updated.',
727
+ actions: lastActions,
749
728
  });
729
+
730
+ return;
750
731
  }
751
- })();
752
732
 
753
- return;
754
- }
733
+ // Update buildId so the handler matches subsequent WS messages
734
+ if (submitResult.buildId) {
735
+ aiThreadStore.buildId = submitResult.buildId;
736
+ }
755
737
 
756
- if (msg.type === 'server_error' || msg.type === 'build_error') {
757
- settled = true;
758
- clearTimeout(timeout);
759
- finishBuild();
760
-
761
- // Backend already reports the underlying pipeline failure to
762
- // Raygun via its structured handler (stage:run_build /
763
- // stage:section_builder / etc. with full Python traceback).
764
- // We report the frontend's RECEIPT of the error frame as a
765
- // separate signal — distinct tag, distinct grouping. This
766
- // gives triangulation: both sides have entry → normal crash;
767
- // frontend only → backend Raygun outage; backend only → WS
768
- // frame didn't reach client (different bug shape).
769
- const wsMsg = msg as {
770
- type: string;
771
- code?: string;
772
- message?: string;
773
- error?: string;
774
- buildId?: string;
775
- };
776
-
777
- raygunUtil.safeSendRaygunError(
778
- new Error(
779
- `AI build ${wsMsg.type}: ${wsMsg.code ?? wsMsg.error ?? 'unknown'}`,
780
- ),
781
- {
782
- tags: [
783
- 'feature:ai-website-builder',
784
- 'failure:websocket_error_received',
785
- `frame_type:${wsMsg.type}`,
786
- ],
787
- customData: {
788
- code: wsMsg.code ?? null,
789
- message: wsMsg.message ?? null,
790
- error: wsMsg.error ?? null,
791
- build_id: wsMsg.buildId ?? null,
792
- thread_id: aiThreadStore.threadId ?? null,
738
+ // eslint-disable-next-line no-plusplus
739
+ retryCount++;
740
+ } catch (err) {
741
+ aiLogger.log('server_response apply error', { err });
742
+ // Client-side apply failure (metadata builder, tool-call parser,
743
+ // missing field, etc.) — server thinks the build succeeded but we
744
+ // couldn't materialise the changes. Mark the chat bubble as an
745
+ // error so the user sees the real outcome, and report to Raygun
746
+ // so the failure is visible in monitoring (the server didn't see it).
747
+ raygunUtil.safeSendRaygunError(
748
+ err instanceof Error
749
+ ? err
750
+ : new Error('AI apply failed: non-Error thrown'),
751
+ {
752
+ tags: [
753
+ 'feature:ai-website-builder',
754
+ 'failure:apply_error',
755
+ 'stage:client_apply',
756
+ ],
757
+ customData: {
758
+ thread_id: aiThreadStore.threadId ?? null,
759
+ build_id: aiThreadStore.buildId ?? null,
760
+ },
793
761
  },
762
+ );
763
+ settled = true;
764
+ clearTimeout(timeout);
765
+ finishBuild();
766
+ resolve({
767
+ text: "I couldn't apply those changes to your website. Please try again.",
768
+ isError: true,
769
+ });
770
+ }
771
+ })();
772
+
773
+ return;
774
+ }
775
+
776
+ if (msg.type === 'server_error' || msg.type === 'build_error') {
777
+ settled = true;
778
+ clearTimeout(timeout);
779
+ finishBuild();
780
+
781
+ // Backend already reports the underlying pipeline failure to
782
+ // Raygun via its structured handler (stage:run_build /
783
+ // stage:section_builder / etc. with full Python traceback).
784
+ // We report the frontend's RECEIPT of the error frame as a
785
+ // separate signal — distinct tag, distinct grouping. This
786
+ // gives triangulation: both sides have entry → normal crash;
787
+ // frontend only → backend Raygun outage; backend only → WS
788
+ // frame didn't reach client (different bug shape).
789
+ const wsMsg = msg as {
790
+ type: string;
791
+ code?: string;
792
+ message?: string;
793
+ error?: string;
794
+ buildId?: string;
795
+ };
796
+
797
+ raygunUtil.safeSendRaygunError(
798
+ new Error(
799
+ `AI build ${wsMsg.type}: ${wsMsg.code ?? wsMsg.error ?? 'unknown'}`,
800
+ ),
801
+ {
802
+ tags: [
803
+ 'feature:ai-website-builder',
804
+ 'failure:websocket_error_received',
805
+ `frame_type:${wsMsg.type}`,
806
+ ],
807
+ customData: {
808
+ code: wsMsg.code ?? null,
809
+ message: wsMsg.message ?? null,
810
+ error: wsMsg.error ?? null,
811
+ build_id: wsMsg.buildId ?? null,
812
+ thread_id: aiThreadStore.threadId ?? null,
794
813
  },
795
- );
814
+ },
815
+ );
796
816
 
797
- resolve({ text: pickWsErrorMessage(msg), isError: true });
817
+ resolve({ text: pickWsErrorMessage(msg), isError: true });
798
818
 
799
- return;
800
- }
801
- } catch (err) {
802
- aiLogger.log('Unexpected error in WS message handler', {
803
- err,
804
- type: msg.type,
819
+ return;
820
+ }
821
+ } catch (err) {
822
+ aiLogger.log('Unexpected error in WS message handler', {
823
+ err,
824
+ type: msg.type,
825
+ });
826
+
827
+ if (!settled) {
828
+ settled = true;
829
+ clearTimeout(timeout);
830
+ finishBuild();
831
+ resolve({
832
+ text: 'An error occurred during the build.',
833
+ isError: true,
805
834
  });
806
-
807
- if (!settled) {
808
- settled = true;
809
- clearTimeout(timeout);
810
- finishBuild();
811
- resolve({ text: 'An error occurred during the build.' });
812
- }
813
835
  }
814
- };
836
+ }
837
+ };
815
838
 
816
- wsClient.onMessage(handler);
817
- },
818
- );
839
+ wsClient.onMessage(handler);
840
+ });
819
841
  } catch (err) {
820
842
  aiThreadStore.isBuildInProgress = false;
821
843
  wsClient.setBuildActive(false);
@@ -896,6 +918,18 @@ export function useAiWebsiteBuilderChat(): UseAiChatResult {
896
918
  if (result.isError) {
897
919
  threadItems.value[messageIndex].isError = true;
898
920
  }
921
+
922
+ // Attach agent-driven actions (e.g. upgrade CTA) only on successful
923
+ // (non-error) responses. Suppressed for premium users client-side as
924
+ // a defence-in-depth guard (server also vetoes via eligibility logic).
925
+ if (
926
+ !result.isError &&
927
+ result.actions?.length &&
928
+ !userStore.hasPremiumSubscription
929
+ ) {
930
+ (threadItems.value[messageIndex] as TextThreadMessage).actions =
931
+ result.actions;
932
+ }
899
933
  } else {
900
934
  threadItems.value[messageIndex].text =
901
935
  'Failed to apply changes. Please try again.';
@@ -997,6 +1031,11 @@ export function useAiWebsiteBuilderChat(): UseAiChatResult {
997
1031
  completedItemIds:
998
1032
  (msg as TextThreadMessage).completedItemIds ?? [],
999
1033
  }),
1034
+ ...(msg.type === 'text' &&
1035
+ !msg.isTyping &&
1036
+ (msg as TextThreadMessage).actions?.length && {
1037
+ actions: (msg as TextThreadMessage).actions,
1038
+ }),
1000
1039
  } as Record<string, unknown>,
1001
1040
  };
1002
1041
  });
@@ -99,6 +99,7 @@ export const UPGRADE_CTA_LOCATIONS = {
99
99
 
100
100
  export const AI_CTA_LOCATIONS = {
101
101
  AI_BUILDER_TAB: 'ai_builder_tab',
102
+ AI_BUILDER_CHAT_UPSELL: 'ai_builder_chat_upsell',
102
103
  };
103
104
 
104
105
  export const TRIGGER_TYPE = {
@@ -12,6 +12,8 @@
12
12
  "modernDisplayName": "modern",
13
13
  "uniqueDisplayName": "einzigartig",
14
14
  "allFontStylesDisplayName": "Alle Schriftstile",
15
+ "searchFontsPlaceholder": "Schriftarten durchsuchen",
16
+ "noFontsFoundMessage": "Keine Schriftarten gefunden",
15
17
  "settingsSaveSuccessMessage": "Einstellungen wurden erfolgreich gespeichert"
16
18
  }
17
19
  }
@@ -12,6 +12,8 @@
12
12
  "modernDisplayName": "moderna",
13
13
  "uniqueDisplayName": "única",
14
14
  "allFontStylesDisplayName": "Todos los estilos de fuente",
15
+ "searchFontsPlaceholder": "Busca fuentes",
16
+ "noFontsFoundMessage": "No se encontraron fuentes",
15
17
  "settingsSaveSuccessMessage": "La configuración se ha guardado correctamente"
16
18
  }
17
19
  }
@@ -12,6 +12,8 @@
12
12
  "modernDisplayName": "Moderne",
13
13
  "uniqueDisplayName": "Unique",
14
14
  "allFontStylesDisplayName": "Tous les styles de police",
15
+ "searchFontsPlaceholder": "Rechercher des polices",
16
+ "noFontsFoundMessage": "Aucune police trouvée",
15
17
  "settingsSaveSuccessMessage": "Paramètres enregistrés avec succès"
16
18
  }
17
19
  }