diff --git a/docs/content.en/docs/release-notes/_index.md b/docs/content.en/docs/release-notes/_index.md index e879903b..dc115c8a 100644 --- a/docs/content.en/docs/release-notes/_index.md +++ b/docs/content.en/docs/release-notes/_index.md @@ -42,6 +42,7 @@ Information about release notes of Coco Server is provided here. - style: modify the style #370 - style: search list details display #378 - refactor: refactoring api error handling #382 +- chore: update assistant icon & think mode #397 ## 0.3.0 (2025-03-31) diff --git a/public/assets/fonts/icons/iconfont.js b/public/assets/fonts/icons/iconfont.js index a916eaaf..8f82f3ac 100644 --- a/public/assets/fonts/icons/iconfont.js +++ b/public/assets/fonts/icons/iconfont.js @@ -1 +1 @@ -window._iconfont_svg_string_4878526='',(c=>{var l=(h=(h=document.getElementsByTagName("script"))[h.length-1]).getAttribute("data-injectcss"),h=h.getAttribute("data-disable-injectsvg");if(!h){var t,a,F,o,p,i=function(l,h){h.parentNode.insertBefore(l,h)};if(l&&!c.__iconfont__svg__cssinject__){c.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(l){console&&console.log(l)}}t=function(){var l,h=document.createElement("div");h.innerHTML=c._iconfont_svg_string_4878526,(h=h.getElementsByTagName("svg")[0])&&(h.setAttribute("aria-hidden","true"),h.style.position="absolute",h.style.width=0,h.style.height=0,h.style.overflow="hidden",h=h,(l=document.body).firstChild?i(h,l.firstChild):l.appendChild(h))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(t,0):(a=function(){document.removeEventListener("DOMContentLoaded",a,!1),t()},document.addEventListener("DOMContentLoaded",a,!1)):document.attachEvent&&(F=t,o=c.document,p=!1,v(),o.onreadystatechange=function(){"complete"==o.readyState&&(o.onreadystatechange=null,d())})}function d(){p||(p=!0,F())}function v(){try{o.documentElement.doScroll("left")}catch(l){return void setTimeout(v,50)}d()}})(window); \ No newline at end of file +window._iconfont_svg_string_4878526='',(h=>{var l=(c=(c=document.getElementsByTagName("script"))[c.length-1]).getAttribute("data-injectcss"),c=c.getAttribute("data-disable-injectsvg");if(!c){var a,t,o,F,i,p=function(l,c){c.parentNode.insertBefore(l,c)};if(l&&!h.__iconfont__svg__cssinject__){h.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(l){console&&console.log(l)}}a=function(){var l,c=document.createElement("div");c.innerHTML=h._iconfont_svg_string_4878526,(c=c.getElementsByTagName("svg")[0])&&(c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.width=0,c.style.height=0,c.style.overflow="hidden",c=c,(l=document.body).firstChild?p(c,l.firstChild):l.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(a,0):(t=function(){document.removeEventListener("DOMContentLoaded",t,!1),a()},document.addEventListener("DOMContentLoaded",t,!1)):document.attachEvent&&(o=a,F=h.document,i=!1,d(),F.onreadystatechange=function(){"complete"==F.readyState&&(F.onreadystatechange=null,v())})}function v(){i||(i=!0,o())}function d(){try{F.documentElement.doScroll("left")}catch(l){return void setTimeout(d,50)}v()}})(window); \ No newline at end of file diff --git a/src/commands/servers.ts b/src/commands/servers.ts index 6843ad86..7cd03de2 100644 --- a/src/commands/servers.ts +++ b/src/commands/servers.ts @@ -31,7 +31,7 @@ async function invokeWithErrorHandler( if (failedResult.failed?.length > 0) { failedResult.failed.forEach((error: any) => { // addError(error.error, 'error'); - console.log(error.error); + console.error(error.error); }); } } diff --git a/src/components/Assistant/AssistantList.tsx b/src/components/Assistant/AssistantList.tsx index 82f9a354..02d7611c 100644 --- a/src/components/Assistant/AssistantList.tsx +++ b/src/components/Assistant/AssistantList.tsx @@ -64,7 +64,7 @@ export function AssistantList({ showChatHistory = true }: AssistantListProps) { onClick={() => setIsOpen(!isOpen)} className="h-6 p-1 px-1.5 flex items-center gap-1 rounded-full bg-white dark:bg-[#202126] text-sm/6 font-semibold text-gray-800 dark:text-[#d8d8d8] border border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none" > -
+
{currentAssistant?._source?.icon?.startsWith("font_") ? (
{isAssistant ? ( -
+
{currentAssistant?._source?.icon?.startsWith("font_") ? ( )} + {!hasFeature.includes("search") && !hasFeature.includes("think") ? (
diff --git a/src/hooks/useFeatureControl.ts b/src/hooks/useFeatureControl.ts new file mode 100644 index 00000000..f3bba97b --- /dev/null +++ b/src/hooks/useFeatureControl.ts @@ -0,0 +1,33 @@ +import { useState, useEffect } from "react"; + +import { useConnectStore } from "@/stores/connectStore"; + +interface UseFeatureControlProps { + initialFeatures: string[]; + featureToToggle: string; + condition: (assistant: any) => boolean; +} + +export const useFeatureControl = ({ + initialFeatures, + featureToToggle, + condition, +}: UseFeatureControlProps) => { + const currentAssistant = useConnectStore((state) => state.currentAssistant); + const [features, setFeatures] = useState(initialFeatures); + + useEffect(() => { + if (condition(currentAssistant)) { + setFeatures((prev) => prev.filter((feature) => feature !== featureToToggle)); + } else { + setFeatures((prev) => { + if (!prev.includes(featureToToggle)) { + return [...prev, featureToToggle]; + } + return prev; + }); + } + }, [currentAssistant?._id, featureToToggle]); + + return features; +}; \ No newline at end of file diff --git a/src/pages/chat/index.tsx b/src/pages/chat/index.tsx index 76007d13..6327178a 100644 --- a/src/pages/chat/index.tsx +++ b/src/pages/chat/index.tsx @@ -30,6 +30,7 @@ import { import { DataSource } from "@/types/commands"; import HistoryList from "@/components/Common/HistoryList"; import { useSyncStore } from "@/hooks/useSyncStore"; +import { useFeatureControl } from "@/hooks/useFeatureControl"; interface ChatProps {} @@ -261,6 +262,12 @@ export default function Chat({}: ChatProps) { await delete_session_chat(currentService.id, id); }; + const hasFeature = useFeatureControl({ + initialFeatures: ["think", "search"], + featureToToggle: "think", + condition: (item) => item?._source?.type === "simple" + }); + return (
@@ -331,6 +338,7 @@ export default function Chat({}: ChatProps) { openFileDialog={openFileDialog} getFileMetadata={getFileMetadata} getFileIcon={getFileIcon} + hasFeature={hasFeature} />
diff --git a/src/pages/main/index.tsx b/src/pages/main/index.tsx index 0bc8beee..d8388ac7 100644 --- a/src/pages/main/index.tsx +++ b/src/pages/main/index.tsx @@ -4,6 +4,7 @@ import SearchChat from "@/components/SearchChat"; import platformAdapter from "@/utils/platformAdapter"; import { useAppStore } from "@/stores/appStore"; import { useSyncStore } from "@/hooks/useSyncStore"; +import { useFeatureControl } from "@/hooks/useFeatureControl"; function MainApp() { const setIsTauri = useAppStore((state) => state.setIsTauri); @@ -55,6 +56,12 @@ function MainApp() { useSyncStore(); + const hasFeature = useFeatureControl({ + initialFeatures: ["think", "search"], + featureToToggle: "think", + condition: (item) => item?._source?.type === "simple" + }); + return ( ); } diff --git a/src/pages/web/index.tsx b/src/pages/web/index.tsx index 40e433c8..9169033f 100644 --- a/src/pages/web/index.tsx +++ b/src/pages/web/index.tsx @@ -6,6 +6,7 @@ import { Get } from "@/api/axiosRequest"; import { useShortcutsStore } from "@/stores/shortcutsStore"; import { useIsMobile } from '@/hooks/useIsMobile'; import { useModifierKeyPress } from "@/hooks/useModifierKeyPress"; +import { useFeatureControl } from "@/hooks/useFeatureControl"; import "@/i18n"; import "@/web.css"; @@ -125,6 +126,12 @@ function WebApp({ const [isChatMode, setIsChatMode] = useState(false); + const hasFeatureCopy = useFeatureControl({ + initialFeatures: hasFeature, + featureToToggle: "think", + condition: (item) => item?._source?.type === "simple" + }); + return (