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 = ({
reportId,
enabled = true,
enabled = false,
}: {
reportId: string | undefined;
enabled?: boolean;

View File

@ -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<{
/>
) : (
<>
<div>
<Paragraph className="break-words whitespace-pre-wrap" onCopy={handleCopy}>
{request}
</Paragraph>
</div>
<Paragraph className="break-words whitespace-pre-line" onCopy={handleCopy}>
{request}
</Paragraph>
{isStreamFinished && canEditChat && (
<RequestMessageTooltip
isTooltipOpen={isTooltipOpen}

View File

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

View File

@ -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]);

View File

@ -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 {