@sybilion/uilib 1.3.88 → 1.3.90

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 (31) hide show
  1. package/dist/esm/components/ui/Chat/ChatMessage/AgentMessageContent.helpers.js +29 -21
  2. package/dist/esm/components/ui/Chat/ChatMessage/ChatMessage.js +4 -1
  3. package/dist/esm/components/ui/Chat/ChatSheet/useChatPanelChromeModel.js +17 -10
  4. package/dist/esm/contexts/chat-context.js +180 -205
  5. package/dist/esm/contexts/chatPersistence.js +6 -18
  6. package/dist/esm/contexts/chatSessionStorage.js +245 -0
  7. package/dist/esm/lib/dashboard-spec/jsonDashboardFence.js +80 -0
  8. package/dist/esm/types/src/components/ui/Chat/ChatMessage/AgentMessageContent.helpers.d.ts +1 -5
  9. package/dist/esm/types/src/components/ui/Chat/ChatMessage/AgentMessageContent.helpers.test.d.ts +1 -0
  10. package/dist/esm/types/src/components/ui/Chat/ChatSheet/useChatPanelChromeModel.d.ts +6 -1
  11. package/dist/esm/types/src/contexts/chat-context.d.ts +6 -0
  12. package/dist/esm/types/src/contexts/chatPersistence.d.ts +4 -1
  13. package/dist/esm/types/src/contexts/chatSessionStorage.d.ts +32 -0
  14. package/dist/esm/types/src/contexts/chatSessionStorage.test.d.ts +1 -0
  15. package/dist/esm/types/src/lib/dashboard-spec/jsonDashboardFence.d.ts +9 -0
  16. package/dist/esm/types/src/lib/dashboard-spec/stripJsonDashboardFences.d.ts +1 -2
  17. package/dist/esm/types/src/lib/dashboard-spec/stripJsonDashboardFences.test.d.ts +1 -0
  18. package/package.json +1 -1
  19. package/src/components/ui/Chat/ChatMessage/AgentMessageContent.helpers.test.tsx +25 -0
  20. package/src/components/ui/Chat/ChatMessage/AgentMessageContent.helpers.tsx +35 -26
  21. package/src/components/ui/Chat/ChatMessage/ChatMessage.tsx +7 -1
  22. package/src/components/ui/Chat/ChatSheet/useChatPanelChromeModel.tsx +21 -8
  23. package/src/contexts/chat-context.tsx +253 -220
  24. package/src/contexts/chatPersistence.test.ts +11 -0
  25. package/src/contexts/chatPersistence.ts +22 -6
  26. package/src/contexts/chatSessionStorage.test.ts +125 -0
  27. package/src/contexts/chatSessionStorage.ts +321 -0
  28. package/src/lib/dashboard-spec/jsonDashboardFence.ts +98 -0
  29. package/src/lib/dashboard-spec/stripJsonDashboardFences.test.ts +84 -0
  30. package/src/lib/dashboard-spec/stripJsonDashboardFences.ts +5 -6
  31. package/dist/esm/lib/dashboard-spec/stripJsonDashboardFences.js +0 -7
@@ -111,6 +111,11 @@ export type UseChatPanelChromeModelInput = {
111
111
  | string
112
112
  | ChatSendMessagePayload
113
113
  | Promise<string | ChatSendMessagePayload>;
114
+ /**
115
+ * When true, preset clicks always use the API send path (skip local `answer` /
116
+ * script demo). Use on /reports/new where first message must hit transformSendPayload.
117
+ */
118
+ submitPresetsViaApi?: boolean;
114
119
  };
115
120
 
116
121
  export type UseChatPanelChromeModelResult = {
@@ -165,6 +170,7 @@ export function useChatPanelChromeModel({
165
170
  onSlashItemCommand,
166
171
  copyHistoryOnNewChat = false,
167
172
  transformSendPayload,
173
+ submitPresetsViaApi = false,
168
174
  }: UseChatPanelChromeModelInput): UseChatPanelChromeModelResult {
169
175
  const effectiveScopeId = scopeId ?? NO_SCOPE_FALLBACK;
170
176
  const isMobile = useIsMobile();
@@ -593,7 +599,7 @@ export function useChatPanelChromeModel({
593
599
  try {
594
600
  const { response: assistantResponse, sessionId } =
595
601
  await sendMessage(payload);
596
- onMessage?.(
602
+ await onMessage?.(
597
603
  displayTextFromSendPayload(payload),
598
604
  assistantResponse,
599
605
  sessionId,
@@ -761,7 +767,7 @@ export function useChatPanelChromeModel({
761
767
  try {
762
768
  const { response: assistantResponse, sessionId } =
763
769
  await sendMessage(payload);
764
- onMessage?.(
770
+ await onMessage?.(
765
771
  displayTextFromSendPayload(payload),
766
772
  assistantResponse,
767
773
  sessionId,
@@ -804,14 +810,19 @@ export function useChatPanelChromeModel({
804
810
  const hasReplies =
805
811
  preset.replies && Object.keys(preset.replies).length > 0;
806
812
  const isLocalDemo =
807
- hasLinearScript ||
808
- scriptGraph ||
809
- Boolean(preset.answer?.trim()) ||
810
- Boolean(hasReplies);
813
+ !submitPresetsViaApi &&
814
+ (hasLinearScript ||
815
+ scriptGraph ||
816
+ Boolean(preset.answer?.trim()) ||
817
+ Boolean(hasReplies));
811
818
 
812
819
  if (!isLocalDemo) {
813
- if (!currentChatId) return;
814
- endLocalDemoFlow(currentChatId);
820
+ let chatId = currentChatId;
821
+ if (!chatId) {
822
+ chatId = startEmptyNewChat() ?? undefined;
823
+ if (!chatId) return;
824
+ }
825
+ endLocalDemoFlow(chatId);
815
826
  await handlePromptSubmit(options?.message ?? preset.text);
816
827
  return;
817
828
  }
@@ -891,10 +902,12 @@ export function useChatPanelChromeModel({
891
902
  },
892
903
  [
893
904
  currentChatId,
905
+ startEmptyNewChat,
894
906
  endLocalDemoFlow,
895
907
  handlePromptSubmit,
896
908
  addMessage,
897
909
  presetsWithFreeform,
910
+ submitPresetsViaApi,
898
911
  ],
899
912
  );
900
913