change redirect logic

This commit is contained in:
Nate Kelley 2025-09-24 22:14:54 -06:00
parent f87f67d895
commit 77721645a1
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
6 changed files with 20 additions and 31 deletions

View File

@ -35,6 +35,7 @@ export const useIsDashboardChanged = ({
}), }),
[] []
), ),
enabled: false,
} }
); );

View File

@ -12,7 +12,7 @@ import { useGetOriginalReport } from './useOriginalReportStore';
export const useIsReportChanged = ({ export const useIsReportChanged = ({
reportId, reportId,
enabled = true, enabled = false,
}: { }: {
reportId: string | undefined; reportId: string | undefined;
enabled?: boolean; enabled?: boolean;

View File

@ -38,22 +38,16 @@ export const ChatUserMessage: React.FC<{
(e?: React.ClipboardEvent) => { (e?: React.ClipboardEvent) => {
// Check if user has selected text // Check if user has selected text
const selection = window.getSelection(); 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 // Always override copy behavior to provide clean text
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
if (e?.clipboardData) { if (e?.clipboardData) {
e.preventDefault(); 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 { } else {
navigator.clipboard.writeText(request || ''); navigator.clipboard.writeText(hasSelection ? selectedText : request || '');
} }
openSuccessMessage('Copied to clipboard'); openSuccessMessage('Copied to clipboard');
}, },
@ -77,11 +71,10 @@ export const ChatUserMessage: React.FC<{
/> />
) : ( ) : (
<> <>
<div> <Paragraph className="break-words whitespace-pre-line" onCopy={handleCopy}>
<Paragraph className="break-words whitespace-pre-wrap" onCopy={handleCopy}> {request}
{request} </Paragraph>
</Paragraph>
</div>
{isStreamFinished && canEditChat && ( {isStreamFinished && canEditChat && (
<RequestMessageTooltip <RequestMessageTooltip
isTooltipOpen={isTooltipOpen} isTooltipOpen={isTooltipOpen}

View File

@ -44,8 +44,6 @@ export const useAutoRedirectStreaming = ({
return; return;
} }
console.log('triggerAutoNavigate', triggerAutoNavigate);
const chatMessage = getChatMessageMemoized(lastMessageId); const chatMessage = getChatMessageMemoized(lastMessageId);
const firstFileId = chatMessage?.response_message_ids?.find((id) => { const firstFileId = chatMessage?.response_message_ids?.find((id) => {
const responseMessage = chatMessage?.response_messages[id]; const responseMessage = chatMessage?.response_messages[id];

View File

@ -1,7 +1,7 @@
import { useQueryClient } from '@tanstack/react-query'; import { useQueryClient } from '@tanstack/react-query';
import { useEffect } from 'react'; import { useEffect } from 'react';
import type { BusterChat, BusterChatMessage, IBusterChat } from '@/api/asset_interfaces/chat'; 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 { prefetchGetMetricDataClient } from '@/api/buster_rest/metrics';
import { useTrackAndUpdateChatChanges } from '@/api/buster-electric/chats'; import { useTrackAndUpdateChatChanges } from '@/api/buster-electric/chats';
import { import {
@ -11,11 +11,11 @@ import {
import { chatQueryKeys } from '@/api/query_keys/chat'; import { chatQueryKeys } from '@/api/query_keys/chat';
import { metricsQueryKeys } from '@/api/query_keys/metric'; import { metricsQueryKeys } from '@/api/query_keys/metric';
import { useBlackboxMessage } from '@/context/BlackBox/useBlackboxMessage'; import { useBlackboxMessage } from '@/context/BlackBox/useBlackboxMessage';
import { updateDocumentTitle, useDocumentTitle } from '@/hooks/useDocumentTitle'; import { updateDocumentTitle } from '@/hooks/useDocumentTitle';
import { useMemoizedFn } from '@/hooks/useMemoizedFn'; import { useMemoizedFn } from '@/hooks/useMemoizedFn';
import { useMount } from '@/hooks/useMount';
import { updateChatToIChat } from '@/lib/chat'; import { updateChatToIChat } from '@/lib/chat';
const stableChatTitleSelector = (chat: IBusterChat) => chat.title;
export const useChatStreaming = ({ export const useChatStreaming = ({
chatId, chatId,
isStreamingMessage, isStreamingMessage,
@ -28,6 +28,10 @@ export const useChatStreaming = ({
const { checkBlackBoxMessage, removeBlackBoxMessage } = useBlackboxMessage(); const { checkBlackBoxMessage, removeBlackBoxMessage } = useBlackboxMessage();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const getChatMessageMemoized = useGetChatMessageMemoized(); const getChatMessageMemoized = useGetChatMessageMemoized();
const { data: chatTitle } = useGetChat(
{ id: chatId || '' },
{ select: stableChatTitleSelector, notifyOnChangeProps: ['data'] }
);
const _prefetchLastMessageMetricData = ( const _prefetchLastMessageMetricData = (
iChat: IBusterChat, iChat: IBusterChat,
@ -136,20 +140,13 @@ export const useChatStreaming = ({
}); });
useEffect(() => { useEffect(() => {
const REASONING_TITLE = 'Reasoning... | ';
if (isStreamingMessage) { if (isStreamingMessage) {
const message = getChatMessageMemoized(messageId); const message = getChatMessageMemoized(messageId);
if (message) { if (message) {
checkBlackBoxMessage(message); checkBlackBoxMessage(message);
} }
updateDocumentTitle((currentTitle) => {
return `${REASONING_TITLE}${currentTitle}`;
});
} else { } else {
removeBlackBoxMessage(messageId); removeBlackBoxMessage(messageId);
updateDocumentTitle((currentTitle) => {
return currentTitle.replace(REASONING_TITLE, '');
});
} }
}, [isStreamingMessage]); }, [isStreamingMessage]);

View File

@ -27,7 +27,7 @@ export const Route = createFileRoute('/app')({
const { queryClient, supabaseSession } = context; const { queryClient, supabaseSession } = context;
try { try {
const [user] = await Promise.all([prefetchGetMyUserInfo(queryClient)]); 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 }); throw redirect({ href: BUSTER_SIGN_UP_URL, replace: true, statusCode: 307 });
} }
return { return {