🐛(front) fix button search web on new conversation (#50)

* 🎨(front) improvement search input scroll

improvement search input scroll and margin

* 🐛(front) fix button search web on new conversation

fix button search web on new conversation'
This commit is contained in:
elvoisin
2025-10-02 16:43:08 +02:00
committed by GitHub
parent 1b9e814be7
commit c9c10ce19a
4 changed files with 38 additions and 30 deletions
+1
View File
@@ -8,6 +8,7 @@ and this project adheres to
## [Unreleased]
- 🐛(front) fix button search web on new conversation
- 🎨(front) improvement search input scroll
### Changed
@@ -1,6 +1,7 @@
import { Command } from 'cmdk';
import { ReactNode, useRef } from 'react';
import { useResponsiveStore } from '@/stores';
import { hasChildrens } from '@/utils/children';
import { Box } from '../Box';
@@ -44,6 +45,7 @@ export const QuickSearch = ({
children,
}: QuickSearchProps) => {
const ref = useRef<HTMLDivElement | null>(null);
const { isMobile, isTablet } = useResponsiveStore();
return (
<>
@@ -54,14 +56,6 @@ export const QuickSearch = ({
$css={`
position: sticky;
top: 0px;
&:before {
content: "";
background-color: #F7F8FA;
position: absolute;
width: 100%;
height: 20px;
top: -8px;
}
&:after {
content: "";
position: absolute;
@@ -75,6 +69,21 @@ export const QuickSearch = ({
rgba(255, 255, 255, 0) 100%
);
}
${
!isMobile && !isTablet
? `
&:before {
content: "";
background-color: #F7F8FA;
position: absolute;
width: 100%;
height: 20px;
top: -8px;
}
background-color: #F7F8FA;
`
: 'background-color: #FFF;'
}
}`}
>
<QuickSearchInput
@@ -90,6 +99,7 @@ export const QuickSearch = ({
)}
<Command.List>
<Box $padding={{ horizontal: 'xs', top: 'sm' }}>{children}</Box>
<Box $padding={{ horizontal: 'xs', top: 'sm' }}>{children}</Box>
</Command.List>
</Command>
</>
@@ -2,7 +2,6 @@ import { UseChatOptions, useChat as useAiSdkChat } from '@ai-sdk/react';
import { fetchAPI } from '@/api';
// Adapter to match the global fetch signature
const fetchAPIAdapter = (input: RequestInfo | URL, init?: RequestInit) => {
let url: string;
if (typeof input === 'string') {
@@ -15,18 +14,9 @@ const fetchAPIAdapter = (input: RequestInfo | URL, init?: RequestInit) => {
throw new Error('Unsupported input type for fetchAPIAdapter');
}
// Add force_web_search parameter if it's globally enabled
if ((window as { globalForceWebSearch?: boolean }).globalForceWebSearch) {
// For relative URLs, just append the parameter
if (url.startsWith('http')) {
const urlObj = new URL(url);
urlObj.searchParams.set('force_web_search', 'true');
url = urlObj.toString();
} else {
// For relative URLs, append the parameter manually
const separator = url.includes('?') ? '&' : '?';
url = `${url}${separator}force_web_search=true`;
}
const separator = url.includes('?') ? '&' : '?';
url = `${url}${separator}force_web_search=true`;
}
return fetchAPI(url, init);
@@ -46,15 +46,28 @@ export const Chat = ({
const { isMobile } = useResponsiveStore();
const streamProtocol = 'data'; // or 'text'
const [forceWebSearch, setForceWebSearch] = useState(false);
const apiUrl = `chats/${initialConversationId}/conversation/?protocol=${streamProtocol}`;
const [forceWebSearch, setForceWebSearch] = useState(() => {
return (
(window as { globalForceWebSearch?: boolean }).globalForceWebSearch ||
false
);
});
const [conversationId, setConversationId] = useState(initialConversationId);
const apiUrl = conversationId
? `chats/${conversationId}/conversation/?protocol=${streamProtocol}`
: `chats/conversation/?protocol=${streamProtocol}`;
useEffect(() => {
(window as { globalForceWebSearch?: boolean }).globalForceWebSearch =
forceWebSearch;
}, [forceWebSearch]);
const router = useRouter();
const [files, setFiles] = useState<FileList | null>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
const chatContainerRef = useRef<HTMLDivElement>(null);
const [conversationId, setConversationId] = useState(initialConversationId);
const [chatErrorModal, setChatErrorModal] = useState<{
title: string;
message: string;
@@ -165,13 +178,7 @@ export const Chat = ({
};
const toggleWebSearch = () => {
setForceWebSearch((prev) => {
const newValue = !prev;
// Update global state for the fetch adapter
(window as { globalForceWebSearch?: boolean }).globalForceWebSearch =
newValue;
return newValue;
});
setForceWebSearch((prev) => !prev);
};
const handleStop = () => {