@agentiffai/design 1.3.6 → 1.3.8

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.
@@ -1,7 +1,8 @@
1
1
  import { useButton } from '@react-aria/button';
2
- import { memo, useState, useRef, useEffect, useCallback } from 'react';
3
- import styled4, { css, keyframes, createGlobalStyle } from 'styled-components';
2
+ import { memo, useRef, useEffect, useState, useMemo, useCallback } from 'react';
3
+ import styled8, { css, keyframes, createGlobalStyle } from 'styled-components';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
+ import { useCopilotChat } from '@copilotkit/react-core';
5
6
  import { CopilotSidebar, useChatContext } from '@copilotkit/react-ui';
6
7
  import { useTextField } from '@react-aria/textfield';
7
8
 
@@ -245,7 +246,7 @@ var sizeStyles = {
245
246
  height: 44px;
246
247
  `
247
248
  };
248
- var StyledButton = styled4.button`
249
+ var StyledButton = styled8.button`
249
250
  /* Base styles */
250
251
  display: inline-flex;
251
252
  align-items: center;
@@ -328,7 +329,7 @@ function Button({
328
329
  );
329
330
  }
330
331
  Button.displayName = "Button";
331
- var ActionsContainer = styled4.div`
332
+ var ActionsContainer = styled8.div`
332
333
  display: flex;
333
334
  gap: ${tokens.spacing.sm};
334
335
  align-items: center;
@@ -388,7 +389,7 @@ var blink = keyframes`
388
389
  opacity: 0;
389
390
  }
390
391
  `;
391
- var ResponseContainer = styled4.div`
392
+ var ResponseContainer = styled8.div`
392
393
  display: inline-flex;
393
394
  align-items: center;
394
395
  gap: ${tokens.spacing.sm};
@@ -400,13 +401,13 @@ var ResponseContainer = styled4.div`
400
401
  max-width: fit-content;
401
402
  margin: 0 auto;
402
403
  `;
403
- var LoadingDots = styled4.div`
404
+ var LoadingDots = styled8.div`
404
405
  display: flex;
405
406
  align-items: center;
406
407
  gap: ${tokens.spacing.xs};
407
408
  padding: 0 ${tokens.spacing.xs};
408
409
  `;
409
- var Dot = styled4.span`
410
+ var Dot = styled8.span`
410
411
  width: ${tokens.spacing.xs};
411
412
  height: ${tokens.spacing.xs};
412
413
  border-radius: ${tokens.borderRadius.full};
@@ -414,7 +415,7 @@ var Dot = styled4.span`
414
415
  animation: ${dotPulse} 1.4s ease-in-out infinite;
415
416
  animation-delay: ${(props) => props.delay}s;
416
417
  `;
417
- var TypingIndicator = styled4.div`
418
+ var TypingIndicator = styled8.div`
418
419
  display: flex;
419
420
  align-items: center;
420
421
  gap: ${tokens.spacing.xs};
@@ -427,14 +428,14 @@ var TypingIndicator = styled4.div`
427
428
  animation: ${dotPulse} 1.4s ease-in-out infinite;
428
429
  }
429
430
  `;
430
- var Message = styled4.span`
431
+ var Message = styled8.span`
431
432
  font-size: ${tokens.typography.fontSize.sm};
432
433
  color: ${tokens.colors.text.primary};
433
434
  font-weight: ${tokens.typography.fontWeight.regular};
434
435
  line-height: ${tokens.typography.lineHeight.normal};
435
436
  white-space: nowrap;
436
437
  `;
437
- var StreamingText = styled4.div`
438
+ var StreamingText = styled8.div`
438
439
  font-size: ${tokens.typography.fontSize.sm};
439
440
  line-height: ${tokens.typography.lineHeight.normal};
440
441
  color: ${tokens.colors.text.primary};
@@ -506,7 +507,7 @@ var shake = keyframes`
506
507
  transform: translateX(5px);
507
508
  }
508
509
  `;
509
- var AgentStateContainer = styled4.div`
510
+ var AgentStateContainer = styled8.div`
510
511
  display: inline-flex;
511
512
  flex-direction: column;
512
513
  align-items: center;
@@ -520,35 +521,35 @@ var AgentStateContainer = styled4.div`
520
521
  max-width: fit-content;
521
522
  margin: 0 auto;
522
523
  `;
523
- var StateContent = styled4.div`
524
+ var StateContent = styled8.div`
524
525
  display: flex;
525
526
  flex-direction: column;
526
527
  gap: ${tokens.spacing.sm};
527
528
  align-items: center;
528
529
  width: 100%;
529
530
  `;
530
- var IdleIndicator = styled4.div`
531
+ var IdleIndicator = styled8.div`
531
532
  width: ${tokens.spacing.xs};
532
533
  height: ${tokens.spacing.xs};
533
534
  background-color: ${tokens.colors.status.idle};
534
535
  border-radius: ${tokens.borderRadius.full};
535
536
  animation: ${dotPulse2} 2s infinite ease-in-out;
536
537
  `;
537
- var ErrorIndicator = styled4.div`
538
+ var ErrorIndicator = styled8.div`
538
539
  width: ${tokens.spacing.xs};
539
540
  height: ${tokens.spacing.xs};
540
541
  background-color: ${tokens.colors.error};
541
542
  border-radius: ${tokens.borderRadius.full};
542
543
  animation: ${shake} 0.5s ease-in-out;
543
544
  `;
544
- var StateLabel = styled4.span`
545
+ var StateLabel = styled8.span`
545
546
  font-size: ${tokens.typography.fontSize.sm};
546
547
  font-weight: ${tokens.typography.fontWeight.regular};
547
548
  color: ${tokens.colors.text.primary};
548
549
  line-height: ${tokens.typography.lineHeight.normal};
549
550
  white-space: nowrap;
550
551
  `;
551
- styled4.p`
552
+ styled8.p`
552
553
  font-size: ${tokens.typography.fontSize.sm};
553
554
  color: ${tokens.colors.text.tertiary};
554
555
  line-height: ${tokens.typography.lineHeight.normal};
@@ -556,7 +557,7 @@ styled4.p`
556
557
  text-align: center;
557
558
  white-space: nowrap;
558
559
  `;
559
- var ProgressBar = styled4.div`
560
+ var ProgressBar = styled8.div`
560
561
  width: 100%;
561
562
  height: ${tokens.spacing.xs};
562
563
  background-color: ${tokens.colors.surface.elevated};
@@ -564,7 +565,7 @@ var ProgressBar = styled4.div`
564
565
  overflow: hidden;
565
566
  margin-top: ${tokens.spacing.xs};
566
567
  `;
567
- var ProgressBarFill = styled4.div`
568
+ var ProgressBarFill = styled8.div`
568
569
  height: 100%;
569
570
  width: ${(props) => Math.min(Math.max(props.progress, 0), 100)}%;
570
571
  background: linear-gradient(135deg, ${tokens.colors.accent} 0%, ${tokens.colors.primary} 100%);
@@ -593,11 +594,11 @@ var AgentState = ({ state, message, progress, className }) => {
593
594
  }
594
595
  return null;
595
596
  };
596
- var Container = styled4.div`
597
+ var Container = styled8.div`
597
598
  margin: ${tokens.spacing.sm} 0;
598
599
  padding: 0 ${tokens.spacing.sm};
599
600
  `;
600
- var ToolName = styled4.div`
601
+ var ToolName = styled8.div`
601
602
  font-size: ${tokens.typography.fontSize.xs};
602
603
  color: ${tokens.colors.text.tertiary};
603
604
  margin-bottom: ${tokens.spacing.xs};
@@ -704,7 +705,7 @@ var getSizeValue = (size = "md") => {
704
705
  };
705
706
  }
706
707
  };
707
- var Container2 = styled4.div`
708
+ var Container2 = styled8.div`
708
709
  display: inline-flex;
709
710
  align-items: center;
710
711
  gap: ${tokens.spacing.md};
@@ -716,7 +717,7 @@ var Container2 = styled4.div`
716
717
  max-width: fit-content;
717
718
  margin: 0 auto;
718
719
  `;
719
- var Avatar = styled4.div`
720
+ var Avatar = styled8.div`
720
721
  width: ${(props) => getSizeValue(props.size).avatar};
721
722
  height: ${(props) => getSizeValue(props.size).avatar};
722
723
  border-radius: ${tokens.borderRadius.full};
@@ -727,23 +728,23 @@ var Avatar = styled4.div`
727
728
  flex-shrink: 0;
728
729
  box-shadow: ${tokens.shadows.glow.primary};
729
730
  `;
730
- var HeadphonesIcon = styled4.svg`
731
+ var HeadphonesIcon = styled8.svg`
731
732
  width: ${(props) => getSizeValue(props.size).icon};
732
733
  height: ${(props) => getSizeValue(props.size).icon};
733
734
  color: ${tokens.colors.text.primary};
734
735
  `;
735
- var Content = styled4.div`
736
+ var Content = styled8.div`
736
737
  display: flex;
737
738
  align-items: center;
738
739
  gap: ${tokens.spacing.sm};
739
740
  `;
740
- var LoadingDots2 = styled4.div`
741
+ var LoadingDots2 = styled8.div`
741
742
  display: flex;
742
743
  align-items: center;
743
744
  gap: ${(props) => props.variant === "wave" ? "2px" : `${tokens.spacing.xs}`};
744
745
  padding: 0 ${tokens.spacing.xs};
745
746
  `;
746
- var Dot2 = styled4.span`
747
+ var Dot2 = styled8.span`
747
748
  width: ${(props) => getSizeValue(props.size).dotSize};
748
749
  height: ${(props) => getSizeValue(props.size).dotSize};
749
750
  border-radius: ${tokens.borderRadius.full};
@@ -761,7 +762,7 @@ var Dot2 = styled4.span`
761
762
  }}
762
763
  1.4s ease-in-out infinite;
763
764
  `;
764
- var Message2 = styled4.span`
765
+ var Message2 = styled8.span`
765
766
  font-size: ${(props) => getSizeValue(props.size).fontSize};
766
767
  color: ${tokens.colors.text.secondary};
767
768
  font-weight: ${tokens.typography.fontWeight.regular};
@@ -821,7 +822,7 @@ function AssistantThinking({
821
822
  );
822
823
  }
823
824
  AssistantThinking.displayName = "AssistantThinking";
824
- var Container3 = styled4.div`
825
+ var Container3 = styled8.div`
825
826
  font-family: ${(props) => props.$variant === "code" ? tokens.typography.fontFamily.monospace : tokens.typography.fontFamily.primary};
826
827
  white-space: pre-wrap;
827
828
  word-break: break-word;
@@ -830,7 +831,7 @@ var Container3 = styled4.div`
830
831
  text-rendering: optimizeSpeed;
831
832
  contain: content;
832
833
  `;
833
- var Cursor = styled4.span`
834
+ var Cursor = styled8.span`
834
835
  display: inline-block;
835
836
  width: 2px;
836
837
  height: 1em;
@@ -854,17 +855,15 @@ var StreamingTextBase = ({
854
855
  content,
855
856
  isStreaming = false,
856
857
  typingSpeed: _typingSpeed = 50,
857
- // Not used - streaming shows chunks as they arrive
858
+ // Reserved for future use
858
859
  cursor = true,
859
860
  variant = "default",
860
861
  onStreamComplete,
861
862
  className
862
863
  }) => {
863
- const [displayedText, setDisplayedText] = useState(content);
864
864
  const wasStreamingRef = useRef(isStreaming);
865
865
  const completionCalledRef = useRef(false);
866
866
  useEffect(() => {
867
- setDisplayedText(content);
868
867
  if (wasStreamingRef.current && !isStreaming && !completionCalledRef.current) {
869
868
  completionCalledRef.current = true;
870
869
  onStreamComplete?.();
@@ -873,45 +872,48 @@ var StreamingTextBase = ({
873
872
  completionCalledRef.current = false;
874
873
  }
875
874
  wasStreamingRef.current = isStreaming;
876
- }, [content, isStreaming, onStreamComplete]);
875
+ }, [isStreaming, onStreamComplete]);
877
876
  const showCursor = isStreaming && cursor;
878
877
  return /* @__PURE__ */ jsxs(Container3, { $variant: variant, className, children: [
879
- displayedText,
878
+ content,
880
879
  showCursor && /* @__PURE__ */ jsx(Cursor, {})
881
880
  ] });
882
881
  };
883
882
  var StreamingText2 = memo(StreamingTextBase);
884
883
  StreamingText2.displayName = "StreamingText";
885
- var MessageContainer = styled4.div`
884
+ var MessageContainer = styled8.div`
886
885
  display: flex;
887
- gap: ${tokens.spacing.sm};
888
- align-items: flex-start;
889
- padding: ${tokens.spacing.sm} 0;
886
+ flex-direction: column;
887
+ gap: ${tokens.spacing.xs};
888
+ padding: ${tokens.spacing.xs} 0;
890
889
  max-width: 100%;
891
890
  /* GPU acceleration hint for smooth rendering during streaming */
892
891
  will-change: contents;
893
892
  contain: content;
894
893
  `;
895
- var AvatarContainer = styled4.div`
894
+ var AvatarContainer = styled8.div`
895
+ display: flex;
896
+ align-items: center;
897
+ gap: ${tokens.spacing.xs};
896
898
  flex-shrink: 0;
897
899
  `;
898
- var Avatar2 = styled4.img`
899
- width: ${tokens.spacing.xl};
900
- height: ${tokens.spacing.xl};
900
+ var Avatar2 = styled8.img`
901
+ width: 20px;
902
+ height: 20px;
901
903
  border-radius: ${tokens.borderRadius.full};
902
904
  object-fit: cover;
903
905
  background-color: transparent;
904
906
  `;
905
- var AvatarInitials = styled4.div`
906
- width: ${tokens.spacing.xl};
907
- height: ${tokens.spacing.xl};
907
+ var AvatarInitials = styled8.div`
908
+ width: 20px;
909
+ height: 20px;
908
910
  border-radius: ${tokens.borderRadius.full};
909
911
  overflow: hidden;
910
912
  display: flex;
911
913
  align-items: center;
912
914
  justify-content: center;
913
915
  background-color: ${tokens.colors.secondary};
914
- padding: ${tokens.spacing.xs};
916
+ padding: 2px;
915
917
  box-sizing: border-box;
916
918
 
917
919
  img {
@@ -920,16 +922,20 @@ var AvatarInitials = styled4.div`
920
922
  object-fit: contain;
921
923
  }
922
924
  `;
923
- var ContentContainer = styled4.div`
924
- flex: 1;
925
+ var AvatarLabel = styled8.span`
926
+ font-size: ${tokens.typography.fontSize.xs};
927
+ font-weight: ${tokens.typography.fontWeight.medium};
928
+ color: ${tokens.colors.text.secondary};
929
+ `;
930
+ var ContentContainer = styled8.div`
931
+ width: 100%;
925
932
  min-width: 0;
926
933
  `;
927
- var MessageContent = styled4.div`
934
+ var MessageContent = styled8.div`
928
935
  /* Use solid color instead of backdrop-filter for performance during streaming */
929
936
  background-color: ${tokens.colors.surface.elevated};
930
- padding: ${tokens.spacing.sm} ${tokens.spacing.md};
937
+ padding: ${tokens.spacing.sm};
931
938
  border-radius: ${tokens.borderRadius.lg};
932
- border-top-left-radius: ${tokens.borderRadius.sm};
933
939
  color: ${tokens.colors.text.primary};
934
940
  font-size: ${tokens.typography.fontSize.sm};
935
941
  line-height: ${tokens.typography.lineHeight.normal};
@@ -939,14 +945,13 @@ var MessageContent = styled4.div`
939
945
  /* Optimize text rendering */
940
946
  text-rendering: optimizeSpeed;
941
947
  `;
942
- var LoadingDots3 = styled4.div`
948
+ var LoadingDots3 = styled8.div`
943
949
  display: flex;
944
950
  gap: ${tokens.spacing.xs};
945
- padding: ${tokens.spacing.sm} ${tokens.spacing.md};
951
+ padding: ${tokens.spacing.sm};
946
952
  /* Use solid color instead of backdrop-filter for performance */
947
953
  background-color: ${tokens.colors.surface.elevated};
948
954
  border-radius: ${tokens.borderRadius.lg};
949
- border-top-left-radius: ${tokens.borderRadius.sm};
950
955
  width: fit-content;
951
956
  `;
952
957
  var pulse2 = keyframes`
@@ -957,7 +962,7 @@ var pulse2 = keyframes`
957
962
  opacity: 1;
958
963
  }
959
964
  `;
960
- var LoadingDot = styled4.div`
965
+ var LoadingDot = styled8.div`
961
966
  width: ${tokens.spacing.sm};
962
967
  height: ${tokens.spacing.sm};
963
968
  border-radius: ${tokens.borderRadius.full};
@@ -966,7 +971,7 @@ var LoadingDot = styled4.div`
966
971
  animation: ${pulse2} 1.4s ease-in-out infinite;
967
972
  animation-delay: ${(props) => props.delay}s;
968
973
  `;
969
- var FileAttachmentContainer = styled4.div`
974
+ var FileAttachmentContainer = styled8.div`
970
975
  display: flex;
971
976
  align-items: center;
972
977
  gap: ${tokens.spacing.sm};
@@ -1002,7 +1007,7 @@ var FileAttachmentContainer = styled4.div`
1002
1007
  }
1003
1008
  `}
1004
1009
  `;
1005
- var FileIconContainer = styled4.div`
1010
+ var FileIconContainer = styled8.div`
1006
1011
  flex-shrink: 0;
1007
1012
  width: ${tokens.spacing.xl};
1008
1013
  height: ${tokens.spacing.xl};
@@ -1012,14 +1017,14 @@ var FileIconContainer = styled4.div`
1012
1017
  font-size: ${tokens.typography.fontSize["2xl"]};
1013
1018
  line-height: 1;
1014
1019
  `;
1015
- var FileInfo = styled4.div`
1020
+ var FileInfo = styled8.div`
1016
1021
  flex: 1;
1017
1022
  min-width: 0;
1018
1023
  display: flex;
1019
1024
  flex-direction: column;
1020
1025
  gap: 2px;
1021
1026
  `;
1022
- var FileTitle = styled4.div`
1027
+ var FileTitle = styled8.div`
1023
1028
  font-size: ${tokens.typography.fontSize.sm};
1024
1029
  font-weight: ${tokens.typography.fontWeight.medium};
1025
1030
  color: ${tokens.colors.text.primary};
@@ -1029,7 +1034,7 @@ var FileTitle = styled4.div`
1029
1034
  text-overflow: ellipsis;
1030
1035
  white-space: nowrap;
1031
1036
  `;
1032
- var FileMetadata = styled4.div`
1037
+ var FileMetadata = styled8.div`
1033
1038
  display: flex;
1034
1039
  align-items: center;
1035
1040
  gap: ${tokens.spacing.xs};
@@ -1039,7 +1044,7 @@ var FileMetadata = styled4.div`
1039
1044
  line-height: ${tokens.typography.lineHeight.tight};
1040
1045
  overflow: hidden;
1041
1046
  `;
1042
- var FileSubtitle = styled4.span`
1047
+ var FileSubtitle = styled8.span`
1043
1048
  color: ${tokens.colors.text.tertiary};
1044
1049
  white-space: nowrap;
1045
1050
  overflow: hidden;
@@ -1095,13 +1100,13 @@ var FileAttachment = ({
1095
1100
  }
1096
1101
  );
1097
1102
  };
1098
- var AttachmentsContainer = styled4.div`
1103
+ var AttachmentsContainer = styled8.div`
1099
1104
  display: flex;
1100
1105
  flex-direction: column;
1101
1106
  gap: ${tokens.spacing.sm};
1102
1107
  margin-top: ${tokens.spacing.sm};
1103
1108
  `;
1104
- var ActionButton = styled4.button`
1109
+ var ActionButton = styled8.button`
1105
1110
  display: inline-flex;
1106
1111
  align-items: center;
1107
1112
  gap: ${tokens.spacing.xs};
@@ -1125,19 +1130,19 @@ var ActionButton = styled4.button`
1125
1130
  transform: scale(0.98);
1126
1131
  }
1127
1132
  `;
1128
- var ActionsContainer2 = styled4.div`
1133
+ var ActionsContainer2 = styled8.div`
1129
1134
  display: flex;
1130
1135
  gap: ${tokens.spacing.xs};
1131
1136
  flex-wrap: wrap;
1132
1137
  margin-top: ${tokens.spacing.sm};
1133
1138
  `;
1134
- var MessageTime = styled4.time`
1139
+ var MessageTime = styled8.time`
1135
1140
  font-size: ${tokens.typography.fontSize.xs};
1136
1141
  color: ${tokens.colors.text.tertiary};
1137
1142
  margin-top: ${tokens.spacing.xs};
1138
1143
  display: block;
1139
1144
  `;
1140
- var StreamingIndicator = styled4.span`
1145
+ var StreamingIndicator = styled8.span`
1141
1146
  display: inline-block;
1142
1147
  width: ${tokens.spacing.xs};
1143
1148
  height: ${tokens.spacing.xs};
@@ -1201,7 +1206,10 @@ var AssistantMessageBase = ({
1201
1206
  ] });
1202
1207
  };
1203
1208
  return /* @__PURE__ */ jsxs(MessageContainer, { className, children: [
1204
- /* @__PURE__ */ jsx(AvatarContainer, { children: avatarUrl ? /* @__PURE__ */ jsx(Avatar2, { src: avatarUrl, alt: "Assistant avatar" }) : /* @__PURE__ */ jsx(AvatarInitials, { children: /* @__PURE__ */ jsx(Avatar2, { src: "/assets/avatar-transparent-bg.png", alt: "AI Assistant" }) }) }),
1209
+ /* @__PURE__ */ jsxs(AvatarContainer, { children: [
1210
+ avatarUrl ? /* @__PURE__ */ jsx(Avatar2, { src: avatarUrl, alt: "Assistant avatar" }) : /* @__PURE__ */ jsx(AvatarInitials, { children: /* @__PURE__ */ jsx(Avatar2, { src: "/assets/avatar-transparent-bg.png", alt: "AI Assistant" }) }),
1211
+ /* @__PURE__ */ jsx(AvatarLabel, { children: "Assistant" })
1212
+ ] }),
1205
1213
  /* @__PURE__ */ jsx(ContentContainer, { children: renderContent() })
1206
1214
  ] });
1207
1215
  };
@@ -1211,7 +1219,78 @@ var TOOL_CALL_MARKER_REGEX = /<!--TOOL_CALL:([^:]+):(.+?)-->/g;
1211
1219
  function stripToolCallMarkers(content) {
1212
1220
  return content.replace(TOOL_CALL_MARKER_REGEX, "").trim();
1213
1221
  }
1214
- var GenerativeUIContainer = styled4.div`
1222
+ var ERROR_PATTERNS = [
1223
+ /\bfailed\b/i,
1224
+ /\berror\b/i,
1225
+ /\bunable to\b/i,
1226
+ /\bcouldn't\b/i,
1227
+ /\bcan't\b/i,
1228
+ /\bcannot\b/i,
1229
+ /\bsomething went wrong\b/i,
1230
+ /\btry again\b/i,
1231
+ /\bunexpected\b/i,
1232
+ /\btimed out\b/i,
1233
+ /\bconnection\b.*\b(lost|failed|refused)\b/i
1234
+ ];
1235
+ var CORRELATION_ID_PATTERNS = [
1236
+ /reference:\s*([a-f0-9-]+)/i,
1237
+ /correlation[_\s]?id:\s*([a-f0-9-]+)/i,
1238
+ /\[([a-f0-9]{8,})\]/i
1239
+ ];
1240
+ function inferErrorCategory(content) {
1241
+ const lowerContent = content.toLowerCase();
1242
+ if (lowerContent.includes("network") || lowerContent.includes("internet") || lowerContent.includes("connection") || lowerContent.includes("offline") || lowerContent.includes("timed out")) {
1243
+ return "Network";
1244
+ }
1245
+ if (lowerContent.includes("unauthorized") || lowerContent.includes("authentication") || lowerContent.includes("login") || lowerContent.includes("session expired") || lowerContent.includes("credentials")) {
1246
+ return "Auth";
1247
+ }
1248
+ if (lowerContent.includes("oauth") || lowerContent.includes("reconnect") || lowerContent.includes("authorization") || lowerContent.includes("token") && lowerContent.includes("expired")) {
1249
+ return "OAuth";
1250
+ }
1251
+ if (lowerContent.includes("workflow") || lowerContent.includes("execution") || lowerContent.includes("failed to start") || lowerContent.includes("automation")) {
1252
+ return "Workflow";
1253
+ }
1254
+ return "Unknown";
1255
+ }
1256
+ function extractCorrelationId(content) {
1257
+ for (const pattern of CORRELATION_ID_PATTERNS) {
1258
+ const match = content.match(pattern);
1259
+ if (match?.[1]) {
1260
+ return match[1];
1261
+ }
1262
+ }
1263
+ return void 0;
1264
+ }
1265
+ function detectErrorInMessage(content) {
1266
+ const hasError = ERROR_PATTERNS.some((pattern) => pattern.test(content));
1267
+ if (!hasError) {
1268
+ return { hasError: false };
1269
+ }
1270
+ return {
1271
+ hasError: true,
1272
+ category: inferErrorCategory(content),
1273
+ correlationId: extractCorrelationId(content),
1274
+ errorMessage: content
1275
+ };
1276
+ }
1277
+ function buildChatSnippet(messages, errorMessageContent, maxMessages = 5, maxLength = 1500) {
1278
+ const recentMessages = messages.filter((msg) => msg.content && msg.content !== errorMessageContent).slice(-maxMessages);
1279
+ const formattedMessages = recentMessages.map((msg) => {
1280
+ const role = msg.role === "user" ? "User" : "Assistant";
1281
+ const content = msg.content || "";
1282
+ const truncatedContent = content.length > 300 ? content.slice(0, 300) + "..." : content;
1283
+ return `[${role}]: ${truncatedContent}`;
1284
+ });
1285
+ const errorSnippet = errorMessageContent.length > 500 ? errorMessageContent.slice(0, 500) + "..." : errorMessageContent;
1286
+ formattedMessages.push(`[Assistant - Error]: ${errorSnippet}`);
1287
+ let result = formattedMessages.join("\n\n");
1288
+ if (result.length > maxLength) {
1289
+ result = result.slice(0, maxLength) + "\n...[truncated]";
1290
+ }
1291
+ return result;
1292
+ }
1293
+ var GenerativeUIContainer = styled8.div`
1215
1294
  margin-top: ${tokens.spacing.sm};
1216
1295
  margin-bottom: ${tokens.spacing.sm};
1217
1296
  `;
@@ -1260,7 +1339,142 @@ var AssistantMessageAdapterBase = ({
1260
1339
  };
1261
1340
  var AssistantMessageAdapter = memo(AssistantMessageAdapterBase);
1262
1341
  AssistantMessageAdapter.displayName = "AssistantMessageAdapter";
1263
- var ChatInputContainer = styled4.div`
1342
+ function createAssistantMessageAdapter(ThinkingIndicator, ToolCallsComponent) {
1343
+ const CustomAssistantMessageAdapter = ({
1344
+ message,
1345
+ isLoading,
1346
+ isGenerating,
1347
+ isCurrentMessage
1348
+ }) => {
1349
+ const showThinking = isLoading || isGenerating && !message?.content;
1350
+ const shouldShowToolCalls = isCurrentMessage && ToolCallsComponent;
1351
+ const rawContent = message?.content || "";
1352
+ const content = stripToolCallMarkers(rawContent);
1353
+ let generativeUIOutput = null;
1354
+ const msgWithUI = message;
1355
+ if (msgWithUI && typeof msgWithUI.generativeUI === "function") {
1356
+ try {
1357
+ generativeUIOutput = msgWithUI.generativeUI();
1358
+ } catch (e) {
1359
+ console.warn("[AssistantMessageAdapter] Error rendering generativeUI:", e);
1360
+ }
1361
+ }
1362
+ const attachments = [];
1363
+ if (showThinking) {
1364
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1365
+ ThinkingIndicator ? /* @__PURE__ */ jsx(ThinkingIndicator, { isLoading, isGenerating }) : /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." }),
1366
+ shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {})
1367
+ ] });
1368
+ }
1369
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1370
+ shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {}),
1371
+ generativeUIOutput && /* @__PURE__ */ jsx(GenerativeUIContainer, { children: generativeUIOutput }),
1372
+ content && /* @__PURE__ */ jsx(
1373
+ AssistantMessage,
1374
+ {
1375
+ content,
1376
+ avatarInitials: "AI",
1377
+ isLoading: false,
1378
+ isStreaming: isGenerating,
1379
+ attachments,
1380
+ enableMarkdown: true
1381
+ }
1382
+ )
1383
+ ] });
1384
+ };
1385
+ CustomAssistantMessageAdapter.displayName = "CustomAssistantMessageAdapter";
1386
+ return memo(CustomAssistantMessageAdapter);
1387
+ }
1388
+ function createAssistantMessageAdapterWithErrorReporting(onReportIssue, ThinkingIndicator, ToolCallsComponent) {
1389
+ const ErrorReportingAssistantMessageAdapter = ({
1390
+ message,
1391
+ isLoading,
1392
+ isGenerating,
1393
+ isCurrentMessage
1394
+ }) => {
1395
+ const { visibleMessages } = useCopilotChat();
1396
+ const showThinking = isLoading || isGenerating && !message?.content;
1397
+ const shouldShowToolCalls = isCurrentMessage && ToolCallsComponent;
1398
+ const rawContent = message?.content || "";
1399
+ const content = stripToolCallMarkers(rawContent);
1400
+ const errorContext = useMemo(() => detectErrorInMessage(content), [content]);
1401
+ const chatSnippet = useMemo(() => {
1402
+ if (!errorContext.hasError) return "";
1403
+ return buildChatSnippet(visibleMessages, content);
1404
+ }, [visibleMessages, content, errorContext.hasError]);
1405
+ const actions = useMemo(() => {
1406
+ if (!errorContext.hasError || !onReportIssue || isGenerating) {
1407
+ return [];
1408
+ }
1409
+ return [
1410
+ {
1411
+ label: "Report Issue",
1412
+ onClick: () => {
1413
+ onReportIssue({
1414
+ errorCategory: errorContext.category,
1415
+ correlationId: errorContext.correlationId,
1416
+ // Include conversation history leading to the error
1417
+ chatSnippet
1418
+ });
1419
+ },
1420
+ icon: /* @__PURE__ */ jsxs(
1421
+ "svg",
1422
+ {
1423
+ width: "14",
1424
+ height: "14",
1425
+ viewBox: "0 0 24 24",
1426
+ fill: "none",
1427
+ stroke: "currentColor",
1428
+ strokeWidth: "2",
1429
+ strokeLinecap: "round",
1430
+ strokeLinejoin: "round",
1431
+ children: [
1432
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
1433
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
1434
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
1435
+ ]
1436
+ }
1437
+ )
1438
+ }
1439
+ ];
1440
+ }, [errorContext, chatSnippet, isGenerating]);
1441
+ let generativeUIOutput = null;
1442
+ const msgWithUI = message;
1443
+ if (msgWithUI && typeof msgWithUI.generativeUI === "function") {
1444
+ try {
1445
+ generativeUIOutput = msgWithUI.generativeUI();
1446
+ } catch (e) {
1447
+ console.warn("[AssistantMessageAdapter] Error rendering generativeUI:", e);
1448
+ }
1449
+ }
1450
+ const attachments = [];
1451
+ if (showThinking) {
1452
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1453
+ ThinkingIndicator ? /* @__PURE__ */ jsx(ThinkingIndicator, { isLoading, isGenerating }) : /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." }),
1454
+ shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {})
1455
+ ] });
1456
+ }
1457
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1458
+ shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {}),
1459
+ generativeUIOutput && /* @__PURE__ */ jsx(GenerativeUIContainer, { children: generativeUIOutput }),
1460
+ content && /* @__PURE__ */ jsx(
1461
+ AssistantMessage,
1462
+ {
1463
+ content,
1464
+ avatarInitials: "AI",
1465
+ isLoading: false,
1466
+ isStreaming: isGenerating,
1467
+ attachments,
1468
+ enableMarkdown: true,
1469
+ actions
1470
+ }
1471
+ )
1472
+ ] });
1473
+ };
1474
+ ErrorReportingAssistantMessageAdapter.displayName = "ErrorReportingAssistantMessageAdapter";
1475
+ return memo(ErrorReportingAssistantMessageAdapter);
1476
+ }
1477
+ var ChatInputContainer = styled8.div`
1264
1478
  display: flex;
1265
1479
  flex-direction: column;
1266
1480
  width: 100%;
@@ -1276,7 +1490,7 @@ var ChatInputContainer = styled4.div`
1276
1490
  padding: ${tokens.spacing.md};
1277
1491
  }
1278
1492
  `;
1279
- var SuggestionsWrapper = styled4.div`
1493
+ var SuggestionsWrapper = styled8.div`
1280
1494
  display: flex;
1281
1495
  flex-direction: row;
1282
1496
  flex-wrap: wrap;
@@ -1285,7 +1499,7 @@ var SuggestionsWrapper = styled4.div`
1285
1499
  width: 100%;
1286
1500
  box-sizing: border-box;
1287
1501
  `;
1288
- var SuggestionButton = styled4.button`
1502
+ var SuggestionButton = styled8.button`
1289
1503
  padding: ${tokens.spacing.sm} ${tokens.spacing.md};
1290
1504
  font-family: ${tokens.typography.fontFamily.primary};
1291
1505
  font-size: 13px;
@@ -1324,7 +1538,7 @@ var SuggestionButton = styled4.button`
1324
1538
  opacity: 0.4;
1325
1539
  }
1326
1540
  `;
1327
- var InputWrapper = styled4.div`
1541
+ var InputWrapper = styled8.div`
1328
1542
  display: flex;
1329
1543
  align-items: flex-end; /* Align button to bottom when textarea expands */
1330
1544
  gap: ${tokens.spacing.sm};
@@ -1342,7 +1556,7 @@ var InputWrapper = styled4.div`
1342
1556
  background-color: rgba(50, 50, 52, 0.6);
1343
1557
  }
1344
1558
  `;
1345
- var InputField = styled4.textarea`
1559
+ var InputField = styled8.textarea`
1346
1560
  flex: 1;
1347
1561
  border: none;
1348
1562
  outline: none;
@@ -1367,7 +1581,7 @@ var InputField = styled4.textarea`
1367
1581
  cursor: not-allowed;
1368
1582
  }
1369
1583
  `;
1370
- var SubmitButton = styled4.button`
1584
+ var SubmitButton = styled8.button`
1371
1585
  display: flex;
1372
1586
  align-items: center;
1373
1587
  justify-content: center;
@@ -1603,7 +1817,7 @@ var InputAdapter = ({
1603
1817
  );
1604
1818
  };
1605
1819
  InputAdapter.displayName = "InputAdapter";
1606
- var StyledUserMessage = styled4.button`
1820
+ var StyledUserMessage = styled8.button`
1607
1821
  /* Base styles */
1608
1822
  display: inline-flex;
1609
1823
  align-items: center;
@@ -1739,7 +1953,7 @@ function UserMessageBase({
1739
1953
  }
1740
1954
  var UserMessage = memo(UserMessageBase);
1741
1955
  UserMessage.displayName = "UserMessage";
1742
- var UserMessageWrapper = styled4.div`
1956
+ var UserMessageWrapper = styled8.div`
1743
1957
  display: flex;
1744
1958
  justify-content: flex-end;
1745
1959
  width: 100%;
@@ -1769,7 +1983,7 @@ var pulse3 = keyframes`
1769
1983
  transform: scale(1.1);
1770
1984
  }
1771
1985
  `;
1772
- var Container4 = styled4.div`
1986
+ var Container4 = styled8.div`
1773
1987
  display: inline-flex;
1774
1988
  align-items: center;
1775
1989
  gap: ${(props) => {
@@ -1785,7 +1999,7 @@ var Container4 = styled4.div`
1785
1999
  }};
1786
2000
  font-family: ${tokens.typography.fontFamily.primary};
1787
2001
  `;
1788
- var StatusDot = styled4.div`
2002
+ var StatusDot = styled8.div`
1789
2003
  width: ${(props) => {
1790
2004
  if (props.variant === "badge") {
1791
2005
  switch (props.size) {
@@ -1846,7 +2060,7 @@ var StatusDot = styled4.div`
1846
2060
  animation: ${(props) => props.status === "streaming" ? pulse3 : "none"} 2s ease-in-out infinite;
1847
2061
  flex-shrink: 0;
1848
2062
  `;
1849
- var Label = styled4.span`
2063
+ var Label = styled8.span`
1850
2064
  font-size: ${(props) => {
1851
2065
  if (props.variant === "badge") {
1852
2066
  switch (props.size) {
@@ -1873,7 +2087,7 @@ var Label = styled4.span`
1873
2087
  color: ${tokens.colors.text.secondary};
1874
2088
  line-height: ${tokens.typography.lineHeight.tight};
1875
2089
  `;
1876
- var BadgeContainer = styled4.div`
2090
+ var BadgeContainer = styled8.div`
1877
2091
  display: inline-flex;
1878
2092
  align-items: center;
1879
2093
  gap: ${(props) => {
@@ -1950,7 +2164,7 @@ var StreamStatusIndicator = ({
1950
2164
  return /* @__PURE__ */ jsx(Container4, { size, className, role: "status", "aria-label": getStatusLabel(status), children: content });
1951
2165
  };
1952
2166
  StreamStatusIndicator.displayName = "StreamStatusIndicator";
1953
- var HeaderContainer = styled4.header`
2167
+ var HeaderContainer = styled8.header`
1954
2168
  display: flex;
1955
2169
  align-items: center;
1956
2170
  justify-content: space-between;
@@ -1966,14 +2180,14 @@ var HeaderContainer = styled4.header`
1966
2180
  padding: ${tokens.spacing.sm} ${tokens.spacing.md};
1967
2181
  }
1968
2182
  `;
1969
- var HeaderContent = styled4.div`
2183
+ var HeaderContent = styled8.div`
1970
2184
  display: flex;
1971
2185
  flex-direction: column;
1972
2186
  gap: ${tokens.spacing.xs};
1973
2187
  flex: 1;
1974
2188
  min-width: 0;
1975
2189
  `;
1976
- var HeaderTitle = styled4.h1`
2190
+ var HeaderTitle = styled8.h1`
1977
2191
  margin: 0;
1978
2192
  font-size: ${tokens.typography.fontSize.base};
1979
2193
  font-weight: ${tokens.typography.fontWeight.semibold};
@@ -1984,7 +2198,7 @@ var HeaderTitle = styled4.h1`
1984
2198
  text-overflow: ellipsis;
1985
2199
  white-space: nowrap;
1986
2200
  `;
1987
- var HeaderSubtitle = styled4.p`
2201
+ var HeaderSubtitle = styled8.p`
1988
2202
  margin: 0;
1989
2203
  font-size: ${tokens.typography.fontSize.sm};
1990
2204
  color: ${tokens.colors.text.secondary};
@@ -1994,13 +2208,13 @@ var HeaderSubtitle = styled4.p`
1994
2208
  text-overflow: ellipsis;
1995
2209
  white-space: nowrap;
1996
2210
  `;
1997
- var HeaderActions = styled4.div`
2211
+ var HeaderActions = styled8.div`
1998
2212
  display: flex;
1999
2213
  align-items: center;
2000
2214
  gap: ${tokens.spacing.xs};
2001
2215
  margin-left: ${tokens.spacing.md};
2002
2216
  `;
2003
- var ActionButton2 = styled4.button`
2217
+ var ActionButton2 = styled8.button`
2004
2218
  display: inline-flex;
2005
2219
  align-items: center;
2006
2220
  justify-content: center;
@@ -2117,7 +2331,7 @@ var Header = ({
2117
2331
  ] });
2118
2332
  };
2119
2333
  Header.displayName = "Header";
2120
- var MessagesContainer = styled4.div`
2334
+ var MessagesContainer = styled8.div`
2121
2335
  display: flex;
2122
2336
  flex-direction: column;
2123
2337
  flex: 1;
@@ -2129,18 +2343,14 @@ var MessagesContainer = styled4.div`
2129
2343
  ${tokens.colors.background.darker},
2130
2344
  ${tokens.colors.background.darkest}
2131
2345
  );
2132
- padding: ${tokens.spacing.sm};
2133
- gap: ${tokens.spacing.md};
2346
+ /* Minimal horizontal padding to maximize message width */
2347
+ padding: ${tokens.spacing.sm} ${tokens.spacing.xs};
2348
+ gap: ${tokens.spacing.sm};
2134
2349
  box-sizing: border-box;
2135
2350
 
2136
2351
  /* Ensure proper scrolling behavior for child components */
2137
2352
  position: relative;
2138
2353
  min-height: 0;
2139
-
2140
- /* Desktop padding */
2141
- @media (min-width: ${tokens.breakpoints.mobile}px) {
2142
- padding: ${tokens.spacing.md};
2143
- }
2144
2354
  `;
2145
2355
  var Messages = ({
2146
2356
  children,
@@ -2150,7 +2360,7 @@ var Messages = ({
2150
2360
  return /* @__PURE__ */ jsx(MessagesContainer, { className, role: "region", "aria-label": ariaLabel, children });
2151
2361
  };
2152
2362
  Messages.displayName = "Messages";
2153
- var WindowContainer = styled4.div`
2363
+ var WindowContainer = styled8.div`
2154
2364
  display: flex;
2155
2365
  flex-direction: column;
2156
2366
  /* Glassmorphism effect */
@@ -2351,7 +2561,7 @@ var GlobalSidebarStyles = createGlobalStyle`
2351
2561
  }
2352
2562
  }
2353
2563
  `;
2354
- var StyledChatButton = styled4.button`
2564
+ var StyledChatButton = styled8.button`
2355
2565
  position: fixed;
2356
2566
  bottom: 8px;
2357
2567
  right: 8px;
@@ -2403,7 +2613,7 @@ var CustomCopilotSidebar = ({
2403
2613
  };
2404
2614
  return /* @__PURE__ */ jsx(Header, { title: "AI Assistant", subtitle: "How can I help you today?", onClose: handleClose });
2405
2615
  };
2406
- const WindowAdapter = (props) => {
2616
+ const WindowAdapter2 = (props) => {
2407
2617
  return /* @__PURE__ */ jsx(Window, { children: props.children });
2408
2618
  };
2409
2619
  const MessagesAdapter = (props) => {
@@ -2459,7 +2669,7 @@ var CustomCopilotSidebar = ({
2459
2669
  UserMessage: UserMessageAdapter,
2460
2670
  Input: InputAdapter,
2461
2671
  Header: HeaderAdapter,
2462
- Window: WindowAdapter,
2672
+ Window: WindowAdapter2,
2463
2673
  Messages: MessagesAdapter,
2464
2674
  Button: CustomButton,
2465
2675
  instructions,
@@ -2485,8 +2695,8 @@ var GlobalSidebarStyles2 = createGlobalStyle`
2485
2695
  /* Override CopilotKit's content wrapper to respect safe areas in landscape */
2486
2696
  @media (orientation: landscape) {
2487
2697
  .copilotKitSidebarContentWrapper {
2488
- right: env(safe-area-inset-right, 0px) !important;
2489
- left: env(safe-area-inset-left, 0px) !important;
2698
+ right: var(--safe-area-right, 0px) !important;
2699
+ left: var(--safe-area-left, 0px) !important;
2490
2700
  }
2491
2701
  }
2492
2702
 
@@ -2515,18 +2725,18 @@ var GlobalSidebarStyles2 = createGlobalStyle`
2515
2725
  /* Override CopilotKit defaults for mobile */
2516
2726
  position: fixed !important;
2517
2727
  /* TOP: Account for status bar safe area (Android notch/status bar) */
2518
- top: calc(${tokens.spacing.sm} + env(safe-area-inset-top, 0px)) !important;
2728
+ top: calc(${tokens.spacing.sm} + var(--safe-area-top, 0px)) !important;
2519
2729
  /* RIGHT: Account for landscape notch on right side */
2520
- right: calc(${tokens.spacing.sm} + env(safe-area-inset-right, 0px)) !important;
2730
+ right: calc(${tokens.spacing.sm} + var(--safe-area-right, 0px)) !important;
2521
2731
  /* BOTTOM: Account for horizontal navbar (52px) + safe area for Android nav buttons */
2522
- bottom: calc(52px + ${tokens.spacing.sm} + env(safe-area-inset-bottom, 0px)) !important;
2732
+ bottom: calc(52px + ${tokens.spacing.sm} + var(--safe-area-bottom, 0px)) !important;
2523
2733
  /* LEFT: Account for landscape notch on left side */
2524
- left: calc(${tokens.spacing.sm} + env(safe-area-inset-left, 0px)) !important;
2525
- width: calc(100vw - ${tokens.spacing.lg} - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)) !important;
2734
+ left: calc(${tokens.spacing.sm} + var(--safe-area-left, 0px)) !important;
2735
+ width: calc(100vw - ${tokens.spacing.lg} - var(--safe-area-left, 0px) - var(--safe-area-right, 0px)) !important;
2526
2736
  /* Adjust height to account for top, bottom safe areas, and navbar */
2527
- height: calc(100vh - ${tokens.spacing.lg} - env(safe-area-inset-top, 0px) - 52px - env(safe-area-inset-bottom, 0px)) !important;
2528
- max-width: calc(100vw - ${tokens.spacing.lg} - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)) !important;
2529
- max-height: calc(100vh - ${tokens.spacing.lg} - env(safe-area-inset-top, 0px) - 52px - env(safe-area-inset-bottom, 0px)) !important;
2737
+ height: calc(100vh - ${tokens.spacing.lg} - var(--safe-area-top, 0px) - 52px - var(--safe-area-bottom, 0px)) !important;
2738
+ max-width: calc(100vw - ${tokens.spacing.lg} - var(--safe-area-left, 0px) - var(--safe-area-right, 0px)) !important;
2739
+ max-height: calc(100vh - ${tokens.spacing.lg} - var(--safe-area-top, 0px) - 52px - var(--safe-area-bottom, 0px)) !important;
2530
2740
  margin: 0 !important;
2531
2741
  border-radius: ${tokens.borderRadius.xl} !important;
2532
2742
 
@@ -2563,17 +2773,17 @@ var GlobalSidebarStyles2 = createGlobalStyle`
2563
2773
  .copilotKitSidebar [role="dialog"] {
2564
2774
  inset: auto !important;
2565
2775
  /* TOP: Account for status bar safe area */
2566
- top: calc(${tokens.spacing.sm} + env(safe-area-inset-top, 0px)) !important;
2776
+ top: calc(${tokens.spacing.sm} + var(--safe-area-top, 0px)) !important;
2567
2777
  /* RIGHT: Account for landscape notch on right side */
2568
- right: calc(${tokens.spacing.sm} + env(safe-area-inset-right, 0px)) !important;
2778
+ right: calc(${tokens.spacing.sm} + var(--safe-area-right, 0px)) !important;
2569
2779
  /* BOTTOM: Account for horizontal navbar (52px) + safe area */
2570
- bottom: calc(52px + ${tokens.spacing.sm} + env(safe-area-inset-bottom, 0px)) !important;
2780
+ bottom: calc(52px + ${tokens.spacing.sm} + var(--safe-area-bottom, 0px)) !important;
2571
2781
  left: auto !important;
2572
2782
  width: 28rem !important;
2573
2783
  /* Adjust height to account for top, bottom safe areas, and navbar */
2574
- height: calc(100vh - ${tokens.spacing.lg} - env(safe-area-inset-top, 0px) - 52px - env(safe-area-inset-bottom, 0px)) !important;
2784
+ height: calc(100vh - ${tokens.spacing.lg} - var(--safe-area-top, 0px) - 52px - var(--safe-area-bottom, 0px)) !important;
2575
2785
  max-width: 28rem !important;
2576
- max-height: calc(100vh - ${tokens.spacing.lg} - env(safe-area-inset-top, 0px) - 52px - env(safe-area-inset-bottom, 0px)) !important;
2786
+ max-height: calc(100vh - ${tokens.spacing.lg} - var(--safe-area-top, 0px) - 52px - var(--safe-area-bottom, 0px)) !important;
2577
2787
  }
2578
2788
  }
2579
2789
 
@@ -2606,8 +2816,8 @@ var GlobalSidebarStyles2 = createGlobalStyle`
2606
2816
  left: auto !important;
2607
2817
  right: 1.5rem !important;
2608
2818
  /* Use top/bottom ONLY - let browser calculate height (more reliable than explicit height) */
2609
- top: env(safe-area-inset-top, 0px) !important;
2610
- bottom: calc(52px + env(safe-area-inset-bottom, 0px)) !important;
2819
+ top: var(--safe-area-top, 0px) !important;
2820
+ bottom: calc(52px + var(--safe-area-bottom, 0px)) !important;
2611
2821
  /* Remove explicit height - let top/bottom define it */
2612
2822
  height: auto !important;
2613
2823
  max-height: none !important;
@@ -2761,10 +2971,10 @@ var GlobalSidebarStyles2 = createGlobalStyle`
2761
2971
  box-shadow: none !important;
2762
2972
  }
2763
2973
  `;
2764
- var StyledChatButton2 = styled4.button`
2974
+ var StyledChatButton2 = styled8.button`
2765
2975
  position: fixed;
2766
- bottom: calc(${tokens.spacing.sm} + env(safe-area-inset-bottom, 0px));
2767
- right: calc(${tokens.spacing.sm} + env(safe-area-inset-right, 0px));
2976
+ bottom: calc(${tokens.spacing.sm} + var(--safe-area-bottom, 0px));
2977
+ right: calc(${tokens.spacing.sm} + var(--safe-area-right, 0px));
2768
2978
  width: 36px;
2769
2979
  height: 36px;
2770
2980
  border-radius: ${tokens.borderRadius.full};
@@ -2795,17 +3005,11 @@ var StyledChatButton2 = styled4.button`
2795
3005
  fill: ${tokens.colors.text.primary};
2796
3006
  }
2797
3007
  `;
2798
- function CustomCopilotSidebar2({
2799
- children,
2800
- defaultOpen = false,
2801
- onSetOpen,
2802
- instructions,
2803
- className,
2804
- disabled = false,
2805
- disabledReason = "Start a free trial to enable AI chat",
2806
- onError,
2807
- renderError
2808
- }) {
3008
+ var WindowAdapter = (props) => {
3009
+ return /* @__PURE__ */ jsx(Window, { children: props.children });
3010
+ };
3011
+ WindowAdapter.displayName = "WindowAdapter";
3012
+ function createHeaderAdapter(onSetOpen) {
2809
3013
  const HeaderAdapterWithClose = (_props) => {
2810
3014
  const { setOpen } = useChatContext();
2811
3015
  const handleClose = () => {
@@ -2814,9 +3018,10 @@ function CustomCopilotSidebar2({
2814
3018
  };
2815
3019
  return /* @__PURE__ */ jsx(Header, { title: "AI Assistant", onClose: handleClose });
2816
3020
  };
2817
- const WindowAdapterLocal = (props) => {
2818
- return /* @__PURE__ */ jsx(Window, { children: props.children });
2819
- };
3021
+ HeaderAdapterWithClose.displayName = "HeaderAdapterWithClose";
3022
+ return HeaderAdapterWithClose;
3023
+ }
3024
+ function createButtonAdapter(disabled, disabledReason, onSetOpen) {
2820
3025
  const CustomButton = (_props) => {
2821
3026
  const { open, setOpen } = useChatContext();
2822
3027
  const handleClick = () => {
@@ -2853,16 +3058,45 @@ function CustomCopilotSidebar2({
2853
3058
  }
2854
3059
  );
2855
3060
  };
3061
+ CustomButton.displayName = "CustomButton";
3062
+ return CustomButton;
3063
+ }
3064
+ function CustomCopilotSidebar2({
3065
+ children,
3066
+ defaultOpen = false,
3067
+ onSetOpen,
3068
+ instructions,
3069
+ className,
3070
+ disabled = false,
3071
+ disabledReason = "Start a free trial to enable AI chat",
3072
+ onError,
3073
+ renderError,
3074
+ ThinkingIndicator,
3075
+ ToolCallsComponent,
3076
+ onReportIssue
3077
+ }) {
3078
+ const HeaderAdapterWithClose = useMemo(
3079
+ () => createHeaderAdapter(onSetOpen),
3080
+ [onSetOpen]
3081
+ );
3082
+ const CustomButton = useMemo(
3083
+ () => createButtonAdapter(disabled, disabledReason, onSetOpen),
3084
+ [disabled, disabledReason, onSetOpen]
3085
+ );
3086
+ const AssistantMessageAdapterMemo = useMemo(
3087
+ () => onReportIssue ? createAssistantMessageAdapterWithErrorReporting(onReportIssue, ThinkingIndicator, ToolCallsComponent) : ThinkingIndicator || ToolCallsComponent ? createAssistantMessageAdapter(ThinkingIndicator, ToolCallsComponent) : AssistantMessageAdapter,
3088
+ [ThinkingIndicator, ToolCallsComponent, onReportIssue]
3089
+ );
2856
3090
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2857
3091
  /* @__PURE__ */ jsx(GlobalSidebarStyles2, {}),
2858
3092
  /* @__PURE__ */ jsx(
2859
3093
  CopilotSidebar,
2860
3094
  {
2861
- AssistantMessage: AssistantMessageAdapter,
3095
+ AssistantMessage: AssistantMessageAdapterMemo,
2862
3096
  UserMessage: UserMessageAdapter,
2863
3097
  Input: InputAdapter,
2864
3098
  Header: HeaderAdapterWithClose,
2865
- Window: WindowAdapterLocal,
3099
+ Window: WindowAdapter,
2866
3100
  Button: CustomButton,
2867
3101
  RenderActionExecutionMessage: ActionExecutionAdapter,
2868
3102
  instructions,
@@ -2883,7 +3117,7 @@ function CustomCopilotSidebar2({
2883
3117
  ] });
2884
3118
  }
2885
3119
  CustomCopilotSidebar2.displayName = "CustomCopilotSidebar";
2886
- var FooterContainer = styled4.footer`
3120
+ var FooterContainer = styled8.footer`
2887
3121
  display: flex;
2888
3122
  align-items: center;
2889
3123
  justify-content: center;
@@ -2892,7 +3126,7 @@ var FooterContainer = styled4.footer`
2892
3126
  border-top: 1px solid ${tokens.colors.border.default};
2893
3127
  min-height: 44px;
2894
3128
  `;
2895
- var FooterContent = styled4.div`
3129
+ var FooterContent = styled8.div`
2896
3130
  display: flex;
2897
3131
  align-items: center;
2898
3132
  justify-content: space-between;
@@ -2905,13 +3139,13 @@ var FooterContent = styled4.div`
2905
3139
  font-family: ${tokens.typography.fontFamily.primary};
2906
3140
  line-height: ${tokens.typography.lineHeight.tight};
2907
3141
  `;
2908
- var FooterBranding = styled4.div`
3142
+ var FooterBranding = styled8.div`
2909
3143
  display: flex;
2910
3144
  align-items: center;
2911
3145
  gap: ${tokens.spacing.xs};
2912
3146
  flex-shrink: 0;
2913
3147
  `;
2914
- var FooterStatus = styled4.div`
3148
+ var FooterStatus = styled8.div`
2915
3149
  display: flex;
2916
3150
  align-items: center;
2917
3151
  gap: ${tokens.spacing.xs};
@@ -2921,7 +3155,7 @@ var FooterStatus = styled4.div`
2921
3155
  font-size: ${tokens.typography.fontSize.xs};
2922
3156
  opacity: 0.8;
2923
3157
  `;
2924
- var FooterLink = styled4.a`
3158
+ var FooterLink = styled8.a`
2925
3159
  color: ${tokens.colors.primary};
2926
3160
  text-decoration: none;
2927
3161
  transition: opacity ${tokens.transitions.fast};
@@ -2969,13 +3203,13 @@ var Footer = ({
2969
3203
  ] }) });
2970
3204
  };
2971
3205
  Footer.displayName = "Footer";
2972
- var InputContainer = styled4.div`
3206
+ var InputContainer = styled8.div`
2973
3207
  display: flex;
2974
3208
  flex-direction: column;
2975
3209
  width: 100%;
2976
3210
  position: relative;
2977
3211
  `;
2978
- var InputWrapper2 = styled4.div`
3212
+ var InputWrapper2 = styled8.div`
2979
3213
  display: flex;
2980
3214
  align-items: flex-end;
2981
3215
  gap: ${tokens.spacing.sm};
@@ -2995,7 +3229,7 @@ var InputWrapper2 = styled4.div`
2995
3229
  border-color: ${tokens.colors.border.subtle};
2996
3230
  }
2997
3231
  `;
2998
- var TextArea = styled4.textarea`
3232
+ var TextArea = styled8.textarea`
2999
3233
  flex: 1;
3000
3234
  min-height: ${tokens.spacing.lg};
3001
3235
  max-height: ${(props) => `${(props.$maxRows || 5) * 24}px`};
@@ -3041,7 +3275,7 @@ var TextArea = styled4.textarea`
3041
3275
  background: ${tokens.colors.scrollbar.thumbHover};
3042
3276
  }
3043
3277
  `;
3044
- var SendButton = styled4.button`
3278
+ var SendButton = styled8.button`
3045
3279
  display: flex;
3046
3280
  align-items: center;
3047
3281
  justify-content: center;
@@ -3171,7 +3405,7 @@ var Input = ({
3171
3405
  )
3172
3406
  ] }) });
3173
3407
  };
3174
- var MessagesListContainer = styled4.div`
3408
+ var MessagesListContainer = styled8.div`
3175
3409
  display: flex;
3176
3410
  flex-direction: column;
3177
3411
  width: 100%;
@@ -3211,7 +3445,7 @@ var MessagesListContainer = styled4.div`
3211
3445
  /* Ensure proper rendering on mobile */
3212
3446
  -webkit-overflow-scrolling: touch;
3213
3447
  `;
3214
- var MessagesListContent = styled4.div`
3448
+ var MessagesListContent = styled8.div`
3215
3449
  display: flex;
3216
3450
  flex-direction: column;
3217
3451
  gap: ${tokens.spacing.sm};
@@ -3327,19 +3561,19 @@ var MessagesList = ({
3327
3561
  }
3328
3562
  );
3329
3563
  };
3330
- var StyledUserMessage2 = styled4.div`
3564
+ var StyledUserMessage2 = styled8.div`
3331
3565
  display: flex;
3332
3566
  justify-content: flex-end;
3333
3567
  align-items: flex-start;
3334
- margin: ${tokens.spacing.sm} 0;
3335
- padding: 0 ${tokens.spacing.md};
3568
+ margin: ${tokens.spacing.xs} 0;
3569
+ padding: 0;
3336
3570
  width: 100%;
3337
3571
  `;
3338
- var MessageBubble = styled4.div`
3572
+ var MessageBubble = styled8.div`
3339
3573
  display: flex;
3340
3574
  flex-direction: column;
3341
- max-width: 70%;
3342
- padding: ${tokens.spacing.sm} ${tokens.spacing.md};
3575
+ max-width: 85%;
3576
+ padding: ${tokens.spacing.sm};
3343
3577
  border-radius: ${tokens.borderRadius.lg};
3344
3578
 
3345
3579
  /* User message colors - dark blue from brand */
@@ -3362,7 +3596,7 @@ var MessageBubble = styled4.div`
3362
3596
  opacity: 0.9;
3363
3597
  }
3364
3598
  `;
3365
- var MessageContent2 = styled4.p`
3599
+ var MessageContent2 = styled8.p`
3366
3600
  margin: 0;
3367
3601
  font-size: ${tokens.typography.fontSize.sm};
3368
3602
  line-height: ${tokens.typography.lineHeight.normal};
@@ -3371,13 +3605,13 @@ var MessageContent2 = styled4.p`
3371
3605
  word-break: break-word;
3372
3606
  white-space: pre-wrap;
3373
3607
  `;
3374
- var MessageTime2 = styled4.time`
3608
+ var MessageTime2 = styled8.time`
3375
3609
  font-size: ${tokens.typography.fontSize.xs};
3376
3610
  opacity: 0.7;
3377
3611
  margin-top: ${tokens.spacing.xs};
3378
3612
  text-align: right;
3379
3613
  `;
3380
- var ActionButton3 = styled4.button`
3614
+ var ActionButton3 = styled8.button`
3381
3615
  display: inline-flex;
3382
3616
  align-items: center;
3383
3617
  gap: ${tokens.spacing.xs};
@@ -3401,12 +3635,12 @@ var ActionButton3 = styled4.button`
3401
3635
  transform: scale(0.98);
3402
3636
  }
3403
3637
  `;
3404
- var ActionsContainer3 = styled4.div`
3638
+ var ActionsContainer3 = styled8.div`
3405
3639
  display: flex;
3406
3640
  gap: ${tokens.spacing.xs};
3407
3641
  flex-wrap: wrap;
3408
3642
  `;
3409
- var StreamingIndicator2 = styled4.span`
3643
+ var StreamingIndicator2 = styled8.span`
3410
3644
  display: inline-block;
3411
3645
  width: ${tokens.spacing.xs};
3412
3646
  height: ${tokens.spacing.xs};
@@ -3427,7 +3661,7 @@ var StreamingIndicator2 = styled4.span`
3427
3661
  }
3428
3662
  }
3429
3663
  `;
3430
- var Avatar3 = styled4.img`
3664
+ var Avatar3 = styled8.img`
3431
3665
  width: ${tokens.spacing.xl};
3432
3666
  height: ${tokens.spacing.xl};
3433
3667
  border-radius: ${tokens.borderRadius.full};
@@ -3460,7 +3694,7 @@ var UserMessage2 = ({
3460
3694
  avatarUrl && /* @__PURE__ */ jsx(Avatar3, { src: avatarUrl, alt: username || "User" })
3461
3695
  ] });
3462
3696
  };
3463
- var ErrorContainer = styled4.div`
3697
+ var ErrorContainer = styled8.div`
3464
3698
  display: flex;
3465
3699
  align-items: flex-start;
3466
3700
  gap: ${tokens.spacing.sm};
@@ -3474,7 +3708,7 @@ var ErrorContainer = styled4.div`
3474
3708
  width: ${(props) => props.variant === "banner" ? "100%" : "auto"};
3475
3709
  max-width: ${(props) => props.variant === "banner" ? "100%" : "600px"};
3476
3710
  `;
3477
- var IconContainer = styled4.div`
3711
+ var IconContainer = styled8.div`
3478
3712
  flex-shrink: 0;
3479
3713
  width: 20px;
3480
3714
  height: 20px;
@@ -3491,29 +3725,29 @@ var ErrorIcon = () => /* @__PURE__ */ jsx(
3491
3725
  children: /* @__PURE__ */ jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" })
3492
3726
  }
3493
3727
  );
3494
- var Content2 = styled4.div`
3728
+ var Content2 = styled8.div`
3495
3729
  flex: 1;
3496
3730
  display: flex;
3497
3731
  flex-direction: column;
3498
3732
  gap: ${tokens.spacing.sm};
3499
3733
  `;
3500
- var ErrorMessage = styled4.div`
3734
+ var ErrorMessage = styled8.div`
3501
3735
  font-size: ${tokens.typography.fontSize.sm};
3502
3736
  line-height: ${tokens.typography.lineHeight.normal};
3503
3737
  color: ${tokens.colors.text.primary};
3504
3738
  `;
3505
- var ErrorDetails = styled4.div`
3739
+ var ErrorDetails = styled8.div`
3506
3740
  font-size: ${tokens.typography.fontSize.xs};
3507
3741
  line-height: 1.4;
3508
3742
  color: ${tokens.colors.text.secondary};
3509
3743
  margin-top: ${tokens.spacing.xs};
3510
3744
  `;
3511
- var Actions2 = styled4.div`
3745
+ var Actions2 = styled8.div`
3512
3746
  display: flex;
3513
3747
  gap: ${tokens.spacing.sm};
3514
3748
  margin-top: ${tokens.spacing.sm};
3515
3749
  `;
3516
- var Button2 = styled4.button`
3750
+ var Button2 = styled8.button`
3517
3751
  display: inline-flex;
3518
3752
  align-items: center;
3519
3753
  gap: ${tokens.spacing.xs};
@@ -3542,7 +3776,7 @@ var Button2 = styled4.button`
3542
3776
  cursor: not-allowed;
3543
3777
  }
3544
3778
  `;
3545
- var CloseButton = styled4.button`
3779
+ var CloseButton = styled8.button`
3546
3780
  flex-shrink: 0;
3547
3781
  width: 24px;
3548
3782
  height: 24px;
@@ -3601,7 +3835,7 @@ var StreamErrorMessage = ({
3601
3835
  ] });
3602
3836
  };
3603
3837
  StreamErrorMessage.displayName = "StreamErrorMessage";
3604
- var SuggestionsContainer = styled4.div`
3838
+ var SuggestionsContainer = styled8.div`
3605
3839
  display: flex;
3606
3840
  flex-wrap: nowrap; /* Single row */
3607
3841
  gap: ${tokens.spacing.sm};
@@ -3634,7 +3868,7 @@ var SuggestionsContainer = styled4.div`
3634
3868
  display: none; /* Chrome/Safari/Opera */
3635
3869
  }
3636
3870
  `;
3637
- var StyledSuggestion = styled4.button`
3871
+ var StyledSuggestion = styled8.button`
3638
3872
  /* Base styles */
3639
3873
  display: inline-flex;
3640
3874
  align-items: center;