@comergehq/studio 0.1.16 → 0.1.17

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.
package/dist/index.mjs CHANGED
@@ -864,9 +864,8 @@ function useThreadMessages(threadId) {
864
864
  const activeRequestIdRef = React4.useRef(0);
865
865
  const foregroundSignal = useForegroundSignal(Boolean(threadId));
866
866
  const upsertSorted = React4.useCallback((prev, m) => {
867
- const include = !isQueuedHiddenMessage(m);
868
867
  const next = prev.filter((x) => x.id !== m.id);
869
- if (include) next.push(m);
868
+ next.push(m);
870
869
  next.sort(compareMessages);
871
870
  return next;
872
871
  }, []);
@@ -881,7 +880,7 @@ function useThreadMessages(threadId) {
881
880
  try {
882
881
  const list = await messagesRepository.list(threadId);
883
882
  if (activeRequestIdRef.current !== requestId) return;
884
- setRaw([...list].filter((m) => !isQueuedHiddenMessage(m)).sort(compareMessages));
883
+ setRaw([...list].sort(compareMessages));
885
884
  } catch (e) {
886
885
  if (activeRequestIdRef.current !== requestId) return;
887
886
  setError(e instanceof Error ? e : new Error(String(e)));
@@ -907,7 +906,11 @@ function useThreadMessages(threadId) {
907
906
  if (foregroundSignal <= 0) return;
908
907
  void refetch();
909
908
  }, [foregroundSignal, refetch, threadId]);
910
- const messages = React4.useMemo(() => raw.map(mapMessageToChatMessage), [raw]);
909
+ const messages = React4.useMemo(() => {
910
+ const visible = raw.filter((m) => !isQueuedHiddenMessage(m));
911
+ const resolved = visible.length > 0 ? visible : raw;
912
+ return resolved.map(mapMessageToChatMessage);
913
+ }, [raw]);
911
914
  return { raw, messages, loading, error, refetch };
912
915
  }
913
916
 
@@ -1951,7 +1954,6 @@ function useStudioActions({
1951
1954
  setSending(true);
1952
1955
  setError(null);
1953
1956
  try {
1954
- onEditStart == null ? void 0 : onEditStart();
1955
1957
  let targetApp = app;
1956
1958
  if (shouldForkOnEdit) {
1957
1959
  setForking(true);
@@ -1963,6 +1965,7 @@ function useStudioActions({
1963
1965
  setForking(false);
1964
1966
  const threadId = targetApp.threadId;
1965
1967
  if (!threadId) throw new Error("No thread available for this app.");
1968
+ onEditStart == null ? void 0 : onEditStart();
1966
1969
  let attachmentMetas;
1967
1970
  if (attachments && attachments.length > 0 && uploadAttachments) {
1968
1971
  attachmentMetas = await uploadAttachments({ threadId, appId: targetApp.id, dataUrls: attachments });
@@ -6933,7 +6936,9 @@ function StudioOverlay({
6933
6936
  const [commentsAppId, setCommentsAppId] = React43.useState(null);
6934
6937
  const [commentsCount, setCommentsCount] = React43.useState(null);
6935
6938
  const threadId = (app == null ? void 0 : app.threadId) ?? null;
6936
- const disableOptimistic = Boolean(chatQueueItems && chatQueueItems.length > 0) || (app == null ? void 0 : app.status) === "editing";
6939
+ const isForking = chatForking || (app == null ? void 0 : app.status) === "forking";
6940
+ const queueItemsForChat = isForking ? [] : chatQueueItems;
6941
+ const disableOptimistic = Boolean(queueItemsForChat && queueItemsForChat.length > 0) || (app == null ? void 0 : app.status) === "editing";
6937
6942
  const optimistic = useOptimisticChatMessages({
6938
6943
  threadId,
6939
6944
  shouldForkOnEdit,
@@ -7075,7 +7080,7 @@ function StudioOverlay({
7075
7080
  onNavigateHome,
7076
7081
  onStartDraw: startDraw,
7077
7082
  onSend: optimistic.onSend,
7078
- queueItems: chatQueueItems,
7083
+ queueItems: queueItemsForChat,
7079
7084
  onRemoveQueueItem
7080
7085
  }
7081
7086
  )