From 77721645a1d8b69023e6488521259e38fdcad17b Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 24 Sep 2025 22:14:54 -0600 Subject: [PATCH] change redirect logic --- .../Dashboards/useIsDashboardChanged.tsx | 1 + .../src/context/Reports/useIsReportChanged.ts | 2 +- .../ChatContent/ChatUserMessage.tsx | 27 +++++++------------ .../useAutoRedirectStreaming.ts | 2 -- .../ChatLayoutContext/useChatStreaming.tsx | 17 +++++------- apps/web/src/routes/app.tsx | 2 +- 6 files changed, 20 insertions(+), 31 deletions(-) diff --git a/apps/web/src/context/Dashboards/useIsDashboardChanged.tsx b/apps/web/src/context/Dashboards/useIsDashboardChanged.tsx index 3e73e1d0d..44b600dd4 100644 --- a/apps/web/src/context/Dashboards/useIsDashboardChanged.tsx +++ b/apps/web/src/context/Dashboards/useIsDashboardChanged.tsx @@ -35,6 +35,7 @@ export const useIsDashboardChanged = ({ }), [] ), + enabled: false, } ); diff --git a/apps/web/src/context/Reports/useIsReportChanged.ts b/apps/web/src/context/Reports/useIsReportChanged.ts index 3a9a576f4..2e4d844b1 100644 --- a/apps/web/src/context/Reports/useIsReportChanged.ts +++ b/apps/web/src/context/Reports/useIsReportChanged.ts @@ -12,7 +12,7 @@ import { useGetOriginalReport } from './useOriginalReportStore'; export const useIsReportChanged = ({ reportId, - enabled = true, + enabled = false, }: { reportId: string | undefined; enabled?: boolean; diff --git a/apps/web/src/layouts/ChatLayout/ChatContent/ChatUserMessage.tsx b/apps/web/src/layouts/ChatLayout/ChatContent/ChatUserMessage.tsx index 760de96aa..007457b70 100644 --- a/apps/web/src/layouts/ChatLayout/ChatContent/ChatUserMessage.tsx +++ b/apps/web/src/layouts/ChatLayout/ChatContent/ChatUserMessage.tsx @@ -38,22 +38,16 @@ export const ChatUserMessage: React.FC<{ (e?: React.ClipboardEvent) => { // Check if user has selected text const selection = window.getSelection(); - const hasSelection = selection && selection.toString().length > 0; + const selectedText = selection?.toString().trim() || ''; + const hasSelection = selectedText.length > 0; - // If user has selected text, let browser handle it naturally - if (hasSelection && e?.clipboardData) { - // Don't prevent default - let browser copy the selected text - return; - } - - // Only override copy behavior when no text is selected - // This handles the case where user presses Ctrl+C without selection - // or when the copy button is clicked + // Always override copy behavior to provide clean text if (e?.clipboardData) { e.preventDefault(); - e.clipboardData.setData('text/plain', request || ''); + // Copy selected text if there is a selection, otherwise copy full message + e.clipboardData.setData('text/plain', hasSelection ? selectedText : request || ''); } else { - navigator.clipboard.writeText(request || ''); + navigator.clipboard.writeText(hasSelection ? selectedText : request || ''); } openSuccessMessage('Copied to clipboard'); }, @@ -77,11 +71,10 @@ export const ChatUserMessage: React.FC<{ /> ) : ( <> -
- - {request} - -
+ + {request} + + {isStreamFinished && canEditChat && ( { const responseMessage = chatMessage?.response_messages[id]; diff --git a/apps/web/src/layouts/ChatLayout/ChatLayoutContext/useChatStreaming.tsx b/apps/web/src/layouts/ChatLayout/ChatLayoutContext/useChatStreaming.tsx index 4badaae96..45f07a646 100644 --- a/apps/web/src/layouts/ChatLayout/ChatLayoutContext/useChatStreaming.tsx +++ b/apps/web/src/layouts/ChatLayout/ChatLayoutContext/useChatStreaming.tsx @@ -1,7 +1,7 @@ import { useQueryClient } from '@tanstack/react-query'; import { useEffect } from 'react'; import type { BusterChat, BusterChatMessage, IBusterChat } from '@/api/asset_interfaces/chat'; -import { useGetChatMessageMemoized } from '@/api/buster_rest/chats'; +import { useGetChat, useGetChatMessageMemoized } from '@/api/buster_rest/chats'; import { prefetchGetMetricDataClient } from '@/api/buster_rest/metrics'; import { useTrackAndUpdateChatChanges } from '@/api/buster-electric/chats'; import { @@ -11,11 +11,11 @@ import { import { chatQueryKeys } from '@/api/query_keys/chat'; import { metricsQueryKeys } from '@/api/query_keys/metric'; import { useBlackboxMessage } from '@/context/BlackBox/useBlackboxMessage'; -import { updateDocumentTitle, useDocumentTitle } from '@/hooks/useDocumentTitle'; +import { updateDocumentTitle } from '@/hooks/useDocumentTitle'; import { useMemoizedFn } from '@/hooks/useMemoizedFn'; -import { useMount } from '@/hooks/useMount'; import { updateChatToIChat } from '@/lib/chat'; +const stableChatTitleSelector = (chat: IBusterChat) => chat.title; export const useChatStreaming = ({ chatId, isStreamingMessage, @@ -28,6 +28,10 @@ export const useChatStreaming = ({ const { checkBlackBoxMessage, removeBlackBoxMessage } = useBlackboxMessage(); const queryClient = useQueryClient(); const getChatMessageMemoized = useGetChatMessageMemoized(); + const { data: chatTitle } = useGetChat( + { id: chatId || '' }, + { select: stableChatTitleSelector, notifyOnChangeProps: ['data'] } + ); const _prefetchLastMessageMetricData = ( iChat: IBusterChat, @@ -136,20 +140,13 @@ export const useChatStreaming = ({ }); useEffect(() => { - const REASONING_TITLE = 'Reasoning... | '; if (isStreamingMessage) { const message = getChatMessageMemoized(messageId); if (message) { checkBlackBoxMessage(message); } - updateDocumentTitle((currentTitle) => { - return `${REASONING_TITLE}${currentTitle}`; - }); } else { removeBlackBoxMessage(messageId); - updateDocumentTitle((currentTitle) => { - return currentTitle.replace(REASONING_TITLE, ''); - }); } }, [isStreamingMessage]); diff --git a/apps/web/src/routes/app.tsx b/apps/web/src/routes/app.tsx index 8426c5d2a..8c26c7225 100644 --- a/apps/web/src/routes/app.tsx +++ b/apps/web/src/routes/app.tsx @@ -27,7 +27,7 @@ export const Route = createFileRoute('/app')({ const { queryClient, supabaseSession } = context; try { const [user] = await Promise.all([prefetchGetMyUserInfo(queryClient)]); - if (!user || !user.organizations || user.organizations.length === 0) { + if (user && user?.organizations?.length === 0) { throw redirect({ href: BUSTER_SIGN_UP_URL, replace: true, statusCode: 307 }); } return {