chore: search & deep think & mcp (#675)

* fix: keep line breaks

* chore: search & deep think & mcp
This commit is contained in:
BiggerRain
2025-06-12 22:06:48 +08:00
committed by GitHub
parent 2ed22d3d7c
commit 0b018cd24f
6 changed files with 58 additions and 46 deletions

View File

@@ -76,14 +76,6 @@ const InputControls = ({
query?: string;
}
): Promise<DataSource[]> => {
if (
!(
assistantConfig.datasourceEnabled && assistantConfig.datasourceVisible
)
) {
return [];
}
const body: Record<string, any> = {
id: serverId,
from: options?.from || 0,
@@ -149,9 +141,6 @@ const InputControls = ({
query?: string;
}
): Promise<DataSource[]> => {
if (!(assistantConfig.mcpEnabled && assistantConfig.mcpVisible)) {
return [];
}
const body: Record<string, any> = {
id: serverId,
from: options?.from || 0,
@@ -260,18 +249,16 @@ const InputControls = ({
onKeyPress={setIsDeepThinkActive}
>
<Brain
className={`size-3 ${
isDeepThinkActive
? "text-[#0072FF] dark:text-[#0072FF]"
: "text-[#333] dark:text-white"
}`}
className={`size-3 ${isDeepThinkActive
? "text-[#0072FF] dark:text-[#0072FF]"
: "text-[#333] dark:text-white"
}`}
/>
</VisibleKey>
{isDeepThinkActive && (
<span
className={`${
isDeepThinkActive ? "text-[#0072FF]" : "dark:text-white"
}`}
className={`${isDeepThinkActive ? "text-[#0072FF]" : "dark:text-white"
}`}
>
{t("search.input.deepThink")}
</span>
@@ -279,25 +266,23 @@ const InputControls = ({
</button>
)}
{source?.datasource?.enabled && source?.datasource?.visible && (
<SearchPopover
isSearchActive={isSearchActive}
setIsSearchActive={setIsSearchActive}
getDataSourcesByServer={getDataSourcesByServer}
/>
)}
<SearchPopover
datasource={source?.datasource}
isSearchActive={isSearchActive}
setIsSearchActive={setIsSearchActive}
getDataSourcesByServer={getDataSourcesByServer}
/>
{source?.mcp_servers?.enabled && source?.mcp_servers?.visible && (
<MCPPopover
isMCPActive={isMCPActive}
setIsMCPActive={setIsMCPActive}
getMCPByServer={getMCPByServer}
/>
)}
<MCPPopover
mcp_servers={source?.mcp_servers}
isMCPActive={isMCPActive}
setIsMCPActive={setIsMCPActive}
getMCPByServer={getMCPByServer}
/>
{!(source?.datasource?.enabled && source?.datasource?.visible) &&
(source?.type !== "deep_think" || !source?.config?.visible) &&
!(source?.mcp_servers?.enabled && source?.mcp_servers?.visible) ? (
(source?.type !== "deep_think" || !source?.config?.visible) &&
!(source?.mcp_servers?.enabled && source?.mcp_servers?.visible) ? (
<div className="px-[9px]">
<Copyright />
</div>

View File

@@ -19,6 +19,7 @@ import Pagination from "@/components/Common/Pagination";
import { specialCharacterFiltering } from "@/utils"
interface MCPPopoverProps {
mcp_servers: any;
isMCPActive: boolean;
setIsMCPActive: () => void;
getMCPByServer: (
@@ -32,6 +33,7 @@ interface MCPPopoverProps {
}
export default function MCPPopover({
mcp_servers,
isMCPActive,
setIsMCPActive,
getMCPByServer,
@@ -163,6 +165,10 @@ export default function MCPPopover({
setPage(page + 1);
};
if (!(mcp_servers?.enabled && mcp_servers?.visible)) {
return null
}
return (
<div
className={clsx(
@@ -176,8 +182,8 @@ export default function MCPPopover({
<VisibleKey shortcut={mcpSearch} onKeyPress={setIsMCPActive}>
<Hammer
className={`size-3 ${isMCPActive
? "text-[#0072FF] dark:text-[#0072FF]"
: "text-[#333] dark:text-white"
? "text-[#0072FF] dark:text-[#0072FF]"
: "text-[#333] dark:text-white"
}`}
/>
</VisibleKey>

View File

@@ -19,6 +19,7 @@ import Pagination from "@/components/Common/Pagination";
import { specialCharacterFiltering } from "@/utils"
interface SearchPopoverProps {
datasource: any;
isSearchActive: boolean;
setIsSearchActive: () => void;
getDataSourcesByServer: (
@@ -32,6 +33,7 @@ interface SearchPopoverProps {
}
export default function SearchPopover({
datasource,
isSearchActive,
setIsSearchActive,
getDataSourcesByServer,
@@ -166,6 +168,10 @@ export default function SearchPopover({
setPage(page + 1);
};
if (!(datasource?.enabled && datasource?.visible)) {
return null
}
return (
<div
className={clsx(

View File

@@ -6,6 +6,7 @@ import {
Suspense,
memo,
useState,
useMemo,
} from "react";
import clsx from "clsx";
import { useMount } from "ahooks";
@@ -61,12 +62,12 @@ function SearchChat({
const source = currentAssistant?._source;
const customInitialState = {
const customInitialState = useMemo(() => ({
...initialAppState,
isDeepThinkActive: source?.type === "deep_think",
isSearchActive: source?.datasource?.enabled_by_default === true,
isMCPActive: source?.mcp_servers?.enabled_by_default === true,
};
}), [source]);
const [state, dispatch] = useReducer(appReducer, customInitialState);
const {
@@ -78,6 +79,12 @@ function SearchChat({
isMCPActive,
isTyping,
} = state;
useEffect(() => {
dispatch({ type: "SET_SEARCH_ACTIVE", payload: customInitialState.isSearchActive });
dispatch({ type: "SET_DEEP_THINK_ACTIVE", payload: customInitialState.isDeepThinkActive });
dispatch({ type: "SET_MCP_ACTIVE", payload: customInitialState.isMCPActive });
}, [customInitialState]);
const [isWin10, setIsWin10] = useState(false);
const blurred = useAppStore((state) => state.blurred);
@@ -101,7 +108,7 @@ function SearchChat({
setIsWin10(isWin10);
const unlisten = platformAdapter.listenEvent("show-coco", () => {
console.log("show-coco");
//console.log("show-coco");
platformAdapter.invokeBackend("simulate_mouse_click", {
isChatMode: isChatModeRef.current,
@@ -281,9 +288,8 @@ function SearchChat({
<div
data-tauri-drag-region={isTauri}
className={`p-2 w-full flex justify-center transition-all duration-500 min-h-[82px] ${
isTransitioned ? "border-t" : "border-b"
} border-[#E6E6E6] dark:border-[#272626]`}
className={`p-2 w-full flex justify-center transition-all duration-500 min-h-[82px] ${isTransitioned ? "border-t" : "border-b"
} border-[#E6E6E6] dark:border-[#272626]`}
>
<InputBox
isChatMode={isChatMode}

View File

@@ -178,7 +178,7 @@ export function useChatActions(
response = res;
}
console.log("_new", response);
console.log("_new", response, queryParams);
const newChat: Chat = response;
curIdRef.current = response?.payload?.id;
@@ -257,7 +257,7 @@ export function useChatActions(
response = res;
}
console.log("_send", response);
console.log("_send", response, queryParams);
curIdRef.current = response[0]?._id;
const updatedChat: Chat = {

View File

@@ -15,10 +15,13 @@ export type AppAction =
| { type: "SET_CHAT_MODE"; payload: boolean }
| { type: "SET_INPUT"; payload: string }
| { type: "TOGGLE_SEARCH_ACTIVE" }
| { type: "SET_SEARCH_ACTIVE"; payload: boolean }
| { type: "TOGGLE_DEEP_THINK_ACTIVE" }
| { type: "SET_DEEP_THINK_ACTIVE"; payload: boolean }
| { type: "TOGGLE_MCP_ACTIVE" }
| { type: "SET_MCP_ACTIVE"; payload: boolean }
| { type: "SET_TYPING"; payload: boolean }
| { type: "SET_LOADING"; payload: boolean };
| { type: "SET_LOADING"; payload: boolean }
const getCachedChatMode = (): boolean => {
const { defaultStartupWindow } = useStartupStore.getState();
@@ -49,10 +52,16 @@ export function appReducer(state: AppState, action: AppAction): AppState {
return { ...state, input: action.payload };
case "TOGGLE_SEARCH_ACTIVE":
return { ...state, isSearchActive: !state.isSearchActive };
case "SET_SEARCH_ACTIVE":
return { ...state, isSearchActive: action.payload };
case "TOGGLE_DEEP_THINK_ACTIVE":
return { ...state, isDeepThinkActive: !state.isDeepThinkActive };
case "SET_DEEP_THINK_ACTIVE":
return { ...state, isDeepThinkActive: action.payload };
case "TOGGLE_MCP_ACTIVE":
return { ...state, isMCPActive: !state.isMCPActive };
case "SET_MCP_ACTIVE":
return { ...state, isMCPActive: action.payload };
case "SET_TYPING":
return { ...state, isTyping: action.payload };
case "SET_LOADING":