mirror of https://github.com/buster-so/buster.git
change redirect logic
This commit is contained in:
parent
f87f67d895
commit
77721645a1
|
@ -35,6 +35,7 @@ export const useIsDashboardChanged = ({
|
|||
}),
|
||||
[]
|
||||
),
|
||||
enabled: false,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { useGetOriginalReport } from './useOriginalReportStore';
|
|||
|
||||
export const useIsReportChanged = ({
|
||||
reportId,
|
||||
enabled = true,
|
||||
enabled = false,
|
||||
}: {
|
||||
reportId: string | undefined;
|
||||
enabled?: boolean;
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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]);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue